public override void OnMissionModeChange(MissionMode oldMissionMode, bool atStart) { base.OnMissionModeChange(oldMissionMode, atStart); if (Utils.IsStartOfBattle(oldMissionMode, Mission.Mode)) { BattleStartEvent?.Invoke(); IsActivated = true; } else if (Utils.IsStartofSiege(oldMissionMode, Mission.Mode)) { PlayerAgent = Agent.Main; IsActivated = true; SiegeBattleStartEvent?.Invoke(); } else if (Utils.IsStartofHideoutBattle(oldMissionMode, Mission.Mode)) { PlayerAgent = Agent.Main; IsActivated = true; HideoutBattleStartEvent?.Invoke(); } else if (Utils.IsEndOfHideoutConversation(oldMissionMode, Mission.Mode)) { IsActivated = true; } else { IsActivated = false; } }
protected Mission(string key, string type, MissionMode mode, bool noTeams) { Key = key; Type = type; Mode = mode; NoTeams = noTeams; }
/// <summary> /// Retrieves the current state of the game. /// </summary> private unsafe string GetGameState() { string currentGameState = ""; // Normal Game (Playing) if ((!State.IsWatchingIngameEvent()) && (State.GameState == GameState.InGame)) { if (State.ModeSwitch.TryDereference(out ModeSwitch * modeSwitch)) { MissionMode missionMode = modeSwitch->Mission; switch (missionMode) { case MissionMode.HardMode when Player.Teams[0] != Team.Sonic: currentGameState = $"Hard Mode, Team {Player.GetTeamName(Players.One)}"; break; case MissionMode.HardMode: currentGameState = $"Hard Mode"; break; case MissionMode.Alternate: currentGameState = $"Team {Player.GetTeamName(Players.One)}, Mission II"; break; default: currentGameState = $"Team {Player.GetTeamName(Players.One)}"; break; } } } // Two player mode. if (State.IsMultiplayerMode() && (!State.IsInMainMenu())) { int total1PVictories = _victoryCounter.GetTotalVictoryCount(Players.One); int total2PVictories = _victoryCounter.GetTotalVictoryCount(Players.Two); int current1PVictories = _victoryCounter.GetVictoryCount(Players.One); int current2PVictories = _victoryCounter.GetVictoryCount(Players.Two); string teamName1P = Player.GetTeamName(Players.One); string teamName2P = Player.GetTeamName(Players.Two); currentGameState = $"Total: {total1PVictories}-{total2PVictories} | {teamName1P} vs {teamName2P} | Set: {current1PVictories}-{current2PVictories}"; } // Gameplay Paused if (State.IsPaused()) { currentGameState = "Paused"; } return(currentGameState); }
public static bool OnMissionModeChange_Prefix(MissionScreen __instance, MissionMode oldMissionMode, bool atStart) { if (__instance.Mission.Mode == MissionMode.Battle && oldMissionMode == MissionMode.Deployment) { Utility.SmoothMoveToAgent(__instance, true); return(false); } return(true); }
void Update() { // 順序 Closed > Completed > Completing > Opeing > Open 倒著寫防止發生Update 2 次以上 if (Global.isGameStart) { gameTime = battleManager.gameTime; //Debug.Log("lastGameTime"+lastGameTime); if (missionMode == MissionMode.Closed) // 任務關閉時,持續判斷是否觸發任務 { MissionTrigger(); } if (missionMode == MissionMode.Completed) // 任務完成時,關閉任務並儲存資訊,回到初始狀態 { if (_mission == Mission.Reduce) { activeScore -= _missionScore; } _missionScore = 0; _missionMode = MissionMode.Closed; _mission = Mission.None; avgMissionTime = (lastGameTime + (gameTime - lastGameTime)) / 2; // 平均任務完成時間 lastGameTime = gameTime; // 任務完成時時間 } if (missionMode == MissionMode.Completing && Global.isMissionCompleted) // 任務完成中,發送完成訊息並等待Server完成資料判斷。 { if (_mission == Mission.DrivingMice) { Global.photonService.MissionCompleted((byte)_mission, missionRate, (Int16)battleManager.combo, ""); } else { Global.photonService.MissionCompleted((byte)_mission, missionRate, 0, ""); } Global.isMissionCompleted = false; } if (missionMode == MissionMode.Opening) // 任務開啟中,持續判斷 完成任務/任務失敗 { MissionExecutor(_mission); } if (missionMode == MissionMode.Open && missionFlag) // 任務開始時,發送任務訊息並等待Server回傳任務 { missionFlag = false; lastScore = battleManager.score; // 儲存任務開始前的分數 Global.photonService.SendMission((byte)_mission, missionRate); } } }
/// <summary> /// Retrieves the current state of the game. /// </summary> private string GetGameState() { string currentGameState = ""; // Normal Game (Playing) if ((!_heroes.IsWatchingIngameEvent()) && (*_heroes.GameState == GameState.InGame)) { MissionMode missionMode = (**_heroes.GameControlStructPointer).MissionMode; switch (missionMode) { case MissionMode.HardMode when * _heroes.TeamOne != Team.Sonic: currentGameState = $"Hard Mode, Team {_heroes.GetTeamName(1)}"; break; case MissionMode.HardMode: currentGameState = $"Hard Mode"; break; case MissionMode.Alternate: currentGameState = $"Team {_heroes.GetTeamName(1)}, Mission II"; break; default: currentGameState = $"Team {_heroes.GetTeamName(1)}"; break; } } // Two player mode. if (_heroes.IsTwoPlayer() && (!_heroes.IsInMainMenu())) { int total1PVictories = _heroes.VictoryTracker.GetTotalVictoryCount(1); int total2PVictories = _heroes.VictoryTracker.GetTotalVictoryCount(2); int current1PVictories = _heroes.VictoryTracker.GetVictoryCount(1); int current2PVictories = _heroes.VictoryTracker.GetVictoryCount(2); string teamName1P = _heroes.GetTeamName(1); string teamName2P = _heroes.GetTeamName(2); currentGameState = $"Total: {total1PVictories}-{total2PVictories} | {teamName1P} vs {teamName2P} | Set: {current1PVictories}-{current2PVictories}"; } // Gameplay Paused if (_heroes.IsPaused()) { currentGameState = "Paused"; } return(currentGameState); }
void OnApplyMission(Mission mission, Int16 missionScore) { if (Global.isGameStart) { if (mission != Mission.HarvestRate) { battleHUD.MissionMsg(mission, missionScore); } _missionScore = missionScore; _mission = mission; lastGameTime = gameTime; // 任務開始時時間 _missionMode = MissionMode.Opening; } }
void OnMissionComplete(Int16 missionReward) { if (Global.isGameStart) { Debug.Log("OnMissionManager:" + missionReward); if (mission == Mission.WorldBoss && missionReward < 0) { battleHUD.MissionFailedMsg(mission, 0); } else { battleHUD.MissionCompletedMsg(mission, missionReward); } Global.isMissionCompleted = false; _missionMode = MissionMode.Completed; } }
public override void OnFormationUnitsSpawned(Team team) { base.OnFormationUnitsSpawned(team); using (IEnumerator <Formation> enumerator = team.FormationsIncludingSpecial.GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current.ApplyActionOnEachUnit(delegate(Agent agent) { if (!agent.IsAIControlled) { return; } agent.SetIsAIPaused(true); }); } } if (team.IsPlayerTeam) { /* To Do: Figure out how to disable combat while formations are set, as the method below is not available. * base.Mission.MainAgent.SetIsCombatActionsDisabled(true); */ base.Mission.MainAgent.Controller = Agent.ControllerType.AI; } this.formationSpawned++; if (this.formationSpawned >= base.Mission.Teams.Count) { base.Mission.IsTeleportingAgents = true; base.Mission.CameraIsFirstPerson = false; this.SetDeploymentBoundary(); Vec3 position = base.Mission.MainAgent.Position; float lookDirectionAsAngle = base.Mission.MainAgent.LookDirectionAsAngle; Vec2 vec = new Vec2(0f, -30f); vec.RotateCCW(lookDirectionAsAngle); MatrixFrame frame = new MatrixFrame(0f, 1f, 0f, 1f, 0f, 0f, -MathF.Sin(lookDirectionAsAngle + 3.14159274f), MathF.Cos(lookDirectionAsAngle + 3.14159274f), -MathF.Cos(1.04719758f), position.X + vec.X, position.Y + vec.Y, position.Z + 40f); frame.Fill(); (ScreenManager.TopScreen as MissionScreen).UpdateFreeCamera(frame); MissionMode mode = base.Mission.Mode; InformationManager.DisplayMessage(new InformationMessage(new TextObject("{=opsdeploy-start}Deployment Phase. Press E to Start Battle.", null).ToString(), new Color(0f, 0.8f, 0f, 1f))); } base.Mission.AllowAiTicking = false; }
private bool _isBadMice; // 是否打到壞老鼠 #endregion void Start() { Global.photonService.ApplyMissionEvent += OnApplyMission; // 加入 接受任務 監聽事件 Global.photonService.OtherMissionScoreEvent += OnOtherMissionComplete; // 加入 顯示對方 完成任務 監聽事件 Global.photonService.MissionCompleteEvent += OnMissionComplete; // 加入 完成任務 監聽事件 Global.photonService.LoadSceneEvent += OnLoadScene; // 移除 離開房間 監聽事件 battleManager = GetComponent <BattleManager>(); battleHUD = GetComponent <BattleHUD>(); activeScore = 1000; activeTime = 15; //15 missionTime = 10; //10 missionRate = 1.0f; lastGameTime = 0; missionFlag = false; seesawFlag = true; _isBadMice = false; _mission = Mission.None; _missionMode = MissionMode.Closed; }
// 任務事件處發者 void MissionTrigger() { if (Global.OtherData.RoomPlace != "Host") // 如果我是主機才會當任務事件判斷者 { float _otherScore = battleManager.otherScore; float _score = battleManager.score; float otherPercent = (_otherScore / (_score + _otherScore)) * 100; float myPercent = 100 - otherPercent; if ((gameTime - lastGameTime) > missionInterval) // 任務間隔時間 { // 如果 我方或對方 分數<10%之間 啟動高平衡機制,只觸發限制次數 if ((otherPercent < lowestPercent || myPercent < lowestPercent) && balanceTimes > 0 && missionMode == MissionMode.Closed && _otherScore != 0 && _score != 0) { Mission[] missionSelect = { Mission.HarvestRate }; _mission = missionSelect[UnityEngine.Random.Range(0, 0)]; _missionMode = MissionMode.Open; missionFlag = true; balanceTimes--; Debug.Log("我方或對方 分數<10%之間 啟動高平衡機制"); }// 如果 我方或對方 分數再10~25%之間 啟動低平衡機制,只觸發限制次數 else if ((myPercent < lowerPercent && myPercent > lowestPercent) || (myPercent < lowerPercent && myPercent > lowestPercent && _otherScore != 0 && _score != 0) && balanceTimes > 0 && missionMode == MissionMode.Closed) { Mission[] missionSelect = { Mission.HarvestRate }; _mission = missionSelect[UnityEngine.Random.Range(0, 0)]; _missionMode = MissionMode.Open; missionFlag = true; balanceTimes--; Debug.Log("我方或對方 分數再10~25%之間 啟動低平衡機制"); } // 如果遊戲時間 > 觸發時間 啟動任務(收穫、趕老鼠) (如果分數觸發 則 時間不觸發) if (gameTime > (lastGameTime + activeTime) && seesawFlag && missionMode == MissionMode.Closed) { Mission[] missionSelect = { Mission.WorldBoss, Mission.WorldBoss, Mission.WorldBoss, Mission.WorldBoss }; _mission = missionSelect[UnityEngine.Random.Range(0, 4)]; activeTime += activeTime + UnityEngine.Random.Range(0, (int)(activeTime / 2)); _missionMode = MissionMode.Open; missionFlag = true; seesawFlag = false; Debug.Log("如果遊戲時間 > 觸發時間 啟動任務(收穫、趕老鼠) (如果分數觸發 則 時間不觸發)"); Debug.Log("gameTime" + gameTime + "lastGameTime" + lastGameTime + "activeTime" + activeTime); } // 如果 任意玩家遊戲分數 > 觸發分數 啟動任務 (如果時間觸發 則 分數不觸發) if ((_score > activeScore || _otherScore > activeScore) && !seesawFlag && missionMode == MissionMode.Closed) { Mission[] missionSelect = { Mission.WorldBoss, Mission.WorldBoss, Mission.WorldBoss, Mission.WorldBoss }; _mission = missionSelect[UnityEngine.Random.Range(0, 4)]; activeScore += activeScore + UnityEngine.Random.Range(0, (int)(activeScore / 2)); _missionMode = MissionMode.Open; missionFlag = true; seesawFlag = true; Debug.Log("// 如果 任意玩家遊戲分數 > 觸發分數 啟動任務 (如果時間觸發 則 分數不觸發)"); } // 如果雙方遊戲分數、遊戲時間 > 觸發條件 出現BOSS if (_score > bossActiveScore && _otherScore > bossActiveScore && gameTime > bossActiveTime && missionMode == MissionMode.Closed) { _mission = Mission.WorldBoss; _missionMode = MissionMode.Open; missionFlag = true; Debug.Log("// 如果雙方遊戲分數、遊戲時間 > 觸發條件 出現BOSS"); } } } }
public void OnMissionModeChange(MissionMode oldMissionMode, bool atStart) { }
internal static bool IsEndOfHideoutConversation(MissionMode oldMode, MissionMode newMode) { return(oldMode == MissionMode.Conversation && newMode == MissionMode.Stealth); }
internal static bool IsStartofHideoutBattle(MissionMode oldMode, MissionMode newMode) { return(oldMode == MissionMode.Battle && newMode == MissionMode.Stealth); }
internal static bool IsStartofSiege(MissionMode oldMode, MissionMode newMode) { return(oldMode == MissionMode.Deployment && newMode == MissionMode.Battle); }
internal static bool IsStartOfBattle(MissionMode oldMode, MissionMode newMode) { return(oldMode == MissionMode.StartUp && newMode == MissionMode.Battle); }
// 任務事件處理者 void MissionExecutor(Mission mission) { switch (mission) { case Mission.Harvest: // 達成XX收穫 { if ((battleManager.score - lastScore) >= _missionScore) // success { _missionMode = MissionMode.Completing; Global.isMissionCompleted = true; } else if (gameTime - lastGameTime > missionTime) // failed { _missionMode = MissionMode.Completed; battleHUD.MissionFailedMsg(mission, 0); } break; } case Mission.Reduce: // 完成後 activeScore要減少Reduce的量 { double endTime = gameTime - lastGameTime - missionTime; if (endTime > -5 && endTime < 0) // 減少糧食 這比較特殊 需要顯示閃爍血調 還沒寫 { battleHUD.HPBar_Shing(); } else if (gameTime - lastGameTime > missionTime) { _missionMode = MissionMode.Completing; Global.isMissionCompleted = true; } break; } case Mission.DrivingMice: { if (gameTime - lastGameTime > missionTime) //missionScore 這裡是 Combo任務目標 { if (battleManager.combo < _missionScore) { _missionMode = MissionMode.Completed; battleHUD.MissionFailedMsg(mission, 0); } else { _missionMode = MissionMode.Completing; Global.isMissionCompleted = true; } } break; } case Mission.HarvestRate: { if (gameTime - lastGameTime > missionTime) { _missionMode = MissionMode.Completing; Global.isMissionCompleted = true; } break; } case Mission.Exchange: { if (gameTime - lastGameTime > missionTime) { _missionMode = MissionMode.Completing; Global.isMissionCompleted = true; } break; } case Mission.WorldBoss: // 要計算網路延遲... **********還沒寫************* // 在 BossPorperty在邏輯判斷 break; } }