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); }
private void CmdGUITurnMessage(ActorTurnSM actorTurnSM, int msgEnum, int extraData) { ActorData actor = actorTurnSM.gameObject.GetComponent <ActorData>(); TurnMessage msg = (TurnMessage)msgEnum; if (!GameFlowData.Get().IsInDecisionState()) { Log.Info($"Recieved CmdGuiTurnMessage not in desicion state! {actor.DisplayName} {msg} ({extraData})"); return; } Log.Info($"CmdGuiTurnMessage {actor.DisplayName} {msg} ({extraData})"); if (msg == TurnMessage.CANCEL_BUTTON_CLICKED) { // TODO distinguish CANCEL button and ability cancelling // actor.TeamSensitiveData_authority.SetToggledAction(actionType, false); // if (DONE) make undone // else if (targeting action) set toggled action(false) actorTurnSM.CallRpcTurnMessage((int)TurnMessage.CANCEL_BUTTON_CLICKED, 0); } else if (msg == TurnMessage.DONE_BUTTON_CLICKED) { actorTurnSM.CallRpcTurnMessage((int)TurnMessage.DONE_BUTTON_CLICKED, 0); } // TODO: Timebanks. Notice that client sends CANCEL msg when selecting ability after confirmed // (but we still should have a fallback if it doesn't) but doesn't send one when updating movement. }
private void PlaceCharacters() { // TODO Log.Info("Placing characters"); int x = 16; int y = 9; foreach (var player in GameFlowData.Get().GetPlayers()) { //UnityUtils.DumpGameObject(player); ActorData actorData = player.GetComponent <ActorData>(); var atsd = actorData.TeamSensitiveData_authority; if (atsd == null) { continue; } BoardSquare start = Board.Get().GetSquare(x++, y); GridPosProp startProp = GridPosProp.FromGridPos(start.GetGridPosition()); atsd.CallRpcMovement(GameEventManager.EventType.Invalid, startProp, startProp, null, ActorData.MovementType.Teleport, false, false); actorData.ServerLastKnownPosSquare = start; actorData.InitialMoveStartSquare = start; actorData.MoveFromBoardSquare = start; Log.Info($"Placing {actorData.DisplayName} at {startProp.m_x}, {startProp.m_y}"); // PATCH internal -> public ActorData.DisplayName } Log.Info("Done placing characters"); }
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; }
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); }
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); } }
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"); }
private void SendToAll(short msgType, MessageBase msg) { foreach (ActorData actor in GameFlowData.Get().GetActors()) { //if (!actor.GetPlayerDetails().IsHumanControlled) { continue; } actor.connectionToClient?.Send(msgType, msg); } }
/// <summary> /// 外部启动 /// </summary> private void ExternalStart() { string[] arguments = Environment.GetCommandLineArgs(); GameFlowData gameFlowData = new GameFlowData(); GameDataManager.FlowData = LabTools.GetDataByString <GameFlowData>(gameFlowData.ToJson()); GameDataManager.LabDataManager.LabDataCollectInit(() => GameDataManager.FlowData.UserId); GameSceneManager.Instance.Change2MainScene(); }
// public class ObserverMessage : MessageBase // { // public Replay.Message Message; // // public override void Serialize(NetworkWriter writer) // { // GeneratedNetworkCode._WriteMessage_Replay(writer, this.Message); // } // // public override void Deserialize(NetworkReader reader) // { // this.Message = GeneratedNetworkCode._ReadMessage_Replay(reader); // } // } public void LaunchGame(bool spawnObjects = true) { MapLoader = new AssetLoader(); MapLoader.LoadAssetBundle("Bundles/scenes/maps.bundle"); MapLoader.LoadAsset( $"archive:/buildplayer-robotfactory_opu_gamemode/buildplayer-{GameConfig.Map.ToLower()}"); MapLoader.ConstructCaches(); AssetsLoader = new AssetLoader(); AssetsLoader.LoadAsset("resources.assets"); AssetsLoader.ConstructCaches(); MiscLoader = new AssetLoader(); MiscLoader.LoadAssetBundle("Bundles/scenes/frontend.bundle"); MiscLoader.LoadAsset("archive:/buildplayer-options_ui/buildplayer-clientenvironmentsingletons"); MiscLoader.ConstructCaches(); if (!spawnObjects) { return; } SpawnObject(MiscLoader, "ApplicationSingletonsNetId", out _); SpawnObject(MiscLoader, "GameSceneSingletons", out var gameSceneSingletons); TheatricsManager = gameSceneSingletons.GetComponent <TheatricsManager>(); AbilityModManager = gameSceneSingletons.GetComponent <AbilityModManager>(); SpawnObject(MiscLoader, "SharedEffectBarrierManager", out SharedEffectBarrierManager); SpawnObject(MiscLoader, "SharedActionBuffer", out SharedActionBuffer); SharedActionBuffer.Networkm_actionPhase = ActionBufferPhase.Done; SpawnScene(MapLoader, 1, out var commonGameLogic); InterfaceManager = commonGameLogic.GetComponent <InterfaceManager>(); GameFlow = commonGameLogic.GetComponent <GameFlow>(); // MatchLogger = commonGameLogic.GetComponent<MatchLogger>(); ServerCombatManager = commonGameLogic.GetComponent <ServerCombatManager>(); ServerEffectManager = commonGameLogic.GetComponent <ServerEffectManager>(); TeamStatusDisplay = commonGameLogic.GetComponent <TeamStatusDisplay>(); ServerActionBuffer = commonGameLogic.GetComponent <ServerActionBuffer>(); TeamSelectData = commonGameLogic.GetComponent <TeamSelectData>(); BarrierManager = commonGameLogic.GetComponent <BarrierManager>(); SpawnObject <Board, Board>(MapLoader, out Board); SpawnScene(MapLoader, 2, out BrushCoordinator); SpawnScene(MapLoader, 3, out var sceneGameLogic); GameFlowData = sceneGameLogic.GetComponent <GameFlowData>(); GameplayData = sceneGameLogic.GetComponent <GameplayData>(); SpoilsManager = sceneGameLogic.GetComponent <SpoilsManager>(); ObjectivePoints = sceneGameLogic.GetComponent <ObjectivePoints>(); SpawnPointManager = sceneGameLogic.GetComponent <SpawnPointManager>(); MatchObjectiveKill = sceneGameLogic.GetComponent <MatchObjectiveKill>(); DumpNetObjects(); }
public static ActorData GetActorByIndex(int actorIndex) { foreach (ActorData actor in GameFlowData.Get().GetActors()) { if (actor.ActorIndex == actorIndex) { return(actor); } } return(null); }
public static Dictionary <int, ActorData> GetActorByIndex() { var actors = GameFlowData.Get().GetActors(); var result = new Dictionary <int, ActorData>(actors.Count); foreach (ActorData actor in actors) { result.Add(actor.ActorIndex, actor); } return(result); }
public void StartButtonClick() { GameFlowData gameFlow = new GameFlowData(); GameDataManager.FlowData = gameFlow; var Id = gameFlow.UserId; GameDataManager.LabDataManager.LabDataCollectInit(() => Id); GameSceneManager.Instance.Change2MainScene(); }
private IEnumerator PrepareForGame() { Log.Info("Preparing for game"); //GameFlowData.Get().enabled = true; GameFlowData.Get().gameState = GameState.Deployment; yield return(new WaitForSeconds(5)); GameFlow.Get().CallRpcSetMatchTime(0); GameFlowData.Get().Networkm_currentTurn = 0; Log.Info("Done preparing for game"); }
public void OnClientResolutionPhaseCompleted(NetworkConnection conn, GameMessageManager.ClientResolutionPhaseCompleted msg) { Player player = GameFlow.Get().GetPlayerFromConnectionId(conn.connectionId); ActorData actor = GameFlowData.Get().FindActorByActorIndex(msg.ActorIndex); if (actor.gameObject.GetComponent <PlayerData>().m_player.m_connectionId != conn.connectionId) { Log.Warning($"OnClientResolutionPhaseCompleted: {actor.DisplayName} does not belong to player {player.m_accountId}!"); } TheatricsPendingClients.Remove(player.m_accountId); }
public void ClientLoaded(NetworkConnection connection, int playerIndex) { Player player = GameFlow.Get().GetPlayerFromConnectionId(connection.connectionId); foreach (ActorData playerActor in GameFlowData.Get().GetAllActorsForPlayer(playerIndex)) { GameObject character = playerActor.gameObject; character.GetComponent <PlayerData>().m_player = player; // PATCH internal -> public PlayerData::m_player GameFlow.Get().playerDetails[player]?.m_gameObjects.Add(character); Log.Info($"Registered player with account id {player.m_accountId} as player {playerIndex} ({character.name})"); NetworkServer.AddPlayerForConnection(connection, character, 0); } }
public bool IsVisible(BoardSquare square) { // no actual edits if (!NetworkServer.active && m_owner != GameFlowData.Get().activeOwnedActorData) { Log.Warning("Calling FogOfWar::IsVisible(BoardSquare square) on a client for not-the-client actor."); } if (square == null) { return(false); } return(m_visibleSquares.ContainsKey(square)); }
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; } } }
protected virtual void Awake() { if (instance == null) { instance = this; } foreach (var player in GameFlowData.Get().GetPlayers()) { ActorTurnSM actorTurnSM = player.GetComponent <ActorTurnSM>(); actorTurnSM.OnCmdGUITurnMessageCallback += CmdGUITurnMessage; actorTurnSM.OnCmdRequestCancelActionCallback += CmdRequestCancelAction; ActorController actorController = player.GetComponent <ActorController>(); actorController.OnCmdSelectAbilityRequestCallback += CmdSelectAbilityRequest; } }
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); }
private void SendActions() { // TODO friendly/hostile visibility Log.Info($"Sending {ActionsThisPhase.Count} actions"); foreach (ClientResolutionAction action in ActionsThisPhase) { Log.Info($"Sending action: {action.GetDebugDescription()}, Caster actor: {action.GetCaster()?.ActorIndex}, Action: {action.GetSourceAbilityActionType()}"); SendToAll((short)MyMsgType.SingleResolutionAction, new SingleResolutionAction() { TurnIndex = GameFlowData.Get().CurrentTurn, PhaseIndex = (int)Phase, Action = action }); } ActionsThisTurn.AddRange(ActionsThisPhase); }
public void SendMovementActions(List <ClientResolutionAction> actions) { if (Phase != AbilityPriority.INVALID) { Log.Error($"SendMovementActions called in {Phase} phase! Ignoring"); return; } SendToAll((short)MyMsgType.StartResolutionPhase, new StartResolutionPhase() { CurrentTurnIndex = GameFlowData.Get().CurrentTurn, CurrentAbilityPhase = Phase, NumResolutionActionsThisPhase = actions.Count }); ActionsThisPhase = actions; SendActions(); }
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>(); if (actorTurnSM != null) { actorTurnSM.OnCmdGUITurnMessageCallback -= CmdGUITurnMessage; } ActorController actorController = player.GetComponent <ActorController>(); if (actorController != null) { actorController.OnCmdSelectAbilityRequestCallback -= CmdSelectAbilityRequest; } } } }
void IGameEventListener.OnGameEvent( GameEventManager.EventType eventType, GameEventManager.GameEventArgs args) { if (eventType != GameEventManager.EventType.GameFlowDataStarted) { return; } if (transform == null) { Log.Print(LogType.Error, "ThinCover receiving GameFlowDataStarted game event, but its transform is null."); } else if (GameFlowData == null) { Log.Print(LogType.Error, "ThinCover receiving GameFlowDataStarted game event, but GameFlowData is null."); } else if (GameFlowData.GetThinCoverRoot() == null) { Log.Print(LogType.Error, "ThinCover receiving GameFlowDataStarted game event, but GameFlowData's ThinCoverRoot is null."); } else { try { transform.father = GameFlowData.GetThinCoverRoot().transform; UpdateBoardSquare(); } catch (NullReferenceException ex) { Log.Print(LogType.Error, "Caught System.NullReferenceException for ThinCover receiving GameFlowDataStarted game event. Highly unexpected!"); } } }
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); }
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); }
/// <summary> /// Init this game and loads all the assets needed to receive players /// </summary> public void LaunchGame() { SetGameStatus(GameStatus.Launching); MapLoader = new AssetLoader(); MapLoader.LoadAssetBundle("Bundles/scenes/maps.bundle"); MapLoader.LoadAsset($"archive:/buildplayer-robotfactory_opu_gamemode/buildplayer-{GameConfig.Map.ToLower()}"); MapLoader.ConstructCaches(); AssetsLoader = new AssetLoader(); AssetsLoader.LoadAsset("resources.assets"); AssetsLoader.ConstructCaches(); MiscLoader = new AssetLoader(); MiscLoader.LoadAssetBundle("Bundles/scenes/frontend.bundle"); MiscLoader.LoadAsset("archive:/buildplayer-options_ui/buildplayer-clientenvironmentsingletons"); MiscLoader.ConstructCaches(); SpawnObject(MiscLoader, "ApplicationSingletonsNetId", out _); SpawnObject(MiscLoader, "GameSceneSingletons", out var gameSceneSingletons); TheatricsManager = gameSceneSingletons.GetComponent <TheatricsManager>(); AbilityModManager = gameSceneSingletons.GetComponent <AbilityModManager>(); SpawnObject(MiscLoader, "SharedEffectBarrierManager", out SharedEffectBarrierManager); SpawnObject(MiscLoader, "SharedActionBuffer", out SharedActionBuffer); SharedActionBuffer.Networkm_actionPhase = ActionBufferPhase.Done; SpawnScene(MapLoader, 1, out var commonGameLogic); InterfaceManager = commonGameLogic.GetComponent <InterfaceManager>(); GameFlow = commonGameLogic.GetComponent <GameFlow>(); MatchLogger = commonGameLogic.GetComponent <MatchLogger>(); ServerCombatManager = commonGameLogic.GetComponent <ServerCombatManager>(); ServerEffectManager = commonGameLogic.GetComponent <ServerEffectManager>(); TeamStatusDisplay = commonGameLogic.GetComponent <TeamStatusDisplay>(); ServerActionBuffer = commonGameLogic.GetComponent <ServerActionBuffer>(); TeamSelectData = commonGameLogic.GetComponent <TeamSelectData>(); BarrierManager = commonGameLogic.GetComponent <BarrierManager>(); SpawnObject <Board, Board>(MapLoader, out Board); SpawnScene(MapLoader, 2, out BrushCoordinator); SpawnScene(MapLoader, 3, out var sceneGameLogic); GameFlowData = sceneGameLogic.GetComponent <GameFlowData>(); GameplayData = sceneGameLogic.GetComponent <GameplayData>(); SpoilsManager = sceneGameLogic.GetComponent <SpoilsManager>(); ObjectivePoints = sceneGameLogic.GetComponent <ObjectivePoints>(); SpawnPointManager = sceneGameLogic.GetComponent <SpawnPointManager>(); MatchObjectiveKill = sceneGameLogic.GetComponent <MatchObjectiveKill>(); PrintAllNetworkGameObjects(); foreach (LobbyPlayerInfo playerInfo in TeamInfo.TeamPlayerInfo) { // We use the ReadyState here to indicate wheter a player or bot finished loading the match if (playerInfo.IsNPCBot) { playerInfo.ReadyState = ReadyState.Ready; // Bots are marked as ready as they don't have to load anything } else { playerInfo.ReadyState = ReadyState.Unknown; // Unknown means it is loading } } SetGameStatus(GameStatus.Launched); }
public void CmdSetSquare(ActorTurnSM actorTurnSM, int x, int y, bool setWaypoint) { ActorData actor = actorTurnSM.gameObject.GetComponent <ActorData>(); if (!GameFlowData.Get().IsInDecisionState()) { Log.Info($"Recieved CmdSetSquare not in desicion state! {actor.DisplayName} [{x}, {y}] (setWaypoint = {setWaypoint})"); actorTurnSM.CallRpcTurnMessage((int)TurnMessage.MOVEMENT_REJECTED, 0); return; } Log.Info($"CmdSetSquare {actor.DisplayName} [{x}, {y}] (setWaypoint = {setWaypoint})"); BoardSquare boardSquare = Board.Get().GetSquare(x, y); ActorMovement actorMovement = actor.GetActorMovement(); if (!setWaypoint) { ClearMovementRequest(actor, false); } actorMovement.UpdateSquaresCanMoveTo(); if (!actor.CanMoveToBoardSquare(boardSquare)) { boardSquare = actorMovement.GetClosestMoveableSquareTo(boardSquare, false); } if (actor.TeamSensitiveData_authority.MovementLine == null) { actor.TeamSensitiveData_authority.MovementLine = new LineData.LineInstance(); } if (actor.TeamSensitiveData_authority.MovementLine.m_positions.Count == 0) { actor.TeamSensitiveData_authority.MovementLine.m_positions.Add(actor.InitialMoveStartSquare.GetGridPosition()); } BoardSquarePathInfo path = actorMovement.BuildPathTo(actor.TeamSensitiveData_authority.MoveFromBoardSquare, boardSquare); if (path == null) // TODO check cost { Log.Info($"CmdSetSquare: Movement rejected"); UpdatePlayerRemainingMovement(actor); // TODO updating because we cancelled movement - perhaps we should not cancel in this case actorTurnSM.CallRpcTurnMessage((int)TurnMessage.MOVEMENT_REJECTED, 0); return; } //List<GridPos> posList = path.ToGridPosPath(); List <GridPos> posList = new List <GridPos>(); for (var pathNode = path; pathNode.next != null; pathNode = pathNode.next) { posList.Add(pathNode.next.square.GetGridPosition()); // TODO why doesnt path.ToGridPosPath() work? } actor.TeamSensitiveData_authority.MovementLine.m_positions.AddRange(posList); actor.TeamSensitiveData_authority.MoveFromBoardSquare = boardSquare; actor.MoveFromBoardSquare = boardSquare; UpdatePlayerRemainingMovement(actor); actorTurnSM.CallRpcTurnMessage((int)TurnMessage.MOVEMENT_ACCEPTED, 0); }
public bool ResolveNextPhase() { bool lastPhase = false; TargetedActorsThisPhase = new Dictionary <ActorData, Dictionary <AbilityTooltipSymbol, int> >(); ActionsThisPhase = new List <ClientResolutionAction>(); Animations = new List <ActorAnimation>(); Barriers = new List <Barrier>(); var sab = Artemis.ArtemisServer.Get().SharedActionBuffer; if (Turn == null) { Turn = new Turn() { TurnID = GameFlowData.Get().CurrentTurn }; TargetedActorsThisTurn = new Dictionary <ActorData, Dictionary <AbilityTooltipSymbol, int> >(); ActionsThisTurn = new List <ClientResolutionAction>(); } while (ActionsThisPhase.Count == 0) { AdvancePhase(); if (Phase >= AbilityPriority.NumAbilityPriorities) { Log.Info("Abilities resolved"); lastPhase = true; break; } Log.Info($"Resolving {Phase} abilities"); foreach (ActorData actor in GameFlowData.Get().GetActors()) { GameFlowData.Get().activeOwnedActorData = actor; ResolveAbilities(actor, Phase); } GameFlowData.Get().activeOwnedActorData = null; Utils.Add(TargetedActorsThisTurn, TargetedActorsThisPhase); } sab.Networkm_abilityPhase = Phase; // TODO check this UpdateTheatricsPhase(); if (lastPhase) { Turn = null; GameFlowData.Get().activeOwnedActorData = null; sab.Networkm_actionPhase = ActionBufferPhase.AbilitiesWait; sab.Networkm_abilityPhase = AbilityPriority.Prep_Defense; Phase = AbilityPriority.INVALID; return(false); } SendToAll((short)MyMsgType.StartResolutionPhase, new StartResolutionPhase() { CurrentTurnIndex = GameFlowData.Get().CurrentTurn, CurrentAbilityPhase = Phase, NumResolutionActionsThisPhase = ActionsThisPhase.Count }); SendActions(); foreach (Barrier barrier in Barriers) { BarrierManager.Get().AddBarrier(barrier, true, out var _); // TODO AddBarrier updates ability blocking. Should we update vision/movement/cover? } // TODO process ClientResolutionManager.SendResolutionPhaseCompleted return(true); }