Esempio n. 1
0
        /// <summary>
        /// Synchronizes, called from callback
        /// </summary>
        internal void Synchronize(IUnitView item, MapVisualisator map)
        {
            serverUnit         = item;
            transform.position = map.ScaleToWorldCoords(item.Position, map.XSize, map.YSize, map.MapScale);

            if (animation != null)
            {
                if (item.IsWalking)
                {
                    animation.Play("UnitWalking");
                }
                else
                {
                    animation.Play("UnitStaying");
                }
            }

            if (lineRenderer != null)
            {
                if (serverUnit.Path == null)//!IsSelected ||
                {
                    lineRenderer.positionCount = 0;
                }
                else
                {
                    var lineRendererPath = ScaleToWotldCoords(map, serverUnit.Path);
                    lineRenderer.positionCount = lineRendererPath.Length;
                    lineRenderer.SetPositions(lineRendererPath);
                }
            }
        }
Esempio n. 2
0
 private Vector3[] ScaleToWotldCoords(MapVisualisator map, IEnumerable <Position> positions)
 {
     Vector3[] res = new Vector3[positions.Count() + 1]; // adds self as a point
     res[0] = this.Position;
     // todo optimize it
     for (int i = 0; i < res.Length - 1; i++)
     {
         res[i + 1]    = map.ScaleToWorldCoords(positions.ElementAt(i), map.XSize, map.YSize, map.MapScale);
         res[i + 1].z -= lineRendererHeight;
     }
     return(res);
 }