コード例 #1
0
    private void ServerMessageReceiver(NetworkMessage NetMsg)
    {
        StringMessage msg = new StringMessage();

        msg.value   = NetMsg.ReadMessage <StringMessage>().value;
        textUI.text = msg.value;
        string[] deltas = msg.value.Split('|');
        switch (deltas[0])
        {
        case "Player":
            int ToSetID;
            if (Int32.TryParse(deltas[1], out ToSetID))
            {
                PlayerID = ToSetID;
                PlayersImages[PlayerID - 1].SetActive(true);
                ConnectButton.SetActive(false);
            }
            break;

        case "Start":
            Scene1UI.SetActive(true);
            PlayersImages[PlayerID - 1].SetActive(false);
            break;

        case "Scene1":
            Scene1UI.SetActive(true);
            Scene2UI.SetActive(false);
            break;

        case "Scene2":
            Scene1UI.SetActive(false);
            Scene2UI.SetActive(true);
            break;

        default:
            Debug.Log("Message");
            break;
        }
    }
コード例 #2
0
    private void ServerMessageReceiver(NetworkMessage NetMsg)
    {
        StringMessage msg = new StringMessage();

        msg.value = NetMsg.ReadMessage <StringMessage>().value;
        string[] deltas = msg.value.Split('|');
        switch (deltas[0])
        {
        case "Player":
            int ToSetID;
            if (Int32.TryParse(deltas[1], out ToSetID))
            {
                PlayerID = ToSetID;
                PlayersImages[PlayerID - 1].SetActive(true);
                ConnectButton.SetActive(false);
                Scene2UI.transform.GetChild(0).GetChild(PlayerID).gameObject.SetActive(true);
                SoundManager.GetInstance().PlaySound(0);
            }
            break;

        case "Start":
            SoundManager.GetInstance().PlaySound(1);
            Scene1UI.SetActive(true);
            Scene2UI.SetActive(false);
            PlayersImages[PlayerID - 1].SetActive(false);
            Scene1 = true;
            break;

        case "Scene1":
            SoundManager.GetInstance().SetRandom(true);
            DeactivateMinigames();
            Scene1UI.SetActive(true);
            Scene2UI.SetActive(false);
            Scene1 = true;
            break;

        case "Scene2":
            SoundManager.GetInstance().SetRandom(true);
            DeactivateMinigames();
            Scene1UI.SetActive(false);
            Scene2UI.SetActive(true);
            Scene1 = false;
            break;

        case "Fallen":
            SoundManager.GetInstance().SetRandom(false);
            SoundManager.GetInstance().PlaySound(2);
            CurrentMinigame = UnityEngine.Random.Range(0, MiniGames.Length);
            MiniGames[CurrentMinigame].SetActive(true);
            MiniGames[CurrentMinigame].GetComponent <MinigameScript>().Restart();
            Scene1UI.SetActive(false);
            Scene2UI.SetActive(false);
            break;

        case "GotUp":
            SoundManager.GetInstance().SetRandom(true);
            SoundManager.GetInstance().PlaySound(3);
            DeactivateMinigames();
            if (Scene1)
            {
                Scene1UI.SetActive(true);
            }
            else
            {
                Scene2UI.SetActive(true);
            }
            break;

        case "Won":
            SoundManager.GetInstance().PlaySound(6);
            DeactivateMinigames();
            Scene1UI.SetActive(false);
            Scene2UI.SetActive(false);
            Victory.SetActive(true);
            break;

        case "Lost":
            SoundManager.GetInstance().PlaySound(7);
            DeactivateMinigames();
            Scene1UI.SetActive(false);
            Scene2UI.SetActive(false);
            Defeat.SetActive(true);
            break;

        default:
            Debug.Log("Message");
            break;
        }
    }