Exemplo n.º 1
0
        public IGhostState Update(Ghost ghost)
        {
            if (PathFindUtils.WarpGhost(ghost))
            {
                getHomePath(ghost);
            }

            if (positions != null)
            {
                if (ghost.GetBody().position == ghost.target)
                {
                    if (currentPosition < positions.Length - 1)
                    {
                        currentPosition++;
                        ghost.target = positions[currentPosition];
                    }
                    else
                    {
                        return(new DeadState(ghost));
                    }
                }
            }

            base.UpdateCommons(ghost);

            return(null);
        }
Exemplo n.º 2
0
        public IGhostState Update(Ghost ghost)
        {
            if (timer < 2f)
            {
                flashCount++;

                if (Mathf.Floor(flashCount / 5) % 2 == 0)
                {
                    //make it flash white and blue every 30 frames
                    ghost.spriteRenderer.material.shader = shaderGUItext;
                }
                else
                {
                    ghost.spriteRenderer.material.shader = shaderSpritesDefault;
                }
            }

            if (PathFindUtils.WarpGhost(ghost))
            {
                getNextRandomPath(ghost);
            }

            if (positions != null)
            {
                if (ghost.GetBody().position == ghost.target)
                {
                    if (timer > 0)
                    {
                        if (currentPosition < positions.Length - 1)
                        {
                            currentPosition++;
                            ghost.target = positions[currentPosition];
                        }
                        else
                        {
                            getNextRandomPath(ghost);
                        }
                    }
                    else
                    {
                        return(new ChaseState());
                    }
                }
            }

            base.UpdateCommons(ghost);

            return(null);
        }
Exemplo n.º 3
0
        public IGhostState Update(Ghost ghost)
        {
            if (PathFindUtils.WarpGhost(ghost))
            {
                getNextScatter(ghost);
            }

            if (positions != null)
            {
                if (ghost.GetBody().position == ghost.target)
                {
                    if (timer > 0)
                    {
                        if (currentPosition < positions.Length - 1)
                        {
                            currentPosition++;
                            ghost.target = positions[currentPosition];
                        }
                        else
                        {
                            if (currentScatterPosition < ScatterPositions.Count - 1)
                            {
                                currentScatterPosition++;
                            }
                            else
                            {
                                currentScatterPosition = 0;
                            }
                            getNextScatter(ghost);
                        }
                    }
                    else
                    {
                        return(new ChaseState());
                    }
                }
            }

            base.UpdateCommons(ghost);

            return(null);
        }
Exemplo n.º 4
0
        protected bool ChaseCommon(Ghost ghost)
        {
            if (PathFindUtils.WarpGhost(ghost))
            {
                return(true);
            }

            if (positions != null)
            {
                if (ghost.GetBody().position == goal * 16)
                {
                    return(true);
                }
                else if (ghost.GetBody().position == ghost.target)
                {
                    var ghostTilePosition = Vector2Int.FloorToInt(ghost.GetBody().position / 16);
                    if (Retarget && lastTilePosition != ghostTilePosition)
                    {
                        SetTarget(ghost);
                        lastTilePosition = ghostTilePosition;
                    }
                    else
                    {
                        if (currentPos < positions.Length - 1)
                        {
                            currentPos++;
                            ghost.target = positions[currentPos];
                        }
                        else
                        {
                            SetTarget(ghost);
                        }
                    }
                }
            }
            else
            {
                SetTarget(ghost);
            }
            return(false);
        }
Exemplo n.º 5
0
 private void getHomePath(Ghost ghost)
 {
     PathFindUtils.Navigate(ghost, true, Vector2Int.FloorToInt(ghost.SpawningLocation / 16), ref positions, ref currentPosition);
 }
Exemplo n.º 6
0
 protected void SetTarget(Ghost ghost)
 {
     goal = GetGoal(ghost);
     PathFindUtils.Navigate(ghost, ConsiderWarps, goal, ref positions, ref currentPos);
 }
Exemplo n.º 7
0
        private void getNextRandomPath(Ghost ghost)
        {
            var start = Vector2Int.FloorToInt(ghost.GetBody().position / 16);

            PathFindUtils.Navigate(ghost, true, GameManager.instance.GetRandomTile(ghost.gridTiles, start), ref positions, ref currentPosition);
        }
Exemplo n.º 8
0
 private void getNextScatter(Ghost ghost)
 {
     PathFindUtils.Navigate(ghost, true, Vector2Int.FloorToInt(ScatterPositions[currentScatterPosition] / 16), ref positions, ref currentPosition);
 }