Exemple #1
0
        private void CmdSelectAbilityRequest(ActorController actorController, int actionTypeInt)
        {
            ActorData actor = actorController.gameObject.GetComponent <ActorData>();

            AbilityData.ActionType actionType = (AbilityData.ActionType)actionTypeInt;

            if (!GameFlowData.Get().IsInDecisionState())
            {
                Log.Info($"Recieved CmdSelectAbilityRequest not in desicion state! {actor.DisplayName} {actionType}");
                return;
            }

            Log.Info($"CmdSelectAbilityRequest {actor.DisplayName} {actionType}");

            if (!actor.QueuedMovementAllowsAbility &&
                actor.GetAbilityData().GetAbilityOfActionType(actionType).GetMovementAdjustment() != Ability.MovementAdjustment.FullMovement)
            {
                Log.Info($"CmdSelectAbilityRequest - Clearing movement for {actor.DisplayName}");
                ArtemisServerMovementManager.Get().ClearMovementRequest(actor, true);
            }

            AbilityData abilityData = actor.gameObject.GetComponent <AbilityData>();

            abilityData.Networkm_selectedActionForTargeting = actionType;
            SetAbilityRequest(actor, actionType, null);
        }
Exemple #2
0
        private IEnumerator MovementResolution()
        {
            Artemis.ArtemisServer.Get().SharedActionBuffer.Networkm_actionPhase = ActionBufferPhase.Movement;

            ArtemisServerMovementManager.Get().ResolveMovement();
            yield return(new WaitForSeconds(6)); // TODO ActorMovement.CalculateMoveTimeout() -- do we need some server version of ProcessMovement?

            foreach (ActorData actor in GameFlowData.Get().GetActors())
            {
                var turnSm = actor.gameObject.GetComponent <ActorTurnSM>();

                //ArtemisServerMovementManager.Get().UpdatePlayerMovement(actor, false);
                turnSm.CallRpcTurnMessage((int)TurnMessage.MOVEMENT_RESOLVED, 0);
                //actor.GetActorMovement().UpdateSquaresCanMoveTo();
            }

            // TODO repeat all of the above for movement_chase
            yield return(null);

            Artemis.ArtemisServer.Get().SharedActionBuffer.Networkm_actionPhase = ActionBufferPhase.MovementChase;
            // ....
            yield return(null);

            Artemis.ArtemisServer.Get().SharedActionBuffer.Networkm_actionPhase = ActionBufferPhase.MovementWait;
            yield return(null);

            Artemis.ArtemisServer.Get().SharedActionBuffer.Networkm_actionPhase = ActionBufferPhase.Done;
        }
Exemple #3
0
        private IEnumerator TurnDecision()
        {
            GameFlowData.Get().gameState = GameState.BothTeams_Decision;
            // TODO timebanks
            GameFlowData.Get().Networkm_willEnterTimebankMode           = false;
            GameFlowData.Get().Networkm_timeRemainingInDecisionOverflow = 0;

            foreach (ActorData actor in GameFlowData.Get().GetActors())
            {
                var turnSm = actor.gameObject.GetComponent <ActorTurnSM>();
                ArtemisServerGameManager.Get().ClearAbilityRequests(actor);
                actor.AppearAtBoardSquare(actor.TeamSensitiveData_authority.MoveFromBoardSquare);
                ArtemisServerMovementManager.Get().ClearMovementRequest(actor, true);
                turnSm.CallRpcTurnMessage((int)TurnMessage.TURN_START, 0);
            }
            ArtemisServerMovementManager.Get().UpdateTurn();
            ArtemisServerBarrierManager.Get().UpdateTurn();
            SharedEffectBarrierManager.Get().UpdateTurn();

            Log.Info("TurnDecision");

            while (GameFlowData.Get().GetTimeRemainingInDecision() > 0)
            {
                Log.Info($"Time remaining: {GameFlowData.Get().GetTimeRemainingInDecision()}");

                GameFlowData.Get().CallRpcUpdateTimeRemaining(GameFlowData.Get().GetTimeRemainingInDecision());
                yield return(new WaitForSeconds(2));
            }
        }
 protected virtual void OnDestroy()
 {
     if (instance == this)
     {
         instance = null;
     }
     if (GameFlowData.Get() != null)
     {
         foreach (var player in GameFlowData.Get().GetPlayers())
         {
             ActorTurnSM actorTurnSM = player.GetComponent <ActorTurnSM>();
             actorTurnSM.OnCmdSetSquareCallback -= CmdSetSquare;
         }
     }
 }
Exemple #5
0
        private void CmdRequestCancelAction(ActorTurnSM actorTurnSM, int actionTypeInt, bool hasIncomingRequest)
        {
            ActorData actor = actorTurnSM.gameObject.GetComponent <ActorData>();

            AbilityData.ActionType actionType = (AbilityData.ActionType)actionTypeInt;

            if (!GameFlowData.Get().IsInDecisionState())
            {
                Log.Info($"Recieved CmdRequestCancelAction not in desicion state! {actor.DisplayName} {actionType} ({hasIncomingRequest})");
                return;
            }

            Log.Info($"CmdRequestCancelAction {actor.DisplayName} {actionType} ({hasIncomingRequest})");
            ClearAbilityRequest(actor, actionType);
            ArtemisServerMovementManager.Get().UpdatePlayerRemainingMovement(actor, !hasIncomingRequest);
        }
Exemple #6
0
        internal void OnCastAbility(NetworkConnection conn, int casterIndex, int actionTypeInt, List <AbilityTarget> targets)
        {
            Player      player = GameFlow.Get().GetPlayerFromConnectionId(conn.connectionId);
            ActorData   actor  = GameFlowData.Get().FindActorByActorIndex(casterIndex);
            ActorTurnSM turnSm = actor.gameObject.GetComponent <ActorTurnSM>();

            AbilityData.ActionType actionType = (AbilityData.ActionType)actionTypeInt;

            if (actor.gameObject.GetComponent <PlayerData>().m_player.m_connectionId != conn.connectionId)
            {
                Log.Error($"Illegal OnCastAbility: {actor.DisplayName} does not belong to player {player.m_accountId}!");
                turnSm.CallRpcTurnMessage((int)TurnMessage.ABILITY_REQUEST_REJECTED, 0);
                ClearAbilityRequest(actor, actionType);
                return;
            }

            Log.Info($"OnCastAbility {actor.DisplayName} {actionType} ({targets.Count} targets)");

            // TODO AbilityData.ValidateAbilityOnTarget
            turnSm.CallRpcTurnMessage((int)TurnMessage.ABILITY_REQUEST_ACCEPTED, 0);
            SetAbilityRequest(actor, actionType, targets);

            ArtemisServerMovementManager.Get().UpdatePlayerRemainingMovement(actor);
        }