mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-29 07:20:19 +00:00
working on displaying players on minimap
This commit is contained in:
parent
acf566f79a
commit
221086fe95
4 changed files with 65 additions and 2 deletions
43
Assets/Scripts/Behaviours/Player2Minimap.cs
Normal file
43
Assets/Scripts/Behaviours/Player2Minimap.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using UnityEngine;
|
||||
using SanAndreasUnity.UI;
|
||||
using SanAndreasUnity.Utilities;
|
||||
|
||||
namespace SanAndreasUnity.Behaviours
|
||||
{
|
||||
|
||||
public class Player2Minimap : MonoBehaviour
|
||||
{
|
||||
Net.Player m_player;
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
m_player = this.GetComponentOrThrow<Net.Player>();
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
UI.MapWindow.Instance.onDrawMapItems += OnMinimapGUI;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
UI.MapWindow.Instance.onDrawMapItems -= OnMinimapGUI;
|
||||
}
|
||||
|
||||
void OnMinimapGUI()
|
||||
{
|
||||
if (m_player == Net.Player.Local) // don't draw anything for local player - it's done by map window
|
||||
return;
|
||||
|
||||
var ped = m_player.OwnedPed;
|
||||
if (null == ped)
|
||||
return;
|
||||
|
||||
MapWindow.Instance.DrawItemOnMapRotated( MiniMap.Instance.PlayerBlip, ped.transform.position, ped.transform.forward,
|
||||
(int) MapWindow.Instance.PlayerPointerSize );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Behaviours/Player2Minimap.cs.meta
Normal file
11
Assets/Scripts/Behaviours/Player2Minimap.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de46f572586cdb697b6c95283affa511
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -7,6 +7,8 @@ namespace SanAndreasUnity.UI {
|
|||
|
||||
public class MapWindow : PauseMenuWindow {
|
||||
|
||||
public static MapWindow Instance { get; private set; }
|
||||
|
||||
//private Rect visibleMapRect = new Rect ();
|
||||
private Vector2 m_focusPos = Vector2.one * MiniMap.mapSize / 2.0f;
|
||||
private float zoomLevel = 1;
|
||||
|
@ -16,6 +18,7 @@ namespace SanAndreasUnity.UI {
|
|||
private Texture2D m_infoAreaTexture;
|
||||
|
||||
private float m_playerPointerSize = 10;
|
||||
public float PlayerPointerSize { get => m_playerPointerSize; set { m_playerPointerSize = value; } }
|
||||
private bool m_drawZones = false;
|
||||
|
||||
private bool m_isWaypointPlaced = false;
|
||||
|
@ -25,6 +28,8 @@ namespace SanAndreasUnity.UI {
|
|||
|
||||
private Vector2 m_infoAreaScrollViewPos = Vector2.zero;
|
||||
|
||||
public event System.Action onDrawMapItems = delegate {};
|
||||
|
||||
|
||||
|
||||
MapWindow() {
|
||||
|
@ -42,6 +47,9 @@ namespace SanAndreasUnity.UI {
|
|||
|
||||
void Awake () {
|
||||
|
||||
if (null == Instance)
|
||||
Instance = this;
|
||||
|
||||
m_infoAreaTexture = F.CreateTexture (1, 1, Color.grey);
|
||||
|
||||
}
|
||||
|
@ -572,6 +580,9 @@ namespace SanAndreasUnity.UI {
|
|||
}
|
||||
|
||||
|
||||
// draw registered items
|
||||
onDrawMapItems();
|
||||
|
||||
// draw player pointer
|
||||
this.DrawItemOnMapRotated( MiniMap.Instance.PlayerBlip, Ped.Instance.transform.position, Ped.Instance.transform.forward, (int) m_playerPointerSize );
|
||||
// this.DrawItemOnMapRotated( MiniMap.Instance.PlayerBlip, Player.Instance.transform.position, Player.Instance.transform.forward, 10 );
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
- Cell focus is not always assigned on client - it happens when a syncvar for current ped in Player script arrives after Ped.Start()
|
||||
|
||||
- add option to pause spawning, and to set spawn interval
|
||||
|
||||
- display players on minimap
|
||||
|
||||
- port the whole UI to multiplayer
|
||||
|
|
Loading…
Reference in a new issue