示例#1
0
    // Use this for initialization
    void Update()
    {
        //Cooses the proper guns and starts the reload screen simultaneously for the first time
        if (once)
        {
            chooseGun(player.weapon, false);
            chooseGun_2(player2.weapon, false);
            showReloadScreen(1);
            showReloadScreen(2);
            once = false;
        }

        if (player.health <= 0 || player2.health <= 0)
        {
            SceneManager.LoadScene("Results");
        }

        //Updates the Reload screen UI to reflect the currentl selected bullet
        if (ES_P1.currentSelectedGameObject != null)
        {
            if (ES_P1.currentSelectedGameObject.tag == "SpellHolder")
            {
                runeName.text   = ES_P1.currentSelectedGameObject.GetComponent <RuneInfo> ().runeName;
                runeDamage.text = ES_P1.currentSelectedGameObject.GetComponent <RuneInfo> ().runeDamage;
                runeDesc.text   = ES_P1.currentSelectedGameObject.GetComponent <RuneInfo> ().runeDesc;
                runeDisplay.GetComponent <Image> ().sprite = ES_P1.currentSelectedGameObject.GetComponent <RuneInfo> ().runeImage;
                runeDisplay.GetComponent <Image> ().color  = new Color(0, 0, 0, 255);
            }
        }
        if (ES_P2.currentSelectedGameObject != null)
        {
            if (ES_P2.currentSelectedGameObject.tag == "SpellHolder")
            {
                runeName_2.text   = ES_P2.currentSelectedGameObject.GetComponent <RuneInfo> ().runeName;
                runeDamage_2.text = ES_P2.currentSelectedGameObject.GetComponent <RuneInfo> ().runeDamage;
                runeDesc_2.text   = ES_P2.currentSelectedGameObject.GetComponent <RuneInfo> ().runeDesc;
                runeDisplay_2.GetComponent <Image> ().sprite = ES_P2.currentSelectedGameObject.GetComponent <RuneInfo> ().runeImage;
                runeDisplay_2.GetComponent <Image> ().color  = new Color(0, 0, 0, 255);
            }
        }

        if (pause)
        {
            if (Input.GetButtonDown("Cancel_P1"))
            {
                if (Temp.Count > 0)
                {
                    removeBullet();
                }
            }
            if (Input.GetButtonDown("Cancel_P2"))
            {
                if (Temp_2.Count > 0)
                {
                    removeBullet_P2();
                }
            }
            if (p1Ready)
            {
                ES_P1.SetSelectedGameObject(null);
            }
            if (p2Ready)
            {
                ES_P2.SetSelectedGameObject(null);
            }
            if (firstPause)
            {
                //Shows the battle screen for both players
                if (p1Ready && p2Ready)
                {
                    //firstPause = false;
                    showBattleScreen(1);
                    showBattleScreen(2);
                }
            }
            else
            {
                //Allows the player to move and shoot when not reloading
                if (!p1reload)
                {
                    player.playerUpdate();
                }
                if (!p2reload)
                {
                    player2.playerUpdate();
                }

                bool enemyReload = true;
                foreach (Spell spell in spells)
                {
                    if (spell != null)
                    {
                        spell.spellUpdate();
                    }
                }
                foreach (Enemy enemy in enemies)
                {
                    if (enemy != null)
                    {
                        enemy.enemyUpdate();
                    }
                }
                foreach (Obstacle ob in obstacles)
                {
                    if (ob != null)
                    {
                        ob.obstacleUpdate();
                    }
                }
                updateSpellList();
                deleteSpells();
                updateObstacleList();
                deleteObstacles();
                if (p1Ready)
                {
                    showBattleScreen(1);
                }
                if (p2Ready)
                {
                    showBattleScreen(2);
                }

                //Allows the player back into the reload screen
                if (!p1reload && Input.GetButtonDown("Start_P1") && player.reload)
                {
                    showReloadScreen(1);
                }
                if (!p2reload && Input.GetButtonDown("Start_P2") && player2.reload)
                {
                    showReloadScreen(2);
                }
            }

            if (Temp.Count == weaponMax)
            {
                ES_P1.SetSelectedGameObject(GameObject.Find("BattleButton"));
            }
            if (Temp_2.Count == weaponMax_2)
            {
                ES_P2.SetSelectedGameObject(GameObject.Find("BattleButton_2"));
            }
        }
        else
        {
            if (!p1reload)
            {
                player.playerUpdate();
            }
            if (!p2reload)
            {
                player2.playerUpdate();
            }
            foreach (Spell spell in spells)
            {
                if (spell != null)
                {
                    spell.spellUpdate();
                }
            }
            foreach (Enemy enemy in enemies)
            {
                if (enemy != null)
                {
                    enemy.enemyUpdate();
                }
            }
            foreach (Obstacle ob in obstacles)
            {
                if (ob != null)
                {
                    ob.obstacleUpdate();
                }
            }
            updateSpellList();
            deleteSpells();
            updateObstacleList();
            deleteObstacles();

            if (player.reload && Input.GetButtonDown("Start_P1"))
            {
                showReloadScreen(1);
            }
            if (player2.reload && Input.GetButtonDown("Start_P2"))
            {
                showReloadScreen(2);
            }
        }
        if (p1reload || p2reload)
        {
            pause = true;
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (once)
        {
            chooseGun(player.weapon, false);
            chooseGun_2(player2.weapon, false);
            once = false;
        }
        //updateHealth ();
        if (player.health <= 0 || player2.health <= 0)
        {
            SceneManager.LoadScene("Results");
        }
        if (pause)
        {
            if (ES_P1.currentSelectedGameObject != null)
            {
                if (ES_P1.currentSelectedGameObject.tag == "SpellHolder")
                {
                    runeName.text   = ES_P1.currentSelectedGameObject.GetComponent <RuneInfo> ().runeName;
                    runeDamage.text = ES_P1.currentSelectedGameObject.GetComponent <RuneInfo> ().runeDamage;
                    runeDesc.text   = ES_P1.currentSelectedGameObject.GetComponent <RuneInfo> ().runeDesc;
                    runeDisplay.GetComponent <Image> ().sprite = ES_P1.currentSelectedGameObject.GetComponent <RuneInfo> ().runeImage;
                    runeDisplay.GetComponent <Image> ().color  = new Color(0, 0, 0, 255);
                }
            }
            if (ES_P2.currentSelectedGameObject != null)
            {
                if (ES_P2.currentSelectedGameObject.tag == "SpellHolder")
                {
                    runeName_2.text   = ES_P2.currentSelectedGameObject.GetComponent <RuneInfo> ().runeName;
                    runeDamage_2.text = ES_P2.currentSelectedGameObject.GetComponent <RuneInfo> ().runeDamage;
                    runeDesc_2.text   = ES_P2.currentSelectedGameObject.GetComponent <RuneInfo> ().runeDesc;
                    runeDisplay_2.GetComponent <Image> ().sprite = ES_P2.currentSelectedGameObject.GetComponent <RuneInfo> ().runeImage;
                    runeDisplay_2.GetComponent <Image> ().color  = new Color(0, 0, 0, 255);
                }
            }
        }
        if (pause && Input.GetButtonDown("Cancel_P1"))
        {
            if (Temp.Count > 0)
            {
                removeBullet();
            }
        }
        if (pause && Input.GetButtonDown("Cancel_P2"))
        {
            if (Temp_2.Count > 0)
            {
                removeBullet_P2();
            }
        }
        if (pause)
        {
            if (Handful.Count == 0 && Handful_2.Count == 0)
            {
                SceneManager.LoadScene("Results");
            }

            if (p1Ready && p2Ready)
            {
                showBattleScreen();
            }
            if (p1Ready)
            {
                ES_P1.SetSelectedGameObject(null);
            }
            if (p2Ready)
            {
                ES_P2.SetSelectedGameObject(null);
            }
            if (Temp.Count == weaponMax)
            {
                ES_P1.SetSelectedGameObject(GameObject.Find("BattleButton"));
            }
            if (Temp_2.Count == weaponMax_2)
            {
                ES_P2.SetSelectedGameObject(GameObject.Find("BattleButton_2"));
            }
        }
        if (!pause)
        {
            player.playerUpdate();
            player2.playerUpdate();
            bool enemyReload = true;
            foreach (Spell spell in spells)
            {
                if (spell != null)
                {
                    spell.spellUpdate();
                }
            }

            foreach (Obstacle ob in obstacles)
            {
                if (ob != null)
                {
                    ob.obstacleUpdate();
                }
            }
            foreach (Enemy enemy in enemies)
            {
                if (enemy != null)
                {
                    enemy.enemyUpdate();
                    if (enemy.reload == false)
                    {
                        enemyReload = false;
                    }
                }
            }
            updateSpellList();
            deleteSpells();
            updateObstacleList();
            deleteObstacles();
            if (player.reload && player2.reload && spells.Length == 0)
            {
                showReloadScreen();
            }
        }
    }