Exemplo n.º 1
0
 public void GameInitialised(GameState state)
 {
     for (int i = 0; i < arrows; i++)
     {
         state.ActiveAgent.GiveItem(new ArrowItem());
     }
 }
Exemplo n.º 2
0
 public ActionResult Execute(GameState state)
 {
     var holder = state.CurrentCell as IItemHolder;
     if(holder == null)
     {
         return new ActionResult()
                    {
                        GameOver = false,
                        Message = "Nothing to pick up",
                        MoveSuccessful = false,
                        ScoreValue = 0,
                        Special = false
                    };
     }
     var sb = new StringBuilder();
     sb.AppendLine("You picked up:");
     var items = new List<IItem>(holder.Items);
     foreach (var item in items)
     {
         state.ActiveAgent.GiveItem(item);
         sb.AppendLine(item.Name);
         holder.RemoveItem(item);
     }
     return new ActionResult()
                {
                    GameOver = false,
                    Message = sb.ToString(),
                    MoveSuccessful = true,
                    ScoreValue = 0,
                    Special = false
                };
 }
Exemplo n.º 3
0
 public ActionResult Execute(GameState state)
 {
     var current = state.CurrentCell;
     var moveTo = state.ActiveAgent.GetForwardCell(current);
     var result = moveTo.MoveTo();
     if (result.MoveSuccessful)
         state.CurrentCell = moveTo;
     return result;
 }
Exemplo n.º 4
0
 public ActionResult Execute(GameState state)
 {
     state.ActiveAgent.TurnRight();
     return new ActionResult()
     {
         GameOver = false,
         Message = string.Empty,
         MoveSuccessful = true,
         ScoreValue = 0,
         Special = false
     };
 }
Exemplo n.º 5
0
        public ActionResult Execute(GameState state)
        {
            var agent = state.ActiveAgent;
            var arrow = agent.Inventory.FirstOrDefault(x => x is ArrowItem);
            if(arrow == null)
            {
                return new ActionResult()
                           {
                               GameOver = false,
                               Message = Strings.NoArrows,
                               MoveSuccessful = false,
                               ScoreValue = 0,
                               Special = false
                           };
            }
            agent.RemoveItem(arrow);
            var direction = agent.CurrentDirection;
            bool hit = false;
            int cellsLeft = ArrowRange;
            var check = state.CurrentCell;
            while (cellsLeft > 0 && !hit)
            {
                cellsLeft--;
                check = check.GetCellInDirection(direction);
                if(check is WallMapCell)
                {
                    break;
                }
                hit = check.HitWumpusWithArrow();
            }
            if (hit)
            {
                return new ActionResult()
                           {
                               GameOver = true,
                               Message = Strings.KillWumpus,
                               MoveSuccessful = true,
                               ScoreValue = ScoreValue,
                               Special = false
                           };
            }

            return new ActionResult()
            {
                GameOver = false,
                Message = Strings.ArrowMiss,
                MoveSuccessful = false,
                ScoreValue = 0,
                Special = false
            };
        }
Exemplo n.º 6
0
 private void Reset(IAgent agent)
 {
     foreach (var item in agent.Inventory)
     {
         agent.RemoveItem(item);
     }
     agent.ResetScore();
     _state = new GameState();
     _state.ActiveAgent = agent;
     _state.CurrentCell = _generator.GenerateMap();
     RunInitialiseHooks();
 }
Exemplo n.º 7
0
 public ActionResult Execute(GameState state)
 {
     var currentCell = state.CurrentCell;
     return currentCell.FindWumpus();
 }