public void SetGhostState(EGhostBehaviour eGhostStateBehaviour)
 {
     IGhostStateObserver ghostStateObserver = controller as IGhostStateObserver;
     if(ghostStateObserver != null)
     {
         ghostStateObserver.SetGhostState(eGhostStateBehaviour);
     }
 }
Beispiel #2
0
 public Point TargetCell(Cell currentCell, EGhostBehaviour behaviour)
 {
     switch (behaviour)
     {
         case EGhostBehaviour.Fright:
             return FrightBehaviour(currentCell);
         case EGhostBehaviour.Hunt:
             return HuntBehaviour(currentCell);
         case EGhostBehaviour.Scatter:
             return scatterTarget;
         case EGhostBehaviour.Exiting:
             return exitTarget;
         case EGhostBehaviour.Dead:
         case EGhostBehaviour.InHouse:
             return homeTarget;
         default:
             return currentCell.GridPosition;
     }
 }
Beispiel #3
0
 public void SetGhostState(EGhostBehaviour eGhostStateBehaviour)
 {
     ghostAi.SetGhostState(eGhostStateBehaviour);
 }
Beispiel #4
0
        public void Update(Cell currentCell, EGhostBehaviour behaviour)
        {
            CurrentCell = currentCell;

            for (int i = 1; i <= 4; i++)
            {
                AddCell((Direction)i, CurrentCell.GridPosition);
            }

            for (int i = 0; i < possibleMoves.Count; i++)
            {
                Cell possibleMove = possibleMoves[i];

                Point oppsitDirection = DirectionExtension.PointFromDirection(DirectionExtension.GetOppositeDirection(lastDirection));
                Cell oppositeCell = level.getCell(CurrentCell.GridPosition.X + oppsitDirection.X,
                                                  CurrentCell.GridPosition.Y + oppsitDirection.Y);

                if(possibleMove == null)
                {
                    possibleMoves.Remove(possibleMove);
                    continue;
                }

                if (oppositeCell.GridPosition == possibleMove.GridPosition || possibleMove.GridPosition == lastCell.GridPosition)
                {
                    possibleMoves.Remove(possibleMove);
                    continue;
                }
            }

            if (possibleMoves.Count > 1)
            {
                Cell wantedCell = level.getCell(ghostAi.TargetCell(CurrentCell, behaviour));

                FindShortestPath(CurrentCell, wantedCell, ref possibleMoves);
            }

            if(possibleMoves.Count >0)
            {
                Cell nextCell = possibleMoves[0];
                Point nextMovement = new Point(nextCell.GridPosition.X - CurrentCell.GridPosition.X,
                                                nextCell.GridPosition.Y - CurrentCell.GridPosition.Y);
                Direction = DirectionExtension.DirectionFromPoint(nextMovement);
            }

            possibleMoves.Clear();
        }
Beispiel #5
0
 /// <summary>
 /// Creates a new PowerUpEffectEventArgs
 /// </summary>
 /// <param name="timer">How long the powerup will have an effect</param>
 /// <param name="speed">How much the speed will be altered</param>
 /// <param name="ghostBehaviour">The behaviour ghosts have after this effect</param>
 public PowerUpEffectEventArgs(int timer, float speed, EGhostBehaviour ghostBehaviour)
 {
     this.timer = timer;
     this.speed = speed;
     this.ghostBehaviour = ghostBehaviour;
 }
Beispiel #6
0
 public void SetGhostState(EGhostBehaviour eGhostStateBehaviour)
 {
     this.ghostBehaviour = eGhostStateBehaviour;
 }