Пример #1
0
        private ClientResolutionAction MakeResolutionAction(
            MovementNode node,
            Barrier barrier,
            GameObject sequenceToPlay,
            Dictionary <ActorData, ClientActorHitResults> actorToHitResults)
        {
            SequenceSource seqSource = new SequenceSource(null, null, ArtemisServerResolutionManager.Get().NextSeqSourceRootID, true);

            ServerClientUtils.SequenceStartData seqStart = new ServerClientUtils.SequenceStartData(
                sequenceToPlay,
                node.pathInfo.square,
                new ActorData[] { node.actor },
                barrier.Caster,
                seqSource);
            ClientBarrierResults barrierResults = new ClientBarrierResults(
                barrier.m_guid,
                barrier.Caster,
                actorToHitResults,
                new Dictionary <Vector3, ClientPositionHitResults>());
            ClientMovementResults movementResults = new ClientMovementResults(
                node.actor,
                node.pathInfo,
                new List <ServerClientUtils.SequenceStartData> {
                seqStart
            },
                null,
                barrierResults,
                null,
                null);

            return(new ClientResolutionAction(ResolutionActionType.BarrierOnMove, null, null, movementResults));
        }
Пример #2
0
 public static Barrier ConsBarrier(
     ActorData caster,
     StandardBarrierData data,
     Vector3 targetPos,
     Vector3 facingDir,
     SequenceSource seqSource,
     List <GameObject> prefabOverride = null)
 {
     Log.Info($"Spawning barrier by {caster.DisplayName}: max duration {data.m_maxDuration}, max hits {data.m_maxHits}, end on caster death {data.m_endOnCasterDeath}");
     return(new Barrier(
                ArtemisServerResolutionManager.Get().NextBarrierGuid,
                "",
                targetPos,
                facingDir,
                data.m_width,
                data.m_bidirectional,
                data.m_blocksVision,
                data.m_blocksAbilities,
                data.m_blocksMovement,
                data.m_blocksPositionTargeting,
                data.m_considerAsCover,
                data.m_maxDuration,
                caster,
                prefabOverride ?? data.m_barrierSequencePrefabs,
                true,
                data.m_onEnemyMovedThrough,
                data.m_onAllyMovedThrough,
                data.m_maxHits,
                data.m_endOnCasterDeath,
                seqSource,
                caster.GetTeam()));
 }
 protected virtual void OnDestroy()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
 protected virtual void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Пример #5
0
        private IEnumerator ActionResolution()
        {
            foreach (ActorData actor in GameFlowData.Get().GetActors())
            {
                var turnSm = actor.gameObject.GetComponent <ActorTurnSM>();
                turnSm.CallRpcTurnMessage((int)TurnMessage.BEGIN_RESOLVE, 0);
            }
            yield return(0);

            Artemis.ArtemisServer.Get().SharedActionBuffer.Networkm_actionPhase = ActionBufferPhase.Abilities;
            GameFlowData.Get().gameState = GameState.BothTeams_Resolve;
            // TODO update ATSDs on a separate tick
            yield return(new WaitForSeconds(1));

            bool hasNextPhase = true;

            while (hasNextPhase)
            {
                hasNextPhase = ArtemisServerResolutionManager.Get().ResolveNextPhase();
                yield return(ArtemisServerResolutionManager.Get().WaitForTheatrics());
            }
            yield return(new WaitForSeconds(1));

            foreach (ActorData actor in GameFlowData.Get().GetActors())
            {
                var turnSm = actor.gameObject.GetComponent <ActorTurnSM>();
                turnSm.CallRpcTurnMessage((int)TurnMessage.CLIENTS_RESOLVED_ABILITIES, 0);
            }
        }
Пример #6
0
        private IEnumerator EndTurn()
        {
            GameFlowData.Get().gameState = GameState.EndingTurn;
            ArtemisServerResolutionManager.Get().ApplyActions();

            // Update statuses
            foreach (ActorData actor in GameFlowData.Get().GetActors())
            {
                var actorStatus = actor.GetActorStatus();
                for (StatusType status = 0; status < StatusType.NUM; status++)
                {
                    if (actorStatus.HasStatus(status))
                    {
                        int duration = Math.Max(0, actorStatus.GetDurationOfStatus(status) - 1);
                        actorStatus.UpdateStatusDuration(status, duration);
                        if (duration == 0)
                        {
                            do
                            {
                                actorStatus.RemoveStatus(status);
                            } while (actorStatus.HasStatus(status));
                            Log.Info($"{actor.DisplayName}'s {status} status has expired.");
                        }
                    }
                }
            }
            yield return(null);
        }
        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");
        }
Пример #8
0
        private IEnumerator EndTurn()
        {
            GameFlowData.Get().gameState = GameState.EndingTurn;
            ArtemisServerResolutionManager.Get().ApplyActions();

            // Iterate over each player in the game
            foreach (ActorData actor in GameFlowData.Get().GetActors())
            {
                // Update statuses
                var actorStatus = actor.GetActorStatus();
                for (StatusType status = 0; status < StatusType.NUM; status++)
                {
                    if (actorStatus.HasStatus(status))
                    {
                        int duration = Math.Max(0, actorStatus.GetDurationOfStatus(status) - 1);
                        actorStatus.UpdateStatusDuration(status, duration);
                        if (duration == 0)
                        {
                            do
                            {
                                actorStatus.RemoveStatus(status);
                            } while (actorStatus.HasStatus(status));
                            Log.Info($"{actor.DisplayName}'s {status} status has expired.");
                        }
                    }
                }
                // Progress the cooldowns
                AbilityData actorAbilityData = actor.GetAbilityData();
                actorAbilityData.ProgressCooldowns();

                // Apply energy/tech point regen effects
                int newTechPoints = actor.TechPoints + actor.m_techPointRegen;
                Log.Info($"{actor.DisplayName} regens ${actor.m_techPointRegen} tech points");
                actor.SetTechPoints(newTechPoints);
            }
            yield return(null);
        }