Exemplo n.º 1
0
        public void GenerateBattleMap()
        {
            PlayerCharacter = new Actor(this, Vec2.Zero, 1);
            PlayerCharacter.SetAI <WaitForUserInputAI>();

            BattleMap.Generate();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an enumerable collection of the entire series of GameResults for the game.
        /// </summary>
        private IEnumerable <GameResult> CreateProcessEnumerable()
        {
            while (true)
            {
                // Not using a foreach loop here so that we don't get a concurrent modification exception if an actor
                // is added or removed during the action.
                for (int actorIndex = 0; actorIndex < BattleMap.Actors.Count; actorIndex++)
                {
                    CurrentActor = BattleMap.Actors[actorIndex];

                    CurrentActor.StartTurn(); //TODO: Add start of turn stuff. Perhaps make this a "foreach GameResult in" loop as well. This is used for any "start of turn" effects, like buffs running out, etc.

                    while (CurrentActor.RemainingActions > 0)
                    {
                        // bail if we need to wait for the UI or AI to provide an action
                        while (CurrentActor.NeedsInput)
                        {
                            Debug.Log("Waiting on user input.");
                            yield return(new GameResult(false));
                        }

                        // get the actor's action
                        Action action = CurrentActor.TakeTurn();
                        {
                            // process it and everything it leads to
                            foreach (GameResult result in ProcessAction(action))
                            {
                                yield return(result);
                            }
                        }
                    }

                    // actor.EndTurn(); - TODO: add end of turn stuff. Perhaps make this a "foreach GameResult in" loop as well. This is used for any "end of turn" effects, such as enemy debuffs running out, etc.

                    // actor was killed, so remove from the collection and shift the next one up.
                    if (!CurrentActor.IsAlive)
                    {
                        BattleMap.RemoveActor(CurrentActor);
                        actorIndex--;
                    }
                }

                // TODO: Process all of the items and other things that need to have something happen each turn

                // TODO: Turn/time increment (advance 1 turn/6 seconds, etc).
            }
        }
Exemplo n.º 3
0
 public Game()
 {
     BattleMap = new BattleMap(this);
 }