Example #1
0
        /// <summary>
        /// Construct a new CombatManager object with the provided data.
        /// </summary>
        /// <param name="parties">All participants in combat, grouped by their Party affiliation.</param>
        /// <param name="standardActionGenerator">Supplier of standard actions which all Actors have access to.</param>
        /// <param name="winningPartyCalculator">Calculator for how CombatManager decides when combat is finished and which party won.</param>
        /// <param name="actorChangeCalculator">Calculator for changes within an actor's properties.</param>
        /// <param name="initiativeQueue">Implementation of an initiative queue for use in this combat session.</param>
        /// <param name="eventQueue">Implementation of an event queue for use in this combat session.</param>
        public CombatManager(
            IReadOnlyCollection <IParty> parties,
            ITurnController turnController,
            IStandardActionGenerator standardActionGenerator,
            IWinningPartyCalculator winningPartyCalculator,
            IActorChangeCalculator actorChangeCalculator,
            IInitiativeQueue initiativeQueue,
            IEventQueue eventQueue)
        {
            _turnController          = turnController ?? new OneActionTurnController();
            _standardActionGenerator = standardActionGenerator ?? new NullStandardActionGenerator();
            _winningPartyCalculator  = winningPartyCalculator ?? new AnyAliveWinningPartyCalculator();
            _actorChangeCalculator   = actorChangeCalculator ?? new NullActorChangeCalculator();
            _initiativeQueue         = initiativeQueue ?? new InitiativeQueue(100);
            _eventQueue = eventQueue ?? new EventQueue();

            _parties.AddRange(parties);
            foreach (IParty party in parties)
            {
                _controllerByPartyId[party.Id] = party.Controller ?? new RandomCharacterController();
                foreach (IInitiativeActor actor in party.Actors)
                {
                    if (actor is ITargetableActor targetableActor)
                    {
                        _allTargets.Add(targetableActor);
                    }

                    float startingInitiative = (float)(RANDOM.NextDouble() * _initiativeQueue.InitiativeThreshold * 0.5f);
                    _initiativeQueue.Add(actor, startingInitiative);
                }
            }

            _combatState = CombatState.Init;
            _eventQueue.EnqueueEvent(new CombatStateChangedEvent(_combatState));
        }
 private void _RegisterWithTurnController()
 {
     TurnControllerMarker[] turnControllerMarkers = FindObjectsOfType <TurnControllerMarker>();
     foreach (TurnControllerMarker turnControllerMarker in turnControllerMarkers)
     {
         ITurnController turnController = turnControllerMarker.GetComponent <ITurnController>();
         turnController.RegisterBattleCamManager(this);
     }
 }
Example #3
0
        //----------------------------------------------------------------------------
        //             Initialise
        //----------------------------------------------------------------------------
        public void Initialise(ITurnController turnController)
        {
            MyTurnController = turnController;
            MyHexContents    = GetComponent <IContents>();
            MyHasSpeed       = GetComponent <IHasSpeed>();
            MyHasAttack      = GetComponent <IHasAttack>();
            MyHasStats       = GetComponent <IHasStats>();
            MyIsVictim       = GetComponent <IIsVictim>();

            _RollInitiative();

            GetComponent <ICanDie>().RegisterHasTurn(this);
        }
Example #4
0
 public void RegisterTurnController(ITurnController turnController)
 {
     MyTurnController = turnController;
 }
 private void CreateTurn()
 {
     turn = TurnFactory.CreateNextTurn();
 }