Пример #1
0
 // Start is called before the first frame update
 void Start()
 {
     powerController = GameObject.Find("PowerHandler").GetComponent <PowerBehaviour>(); //Get the PowerBehaviour script.
     isPausedCheck   = GameObject.Find("UIHandler").GetComponent <UIController>();
     deadtext        = deadtextObj.GetComponentInChildren <Text>();
     deadtextObj.SetActive(false);
     deadtext.enabled = false;
 }
Пример #2
0
 // Start is called before the first frame update
 void Start()
 {
     isPausedCheck = GameObject.Find("UIHandler").GetComponent <UIController>(); //Get component for checking for pausing
     anim          = this.gameObject.GetComponent <Animator>();
     duplicateCD   = cooldown;
     playerScript  = GameObject.Find("Player").GetComponent <Player>();
     power         = GameObject.Find("PowerHandler").GetComponent <PowerBehaviour>();
 }
Пример #3
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Power"))
     {
         PowerBehaviour targetPower = other.GetComponent <PowerBehaviour>();
         if (playerScript.currentPower != null || playerScript.currentPower != targetPower)
         {
             playerScript.currentPower = targetPower;
             targetPower.AssignActivePlayer(this);
         }
     }
 }
Пример #4
0
 Color cActive, cInactive;                 //Color pallettes for active/inactive.
 void Start()
 {
     powers      = GameObject.Find("PowerHandler").GetComponent <PowerBehaviour>();
     description = powerDescription.GetComponent <Text>(); //0,255,20
     cActive.r   = 0f;                                     //0
     cActive.g   = 1f;                                     //255
     cActive.b   = 0.078f;                                 //20 //255,19,0
     cActive.a   = 1f;
     cInactive.r = 1f;                                     //255
     cInactive.g = 0.0745f;                                //19
     cInactive.b = 0f;                                     //0
     cInactive.a = 1f;
     powerState  = powerStateObj.GetComponent <Text>();
     powerTitle  = powerTitleObj.GetComponent <Text>();
 }
Пример #5
0
 bool powerModified = false; //Boolean so that the power is not endlessly applied.
 // Start is called before the first frame update
 void Start()
 {
     dupeCD       = shootingCooldown;
     isPauseCheck = GameObject.Find("UIHandler").GetComponent <UIController>();
     //Obtain any powers that modify.
     text           = UITempWeaponText.GetComponent <Text>();
     PowerBehaviour = GameObject.Find("PowerHandler").GetComponent <PowerBehaviour>();
     if (PowerBehaviour.powerHandler[6].GetPowerActive() == true)
     {
         //Reduce the cooldown of shooting by 1/3 with power 6.
         shootingCooldown = shootingCooldown / 1.5f;
         dupeCD           = shootingCooldown;
         powerModified    = true;
     }
 }
Пример #6
0
    bool enemyIsDead = false; //Prevent multiple point additions!

    // Start is called before the first frame update
    void Start()
    {
        enemyAnimations       = this.GetComponent <Animator>();
        attackTime            = this.gameObject.GetComponentInChildren <EnemyAttack>().attackSpeed;
        attackSpeed           = attackTime;
        pauseCheck            = GameObject.Find("UIHandler").GetComponent <UIController>();
        progressionController = GameObject.Find("ProgressionHandler").GetComponent <Progression>();
        powerScaleCheck       = GameObject.Find("PowerHandler").GetComponent <PowerBehaviour>();
        i = GetComponent <Rigidbody>();
        startingScaleX = transform.localScale.x;
        startingScaleY = transform.localScale.y;
        startingScaleZ = transform.localScale.z;
        inflatedScaleX = startingScaleX * INFLATED_POWER_SCALE;
        inflatedScaleY = startingScaleY * INFLATED_POWER_SCALE;
        inflatedScaleZ = startingScaleZ * INFLATED_POWER_SCALE;
        animator       = GetComponent <Animator>();
        TutorialStatus = GameObject.FindWithTag("TutorialHandler").GetComponent <TutorialHandler>();
    }
Пример #7
0
    // Update is called once per frame
    void Update()
    {
        checkPower();
        if (!isPausedCheck.GetIsPaused())
        {
            cooldown = cooldown - Time.deltaTime;
            if (cooldown <= 0)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    //Melee Attack
                    StartCoroutine("animCode");
                    GameObject.FindGameObjectWithTag("MusicHandler").GetComponent <AudioController>().PlaySoundEffect(7); //Case 7 is Melee Attack.
                    cooldown = duplicateCD;
                    if (Physics.Raycast(transform.parent.position, transform.forward, out hit, SWORD_ATTACK_DISTANCE))
                    {
                        Debug.Log("RNG rolled!");
                        if (hit.collider.gameObject.CompareTag("ProjectileEnemy") || hit.collider.gameObject.CompareTag("SwordEnemy") || hit.collider.gameObject.CompareTag("FinalBoss"))
                        {
                            GameObject     obj         = hit.collider.gameObject;
                            Enemy          enemyScript = hit.collider.gameObject.GetComponent <Enemy>();
                            PowerBehaviour powers      = GameObject.FindWithTag("PowerHandler").GetComponent <PowerBehaviour>();
                            var            rand        = new System.Random();
                            Player         player      = GameObject.FindWithTag("MainCamera").GetComponent <Player>();
                            int            RNGRoll     = rand.Next(0, 9999);
                            if (RNGRoll > RAIN_POWER_CHANCE && RNGRoll < RAIN_POWER_CHANCE * 2 && player.GetRainAvailable())
                            {
                                if (powers.powerHandler[11].GetPowerActive() == true)
                                {
                                    RNGRoll = 1;
                                }
                            }
                            if (RNGRoll < RAIN_POWER_CHANCE)
                            {
                                if (powers.powerHandler[12].GetPowerActive() == true)
                                {
                                    isPausedCheck.ShowPowerActivatedMessage(1);
                                    powers.DisableAllFires();
                                    player.SetRainAvailable(false);
                                }
                            }
                            RNGRoll = rand.Next(0, 9999); //Roll another number between 0 and 999.
                            if (RNGRoll > JUSTICE_POWER_CHANCE && RNGRoll < JUSTICE_POWER_CHANCE * 2 && player.GetJusticeAvailable())
                            {
                                if (powers.powerHandler[11].GetPowerActive() == true)
                                {
                                    RNGRoll = 1;
                                }
                            }
                            if (RNGRoll < JUSTICE_POWER_CHANCE && player.GetJusticeAvailable())
                            {
                                //Justice rains from above. 2.5% chance of occuring when damage is dealt.

                                if (powers.powerHandler[13].GetPowerActive() == true)
                                {
                                    GameObject[] projectileEnemies = GameObject.FindGameObjectsWithTag("ProjectileEnemy");
                                    GameObject[] swordEnemies      = GameObject.FindGameObjectsWithTag("SwordEnemy");
                                    foreach (GameObject obj1 in projectileEnemies)
                                    {
                                        JusticeSpawn projectiles = obj1.GetComponentInChildren <JusticeSpawn>();
                                        if (projectiles != null)
                                        {
                                            isPausedCheck.ShowPowerActivatedMessage(2);
                                            projectiles.FirePowerEffect();
                                            player.SetJusticeAvailable(false);
                                        }
                                    }
                                    foreach (GameObject obj1 in swordEnemies)
                                    {
                                        JusticeSpawn projectiles = obj1.GetComponentInChildren <JusticeSpawn>();
                                        if (projectiles != null)
                                        {
                                            projectiles.FirePowerEffect();
                                            player.SetJusticeAvailable(false);
                                        }
                                    }
                                }
                            }
                            double damageCalc;
                            double bonusDamagePower;
                            if (power.powerHandler[8].GetPowerAvailable() == true)
                            {
                                bonusDamagePower = 1.5f;
                            }
                            else
                            {
                                bonusDamagePower = 1f;
                            }
                            damageCalc = damageDealt * bonusDamagePower; //Additional calculation here if in Expert difficulty, to reduce damage.
                            if (hit.collider.gameObject.CompareTag("FinalBoss"))
                            {
                                FinalBoss fbScript = hit.collider.gameObject.GetComponent <FinalBoss>();
                                fbScript.DealDamage((float)damageCalc);
                            }
                            if (enemyScript != null)
                            {
                                enemyScript.takeDamage(damageCalc);
                            }
                        }
                    }
                }
            }
        }
        else
        {
        }
    }
Пример #8
0
    //Power1 is true if it is the LEFT power chosen. Otherwise, it is false (RIGHT power).
    public void LosePower(bool Power1)
    {
        UIController   ui               = GameObject.Find("UIHandler").GetComponent <UIController>();
        PowerBehaviour powers           = GameObject.Find("PowerHandler").GetComponent <PowerBehaviour>();
        Progression    progressionCheck = GameObject.Find("ProgressionHandler").GetComponent <Progression>();
        GameObject     audioController;

        audioController = GameObject.FindGameObjectWithTag("MusicHandler");
        audioController.GetComponent <AudioController>().PlayMusic(0);
        TutorialHandler TutStatus = GameObject.FindWithTag("TutorialHandler").GetComponent <TutorialHandler>();

        if (TutStatus.GetTutorialStage() > 0)
        {
            TutStatus.PowerDrained();
        }
        if (Power1)
        {
            powers.LoseSpecificPower(ui.losePower1);
            switch (powers.powerHandler[ui.losePower1].PowerStrength)
            {
            case 3:
            {
                ui.AddPoints((progressionCheck.GetMaximumWaves() - progressionCheck.GetCurrentWave()) * 500);
                break;
            }

            case 2:
            {
                ui.AddPoints((progressionCheck.GetMaximumWaves() - progressionCheck.GetCurrentWave()) * 250);
                break;
            }

            case 1:
            {
                break;
            }

            default:
            {
                break;
            }
            }
        }
        else
        {
            powers.LoseSpecificPower(ui.losePower2);
            switch (powers.powerHandler[ui.losePower2].PowerStrength)
            {
            case 3:
            {
                ui.AddPoints((progressionCheck.GetMaximumWaves() - progressionCheck.GetCurrentWave()) * 500);
                break;
            }

            case 2:
            {
                ui.AddPoints((progressionCheck.GetMaximumWaves() - progressionCheck.GetCurrentWave()) * 250);
                break;
            }

            case 1:
            {
                break;
            }

            default:
            {
                break;
            }
            }
        }
        ui.setLockPauseMenu(false);
        ui.returnToMainGame();
        Cursor.lockState = CursorLockMode.None;
        if (TutStatus.GetTutorialStage() > 0) //Skip weapon selection.
        {
            progressionCheck.SetWaveComplete(false);
            Cursor.lockState = CursorLockMode.Locked;
            return;
        }
        ui.WeaponSelection();
        progressionCheck.SetWaveComplete(false);
    }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        if (!isPaused.GetIsPaused()) //Only increment timer if the game is not paused!
        {
            timer = timer + Time.deltaTime;
            if (timer > TIME_TO_DESTROY)
            {
                Destroy(gameObject);
            }
        }
        Vector3 forward = transform.TransformDirection(Vector3.forward);

        if (Physics.SphereCast(transform.position, 0.25f, forward, out hit, 1.5f))
        {
            if (hit.collider.gameObject.CompareTag("ProjectileEnemy") || hit.collider.gameObject.CompareTag("SwordEnemy") || hit.collider.gameObject.CompareTag("FinalBoss"))
            {
                if (gameObject.tag == "EnemyProjectile")
                {
                    return;
                }

                var rand    = new System.Random();
                int RNGRoll = rand.Next(0, 9999); //Roll a number between 0 and 999.

                Player player = GameObject.FindWithTag("MainCamera").GetComponent <Player>();
                if (RNGRoll > RAIN_INT_CHANCE && RNGRoll < RAIN_INT_CHANCE * 2 && player.GetRainAvailable()) //Mysterious power doubles the chance of the environmental effects occuring.
                {
                    if (GameObject.FindWithTag("PowerHandler").GetComponent <PowerBehaviour>().powerHandler[11].GetPowerActive() == true)
                    {
                        RNGRoll = 1; //change RNG to pass.
                    }
                }

                if (RNGRoll < RAIN_INT_CHANCE && player.GetRainAvailable()) //0 to 24 gives a 2.5% chance when damaging.
                {
                    UIController ui = GameObject.FindWithTag("UIHandler").GetComponent <UIController>();

                    PowerBehaviour powers = GameObject.FindWithTag("PowerHandler").GetComponent <PowerBehaviour>();
                    if (powers.powerHandler[12].GetPowerActive() == true)
                    {
                        ui.ShowPowerActivatedMessage(1);
                        powers.DisableAllFires();
                        player.SetRainAvailable(false); //Start the cooldown.
                    }
                }

                RNGRoll = rand.Next(0, 9999); //Roll 10,000 numbers. Chance is a constant.

                if (RNGRoll > JUSTICE_INT_CHANCE && RNGRoll < JUSTICE_INT_CHANCE * 2 && player.GetJusticeAvailable())
                {
                    if (GameObject.FindWithTag("PowerHandler").GetComponent <PowerBehaviour>().powerHandler[11].GetPowerActive() == true)
                    {
                        RNGRoll = 1; //change RNG to pass.
                    }
                }
                if (RNGRoll < JUSTICE_INT_CHANCE && player.GetJusticeAvailable())
                {
                    //Justice rains from above. 2.5% chance of occuring when damage is dealt.
                    PowerBehaviour powers = GameObject.FindWithTag("PowerHandler").GetComponent <PowerBehaviour>();
                    if (powers.powerHandler[13].GetPowerActive() == true)
                    {
                        UIController ui = GameObject.FindWithTag("UIHandler").GetComponent <UIController>();

                        GameObject[] projectileEnemies = GameObject.FindGameObjectsWithTag("ProjectileEnemy");
                        GameObject[] swordEnemies      = GameObject.FindGameObjectsWithTag("SwordEnemy");
                        GameObject   FB = GameObject.FindGameObjectWithTag("FinalBoss");
                        if (FB != null)
                        {
                            JusticeSpawn projectiles = FB.GetComponentInChildren <JusticeSpawn>();
                            if (projectiles != null)
                            {
                                ui.ShowPowerActivatedMessage(2);
                                projectiles.FirePowerEffect();
                                player.SetJusticeAvailable(false);
                            }
                        }
                        foreach (GameObject obj in projectileEnemies)
                        {
                            JusticeSpawn projectiles = obj.GetComponentInChildren <JusticeSpawn>();
                            if (projectiles != null)
                            {
                                ui.ShowPowerActivatedMessage(2);
                                projectiles.FirePowerEffect();
                                player.SetJusticeAvailable(false);
                            }
                        }
                        foreach (GameObject obj in swordEnemies)
                        {
                            JusticeSpawn projectiles = obj.GetComponentInChildren <JusticeSpawn>();
                            if (projectiles != null)
                            {
                                projectiles.FirePowerEffect();
                                player.SetJusticeAvailable(false);
                            }
                        }
                    }
                }
                double damageCalc;
                Enemy  enemy = hit.collider.gameObject.GetComponent <Enemy>();
                damageCalc = player.GetWeaponPower() * damagePower; //Needs modification to check difficulty.
                Debug.Log("Enemy Damaged!");
                if (hit.collider.gameObject.GetComponent <Enemy>() != null)
                {
                    hit.collider.gameObject.GetComponent <Enemy>().takeDamage(damageCalc);
                }
                if (hit.collider.gameObject.CompareTag("FinalBoss"))
                {
                    hit.collider.gameObject.GetComponent <FinalBoss>().DealDamage((float)damageCalc);
                }
                Destroy(this.gameObject);
            }
            else if (hit.collider.gameObject.CompareTag("MainCamera"))
            {
                Destroy(this.gameObject);
                Player player = hit.collider.gameObject.GetComponent <Player>();
                player.takeDamage(damagePower);
            }
            else if (hit.collider.gameObject.CompareTag("FireDamager"))
            {
                if (gameObject.gameObject.CompareTag("EnemyProjectile"))
                {
                    return;
                }
                else
                {
                    Destroy(this.gameObject);
                    PowerBehaviour power = GameObject.Find("PowerHandler").GetComponent <PowerBehaviour>();
                    //When the trident model is integrated, check if the weapon is the trident, and NOT the other staff.
                    if (power.powerHandler[10].GetPowerActive()) //Check if the power is active
                    {
                        hit.collider.gameObject.GetComponent <FireCollision>().temporarilyDisableFire();
                    }
                }
            }
        }
    }
Пример #10
0
 UIController UIControl;                                             //Reference to the main UIController - used for calling pause/unpause functionality.
 // Start is called before the first frame update
 void Start()
 {
     powerController = GameObject.FindGameObjectWithTag("PowerHandler").GetComponent <PowerBehaviour>();
     UIControl       = GameObject.FindGameObjectWithTag("UIHandler").GetComponent <UIController>();
 }
Пример #11
0
//========================================================Power control
    public void ModifyPlayer()                                                             //This script will check all current modifiers, and update the player's abilities accordingly.
    {
        powerController = GameObject.Find("PowerHandler").GetComponent <PowerBehaviour>(); //Get the PowerBehaviour script.
        Debug.Log("ModifyPlayer triggered.");
        //Check difficulty - Easy will boost player's HP by 100.
        if (powerController.difficultyLevel == 1) //Easy
        {
            maximumHealth  = maximumHealth * EasyMaxHealthModifier;
            weaponPower    = weaponPower * EasyWeaponPowerModifier;
            damageTaken    = damageTaken * EasyDamageTakenModifier;
            pointsModifier = pointsModifier * EasyPointsModifier;
        }
        else if (powerController.difficultyLevel == 2) //Normal
        {
            maximumHealth  = maximumHealth * NormalMaxHealthModifier;
            weaponPower    = weaponPower * NormalWeaponPowerModifier;
            damageTaken    = damageTaken * NormalDamageTakenModifier;
            pointsModifier = pointsModifier * NormalPointsModifier;
        }
        else if (powerController.difficultyLevel == 3)
        {
            maximumHealth  = maximumHealth * HardMaxHealthModifier;
            weaponPower    = weaponPower * HardWeaponPowerModifier;
            damageTaken    = damageTaken * HardDamageTakenModifier;
            pointsModifier = pointsModifier * HardPointsModifier;
        }
        else if (powerController.difficultyLevel == 4) //Expert
        {
            maximumHealth  = maximumHealth * ExpertMaxHealthModifier;
            weaponPower    = weaponPower * ExpertWeaponPowerModifier;
            damageTaken    = damageTaken * ExpertDamageTakenModifier;
            pointsModifier = pointsModifier * ExpertPointsModifier;
        }
        //else if (powerController.difficultyLevel == 5) //Satanic
        //{
        //    weaponPower = 0.5f; //Weapons are 50% effective.
        //    pointsModifier = 3.5f; //+250% points.
        //}
        //Check powers.
        //Slot 2 & 3 effect the player immediately.
        //Increase player's HP by 2x.
        if (powerController.powerHandler[1].GetPowerActive())
        {
            Debug.Log("Power 1 in effect!");
            weaponPower = weaponPower * 2f; //Weapons are twice as effective in terms of damage dealt.
            if (weaponPower > 2)
            {
                weaponPower = 2;
            }
        }
        //Power 3 check. Double maximum HP.
        if (powerController.powerHandler[2].GetPowerActive())
        {
            Debug.Log("Power 2 in effect!");
            maximumHealth = maximumHealth * 2f; //Health is doubled with this modifier
            health        = maximumHealth;
        }
        //Power 10 check
        if (powerController.powerHandler[9].GetPowerActive())
        {
            damageTaken = damageTaken * 0.5f; //Damage taken is 50% lower.
        }
        baseWeaponPower = weaponPower;        //Used for power 5 method.
        health          = maximumHealth;
    }
Пример #12
0
 //Script notes
 //This should be applied to a child object for every enemy.
 //The specified height for this object is 19.67 in the Y direction, 0 for X/Z.
 //The height is different for the final boss due to the size!
 void Start()
 {
     powerCheck = GameObject.Find("PowerHandler").GetComponent <PowerBehaviour>();
 }