Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //  Debug.Log("Rand is: " + rand);
        //Debug.Log(playerTurn + "equals Player Turn ");
        //Debug.Log("rand is: "+ rand);
        if (rand == 1)//players turn
        {
            defend.SetActive(false);
            counter.SetActive(false);
            DefMag.SetActive(false);
            giveUp.SetActive(false);

            //attack.SetActive(true); strike.SetActive(true); AtkMag.SetActive(true); charge.SetActive(true);
            playerTurn = true;
        }

        else
        {
            //defend.SetActive(true); counter.SetActive(true); DefMag.SetActive(true); giveUp.SetActive(true);
            playerTurn = false; //enemy turn
        }



        if (GameObject.FindGameObjectsWithTag("Player").Length < 1)
        {
            rockPlayer.SetActive(true);
        }
        else if (GameObject.FindGameObjectsWithTag("Enemy").Length < 1)
        {
            rockEnemy.SetActive(true);
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        //Debug.Log(GameManager.rand + "is the deciding thing");



        //cheats
        if (Input.GetKeyDown(KeyCode.T))
        {
            Activate.activateflag = true;
            Debug.Log("IS TROO");
        }
        else if (Input.GetKeyDown(KeyCode.F))
        {
            Activate.activateflag = false;
            Debug.Log("IZZ FALSZ");
        }
        else if (Input.GetKeyDown(KeyCode.Q))
        {
            isPlayerTurn = true;
            Debug.Log("Playturn has changed");
        }


        isPlayerTurn = GameManager.playerTurn; //

        //Debug.Log("isPlayerTurn is: "+ isPlayerTurn);



        if (isPlayerTurn)
        {
            strikeFlag = false;//reset bool
            if (buttonsMade == false)
            {
                attack.SetActive(true);
                defend.SetActive(false);
                strike.SetActive(true);
                counter.SetActive(false);
                charge.SetActive(true);
                AtkMag.SetActive(true);
                DefMag.SetActive(false);
                giveUp.SetActive(false);

                ButtonCreate();
            }

            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                buttonList[prevButton].image.color = Color.white;
                prevButton     = 3;
                selectedButton = 3;
                buttonList[selectedButton].image.color = Color.yellow;
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                buttonList[prevButton].image.color = Color.white;
                prevButton     = 2;
                selectedButton = 2;
                buttonList[selectedButton].image.color = Color.yellow;
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                buttonList[prevButton].image.color = Color.white;
                prevButton     = 0;
                selectedButton = 0;
                buttonList[selectedButton].image.color = Color.yellow;
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                buttonList[prevButton].image.color = Color.white;
                prevButton     = 1;
                selectedButton = 1;
                buttonList[selectedButton].image.color = Color.yellow;
            }



            if (Input.GetKeyDown(KeyCode.Space)) //players actions only work on his/her turn
            {
                //buttonList[selectedButton].action();
                //buttonList[selectedButton].image.color = Color.yellow;

                foreach (GameObject go in gos)
                {
                    if (go.layer == (9) && go.CompareTag("OffenseChoice"))
                    {
                        go.SetActive(false); //turns off the button objects :o only when space is pressed
                                             // Debug.Log("DESTROY BUTTONS-PLAYER CHOICE MADE");
                    }
                }

                // GameObject[] gos = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[]; //will return an array of all GameObjects in the scene

                //foreach (GameObject go in gos)
                //{
                //  if (go.layer == (9) && go.CompareTag("OffsenseChoice"))
                //{
                //  go.SetActive(false); //turns off the button objects :o only when space is pressed
                // Debug.Log("DESTROY BUTTONS-PLAYER CHOICE MADE");
                //}
                //}
                //Debug.Log("PRESSED");
                action = GameObject.FindWithTag("Enemy").GetComponent <EnemyActions>();

                move = Random.Range(1, 5); //chooses a number between 1 and 4 //neeed 5
                //Set the appropiate methods
                if (move == 1)
                {
                    enemyMove = "defend";
                    action.defenseMethod(); //call the attack action from the skeleton script
                }
                else if (move == 2)
                {
                    enemyMove = "counter";
                    action.counterMethod();
                }
                else if (move == 3)
                {
                    enemyMove = "giveUp";
                    action.giveUpMethod();
                }
                else if (move == 4)
                {
                    enemyMove = "defMagic";
                    action.defMagMethod();
                }

                buttonList[selectedButton].action();
                buttonList[selectedButton].image.color = Color.yellow;

                GameManager.rand = 2;
                GameManager.addCount(); //increase turn number
                                        // Debug.Log(GameManager.count + " has increased");
                buttonsMade = false;
            }
        }
        else //enemy turn
        {
            //counterFlag = false; //reset upon turn switch so no repeat guarentee
            //GameManager.rand = 2; THIS WAS THE PROBLEM

            foreach (GameObject go in gos)
            {
                if (go.layer == (9) && go.CompareTag("DefenseChoice"))
                {
                    go.SetActive(true); //turns on/off the button objects
                }
            }

            if (buttonsMade == false)
            {
                ButtonCreate();
            }

            //give player actions
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                buttonList[prevButton].image.color = Color.white;
                prevButton     = 3;
                selectedButton = 3;
                buttonList[selectedButton].image.color = Color.yellow;
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                //counterFlag = true;
                buttonList[prevButton].image.color = Color.white;
                prevButton     = 2;
                selectedButton = 2;
                buttonList[selectedButton].image.color = Color.yellow;
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                buttonList[prevButton].image.color = Color.white;
                prevButton     = 0;
                selectedButton = 0;
                buttonList[selectedButton].image.color = Color.yellow;
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                buttonList[prevButton].image.color = Color.white;
                prevButton     = 1;
                selectedButton = 1;
                buttonList[selectedButton].image.color = Color.yellow;
            }

            else if (Input.GetKeyDown(KeyCode.P))
            {
                GameManager.playerTurn = true;
            }

            if (Input.GetKeyDown(KeyCode.Space)) //players actions only work on his/her turn
            {
                //enemy selection OFFENSE


                action = GameObject.FindWithTag("Enemy").GetComponent <EnemyActions>();

                move        = 2;// Random.Range(1, 5); //chooses a number between 1 and 4
                counterFlag = false;

                buttonList[selectedButton].action();
                buttonList[selectedButton].image.color = Color.yellow; //Do action after the changes are made

                //Set the appropiate methods
                if (move == 1)
                {
                    action.attackMethod(); //call the attack action from the skeleton script
                    enemyMove = "attack";
                }
                else if (move == 2)
                {
                    enemyMove  = "strike";
                    strikeFlag = true;
                    action.strikeMethod();
                }
                else if (move == 3)
                {
                    action.chargeMethod();
                    enemyMove = "charge";
                }
                else if (move == 4)
                {
                    action.atkMagMethod();
                    enemyMove = "atkMagic";
                }

                //Debug.Log(strikeFlag);



                // GameObject[] gos = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[]; //will return an array of all GameObjects in the scene
                foreach (GameObject go in gos)
                {
                    if (go.layer == (9) && go.CompareTag("DefenseChoice"))
                    {
                        go.SetActive(false); //turns off the button objects :o only when space is pressed
                                             // Debug.Log("DESTROY BUTTONS-PLAYER CHOICE MADE");
                    }
                }
                //Debug.Log("PRESSED");
                GameManager.rand = 1;
                GameManager.addCount(); //increase turn number
                                        //  Debug.Log(GameManager.count + " has increased");
                buttonsMade = false;
            }

            //To do here
            // Debug.Log("Skelly time");
            if (Input.GetKeyDown(KeyCode.P))
            {
                GameManager.rand = 1;
            }
        }
    }