Пример #1
0
        /// <summary>
        /// Calculate position of other players from your localPlayer and put the dot in the right place. If the player turn it simply pivot around the center of the minimap
        /// </summary>
        void DrawMinimapDots()
        {
            for (int i = 0; i < _objects.Count; i++)
            {
                MinimapObject obj = _objects [i];
                if (obj.Owner != null && obj.Icon != null)
                {
                    Transform playerPos    = PlayerManager.LocalPlayerInstance.transform;
                    Vector3   minimapPos   = (obj.Owner.transform.position - playerPos.position);
                    float     distToObject = Vector3.Distance(playerPos.position, obj.Owner.transform.position) * mapScale;
                    float     deltaY       = Mathf.Atan2(minimapPos.x, minimapPos.z) * Mathf.Rad2Deg - 270 - playerPos.eulerAngles.y;
                    minimapPos.x = distToObject * Mathf.Cos(deltaY * Mathf.Deg2Rad) * -1;
                    minimapPos.z = distToObject * Mathf.Sin(deltaY * Mathf.Deg2Rad);

                    obj.Icon.transform.position = new Vector3(minimapPos.x, minimapPos.z, 0) + transform.position;
                }
                else
                {
                    if (obj.Owner != null)
                    {
                        Debug.Log("Owner: " + obj.Owner);
                    }
                    else if (obj.Icon != null)
                    {
                        Debug.Log("Icon: " + obj.Icon.name + ".");
                    }
                    else
                    {
                        Debug.Log("No information");
                    }
                    Minimap.Instance.RemoveMinimapObject(obj);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Recolor the image in the minimap.
        /// </summary>
        public void RecolorMinimapObject(GameObject owner)
        {
            MinimapObject mO = _objects.Find(o => o.Owner == owner);

            if (mO != null)
            {
                mO.Icon.color = owner.GetComponent <MinimapObjectID>().color;
            }
            else
            {
                Debug.Log("Error: the minimap object for " + owner.name + " has not been found!");
            }
        }
Пример #3
0
 /// <summary>
 /// Remove the image from the minimap and from the list of minimap objects.
 /// </summary>
 public void RemoveMinimapObject(MinimapObject mO)
 {
     Destroy(mO.Icon);
     _objects.Remove(mO);
 }