public override void OnClientEnterRoom()
        {
            base.OnClientEnterRoom();

            manager = (NetworkLobbyManager_Mirror)NetworkLobbyManager_Mirror.singleton; //get the network lobby manager component

            if (manager == null)
            {
                return;
            }

            IsHost = false; //initially marked as non-host.

            manager.UIMgr.SetLobbyFactionParent(transform);

            manager.UIMgr.ToggleMapSettings();

            ResetFactionTypeDropDownMenu(); //so that the faction type drop down menu contains the correct map settings.

            if (isLocalPlayer == true)      //if this is the local player (player who owns this network lobby faction)
            {
                InitLocal();
            }
            else
            {
                InitOther();
            }

            NetworkLobbyManager_Mirror.LobbyFactions.Add(this); //add new instance to lobby faction components list
        }
        //after CmdInit is called, this method will be called to initialize this component
        private void Start()
        {
            this.gameMgr = FindObjectOfType(typeof(GameManager)) as GameManager; //get the game manager component
            this.manager = FindObjectOfType(typeof(NetworkLobbyManager_Mirror)) as NetworkLobbyManager_Mirror;

            if (GameManager.HostFactionID == factionID) //if this is the host
            {
                HostFactionMgr = this;
                NetworkPlayers = new List <NetworkPlayer_Mirror>(); //init the network players list

                syncTest.Init();                                    //initialize the sync test instance
            }

            if (factionID == GameManager.PlayerFactionID)
            {
                gameMgr.GetFaction(factionID).FactionManager_Mirror = this;
            }

            isFactionSpawned = false; //by default faction is marked as not spawned, yet.

            receivedCommands = 0;
            currentTurn      = 0;
            ServerTurn       = 0;

            if (isServer)                                                                      //if this component is initiated on the server's side
            {
                gameMgr.GetFaction(factionID).ConnID_Mirror = connectionToClient.connectionId; //set the unique connection ID field for the host/server (will be used to check for clients that disconnect during the game).
            }
            initialized = true;
        }
Exemplo n.º 3
0
        private bool InitMirrorMultiplayerGame()
        {
#if RTSENGINE_MIRROR
            NetworkManager_Mirror = (NetworkLobbyManager_Mirror)NetworkLobbyManager_Mirror.singleton;

            if (NetworkManager_Mirror == null) //if there's mirror network lobby manager component in the scene then this is not a multiplayer game
            {
                return(false);
            }

            //randomize the faction slots in this map before starting the assignment of each faction slot
            RandomizeFactionSlots(NetworkManager_Mirror.FactionSlotIndexes);

            MultiplayerGame = true;                                                                     //this is now a multiplayer game.
            List <NetworkLobbyFaction_Mirror> lobbyfactions = NetworkLobbyManager_Mirror.LobbyFactions; //get all lobby faction components into a list

            if (lobbyfactions.Count > factions.Count)                                                   //if there aren't enough slots in this map for all factions.
            {
                Debug.LogError("[Game Manager]: Not enough slots available for all the factions coming from the multiplayer menu.");
                return(false);
            }

            //set the defeat condition & speed modifier:
            defeatCondition = NetworkManager_Mirror.UIMgr.defeatConditionMenu.GetValue();
            speedModifier   = NetworkManager_Mirror.UIMgr.speedModifierMenu.GetValue();

            //we have enough slots:
            for (int i = 0; i < lobbyfactions.Count; i++) //Loop through all the slots and set up the factions.
            {
                int index = lobbyfactions[i].index;       //get the faction ID.
                factions[index].Init(
                    lobbyfactions[i].GetFactionName(),
                    NetworkManager_Mirror.GetFactionTypeInfo(lobbyfactions[i].GetFactionTypeID()),
                    NetworkManager_Mirror.FactionColor.Get(lobbyfactions[i].GetFactionColorID()),
                    lobbyfactions[i].isLocalPlayer,
                    NetworkManager_Mirror.GetMapInitialPopulation(),
                    null,
                    gameObject.AddComponent <FactionManager>(), i, this);

                if (lobbyfactions[i].IsHost) //does this lobby faction belong to the host?
                {
                    HostFactionID = i;       //mark it.
                }
                factions[index].InitMultiplayer(lobbyfactions[i]);
            }

            //if there are more slots than required, remove them
            while (lobbyfactions.Count < factions.Count)
            {
                factions[factions.Count - 1].InitDestroy();
                factions.RemoveAt(factions.Count - 1);
            }
#endif
            return(true);
        }
        private void Awake()
        {
            infoMessageText.gameObject.SetActive(false); //hide the info message text UI element

            //get the network components
            manager   = GetComponent <NetworkLobbyManager_Mirror>();
            transport = GetComponent <TelepathyTransport>();

            EnableMenu(MultiplayerMenu.main); //by default, we're in the main MP menu

            //initialize the defeat condition & speed modifier drop down menu options.
            defeatConditionMenu.Init();
            speedModifierMenu.Init();
        }
 public void OnEnable()
 {
     manager    = (NetworkLobbyManager_Mirror)target;
     manager_SO = new SerializedObject(manager);
 }