Esempio n. 1
0
        public CellSaveData GetSaveData()
        {
            CellSaveData save = new CellSaveData();

            save.Position = new PositionIndex(this.position);

            CellNeighbourIndicies neighborIndicies = new CellNeighbourIndicies();
            CellNeighbourIndicies linkIndicies     = new CellNeighbourIndicies();

            if (Neighbours.East != null)
            {
                neighborIndicies.East = new PositionIndex(Neighbours.East.position);
            }
            if (Neighbours.West != null)
            {
                neighborIndicies.West = new PositionIndex(Neighbours.West.position);
            }
            if (Neighbours.North != null)
            {
                neighborIndicies.North = new PositionIndex(Neighbours.North.position);
            }
            if (Neighbours.South != null)
            {
                neighborIndicies.South = new PositionIndex(Neighbours.South.position);
            }

            if (linkNeigbours.East != null)
            {
                linkIndicies.East = new PositionIndex(linkNeigbours.East.position);
            }
            if (linkNeigbours.West != null)
            {
                linkIndicies.West = new PositionIndex(linkNeigbours.West.position);
            }
            if (linkNeigbours.North != null)
            {
                linkIndicies.North = new PositionIndex(linkNeigbours.North.position);
            }
            if (linkNeigbours.South != null)
            {
                linkIndicies.South = new PositionIndex(linkNeigbours.South.position);
            }

            save.Neigbours = neighborIndicies;
            save.Links     = linkIndicies;

            return(save);
        }
Esempio n. 2
0
        public CellNeighbours Index2Neighbor(CellNeighbourIndicies indicies)
        {
            CellNeighbours neighbours = new CellNeighbours();

            if (indicies.East != null)
            {
                neighbours.East = _cells[indicies.East.y * Width + indicies.East.x];
            }
            if (indicies.West != null)
            {
                neighbours.West = _cells[indicies.West.y * Width + indicies.West.x];
            }
            if (indicies.North != null)
            {
                neighbours.North = _cells[indicies.North.y * Width + indicies.North.x];
            }
            if (indicies.South != null)
            {
                neighbours.South = _cells[indicies.South.y * Width + indicies.South.x];
            }

            return(neighbours);
        }