//instantiate commander object public static void AddController(AgentController agentController) //, string defaultController { if (PlayerManager.ContainsController(agentController)) { Debug.Log("BOOM"); return; } agentController.PlayerIndex = AgentControllers.Add(agentController); if (MainController == null) { MainController = agentController; } // CreatePlayerObject(agentController, defaultController); }
public void CreateCommander() { if (Commander != null) { Debug.LogError("A commander called '" + Commander.gameObject.name + "' already exists for '" + this.ToString() + "'."); } if (!UnityEngine.Object.FindObjectOfType <RTSGameManager>()) { Debug.LogError("A game manager has not been initialized!"); } //load from ls db GameObject commanderObject = GameObject.Instantiate(GameResourceManager.GetCommanderObject(), UnityEngine.Object.FindObjectOfType <RTSGameManager>().GetComponentInChildren <AgentCommanders>().transform); commanderObject.name = this.ControllerName; AgentCommander commanderClone = commanderObject.GetComponent <AgentCommander>(); //change to user's selected username commanderClone.username = this.ControllerName; commanderClone.SetController(this); if (PlayerManager.ContainsController(this)) { commanderClone.human = true; } //come up with better way to set selected commander to the current commander if (this == PlayerManager.MainController) { PlayerManager.SelectPlayer(commanderClone.username, 0, this.ControllerID, this.PlayerIndex); } _commander = commanderClone; BehaviourHelperManager.InitializeOnDemand(_commander); }