예제 #1
0
    IEnumerator SetupPlayer2()
    {
        yield return(new WaitForSeconds(0.1f));

        GameObject[] sticksOnline = GameObject.FindGameObjectsWithTag("StickOnline");
        foreach (GameObject stick in sticksOnline)
        {
            if (stick.GetComponent <NetworkIdentity>().isLocalPlayer)
            {
                stick.GetComponent <Rigidbody>().position = new Vector3(-1500.0f, 0.0f, -7745.6f);
                stick.tag = "Stick2";

                Stick stickOnlineScript = stick.GetComponent <Stick>();
                stickOnlineScript.setStickOptionsForOnline(-7050.0f, -8600.0f, false, false);
                stickOnlineScript.UpdateControls();
            }
        }
    }
예제 #2
0
    public void HideSettingsMenu()
    {
        Time.timeScale = 1;
        settingsPanel.SetActive(false);
        settingsBackground.SetActive(false);
        settingsText.SetActive(false);
        settingsStartButton.SetActive(false);
        settingsCreateOnlineButton.SetActive(false);
        settingsJoinOnlineButton.SetActive(false);
        settingsStartAiEasyButton.SetActive(false);
        settingsStartAiHardButton.SetActive(false);
        settingsBackButton.SetActive(false);
        turnsSlider.SetActive(false);
        turnsText.SetActive(false);
        turnNumberText.SetActive(false);

        scoreText.SetActive(true);
        playerReady.SetActive(true);
        startButton          = keybindsMenu.GetStartButton();
        playerReadyText.text = "Player one's turn, \n Press the start button(" + startButton.ToString() + ") to start!";
        gameInfo.SetActive(true);

        pauseMenu.UpdatePauseButton();

        gameController.UpdateStartButton();

        stick = GameObject.FindGameObjectWithTag("Stick");
        if (stick != null)
        {
            stickScript = stick.GetComponent <Stick>();
        }
        stick2 = GameObject.FindGameObjectWithTag("Stick2");
        if (stick2 != null)
        {
            stickScript2 = stick2.GetComponent <Stick>();
        }
        if (stickScript != null)
        {
            stickScript.UpdateControls();
        }
        if (stickScript2 != null)
        {
            stickScript2.UpdateControls();
        }

        loadingScreen.displayLoadingScreen();

        if (aiModeEasy)
        {
            gameController.aiMode = true;
            ai.activateAI();
            ai.UnpauseAI();
            ai.setSimulationEasy();
        }
        else if (aiModeHard)
        {
            gameController.aiMode = true;
            ai.activateAI();
            ai.UnpauseAI();
            ai.setSimulationHard();
        }
    }
예제 #3
0
    public void createPlayersSticks()
    {
        string     model1;
        GameObject prefab1;

        Color[] colors1;
        float   leftLimit1  = 775.0f;
        float   rightLimit1 = -775.0f;
        float   size1;

        string     model2;
        GameObject prefab2;

        Color[] colors2;
        float   leftLimit2  = -7050.0f;
        float   rightLimit2 = -8600.0f;
        float   size2;

        Vector3 stickSize;

        DestroyAllSticks();

        model1 = avatars.getPlayer1Avatar(out prefab1, out colors1, out size1);

        leftLimit1  = 750.0f + ((size1 - 300) * -0.576f);
        rightLimit1 = -740.0f + ((size1 - 300) * 0.456f);

        GameObject stick1 = Instantiate(prefab1, new Vector3(), new Quaternion());

        stick1.GetComponent <Rigidbody>().position = new Vector3(-1500.0f, 0.0f, 42.0f);
        stick1.tag = "Stick";

        stickSize   = stick1.GetComponent <Transform>().localScale;
        stickSize.z = size1;
        stick1.GetComponent <Transform>().localScale = stickSize;

        stick1.AddComponent <AudioSource>();
        stick1.GetComponent <AudioSource>().clip        = Resources.Load <AudioClip>("palletHit");
        stick1.GetComponent <AudioSource>().playOnAwake = false;
        if (model1.Equals("Flower"))
        {
            var children = stick1.GetComponentsInChildren <Transform>();
            foreach (var child in children)
            {
                if (child.name.Equals("Stem"))
                {
                    if (!colors1[0].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors1[0];
                    }
                }
                else if (child.name.Equals("Middle"))
                {
                    if (!colors1[1].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors1[1];
                    }
                }
                else if (child.name.Contains("Petal"))
                {
                    if (!colors1[2].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors1[2];
                    }
                }
            }
        }
        if (model1.Equals("Sword"))
        {
            var children = stick1.GetComponentsInChildren <Transform>();
            foreach (var child in children)
            {
                if (child.name == "Blade")
                {
                    if (!colors1[0].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors1[0];
                    }
                }
                else if (child.name == "Crossguard")
                {
                    if (!colors1[1].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors1[1];
                    }
                }
                else if (child.name == "Grip")
                {
                    if (!colors1[2].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors1[2];
                    }
                }
                else if (child.name == "Pomel")
                {
                    if (!colors1[3].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors1[3];
                    }
                }
            }
        }
        if (model1.Equals("Normal"))
        {
            if (!colors1[0].Equals(Color.clear))
            {
                stick1.GetComponent <Renderer>().material.color = colors1[0];
            }
        }

        Stick stick1Script = stick1.GetComponent <Stick>();

        stick1Script.setStickOptions(leftLimit1, rightLimit1, true);
        stick1Script.UpdateControls();

        model2 = avatars.getPlayer2Avatar(out prefab2, out colors2, out size2);

        leftLimit2  = -7050.0f + ((size1 - 300) * -0.467f);
        rightLimit2 = -8540.0f + ((size1 - 300) * 0.533f);

        GameObject stick2 = Instantiate(prefab2, new Vector3(), new Quaternion());

        stick2.GetComponent <Rigidbody>().position = new Vector3(-1500.0f, 0.0f, -7745.6f);
        stick2.tag = "Stick2";

        stickSize   = stick2.GetComponent <Transform>().localScale;
        stickSize.z = size2;
        stick2.GetComponent <Transform>().localScale = stickSize;

        stick2.AddComponent <AudioSource>();
        stick2.GetComponent <AudioSource>().clip        = Resources.Load <AudioClip>("palletHit");
        stick2.GetComponent <AudioSource>().playOnAwake = false;
        if (model2.Equals("Flower"))
        {
            var children = stick2.GetComponentsInChildren <Transform>();
            foreach (var child in children)
            {
                if (child.name.Equals("Stem"))
                {
                    if (!colors2[0].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors2[0];
                    }
                }
                else if (child.name.Equals("Middle"))
                {
                    if (!colors2[1].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors2[1];
                    }
                }
                else if (child.name.Contains("Petal"))
                {
                    if (!colors2[2].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors2[2];
                    }
                }
            }
        }
        if (model2.Equals("Sword"))
        {
            var children = stick2.GetComponentsInChildren <Transform>();
            foreach (var child in children)
            {
                if (child.name == "Blade")
                {
                    if (!colors2[0].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors2[0];
                    }
                }
                else if (child.name == "Crossguard")
                {
                    if (!colors2[1].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors2[1];
                    }
                }
                else if (child.name == "Grip")
                {
                    if (!colors2[2].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors2[2];
                    }
                }
                else if (child.name == "Pomel")
                {
                    if (!colors2[3].Equals(Color.clear))
                    {
                        child.GetComponent <Renderer>().material.color = colors2[3];
                    }
                }
            }
        }
        if (model2.Equals("Normal"))
        {
            if (!colors2[0].Equals(Color.clear))
            {
                stick2.GetComponent <Renderer>().material.color = colors2[0];
            }
        }

        Stick stick2Script = stick2.GetComponent <Stick>();

        stick2Script.setStickOptions(leftLimit2, rightLimit2, false);
        stick2Script.UpdateControls();
    }