示例#1
0
 protected virtual void OnDestroy()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
示例#2
0
 protected virtual void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
示例#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));
            }
        }
        public void ResolveMovement()
        {
            Dictionary <int, BoardSquarePathInfo> paths = new Dictionary <int, BoardSquarePathInfo>();

            foreach (ActorData actor in GameFlowData.Get().GetActors())
            {
                paths.Add(actor.ActorIndex, ResolveMovement(actor));
            }

            Dictionary <int, BoardSquarePathInfo> nodes = new Dictionary <int, BoardSquarePathInfo>(paths);
            bool finished = false;

            for (float time = 0; !finished; time += RESOLUTION_STEP)
            {
                if (!ResolveSubstep(nodes, time, out finished))
                {
                    // TODO optimize
                    time  = -RESOLUTION_STEP;
                    nodes = new Dictionary <int, BoardSquarePathInfo>(paths);
                    Log.Info("Restarting movement resolution loop");
                }
            }

            var movementActions = ArtemisServerBarrierManager.Get().OnMovement(paths);

            ArtemisServerResolutionManager.Get().SendMovementActions(movementActions);

            // TODO ClientMovementManager.MsgServerMovementStarting

            foreach (ActorData actor in GameFlowData.Get().GetActors())
            {
                BoardSquarePathInfo start = paths[actor.ActorIndex];
                BoardSquarePathInfo end   = start;
                while (end.next != null)
                {
                    end = end.next;
                }

                ActorTeamSensitiveData atsd = actor.TeamSensitiveData_authority;

                // TODO GetPathEndpoint everywhere

                // TODO movement camera bounds
                actor.MoveFromBoardSquare    = end.square;
                actor.InitialMoveStartSquare = end.square;

                atsd.CallRpcMovement(
                    GameEventManager.EventType.Invalid,
                    GridPosProp.FromGridPos(start.square.GetGridPosition()),
                    GridPosProp.FromGridPos(end.square.GetGridPosition()),
                    MovementUtils.SerializePath(start),
                    ActorData.MovementType.Normal,
                    false,
                    false);

                atsd.MovementLine?.m_positions.Clear();
            }
            Log.Info("Movement resolved");
        }