コード例 #1
0
ファイル: IsoGrid.cs プロジェクト: davidrochin/pixeltile
    private int CalculateGridOrder()
    {
        List <IsoGrid> grids   = new List <IsoGrid>(FindObjectsOfType <IsoGrid>());
        List <IsoGrid> ordered = new List <IsoGrid>();

        // Get the closest to the camera
        while (grids.Count > 0)
        {
            IsoGrid closest = grids[0];
            //grids.Remove(closest);

            foreach (IsoGrid g in grids)
            {
                if ((Camera.main.transform.position - g.transform.position).magnitude > (Camera.main.transform.position - closest.transform.position).magnitude)
                {
                    closest = g;
                }
            }

            grids.Remove(closest);
            ordered.Add(closest);
        }

        for (int i = 0; i < ordered.Count; i++)
        {
            if (ordered[i] == this)
            {
                return(i);
            }
        }
        return(-1);
    }
コード例 #2
0
 // This supports non-rectangular data, because the X and Z "grid coordinates" are stored in the payload itself
 private void AssignElements(IEnumerable <MutableObject> mutables)
 {
     foreach (var element in mutables)
     {
         IsoGrid.AddEntry(XAxis.GetLastKeyValue(element), ZAxis.GetLastKeyValue(element), element);
     }
 }
コード例 #3
0
ファイル: IsoPathfinder.cs プロジェクト: Botyto/UnityTown
 public IsoPathfinder(IsoGrid world)
 {
     World = world;
     First = new Point (-1, -1);
     Last = new Point (-1, -1);
     Path = new List<Point> ();
 }
コード例 #4
0
        protected override IEnumerator ProcessPayload(VisualPayload payload)
        {
            Debug.LogWarning("[BOUND DEBUG] IsoGrid rendering to bound.", payload.VisualData.Bound);

            IsoGrid = VisualizerFactory.InstantiateIsoGrid();

            IsoGrid.Initialize(this, payload);
            //payload.VisualData.Bound.ChildVisualizer(this, IsoGrid);

            IsoGrid.DrawBackgrounds = ShowBackgrounds.GetLastKeyValue(payload.Data);

            IsoGrid.InitializeIsoGrid(payload.VisualData.Bound);

            IsoGrid.AllowSlicer = AllowSlicerField.GetLastKeyValue(payload.Data);

            AssignStates(IsoGrid);

            var entries = EntryField.GetFirstValue(payload.Data);

            if (entries == null)
            {
                throw new Exception("Illegal mutable field here!  " + EntryField.AbsoluteKey + " is not an enumerable of mutables!");
            }


            // Determine the full size of the entire isogrid
            int numCellsXAxis = 0;
            int numCellsZAxis = 0;

            if (entries.Any())
            {
                numCellsXAxis = XAxis.GetEntries(payload.Data).Max(e => XAxis.GetValue(e)) + 1;
                numCellsZAxis = ZAxis.GetEntries(payload.Data).Max(e => ZAxis.GetValue(e)) + 1;
            }

            IsoGrid.UpdateHorizontalScale(numCellsXAxis);
            IsoGrid.UpdateDepthScale(numCellsZAxis);

            AssignElements(entries);

            var iterator = IsoGrid.Apply();

            while (iterator.MoveNext( ))
            {
                yield return(null);
            }

            // PROCESS the label stuff, that was specified by the author:
            LabelSystem.Render(payload, IsoGrid.transform, IsoGrid.SelectionManager);
        }
コード例 #5
0
ファイル: IsoGrid.cs プロジェクト: davidrochin/pixeltile
    private IsoGrid[] GetOrderedGrids()
    {
        List <IsoGrid> grids   = new List <IsoGrid>(FindObjectsOfType <IsoGrid>());
        List <IsoGrid> ordered = new List <IsoGrid>();

        // Order from farthest to nearest
        while (grids.Count > 0)
        {
            IsoGrid closest = grids[0];

            foreach (IsoGrid g in grids)
            {
                if ((Camera.main.transform.position - g.transform.position).magnitude > (Camera.main.transform.position - closest.transform.position).magnitude)
                {
                    closest = g;
                }
            }

            grids.Remove(closest);
            ordered.Add(closest);
        }
        return(ordered.ToArray());
    }
コード例 #6
0
ファイル: IsoSprite.cs プロジェクト: davidrochin/pixeltile
 void Awake()
 {
     currentGrid = FindObjectOfType <IsoGrid>();
     renderer    = GetComponent <SpriteRenderer>();
 }
コード例 #7
0
ファイル: MoveWall.cs プロジェクト: jor-el-swe/CityBuilder
 void Start()
 {
     _isoGrid = FindObjectOfType <IsoGrid>();
     _isoGrid.removeTransformFromGrid(this.GetComponentInChildren <SpriteRenderer>().transform);
 }
コード例 #8
0
ファイル: IsoTile.cs プロジェクト: Botyto/UnityTown
 public IsoTile(IsoGrid world, int x, int y)
 {
     World = world;
     Index = new Point (x, y);
 }
コード例 #9
0
 private void OnEnable()
 {
     isoGrid = (IsoGrid)target;
 }