Exemple #1
0
    void PlayerTurn()
    {
        DiceScript diceScript = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();

        state = CombatState.PLAYERROLL;
        diceScript.ConsoleText.text = "Your turn";
    }
    void Update()
    {
        Player       player       = GameObject.FindWithTag("Player").GetComponent <Player>();
        Enemy        enemy        = GameObject.FindWithTag("Enemy").GetComponent <Enemy>();
        DiceScript   diceScript   = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();
        AttackScript attackScript = GameObject.FindWithTag("CombatSystem").GetComponent <AttackScript>();

        if (state == CombatState.PLAYERROLL)
        {
            PlayerRollDice();
        }

        if (state == CombatState.PLAYERCOMBAT)
        {
            Debug.Log("I am in combat");
            MeleeAttackButton.SetActive(true);
            FireballAttackButton.SetActive(true);
        }
        else
        {
            MeleeAttackButton.SetActive(false);
            FireballAttackButton.SetActive(false);
        }

        if (state == CombatState.ENEMYTURN)
        {
            Debug.Log("Enemy is in combat");
            Invoke("EnemyRoll", 2f);
        }

        if (Input.GetKey("escape"))
        {
            Application.Quit();
        }
    }
Exemple #3
0
    //CODE DEALING WITH PLAYER COMBAT STAGE

    public void HealButton()
    {
        EnemyChange enemyChange = GameObject.FindWithTag("EnemyChange").GetComponent <EnemyChange>();

        if (enemyChange.IsLevel1 == true || enemyChange.IsLevel3 == true)//This code will only run during lvl 1 and 3
        {
            Player     player     = GameObject.FindWithTag("Player").GetComponent <Player>();
            DiceScript diceScript = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();

            player.currentHealth               = 10f;
            playerfillAmountHealth             = player.currentHealth / player.maxHealth;
            diceScript.playerHealth.fillAmount = player.currentHealth / 1;

            PlayerHealGlow.SetActive(true);
            Invoke("PlayerGlowDisappear", 0.5f);

            Invoke("EnemyTurnChange", 2f);
            PlayerCanAttack = false;

            if (0 < player.defenceNumber)
            {
                player.defenceNumber  -= 1;
                playerDefenceText.text = player.defenceNumber.ToString();

                healGlowText.text = player.defenceNumber.ToString();
                healGlow.SetActive(true);
                Invoke("PlayerGlowDisappear", 0.5f);
            }
        }

        CombatSystem combatSystem = GameObject.FindWithTag("CombatSystem").GetComponent <CombatSystem>();

        combatSystem.CanRoll = false;
    }
Exemple #4
0
 // Start is called before the first frame update
 void Start()
 {
     anim        = gameObject.GetComponent <Animator>();
     gameManager = GameObject.FindObjectOfType <Master>();
     diceManager = GameObject.FindObjectOfType <DiceScript>();
     startPos    = transform.position;
 }
    void SpawnDiceBlock()
    {
        Vector3 playerPosition = new Vector3(player.transform.position.x,
                                             player.transform.position.y + 2.75f,
                                             player.transform.position.z);

        diceBlock  = Instantiate(diceBlockPrefab, playerPosition, Quaternion.identity);
        diceScript = diceBlock.GetComponent <DiceScript>();
    }
    public void EnemyRoll() //CODE DEALING WITH ENEMY TURN
    {
        if (EnemyCanRoll == true)
        {
            DiceScript diceScript = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();

            diceScript.EnemyNumberRolled = Random.Range(1, 6);
            diceScript.EnemyDiceText.GetComponent <UnityEngine.UI.Text>().text = diceScript.EnemyNumberRolled.ToString("F0");

            ScreenshakeController screenShakeController = GameObject.FindWithTag("MainCamera").GetComponent <ScreenshakeController>();
            Player player = GameObject.FindWithTag("Player").GetComponent <Player>();
            Enemy  enemy  = GameObject.FindWithTag("Enemy").GetComponent <Enemy>();

            if (diceScript.EnemyNumberRolled <= player.defenceNumber) //Enemy misses.
            {
                EnemyMissText.SetActive(true);
                Invoke("FeedbackTextDisappear", 2f);
                Invoke("PlayerTurn", 2f);
                Debug.Log("Enemy has missed");

                if (FirstTimeEnemyMiss == true && enemyMissExplanation != null)
                {
                    enemyMissExplanation.SetActive(true);
                    Invoke("MissTextDisappear", 3f);
                    FirstTimeEnemyMiss = false;
                }
            }

            if (player.defenceNumber < diceScript.EnemyNumberRolled) //Deals damage to player.
            {
                player.currentHealth -= enemy.attackPower;
                fillAmountHealth      = player.currentHealth / 10;
                diceScript.playerHealth.fillAmount = fillAmountHealth / 1;

                Invoke("PlayerTurn", 2f);

                PlayerHealthGlow.SetActive(true);
                Invoke("GlowDisappear", 0.5f);

                PlayerDamage.text = enemy.attackPower.ToString();
                Invoke("DamageDisappear", 2f);

                StartCoroutine(screenShakeController.CameraShake(0.1f, 0.05f)); //Screenshake

                Debug.Log("Enemy has hit");

                if (player.currentHealth < 1f /* || player.currentHealth > 1f*/) //Player Loses
                {
                    Debug.Log("Has Lost");
                    LoseUI.SetActive(true);
                }
            }

            EnemyCanRoll = false;
        }
    }
Exemple #7
0
 // Start is called before the first frame update
 void Start()
 {
     myGM         = GameObject.Find("GameController").GetComponent <gameManager>();
     Dice1        = GameObject.Find("Dice1").GetComponent <DiceScript>();
     Dice2        = GameObject.Find("Dice2").GetComponent <DiceScript>();
     myRB         = GetComponent <Rigidbody>();
     playerRender = GetComponent <Renderer>();
     playerStats  = GetComponent <PlayerStats>();
     lineRenderer.positionCount = numPoints;
 }
    // Start is called before the first frame update
    void Start()
    {
        Vector3 playerPosition = new Vector3(player.transform.position.x,
                                             player.transform.position.y + 2.75f,
                                             player.transform.position.z);

        diceBlock = Instantiate(diceBlockPrefab, playerPosition, Quaternion.identity);

        diceScript   = GameObject.FindGameObjectWithTag("DiceBlock").GetComponent <DiceScript>();
        playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerScript>();
    }
    //CODE DEALING WITH PLAYER COMBAT STAGE

    public void FireballButton()
    {
        Enemy        enemy        = GameObject.FindWithTag("Enemy").GetComponent <Enemy>();
        CombatSystem combatSystem = GameObject.FindWithTag("CombatSystem").GetComponent <CombatSystem>();

        FireballBurn = Random.Range(1, 6);

        if (FireballBurn >= 3 && PlayerCanAttack == true) //Player is burned
        {
            enemy.currentHealth   -= 0.1f;
            enemyHealth.fillAmount = enemy.currentHealth / 1;

            Player     player     = GameObject.FindWithTag("Player").GetComponent <Player>();
            DiceScript diceScript = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();

            player.currentHealth -= 0.3f;
            diceScript.playerHealth.fillAmount = player.currentHealth / 1;
            ConsoleText.text = "You were burned";

            if (enemy.currentHealth < 0.1f || enemy.currentHealth > 1f) //Player Wins
            {
                Debug.Log("Has Won");
                WinUI.SetActive(true);
            }

            if (player.currentHealth < 0.1f || player.currentHealth > 1f) //Player Loses
            {
                Debug.Log("Has Lost");
                LoseUI.SetActive(true);
            }

            PlayerCanAttack = false;
        }

        if (FireballBurn < 3 && PlayerCanAttack == true) // Player is not burned
        {
            enemy.currentHealth   -= 0.4f;
            enemyHealth.fillAmount = enemy.currentHealth / 1;

            ConsoleText.text = "You were not burned";

            if (enemy.currentHealth < 0.1f || enemy.currentHealth > 1f) //Player Wins
            {
                Debug.Log("Has Won");
                WinUI.SetActive(true);
            }

            PlayerCanAttack = false;
        }

        Invoke("EnemyTurnChange", 3f);
    }
Exemple #10
0
        public void CheckUiUpdates(SkillPanel s)
        {
            switch (s.data.type)
            {
            case SkillType.Movement:
                DiceScript diceScript = s.GetDie(DiceType.Range);

                if (diceScript != null)
                {
                    moves = maxMoves = diceScript.value;
                    GameManager.Instance.UpdateUI();
                }

                break;
            }
        }
Exemple #11
0
    private void RecalculatePresentDice()
    {
        foreach (DiceScript dice in currentDice)
        {
            Destroy(dice.gameObject);
        }

        currentDice.Clear();

        for (int i = 0; i < diceNum; ++i)
        {
            GameObject diceGO = Instantiate(dicePrefabs[(int)diceType], gravityGround.transform.position + gravityGround.transform.rotation * spawnLocations[i], Quaternion.identity);
            diceGO.transform.SetParent(gravityGround.transform.parent, true);

            DiceScript diceScript = diceGO.GetComponent <DiceScript>();
            diceScript.spawnPos = spawnLocations[i];
            currentDice.Add(diceScript);
        }
    }
    public void EnemyRoll() //CODE DEALING WITH ENEMY TURN
    {
        if (EnemyCanRoll == true)
        {
            DiceScript diceScript = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();

            diceScript.EnemyNumberRolled = Random.Range(1, 6);
            diceScript.EnemyDiceText.GetComponent <UnityEngine.UI.Text>().text = diceScript.EnemyNumberRolled.ToString("F0");

            Player player = GameObject.FindWithTag("Player").GetComponent <Player>();

            if (player.defenceNumber >= diceScript.EnemyNumberRolled) //Enemy defends itself.
            {
                diceScript.ConsoleText.text = "Enemy misses";
                Invoke("PlayerTurn", 2f);
                Debug.Log("Enemy has missed");

                if (FirstTimeEnemyMiss == true)
                {
                    enemyMissExplanation.SetActive(true);
                    Invoke("MissTextDisappear", 3f);
                    FirstTimeEnemyMiss = false;
                }
            }

            if (player.defenceNumber < diceScript.EnemyNumberRolled) //Deals damage to player.
            {
                player.currentHealth -= 0.2f;
                diceScript.playerHealth.fillAmount = player.currentHealth / 1;
                Invoke("PlayerTurn", 2f);
                Debug.Log("Enemy has hit");

                if (player.currentHealth < 0.1f || player.currentHealth > 1f) //Player Loses
                {
                    Debug.Log("Has Lost");
                    LoseUI.SetActive(true);
                }
            }

            EnemyCanRoll = false;
        }
    }
Exemple #13
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("DiceBlock"))
        {
            DiceScript diceScript = collision.gameObject.GetComponent <DiceScript>();

            moveSpaces = diceScript.number;

            Destroy(collision.gameObject);
        }

        if (collision.gameObject.CompareTag("BoardSpace"))
        {
            isGrounded = true;

            currentSpace = collision.gameObject;

            if (startingSpace == null)
            {
                startingSpace = currentSpace;
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     gameManager = GameObject.FindObjectOfType <Master>();
     diceScript  = GameObject.FindObjectOfType <DiceScript>();
 }
    void Update()
    {
        Player       player       = GameObject.FindWithTag("Player").GetComponent <Player>();
        Enemy        enemy        = GameObject.FindWithTag("Enemy").GetComponent <Enemy>();
        DiceScript   diceScript   = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();
        AttackScript attackScript = GameObject.FindWithTag("CombatSystem").GetComponent <AttackScript>();

        if (state == CombatState.PLAYERROLL)
        {
            RollButton.SetActive(true);
            //PlayerRollDice();
        }
        else
        {
            RollButton.SetActive(false);
        }

        if (state == CombatState.PLAYERCOMBAT)
        {
            EnemyCanRoll = false;

            Debug.Log("I am in combat");
            EnemyChange enemyChange = GameObject.FindWithTag("EnemyChange").GetComponent <EnemyChange>();


            if (FireballAttackButton != null)
            {
                FireballAttackButton.SetActive(true);
            }

            if (/*hasUsed == false && */ HealButton != null)
            {
                HealButton.SetActive(true);
            }
            MeleeAttackButton.SetActive(true);
        }

        else
        {
            if (HealButton != null)
            {
                HealButton.SetActive(false);
            }

            if (FireballAttackButton != null)
            {
                FireballAttackButton.SetActive(false);
                Debug.Log("This code has not run");
            }

            MeleeAttackButton.SetActive(false);
        }

        if (state == CombatState.ENEMYTURN)
        {
            Debug.Log("Enemy is in combat");
            Invoke("EnemyRoll", 2f);
        }

        if (Input.GetKey("escape"))
        {
            Application.Quit();
        }
    }
Exemple #16
0
    public void FireballButton()
    {
        EnemyChange enemyChange = GameObject.FindWithTag("EnemyChange").GetComponent <EnemyChange>();

        if (enemyChange.IsLevel2 == true || enemyChange.IsLevel3 == true) //This code only runs during lvl 2 and 3
        {
            Enemy enemy = GameObject.FindWithTag("Enemy").GetComponent <Enemy>();

            FireballBurn = Random.Range(1, 6);

            //EnemyHealthGlow.SetActive(true);
            //Invoke("EnemyGlowDisappear", 0.5f);

            //EnemyDamage.text = "4";
            //Invoke("DamageDisappear", 2f);

            //ScreenshakeController screenShakeController = GameObject.FindWithTag("MainCamera").GetComponent<ScreenshakeController>();
            //StartCoroutine(screenShakeController.CameraShake(0.15f, 0.1f));

            if (FireballBurn >= 3 && PlayerCanAttack == true) //Player is burned
            {
                EnemyHealthGlow.SetActive(true);
                Invoke("EnemyGlowDisappear", 0.5f);

                EnemyDamage.text = "4";
                Invoke("DamageDisappear", 2f);

                ScreenshakeController screenShakeController = GameObject.FindWithTag("MainCamera").GetComponent <ScreenshakeController>();
                StartCoroutine(screenShakeController.CameraShake(0.15f, 0.1f));

                Debug.Log("BURN TEXT HAS RUN");

                Player     player     = GameObject.FindWithTag("Player").GetComponent <Player>();
                DiceScript diceScript = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();

                enemy.currentHealth   -= 4;
                fillAmountHealth       = enemy.currentHealth / enemy.maxHealth;
                enemyHealth.fillAmount = fillAmountHealth / 1;

                player.currentHealth              -= 3f;
                playerfillAmountHealth             = player.currentHealth / player.maxHealth;
                diceScript.playerHealth.fillAmount = playerfillAmountHealth / 1;

                BurnText.text = "You were burned";
                Invoke("DamageDisappear", 2f);

                PlayerDamage.text = "3";
                Invoke("DamageDisappear", 2f);

                PlayerHealthGlow.SetActive(true);
                Invoke("PlayerGlowDisappear", 0.5f);

                if (enemy.currentHealth < 1f) //Player Wins
                {
                    Debug.Log("Has Won");
                    WinUI.SetActive(true);
                }

                if (player.currentHealth < 1f) //Player Loses
                {
                    Debug.Log("Has Lost");
                    LoseUI.SetActive(true);
                }

                PlayerCanAttack = false;
            }

            if (FireballBurn < 3 && PlayerCanAttack == true) //Player does not get burned
            {
                EnemyHealthGlow.SetActive(true);
                Invoke("EnemyGlowDisappear", 0.5f);

                EnemyDamage.text = "4";
                Invoke("DamageDisappear", 2f);

                ScreenshakeController screenShakeController = GameObject.FindWithTag("MainCamera").GetComponent <ScreenshakeController>();
                StartCoroutine(screenShakeController.CameraShake(0.15f, 0.1f));

                enemy.currentHealth   -= 4;
                fillAmountHealth       = enemy.currentHealth / enemy.maxHealth;
                enemyHealth.fillAmount = fillAmountHealth / 1;


                if (enemy.currentHealth < 1f) //Player Wins
                {
                    Debug.Log("Has Won");
                    WinUI.SetActive(true);
                }

                PlayerCanAttack = false;
            }

            Invoke("EnemyTurnChange", 3f);
        }

        PlayerCanAttack = false;
        CombatSystem combatSystem = GameObject.FindWithTag("CombatSystem").GetComponent <CombatSystem>();

        combatSystem.CanRoll = false;
    }
Exemple #17
0
    //CODE DEALING WITH PLAYER COMBAT STAGE

    public void FireballButton()
    {
        Enemy        enemy        = GameObject.FindWithTag("Enemy").GetComponent <Enemy>();
        CombatSystem combatSystem = GameObject.FindWithTag("CombatSystem").GetComponent <CombatSystem>();

        FireballBurn = Random.Range(1, 6);

        EnemyHealthGlow.SetActive(true);
        Invoke("EnemyGlowDisappear", 0.5f);

        EnemyDamage.text = "4";
        Invoke("DamageDisappear", 2f);

        ScreenshakeController screenShakeController = GameObject.FindWithTag("MainCamera").GetComponent <ScreenshakeController>();

        StartCoroutine(screenShakeController.CameraShake(0.15f, 0.1f));

        if (FireballBurn >= 3 && PlayerCanAttack == true)
        {
            Debug.Log("BURN TEXT HAS RUN");

            enemy.currentHealth   -= 0.4f;
            enemyHealth.fillAmount = enemy.currentHealth / 1;

            Player     player     = GameObject.FindWithTag("Player").GetComponent <Player>();
            DiceScript diceScript = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();

            player.currentHealth -= 0.2f;
            diceScript.playerHealth.fillAmount = player.currentHealth / 1;

            //ConsoleText.text = "You were burned";
            BurnText.text = "You were burned";
            Invoke("DamageDisappear", 2f);

            PlayerDamage.text = "2";
            Invoke("DamageDisappear", 2f);

            PlayerHealthGlow.SetActive(true);
            Invoke("PlayerGlowDisappear", 0.5f);

            if (enemy.currentHealth < 0.1f || enemy.currentHealth > 1f) //Player Wins
            {
                Debug.Log("Has Won");
                WinUI.SetActive(true);
            }

            if (player.currentHealth < 0.1f || player.currentHealth > 1f) //Player Loses
            {
                Debug.Log("Has Lost");
                LoseUI.SetActive(true);
            }

            PlayerCanAttack = false;
        }

        if (FireballBurn < 3 && PlayerCanAttack == true)
        {
            enemy.currentHealth   -= 0.4f;
            enemyHealth.fillAmount = enemy.currentHealth / 1;

            //ConsoleText.text = "You were not burned";



            if (enemy.currentHealth < 0.1f || enemy.currentHealth > 1f) //Player Wins
            {
                Debug.Log("Has Won");
                WinUI.SetActive(true);
            }

            PlayerCanAttack = false;
        }

        Invoke("EnemyTurnChange", 3f);
    }
Exemple #18
0
 // Start is called before the first frame update
 void Start()
 {
     diceManager = GameObject.FindObjectOfType <DiceScript>();
 }