Example #1
0
    private void setUp()
    {
        //Sets up the players and enemies
        GameObject character1 = Instantiate(player1) as GameObject;
        GameObject character2 = Instantiate(player2) as GameObject;

        p1      = character1.GetComponent <Character> ();
        p2      = character2.GetComponent <Character> ();
        enemies = new Enemy[3];
        GameObject e1 = Instantiate(enemy) as GameObject;
        GameObject e2 = Instantiate(enemy) as GameObject;
        GameObject e3 = Instantiate(enemy) as GameObject;

        enemies [0]      = e1.GetComponent <Enemy>();
        enemies [1]      = e2.GetComponent <Enemy>();
        enemies [2]      = e3.GetComponent <Enemy>();
        enemies [0].Slot = 1;
        enemies [1].Slot = 2;
        enemies [2].Slot = 3;
        enemies [0].setSlot();
        enemies [1].setSlot();
        enemies [2].setSlot();
        //turnOrder = new GameObject[4];

        //Manages enemy selection
        selectedSlot = 0;
        GameObject theCursor = Instantiate(cursor) as GameObject;

        theCursor.GetComponent <Renderer>().enabled = false;
        selector = theCursor.GetComponent <AnimationOffset>();
        selector.setParent(enemies[selectedSlot].gameObject);

        menuOptions    = new string[4];
        menuOptions[0] = "Attack";
        menuOptions[1] = "Magic";
        menuOptions[2] = "Items";
        menuOptions[3] = "Flee";
        menuIndex      = 0;

        turn     = Turn.P1Choice;
        nextTurn = Turn.P1Choice;

        totalExpReward = 0;
    }
Example #2
0
    private void setUp()
    {
        //Sets up the players and enemies
        GameObject character1 = Instantiate(player1) as GameObject;
        GameObject character2 = Instantiate(player2) as GameObject;

        p1 = character1.GetComponent <Character> ();
        p2 = character2.GetComponent <Character> ();
        GameObject boss1 = Instantiate(bossObject) as GameObject;

        boss      = boss1.GetComponent <Enemy>();
        boss.Slot = 1;
        boss.setSlot();
        boss.data().setMaxHealth(400);
        boss.data().setAttack(50);
        turnOrder = new GameObject[3];

        //Manages enemy selection
        selectedSlot = 0;
        GameObject theCursor = Instantiate(cursor) as GameObject;

        theCursor.GetComponent <Renderer>().enabled = false;
        selector = theCursor.GetComponent <AnimationOffset>();
        selector.setParent(boss.gameObject);

        menuOptions    = new string[4];
        menuOptions[0] = "Attack";
        menuOptions[1] = "Magic";
        menuOptions[2] = "Items";
        menuOptions[3] = "Flee";
        menuIndex      = 0;

        turn     = Turn.P1Choice;
        nextTurn = Turn.P1Choice;

        totalExpReward = 0;
    }
Example #3
0
    //GUI properties
    void OnGUI()
    {
        //Player1 GUI
        GUI.DrawTexture(p1BackSize, p1BarBackground, ScaleMode.StretchToFill, true, 0);
        GUI.DrawTexture(new Rect(p1HealthSize.x, p1HealthSize.y,
                                 (Screen.width / 8) * percentRemaining(GameManager.Instance.P1Data, 'h'),
                                 Screen.height / 30), healthBar, ScaleMode.StretchToFill, true, 0);
        GUI.DrawTexture(new Rect(p1ManaSize.x, p1ManaSize.y,
                                 (Screen.width / 8) * percentRemaining(GameManager.Instance.P1Data, 'm'),
                                 Screen.height / 30), manaBar, ScaleMode.StretchToFill, true, 0);
        GUI.DrawTexture(p1ProfileSize, p1Profile, ScaleMode.StretchToFill, true, 0);
        //GUI.Label (p1Name, GameManager.Instance.P1Data.Name);

        GUI.Label(p1HealthLabel, GameManager.Instance.P1Data.getCurrentHealth()
                  + "/" + GameManager.Instance.P1Data.getMaxHealth());
        GUI.Label(p1ManaLabel, GameManager.Instance.P1Data.getCurrentMana()
                  + "/" + GameManager.Instance.P1Data.getMaxMana());
        //Player2 GUI
        GUI.DrawTexture(p2BackSize, p1BarBackground, ScaleMode.StretchToFill, true, 0);
        GUI.DrawTexture(new Rect(p2HealthSize.x, p2HealthSize.y,
                                 (Screen.width / 8) * percentRemaining(GameManager.Instance.P2Data, 'h'),
                                 Screen.height / 30), healthBar, ScaleMode.StretchToFill, true, 0);
        GUI.DrawTexture(new Rect(p2ManaSize.x, p2ManaSize.y,
                                 (Screen.width / 8) * percentRemaining(GameManager.Instance.P2Data, 'm'),
                                 Screen.height / 30), manaBar, ScaleMode.StretchToFill, true, 0);
        GUI.DrawTexture(p2ProfileSize, p2Profile, ScaleMode.StretchToFill, true, 0);
        GUI.Label(p2HealthLabel, GameManager.Instance.P2Data.getCurrentHealth()
                  + "/" + GameManager.Instance.P2Data.getMaxHealth());
        GUI.Label(p2ManaLabel, GameManager.Instance.P2Data.getCurrentMana()
                  + "/" + GameManager.Instance.P2Data.getMaxMana());

        if (turn == Turn.P1Choice)
        {
            GUI.DrawTexture(new Rect(Screen.width / 2 - (2.88f * Screen.width / 10.6f), Screen.height * 0.84f,
                                     Screen.width / 10.6f, Screen.width / 10.6f),
                            p1Profile, ScaleMode.StretchToFill, true, 0);
            //Attack Button
            GUI.SetNextControlName("Attack");
            if ((menuIndex == 0 && Input.GetKeyDown(KeyCode.Z)) ||
                GUI.Button(new Rect(Screen.width / 2 - (2 * Screen.width / 10.6f), Screen.height * 0.88f,
                                    Screen.width / 10.6f, Screen.height / 16f), "Attack"))
            {
                timer = 1;
                p1.setNextAction(1);
                nextTurn      = Turn.P1Target;
                turn          = Turn.Transition;
                selectedSlot  = 0;
                boss.Selected = true;
                selector.gameObject.GetComponent <Renderer>().enabled = true;
                selector.setParent(boss.gameObject);
                selector.setOffset(0, boss.gameObject.GetComponent <Renderer>().bounds.size.y / 2, 0);
                playSound(0);
            }
            //Magic Button
            GUI.SetNextControlName("Magic");
            if ((menuIndex == 1 && Input.GetKeyDown(KeyCode.Z)) ||
                GUI.Button(new Rect(Screen.width / 2 - Screen.width / 10.6f, Screen.height * 0.88f,
                                    Screen.width / 10.6f, Screen.height / 16f), "Magic"))
            {
                timer = 1;
                p1.setNextAction(2);
                nextTurn      = Turn.P1Target;
                turn          = Turn.Transition;
                selectedSlot  = 0;
                boss.Selected = true;
                selector.gameObject.GetComponent <Renderer>().enabled = true;
                selector.setParent(boss.gameObject);
                selector.setOffset(0, boss.gameObject.GetComponent <Renderer>().bounds.size.y / 2, 0);
                playSound(0);
            }
            //Items Button
            GUI.SetNextControlName("Items");
            if (menuIndex == 2 && Input.GetKeyDown(KeyCode.Z) ||
                GUI.Button(new Rect(Screen.width / 2, Screen.height * 0.88f,
                                    Screen.width / 10.6f, Screen.height / 16f), "Items"))
            {
                timer = 5;
                p1.setNextAction(3);
                if (!p2.isDown())
                {
                    nextTurn = Turn.P2Choice;
                    turn     = Turn.Transition;
                }
                else
                {
                    nextTurn = Turn.CalculationPhase;
                    turn     = Turn.Transition;
                }
            }
            //Flee Button
            GUI.SetNextControlName("Flee");
            if ((menuIndex == 3 && Input.GetKeyDown(KeyCode.Z)) ||
                GUI.Button(new Rect(Screen.width / 2 + Screen.width / 10.6f, Screen.height * 0.88f,
                                    Screen.width / 10.6f, Screen.height / 16f), "Flee"))
            {
                playSound(0);
                GameManager.Instance.setLevel("Overworld Map");
                Application.LoadLevel("Overworld");
                print("You flee the battle");
            }

            GUI.FocusControl(menuOptions[menuIndex]);
        }

        if (turn == Turn.P2Choice)
        {
            //PlayerProfile
            GUI.DrawTexture(new Rect(Screen.width / 2 - (2.88f * Screen.width / 10.6f), Screen.height * 0.84f,
                                     Screen.width / 10.6f, Screen.width / 10.6f),
                            p2Profile, ScaleMode.StretchToFill, true, 0);
            //Attack Button
            GUI.SetNextControlName("Attack");
            if ((menuIndex == 0 && Input.GetKeyDown(KeyCode.Z)) ||
                GUI.Button(new Rect(Screen.width / 2 - (2 * Screen.width / 10.6f), Screen.height * 0.88f,
                                    Screen.width / 10.6f, Screen.height / 16f), "Attack"))
            {
                timer = 1;
                p2.setNextAction(1);
                nextTurn      = Turn.P2Target;
                turn          = Turn.Transition;
                selectedSlot  = 0;
                boss.Selected = true;
                selector.gameObject.GetComponent <Renderer>().enabled = true;
                selector.setParent(boss.gameObject);
                selector.setOffset(0, boss.gameObject.GetComponent <Renderer>().bounds.size.y / 2, 0);
                playSound(0);
            }
            //Magic Button
            GUI.SetNextControlName("Magic");
            if ((menuIndex == 1 && Input.GetKeyDown(KeyCode.Z)) ||
                GUI.Button(new Rect(Screen.width / 2 - Screen.width / 10.6f, Screen.height * 0.88f,
                                    Screen.width / 10.6f, Screen.height / 16f), "Magic"))
            {
                timer = 1;
                p2.setNextAction(2);
                nextTurn      = Turn.P2Target;
                turn          = Turn.Transition;
                selectedSlot  = 0;
                boss.Selected = true;
                selector.gameObject.GetComponent <Renderer>().enabled = true;
                selector.setParent(boss.gameObject);
                selector.setOffset(0, boss.gameObject.GetComponent <Renderer>().bounds.size.y / 2, 0);
                playSound(0);
            }
            //Items Button
            GUI.SetNextControlName("Items");
            if (menuIndex == 2 && Input.GetKeyDown(KeyCode.Z) ||
                GUI.Button(new Rect(Screen.width / 2, Screen.height * 0.88f,
                                    Screen.width / 10.6f, Screen.height / 16f), "Items"))
            {
                timer = 5;
                p2.setNextAction(3);
                nextTurn = Turn.CalculationPhase;
                turn     = Turn.Transition;
            }
            //Flee Button
            GUI.SetNextControlName("Flee");
            if ((menuIndex == 3 && Input.GetKeyDown(KeyCode.Z)) ||
                GUI.Button(new Rect(Screen.width / 2 + Screen.width / 10.6f, Screen.height * 0.88f,
                                    Screen.width / 10.6f, Screen.height / 16f), "Flee"))
            {
                playSound(0);
                GameManager.Instance.setLevel("Overworld Map");
                Application.LoadLevel("Overworld");
                print("You flee the battle");
            }

            GUI.FocusControl(menuOptions[menuIndex]);
        }

        if (turn == Turn.GameOver)
        {
            GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 + 50, 120, 100), "You Died.\n\n Game Over");

            GUI.SetNextControlName("StartOver");
            if (Input.GetKeyDown(KeyCode.Z) ||
                GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 - 50, 120, 40), "Start Over"))
            {
                GameManager.Instance.setLevel("Start Screen");
                Application.LoadLevel("StartScreen");
            }
            GUI.FocusControl("StartOver");
        }

        if (turn == Turn.Victory)
        {
            GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 + 50, 120, 100), "You won!");

            GUI.SetNextControlName("ReturnToMap");
            if (Input.GetKeyDown(KeyCode.Z) ||
                GUI.Button(new Rect(Screen.width / 2 - 80, Screen.height / 2 - 50, 160, 40), "Back to Overworld"))
            {
                GameManager.Instance.setLevel("Overworld Map");
                Application.LoadLevel("Overworld");
            }
            GUI.FocusControl("ReturnToMap");
        }
    }