public BattleInfoSet() { if (MainDiplomacyManager == null) { MainDiplomacyManager = GameObject.Find("GameManager").GetComponent <GameController>().GetDiplomacyManager(); } }
/// <summary> /// returns the new relation value between the two facs /// </summary> /// <param name="facID1"></param> /// <param name="facID2"></param> /// <param name="addition"></param> /// <param name="preventBecomingAllies"></param> /// <returns></returns> public float AddRelationBetweenFactions(int facID1, int facID2, float addition, bool preventBecomingAllies = false) { foreach (FactionRelation rel in relations) { if (rel.relatedFacs[0] == facID1 || rel.relatedFacs[1] == facID1) { if (rel.relatedFacs[0] == facID2 || rel.relatedFacs[1] == facID2) { float relationsBeforeChange = rel.relationValue; rel.relationValue = Mathf.Clamp(rel.relationValue + addition, MIN_RELATIONS, preventBecomingAllies ? CONSIDER_ALLY_THRESHOLD : MAX_RELATIONS); //register this relation for later announcement of changes if (!reportedRelationChanges.ContainsKey(rel)) { reportedRelationChanges.Add(rel, relationsBeforeChange); } //if a new alliance was made here, everyone should react! if (RelationValueToStanding(rel.relationValue) == FactionStanding.ally && RelationValueToStanding(relationsBeforeChange) != FactionStanding.ally) { DiplomacyManager.GlobalReactToAlliance(rel.relatedFacs[0], rel.relatedFacs[1]); } return(rel.relationValue); } } } return(INITIAL_REL); }
public void EstablishReference() { MainDiplomacyManager = MainGameController.GetDiplomacyManager(); MainCardManager = MainGameController.GetCardManager(); MainCardDisplayController = MainGameController.GetCardDisplayController(); MainUIController = MainGameController.GetUIController(); MainRoundManager = MainGameController.GetRoundManager(); }
public override void OnPhaseStart() { base.OnPhaseStart(); //only zones with our commanders should have something happening conflictZones.Clear(); zonesToCleanUp.Clear(); commandersBeingDeleted.Clear(); Faction playerFac = GameModeHandler.instance.curPlayingFaction; GameInfo gData = GameController.CurGameData; List <Commander> verifiedCmders = playerFac.OwnedCommanders; List <Zone> verifiedZones = playerFac.OwnedZones; if (gData.unifyBattlePhase && playerFac.ID == gData.factions[gData.factions.Count - 1].ID) { //if it's the "big post-battle", check all cmders instead of just the playing faction's verifiedCmders = gData.deployedCommanders; } infoTxt.text = "The effects of any battles(commanders disappearing, zones being taken) happen now"; Zone zoneCmderIsIn = null; Faction curZoneOwnerFac = null; foreach (Commander cmder in verifiedCmders) { zoneCmderIsIn = GameController.GetZoneByID(cmder.zoneIAmIn); if (!conflictZones.Contains(zoneCmderIsIn)) { if (zoneCmderIsIn.CanBeTakenBy(cmder.ownerFaction)) { conflictZones.Add(zoneCmderIsIn); curZoneOwnerFac = GameController.GetFactionByID(zoneCmderIsIn.ownerFaction); DiplomacyManager.GlobalReactToAttack(zoneCmderIsIn); } } } //also add owned zones that should become neutral due to being completely abandoned foreach (Zone z in verifiedZones) { if (!conflictZones.Contains(z)) { if (GameController.GetCombinedTroopsInZoneFromFactionAndAllies(z, z.ownerFaction).Count == 0) { conflictZones.Add(z); } } } if (conflictZones.Count > 0) { StartCoroutine(GoToNextConflict()); } else { infoTxt.text = "End of Turn!"; OnPhaseEnding(GameModeHandler.instance.currentTurnIsFast); } }
// Start is called before the first frame update void Start() { UpdateMode(); PoliticalCoordsMenuBackground = GameObject.Find("PoliticalCoordsMenuBackground"); PoliticalCoordsMenuBackground.SetActive(false); PauseMenu = GameObject.Find("PauseMenu"); PauseMenu.SetActive(false); ConsoleInput = GameObject.Find("Console"); ConsoleInput.SetActive(false); GameModeMenu = GameObject.Find("GameModeMenu"); EconomicMenu = GameObject.Find("Economic Menu"); EconomicMenu.SetActive(false); ConstructionMenu = GameObject.Find("ConstructionMenu"); ConstructionMenu.SetActive(false); ArmyMenu = GameObject.Find("ArmyMenu"); ArmyMenu.SetActive(false); DiplomacyMenu = GameObject.Find("DiplomacyMenu"); DiplomacyMenu.SetActive(false); SeparatismMenu = GameObject.Find("SeparatismMenu"); SeparatismMenu.SetActive(false); EndGameMenu = GameObject.Find("EndGameMenu"); EndGameMenu.SetActive(false); Armymanager = ArmyMenu.GetComponent <ArmyManager>(); diplomacyManager = DiplomacyMenu.GetComponent <DiplomacyManager>(); scene_name = SceneManager.GetActiveScene().name; EconomicModeMinColor = new Color(95, 20, 198); EconomicModeMaxColor = new Color(0, 255, 211); ArmyModeMinColor = new Color(22, 104, 122); ArmyModeMaxColor = new Color(83, 98, 20); ConstructionModeMinColor = new Color(37, 201, 195); ConstructionModeMaxColor = new Color(201, 37, 181); DiplomacyModeWorstColor = new Color(114, 63, 0); DiplomacyModeBestColor = new Color(59, 114, 0); DiplomacyModeEnemyColor = new Color(114, 0, 0); DiplomacyModeAllyColor = new Color(0, 114, 101); DiplomacyModeProtagonistColor = new Color(12, 0, 146); SeparatismModeMinColor = new Color(0, 0, 208); SeparatismModeMaxColor = new Color(208, 0, 0); NatresModeMinColor = new Color(185, 255, 113); NatresModeMaxColor = new Color(255, 173, 113); EduModeMinColor = new Color(251, 243, 146); EduModeMaxColor = new Color(127, 162, 255); ClimateModeMinColor = new Color(50, 200, 250); ClimateModeMaxColor = new Color(50, 250, 63); Consequentor = GameObject.Find("Consequentor").GetComponent <consequentor>(); UpdateStep(); UpdateBalance(); UpdateActions(); foreach (GameObject province in list_of_provinces) { province.GetComponent <Renderer>().material.SetColor("_EmissionColor", province.GetComponent <provincegen>().state.GetComponent <stategen>().state_color); province.GetComponent <Renderer>().material.EnableKeyword("__EMISSION"); } }
public void SpawnUnit(int templateID, Vector3 pos, DiplomacyManager.SideCode side) { Unit newUnit = Instantiate(genericUnit, pos, new Quaternion()) as Unit; newUnit.template = UnitTemplateManager.UnitReference(templateID); newUnit.side = side; if (gameManager.GetPlayerSide() == side) { newUnit.tag = SelectRectangle.SELECTABLE; } //unitInstance.Add(newUnit.id, newUnit); }
public void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); return; } }
// Use this for initialization void Start() { // 获取位于网络管理器上的网络控制器 //MainNetworkController = GameObject.Find("NetworkManager").GetComponent<NetworkController>(); // 向网络管理器注册自己的数据包处理函数 //MainNetworkController.ManagerRegistion("GameManager", MessageReceive); // 用于单场景开发时加载测试使用 if (GameObject.Find("ClientPlayerManager") == null) { PlayerID = 0; GameMapID = "FreedomDay"; FirstRoundPlayerID = 0; } else { MainClientPlayerController = GameObject.Find("ClientPlayerManager").GetComponent <ClientPlayerController>(); PlayerID = MainClientPlayerController.GetPlayerID(); GameMapID = MainClientPlayerController.GetGameMapID(); FirstRoundPlayerID = MainClientPlayerController.GetFirstRoundPlayerID(); } // 1. 生成所有游戏必要组件 //=================================================================================================================== MainLibraryManager = new LibraryManager(this); MainCardManager = new CardManager(this); MainResourceManager = new ResourceManager(this); MainDiplomacyManager = new DiplomacyManager(this); MainRoundManager = new RoundManager(this); MainEnvironmentManager = new EnvironmentManager(this); MainWorldManager = new WorldManager(this); MainGameLoader = new GameLoader(this); MainInitialHandCardManager = new InitialHandCardManager(this); GameObject CardDisplayManagerPrefab = (GameObject)Resources.Load("Prefabs/Manager/GamePlay/CardDisplayManager"); CardDisplayManager = GameObject.Instantiate(CardDisplayManagerPrefab); CardDisplayManager.name = "CardDisplayManager"; MainCardDisplayController = CardDisplayManager.GetComponent <CardDisplayController>(); MainCardDisplayController.Initialize(this); GameObject InputManagerPrefab = (GameObject)Resources.Load("Prefabs/Manager/GamePlay/InputManager"); InputManager = GameObject.Instantiate(InputManagerPrefab); InputManager.name = "InputManager"; MainInputController = InputManager.GetComponent <InputController>(); MainInputController.SetCurrentPlayerID(PlayerID); MainInputController.Initialize(this); GameObject MessageManagerPrefab = (GameObject)Resources.Load("Prefabs/Manager/GamePlay/MassageManager"); MessageManager = GameObject.Instantiate(MessageManagerPrefab); MessageManager.name = "MessageManager"; MainMessageController = MessageManager.GetComponent <MessageController>(); MainMessageController.Initialize(this); GameObject UIManagerPrefab = (GameObject)Resources.Load("Prefabs/Manager/GamePlay/UIManager"); UIManager = GameObject.Instantiate(UIManagerPrefab); UIManager.name = "UIManager"; MainUIController = UIManager.GetComponent <UIController>(); MainUIController.Initialize(this); //2. 将游戏组件中的refernece建立 //=================================================================================================================== MainLibraryManager.EstablishReference(); MainCardManager.EstablishReference(); MainResourceManager.EstablishReference(); MainDiplomacyManager.EstablishReference(); MainRoundManager.EstablishReference(); MainEnvironmentManager.EstablishReference(); MainWorldManager.EstablishReference(); MainGameLoader.EstablishReference(); MainInitialHandCardManager.EstablishReference(); MainCardDisplayController.EstablishReference(); MainInputController.EstablishReference(); MainMessageController.EstablishReference(); MainUIController.EstablishReference(); // 参数设置 //=================================================================================================================== MainRoundManager.SetCurrentRoundPlayerID(FirstRoundPlayerID); MainGameLoader.SetGameMapID(GameMapID); //=================================================================================================================== MainLibraryManager.LoadGameDataFromXML(); MainGameLoader.LoadGame(); // 生成发送信息 string SendMessage = ""; // 通知网络管理器发送信息 //CurrentMessageToBeSent = MainNetworkController.AddMessageInSendList(SendMessage); MainInitialHandCardManager.GenerateInitialHandCard(3); }