Beispiel #1
0
        private void UpdateCellPipeType(PlayableCell cell, List <IntVect2> path)
        {
            //TODO: Left is coming from chance card
            if (path.Count < 1)
            {
                cell.Pipe = PlayableCell.PipeType.TOP;
                return;
            }
            PlayableCell prevCell = GetCell(path[path.Count - 1]);

            if (prevCell.Key.x < cell.Key.x)
            {
                cell.Pipe = PlayableCell.PipeType.LEFT;
            }
            else if (prevCell.Key.x > cell.Key.x)
            {
                cell.Pipe = PlayableCell.PipeType.RIGHT;
            }
            else if (prevCell.Key.y < cell.Key.y)
            {
                cell.Pipe = PlayableCell.PipeType.TOP;
            }
            else if (prevCell.Key.y > cell.Key.y)
            {
                cell.Pipe = PlayableCell.PipeType.BOTTOM;
            }

            UpdatePrevCell(prevCell, cell);
        }
Beispiel #2
0
        public void IncreaseCellBounty(IntVect2 cellKey, int amount)
        {
            PlayableCell cell = GetCell(cellKey);

            cell.Bounty += amount;
            Messenger <PlayableCell> .Broadcast(PlayableCell.EVENT_CELL_UPDATED, cell);
        }
Beispiel #3
0
        public void ResetCell(IntVect2 cellKey)
        {
            PlayableCell cell = GetCell(cellKey);

            cell.Reset();
            Messenger <PlayableCell> .Broadcast(PlayableCell.EVENT_CELL_UPDATED, cell);
        }
Beispiel #4
0
        public void CellProgressed(IntVect2 cellKey, float progress)
        {
            PlayableCell cell = GetCell(cellKey);

            cell.Progress = progress;
            Messenger <PlayableCell> .Broadcast(PlayableCell.EVENT_CELL_UPDATED, cell);
        }
Beispiel #5
0
 public void ResetCellsProgress(List <IntVect2> path)
 {
     foreach (IntVect2 cellKey in path)
     {
         PlayableCell cell = GetCell(cellKey);
         cell.Progress = 0.0f;
     }
     Messenger <List <List <PlayableCell> > > .Broadcast(EVENT_GRID_UPDATED, _Cells);
 }
Beispiel #6
0
        public bool ValidateCellInput(IntVect2 key, List <IntVect2> path)
        {
            PlayableCell cell = GetCell(key);

            if (CellIsConnected(key, path) &&
                GetCell(key).IsFree() &&
                CheckPrevCellPositions(key, path))
            {
                UpdateCellPipeType(cell, path);
                Messenger <PlayableCell> .Broadcast(PlayableCell.EVENT_CELL_UPDATED, cell);

                return(true);
            }
            return(false);
        }
Beispiel #7
0
        public void SetPath(List <IntVect2> path)
        {
            if (path.Count < 1)
            {
                return;
            }
            PlayableCell finalCell = GetCell(path[path.Count - 1]);

            if (finalCell.TargetID == "")
            {
                ResetCellsInPath(path);
                Messenger.Broadcast(EVENT_MISSION_FAILED);
                return;
            }
            else
            {
                //TODO create an active mission.
            }
            Messenger <List <IntVect2> > .Broadcast(EVENT_SET_PATH, path);
        }
Beispiel #8
0
        private void UpdatePrevCell(PlayableCell prevCell, PlayableCell cell)
        {
            if (prevCell.Pipe == cell.Pipe)
            {
                prevCell.Pipe = (prevCell.Pipe == PlayableCell.PipeType.LEFT ||
                                 prevCell.Pipe == PlayableCell.PipeType.RIGHT) ?
                                PlayableCell.PipeType.HORI  : PlayableCell.PipeType.VERT;
            }
            switch (prevCell.Pipe)
            {
            case PlayableCell.PipeType.LEFT:
                switch (cell.Pipe)
                {
                case PlayableCell.PipeType.TOP:
                    prevCell.Pipe = PlayableCell.PipeType.SW;
                    break;

                case PlayableCell.PipeType.BOTTOM:
                    prevCell.Pipe = PlayableCell.PipeType.NW;
                    break;
                }
                break;

            case PlayableCell.PipeType.RIGHT:
                switch (cell.Pipe)
                {
                case PlayableCell.PipeType.TOP:
                    prevCell.Pipe = PlayableCell.PipeType.SE;
                    break;

                case PlayableCell.PipeType.BOTTOM:
                    prevCell.Pipe = PlayableCell.PipeType.NE;
                    break;
                }
                break;

            case PlayableCell.PipeType.TOP:
                switch (cell.Pipe)
                {
                case PlayableCell.PipeType.LEFT:
                    prevCell.Pipe = PlayableCell.PipeType.NE;
                    break;

                case PlayableCell.PipeType.RIGHT:
                    prevCell.Pipe = PlayableCell.PipeType.NW;
                    break;
                }
                break;

            case PlayableCell.PipeType.BOTTOM:
                switch (cell.Pipe)
                {
                case PlayableCell.PipeType.LEFT:
                    prevCell.Pipe = PlayableCell.PipeType.SE;
                    break;

                case PlayableCell.PipeType.RIGHT:
                    prevCell.Pipe = PlayableCell.PipeType.SW;
                    break;
                }
                break;

            case PlayableCell.PipeType.NONE:
                Debug.Log("Prev cell cant be NONE");
                break;
            }
            Messenger <PlayableCell> .Broadcast(PlayableCell.EVENT_CELL_UPDATED, prevCell);
        }