Example #1
0
    // Use this for initialization
    private void Start()
    {
        if (DataManager.instance.isMulti)
        {
            playerEventSystem = canvasMenu.GetComponent <CanvasMenu>().EventSystem[0];
        }
        else
        {
            playerEventSystem = canvasMenu.GetComponent <CanvasMenu>().EventSystem[playerIndex];
        }

        giftCount = 0;

        choosedClass = DataManager.TypeClass.Warrior;
        DataManager.instance.player[playerIndex] = championModel.transform.GetChild((int)choosedClass).GetComponent <Player>();
        DataManager.instance.player[playerIndex].gameObject.SetActive(true);

        isToolTipsToggled = false;
        if (DataManager.instance.isMulti)
        {
            typeScreen = TypeScreen.screenGift;
        }
        else
        {
            typeScreen = TypeScreen.screenClass;
        }

        if (blockPanel)
        {
            blockPanel.SetActive(!DataManager.instance.isMulti);
        }
    }
Example #2
0
 public void CloseSingle(TypeScreen type)
 {
     foreach (Screens s in Screens)
     {
         if (s.typeSceen == type)
         {
             s.Close();
             break;
         }
     }
 }
Example #3
0
 public void OpenSingle(TypeScreen type)
 {
     foreach (Screens s in Screens)
     {
         if (s.typeSceen == type)
         {
             s.Open();
             break;
         }
     }
 }
Example #4
0
 public void OpenScreen(TypeScreen type)
 {
     foreach (Screens s in Screens)
     {
         if (s.typeSceen == type)
         {
             s.Open();
         }
         else
         {
             s.Close();
         }
     }
 }
Example #5
0
 public void ActiveScreen(TypeScreen type)
 {
     foreach (Screen1 s in Screens)
     {
         if (s.Type == type)
         {
             s.Open();
             OpenScreen(type);
         }
         else
         {
             s.Close();
         }
     }
 }
Example #6
0
    public void OpenScreen(TypeScreen type)
    {
        switch (type)
        {
        case TypeScreen.LoadingScreen:

            isGameOver = true;
            isGameOver = true;
            break;

        case TypeScreen.PlayScreen:

            StartGame();
            break;
        }
    }
Example #7
0
    //Fonction that reinitialise the Class screen Panel when it is leaved
    public void Reinitialisation()
    {
        if (DataManager.instance.isMulti)
        {
            typeScreen = TypeScreen.screenGift;
        }
        else
        {
            typeScreen = TypeScreen.screenClass;
        }

        hasChangedScreen = false;

        //All player select warrior by default
        choosedClass = DataManager.TypeClass.Warrior;

        for (int i = 0; i < (int)DataManager.TypeClass.nbClass; i++)
        {
            championModel.transform.GetChild(i).gameObject.SetActive(false);
        }
        //DataManager.instance.player[playerIndex].gameObject.SetActive(false);
        DataManager.instance.player[playerIndex] = championModel.transform.GetChild((int)DataManager.TypeClass.Warrior).GetComponent <Player>();
        DataManager.instance.player[playerIndex].gameObject.SetActive(true);

        //Reset Gift
        if (giftCount > 0)
        {
            classScreen[(int)TypeScreen.screenGift].GetComponent <GiftsMenu>().ResetGift();
        }

        //Reset Ready button
        for (int i = 0; i < DataManager.instance.currentNbrPlayer; i++)
        {
            DataManager.instance.isPlayerReady[i]      = false;
            nextButtons[1].GetComponent <Text>().color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
        }


        if (typeScreen != TypeScreen.screenGift)
        {
            DataManager.instance.isPlayerReady[playerIndex] = false;
        }
    }
Example #8
0
    // Update is called once per frame
    void Update()
    {
        if (DataManager.instance.isMulti)
        {
            playerName.text = GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[transform.GetSiblingIndex()].playerName;
            if (isToolTipsToggled)
            {
                playerName.text = "";
            }
        }

        if (textIPserver && DataManager.instance.isMulti && DataManager.instance.localPlayerIndex == 1 && !isToolTipsToggled)
        {
            textIPserver.text = "IP: " + GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[0].LocalIPAddress();
        }
        else if (textIPserver)
        {
            textIPserver.text = "";
        }

        if (DataManager.instance.isMulti && hasChangedScreen == false)
        {
            if (transform.GetSiblingIndex() == DataManager.instance.localPlayerIndex - 1)
            {
                typeScreen       = TypeScreen.screenClass;
                hasChangedScreen = true;
            }
        }

        CharacterSelectionInput();

        //DisplayHelpButton();
        DisplayScreen();

        //Reinitialisation();

        DisplayInformationPanel();

        GiftPresetManager();

        ReadyButtonDisplay();
    }
Example #9
0
    //Set player as READY and color ReadyButton accordingly
    public void NextButton()
    {
        //When player is in SkillMenu
        if (typeScreen == TypeScreen.screenClass)
        {
            SoundManager.instance.PlaySound(6, 1.0f, AudioType.SFX);

            typeScreen = TypeScreen.screenGift;

            StartCoroutine(SetEventSystemCursor(name + "/GiftScreen/Gifts/Gift 1"));
        }

        //When player is in GiftMenu
        else if (typeScreen == TypeScreen.screenGift)
        {
            SoundManager.instance.PlaySound(6, 1.0f, AudioType.SFX);

            if (!DataManager.instance.isPlayerReady[playerIndex])
            {
                if (choosedClass == DataManager.TypeClass.Warrior)
                {
                    SoundManager.instance.PlaySound(10, 1.0f, AudioType.Voice);
                }
                else if (choosedClass == DataManager.TypeClass.Archer)
                {
                    SoundManager.instance.PlaySound(25, 1.0f, AudioType.Voice);
                }
            }

            if (DataManager.instance.isMulti)
            {
                if (DataManager.instance.isPlayerReady[DataManager.instance.localPlayerIndex - 1])
                {
                    GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].CmdPlayerReady(DataManager.instance.localPlayerIndex - 1, false);
                    GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].SendNotReadyToBeginMessage();
                }
                else
                {
                    if (giftCount == 3)
                    {
                        GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].CmdPlayerReady(DataManager.instance.localPlayerIndex - 1, true);
                        GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].SendReadyToBeginMessage();
                    }
                    else
                    {
                        transform.Find("GiftScreen").GetComponent <GiftsMenu>().StartCoroutineShowWarning();
                        nextButtons[1].GetComponent <Text>().color = new Color(1.0f, 0.0f, 0.0f, 1.0f);
                    }
                }
            }
            else
            {
                if (giftCount == 3)
                {
                    DataManager.instance.isPlayerReady[playerIndex] = !DataManager.instance.isPlayerReady[playerIndex];
                }
                else
                {
                    transform.Find("GiftScreen").GetComponent <GiftsMenu>().StartCoroutineShowWarning();
                    nextButtons[1].GetComponent <Text>().color = new Color(1.0f, 0.0f, 0.0f, 1.0f);
                }
            }
        }
    }
Example #10
0
    //Manage All Keyboard + controller input inside the Character Selection subScreen
    void CharacterSelectionInput()
    {
        if (DataManager.instance.isMulti)
        {
            if (playerIndex == DataManager.instance.localPlayerIndex - 1)
            {
                //Switch between class
                if (Input.GetKeyDown(KeyCode.E))
                {
                    DataManager.instance.isPlayerReady[playerIndex] = false;
                    classSelect.GetComponent <ClassSelection>().SwitchingClass(choosedClass, playerIndex, true, false);
                    GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].SendNotReadyToBeginMessage();
                    GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].CmdChangeModel(DataManager.instance.localPlayerIndex - 1);
                    GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].CmdPlayerReady(DataManager.instance.localPlayerIndex - 1, false);
                }
                if (Input.GetKeyDown(KeyCode.A))
                {
                    DataManager.instance.isPlayerReady[playerIndex] = false;
                    classSelect.GetComponent <ClassSelection>().SwitchingClass(choosedClass, playerIndex, true, false);
                    GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].SendNotReadyToBeginMessage();
                    GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].CmdChangeModel(DataManager.instance.localPlayerIndex - 1);
                    GameObject.Find("LobbyManager").GetComponent <Prototype.NetworkLobby.LobbyManager>().GetComponentsInChildren <Prototype.NetworkLobby.LobbyPlayer>()[DataManager.instance.localPlayerIndex - 1].CmdPlayerReady(DataManager.instance.localPlayerIndex - 1, false);
                }

                //Return
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    if (typeScreen == TypeScreen.screenGift)
                    {
                        nextButtons[1].GetComponent <Text>().color = new Color(255.0f, 255.0f, 255.0f, 255.0f);
                        typeScreen = TypeScreen.screenClass;
                        StartCoroutine(SetEventSystemCursor(name + "/SkillsScreen/Skills/AutoAttack"));
                    }
                    else if (typeScreen == TypeScreen.screenClass)
                    {
                        ShowDirector.instance.hasSwitchPos = false;
                        GameObject.Find("Canvas MenuScene").GetComponent <CanvasMenu>().waitForDisconnected(1.0f);
                        GetComponentInParent <SelectionScreens>().FadeAllCanvas();
                    }
                }

                //Toggle Help
                if (Input.GetKey(KeyCode.Tab))
                {
                    isToolTipsToggled = true;
                }
                else
                {
                    isToolTipsToggled = false;
                }
            }
        }
        else
        {
            //KEYBOARD
            if (playerIndex == 0)
            {
                //Switch between class
                if (Input.GetKeyDown(KeyCode.E))
                {
                    SoundManager.instance.PlaySound(78, 0.2f, AudioType.SFX);
                    choosedClass = classSelect.GetComponent <ClassSelection>().SwitchingClass(choosedClass, playerIndex);
                    DataManager.instance.isPlayerReady[playerIndex] = false;
                }
                if (Input.GetKeyDown(KeyCode.A))
                {
                    SoundManager.instance.PlaySound(78, 0.2f, AudioType.SFX);
                    choosedClass = classSelect.GetComponent <ClassSelection>().SwitchingClass(choosedClass, playerIndex);
                    DataManager.instance.isPlayerReady[playerIndex] = false;
                }

                //Return
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    if (typeScreen == TypeScreen.screenGift)
                    {
                        nextButtons[1].GetComponent <Text>().color = new Color(255.0f, 255.0f, 255.0f, 255.0f);
                        typeScreen = TypeScreen.screenClass;
                        StartCoroutine(SetEventSystemCursor(name + "/SkillsScreen/Skills/AutoAttack"));
                    }
                    else if (typeScreen == TypeScreen.screenClass)
                    {
                        ShowDirector.instance.hasSwitchPos = false;
                        GetComponentInParent <SelectionScreens>().FadeAllCanvas();
                    }
                }

                //Toggle Help
                if (Input.GetKey(KeyCode.Tab))
                {
                    isToolTipsToggled = true;
                }
                else
                {
                    isToolTipsToggled = false;
                }
            }

            if (playerIndex != 0)
            {
                //CONTROLLER
                for (int i = 1; i < DataManager.instance.currentNbrPlayer; i++)
                {
                    string ControllerReturn      = "Controller_" + i + "_ButtonB";
                    string ControllerRightButton = "Controller_" + i + "_RightButton";
                    string ControllerLeftButton  = "Controller_" + i + "_LeftButton";
                    string ControllerToggleHelp  = "Controller_" + i + "_ButtonY";

                    if (playerIndex == i)
                    {
                        //Switch between class
                        if (Input.GetButtonDown(ControllerRightButton))
                        {
                            SoundManager.instance.PlaySound(78, 0.2f, AudioType.SFX);
                            choosedClass = classSelect.GetComponent <ClassSelection>().SwitchingClass(choosedClass, playerIndex);
                            DataManager.instance.isPlayerReady[playerIndex] = false;
                        }
                        if (Input.GetButtonDown(ControllerLeftButton))
                        {
                            SoundManager.instance.PlaySound(78, 0.2f, AudioType.SFX);
                            choosedClass = classSelect.GetComponent <ClassSelection>().SwitchingClass(choosedClass, playerIndex);
                            DataManager.instance.isPlayerReady[playerIndex] = false;
                        }

                        //Return
                        if (Input.GetButtonDown(ControllerReturn))
                        {
                            if (typeScreen == TypeScreen.screenGift)
                            {
                                nextButtons[1].GetComponent <Text>().color = new Color(255.0f, 255.0f, 255.0f, 255.0f);
                                typeScreen = TypeScreen.screenClass;
                                StartCoroutine(SetEventSystemCursor(name + "/SkillsScreen/Skills/AutoAttack"));
                            }
                            else if (typeScreen == TypeScreen.screenClass)
                            {
                                ShowDirector.instance.hasSwitchPos = false;
                                GetComponentInParent <SelectionScreens>().FadeAllCanvas();
                            }
                        }

                        //Toggle Help
                        if (Input.GetButton(ControllerToggleHelp))
                        {
                            isToolTipsToggled = true;
                        }
                        else
                        {
                            isToolTipsToggled = false;
                        }
                    }
                }
            }
        }
    }