コード例 #1
0
#pragma warning restore CS0618

        public void SuggestPower(string power)
        {
            NetPower np = new NetPower {
                Suggestion = power
            };

            SendToServer(np);
        }
コード例 #2
0
        private void AddPowerToPool(int connId, NetMsg msg)
        {
            CurrentPowers++;
            NetPower np = (NetPower)msg;

            ps.AddPowerToPool(np.Suggestion);
            GameObject.Find("/Canvases").GetComponent <ConnectionMenu>()
            .IncrementUserSuggestions(connId);
        }
コード例 #3
0
#pragma warning restore CS0618

        public void AssignPowersAndStartGame()
        {
            ps.Randomize();
            int totalNumOfPowers = ps.Count();

            // Send to GM for first pick
            for (int i = 0; i < 4; i++)
            {
                string item = ps.PopItem();
                Debug.Log($"Sending {item} to GM");
                Player.Instance.AddPower(item);
            }

            NetAllPowersIn napi = new NetAllPowersIn();

            for (int connId = 1; connId <= currentConnections; connId++)
            {
                for (int j = 0; j < 4; j++)
                {
                    string item = ps.PopItem();
                    Debug.Log($"Sending {item} to {connId}");
                    NetPower np = new NetPower {
                        Suggestion = item
                    };
                    SendToClient(0, connId, np);
                }
                SendToClient(0, connId, napi);
            }
            Debug.Log("Finished Sending Items");
            // Switch GM canvas
            var canvases = GameObject.Find("/Canvases").GetComponent <CanvasSwitcher>();

            Player.Instance.SetPowers();
            canvases.SwitchCanvas(canvases[1]);
            Debug.Log("Switched GM Canvas");
            // Stop checking if players are ready
            playing = true;
            Debug.Log("Stopping player ready check");
            // Stop broadcasting
            canvases.GetComponent <NewConnections>().ToggleConnections(false);
            Debug.Log("Stopping broadcast");
        }