Exemplo n.º 1
0
    public void UpdateHealth(int HPupdate)
    {
        if (IsImmune == false)
        {
            if (HPupdate < 0)
            {
                HP            += HPupdate;
                AudioHits.clip = AudioDamaged;
                AudioHits.Play();
                RedBoxLeft.enabled  = true;
                RedBoxRight.enabled = true;
                RedBoxLeft.CrossFadeAlpha(0, .5f, false);
                RedBoxRight.CrossFadeAlpha(0, .5f, false);
                DelayHelper.DelayAction(this, Resetboxes, .5f);
            }
            if (HPupdate > 0)
            {
                if (HP < 5)
                {
                    HP += HPupdate;
                }
            }

            int HealhGUISize = HP * 100;
            HealthGUI.rectTransform.sizeDelta = new Vector2(HealhGUISize, 50);
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        if (TimeCounter > 0 && playerShip.Won == false)
        {
            TimeCounter  -= Time.deltaTime;
            TimeOnScreen  = Mathf.Floor(TimeCounter);
            TimeText.text = "Time: " + TimeOnScreen;

            if (playerShip != null && TimeCounter <= 0f)
            {
                playerShip.Kill();
                YouLoseText.enabled = true;
                DelayHelper.DelayAction(this, ReloadLevel, 5.0f);
            }
        }
        else if (TimeCounter <= 0)
        {
            TimeText.text = "Time: " + 0;
        }

        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            ReloadLevel();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
    }
Exemplo n.º 3
0
    public void TakeDamage(int damage)
    {
        Health -= damage;
        Debug.Log("Health for " + this.transform.name + " is " + Health);

        HitCircle.color = Color.red;
        DelayHelper.DelayAction(this, swapToWhite, .7f);
        bool deathnoise = false;

        if (Health <= 0)
        {
            if (deathnoise == false)
            {
                EnemyAudio.clip = AudioExploding;
                EnemyAudio.Play();
                deathnoise = true;
                Exploder.Play();
                PLC.UpdateHealth(1);
            }

            DisableObject();
            Debug.Log(this.transform.name + " is " + "dead");
            LV.IncreaseScore(5);
            if (IsFreezeOn == true)
            {
                LV.IncreaseScore(5);
            }
        }
    }
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         Resume();
         DelayHelper.DelayAction(this, Pause, 0.1f);
     }
 }
 //FIRE PROJECTILE
 void Shoot()
 {
     //create projectile
     Instantiate(confuseProjectile, projectileSpawnPoint.position, transform.rotation, projectileParent);
     //play projectile effects
     PlayShootFeedback();
     //prevents from shooting again until DelayAction marks the ship as reloaded
     canFire = false;
     DelayHelper.DelayAction(this, ReadyToFire, projectileReloadTime);
 }
Exemplo n.º 6
0
    void displayScoreText()
    {
        scoreText.text = "Score: " + count.ToString(); //count is an integer; it can become a String (literal text)

        if (count >= 5)
        {
            winText.SetActive(true);
            AudioHelper.PlayClip2D(_WSound, 3);
            DelayHelper.DelayAction(this, RespawnPlayer, 2f);
        }
    }
Exemplo n.º 7
0
    private void OnTriggerStay(Collider other)
    {
        //if collides with player ship, kill it
        PlayerShip playerShip = other.GetComponent <PlayerShip>();

        if (playerShip != null && !playerShip.invinciblePowerupActive)
        {
            playerShip.Kill();
            DelayHelper.DelayAction(this, playerShip.Respawn, 2f);
        }
    }
Exemplo n.º 8
0
    /*
     * private void OnTriggerEnter(Collider other)
     * {
     *  if (other.CompareTag("Player"))
     *  {
     *      Debug.Log("Player has entered");
     *      targetingOn = true;
     *  }
     * }
     *
     * private void OnTriggerStay(Collider other)
     * {
     *  Debug.Log("Player is staying");
     *  targetingOn = true;
     * }
     * private void OnTriggerExit(Collider other)
     * {
     *  Debug.Log("Player has left");
     *  targetingOn = false;
     * }
     */


    private void Update()
    {
        frozenSoundTimer      += Time.deltaTime;
        DecayFreezeLimitTimer += Time.deltaTime;
        if (Health >= 1)
        {
            if (DecayFreezeLimitTimer > DecayFreezeLimit && FreezeContainer > .001f && DecayTimerFinished == false && IsFreezeOn == false)
            {
                Debug.Log("decay freeze conditions have been met");
                DelayHelper.DelayAction(this, UnfreezingAction, Unfreeze);
                beginUnfreeze = true;
            }
            //checks to see if they are frozen
            if (IsFreezeOn == true)
            {
                //Begins the unfreeze effect after 2 seconds
                if (frameStartUnFreeze == 0)
                {
                    DelayHelper.DelayAction(this, FreezeDelay, 2f);
                    frameStartUnFreeze = 1;
                }
                //Unfreezing and updates every unfreeze rate
                if (frameUnFreeze == 0)
                {
                    DelayHelper.DelayAction(this, UnfreezingAction, Unfreeze);
                    frameUnFreeze      = 1;
                    DecayTimerFinished = true;
                }
            }
            else
            {
                timerShoot    += Time.deltaTime;
                targetVelocity = rb.velocity;
                //targetpos = Player.transform.position;
                targetpos = PlayerPos;
                //distanceToTarget = Vector3.Distance(SphereCollider.transform.position, Player.transform.position);
                distanceToTarget = Vector3.Distance(SphereCollider.transform.position, PlayerPos);
                if (timerShoot >= ShootCoolDown)
                {
                    // Get target info

                    ShootPlayer();
                }
            }
        }

        NothingHitTimer += Time.deltaTime;
        if (NothingHitTimer >= .8f)
        {
            HitCircle.color = Color.white;
            NothingHitTimer = 0f;
        }
    }
Exemplo n.º 9
0
    private void OnTriggerEnter(Collider other)
    {
        PlayerShip playerShip
            = other.gameObject.GetComponent <PlayerShip>();

        if (playerShip != null)
        {
            YouLoseText.enabled = true;
            playerShip.Kill();
            DelayHelper.DelayAction(this, GameRestart, 2.0f);
        }
    }
    protected override void PowerupDuration(Player player)
    {
        Player _player = player.GetComponent <Player>();

        if (_player != null)
        {
            player.changeColor();

            DelayHelper.DelayAction(this, player.returnColor, 3.0f);

            base.PowerupDuration(player);
        }
    }
Exemplo n.º 11
0
    void PowerupSequence(PlayerShip playerShip)
    {
        //duplicate handling
        FixDuplicatePowerups(playerShip);

        //set boolean for detecting lockout
        poweredUp = true;

        ActivatePowerup(playerShip);
        //simulate this object being disabled
        DisableObject();

        //delay end of powerup
        DelayHelper.DelayAction(this, EndPowerupSequence, playerShip, powerupDuration);
    }
Exemplo n.º 12
0
    private void OnTriggerEnter(Collider other)
    {
        //Detect if it's the player
        PlayerShip playerShip
            = other.gameObject.GetComponent <PlayerShip>();

        // if we found something valid, continue
        if (playerShip != null)
        {
            // do something!
            playerShip.Kill();
            AudioHelper.PlayClip2D(_DSound, 1);
            loseText.SetActive(true);
            DelayHelper.DelayAction(this, RespawnPlayer, 2f);
        }
    }
Exemplo n.º 13
0
 //CONFUSED EFFECT
 public void ActivateConfused(float duration)
 {
     //only activate confused effects if not already confused (prevents getting overwhelmed)
     if (!isConfused && !invinciblePowerupActive)
     {
         isConfused = true;
         //delay deactivation
         DelayHelper.DelayAction(this, DeactivateConfused, duration);
         //particles
         confusedParticle.Play();
         //sound
         AudioHelper.PlayClip2D(confusedStartSound, .2f);
         //cockpit turns red
         //'7': Cockpit ID
         transform.GetChild(0).GetComponentsInChildren <MeshRenderer>()[7].material = cockpitConfusedMaterial;
     }
 }
Exemplo n.º 14
0
    private void Update()
    {
        if (playerShip != null && poweredUp == true && TeleportHolder >= 1)
        {
            playerShip?.SetTeleportReference(true);
            DisableObject();

            if (Input.GetKeyDown(KeyCode.J))
            {
                playerShip?.SetTeleportBoost(true);

                playerShip?.TeleportPower();

                TeleportHolder -= TeleportUses;
                playerShip?.SetTeleportReference(false);
                DelayHelper.DelayAction(this, EnableObject, 5.0f);
                poweredUp = false;
            }
        }
    }
Exemplo n.º 15
0
    private void Update()
    {
        //checks to see if they are frozen
        if (IsFreezeOn == true)
        {
            //Begins the unfreeze effect after 2 seconds
            if (frameStartUnFreeze == 0)
            {
                DelayHelper.DelayAction(this, FreezeDelay, 2f);
                frameStartUnFreeze = 1;
            }
            //Unfreezing and updates every unfreeze rate
            if (frameUnFreeze == 0)
            {
                DelayHelper.DelayAction(this, UnfreezingAction, Unfreeze);
                frameUnFreeze = 1;
            }
        }
        else
        {
            timerShoot += Time.deltaTime;
            Vector3 shooterPosition = ShootingArea.transform.position;
            Vector3 targetPosition  = Player.transform.position;
            Vector3 shooterVelocity = TurretRb.velocity;
            Vector3 targetVelocity  = rb.velocity;

            interceptPoint = FirstOrderIntercept(shooterPosition, shooterVelocity, shootSpeed, targetPosition, targetVelocity);

            if (timerShoot >= ShootCoolDown)
            {
                // Get target info

                ShootPlayer();
            }
        }
    }
Exemplo n.º 16
0
 void SetConfuseRotation()
 {
     //dont confine rotation
     confuseRotation = GetNewConfuseAmount(confuseRotationMax, confuseRotationMin);
     DelayHelper.DelayAction(this, SetConfuseRotation, confusedChangeTime);
 }
Exemplo n.º 17
0
 //calculate confused effect every interval
 void SetConfuseForce()
 {
     //confine the force
     confuseForce = ConfineConfusion(GetNewConfuseAmount(confuseForceMax, confuseForceMin));
     DelayHelper.DelayAction(this, SetConfuseForce, confusedChangeTime);
 }
Exemplo n.º 18
0
    private void Update()
    {
        if (PL.CheckIsPlaying() == true)
        {
            if (Input.GetKeyUp(KeyCode.Mouse0))
            {
                IceGunParticle.Emit(0);
            }

            if (Input.GetKey(KeyCode.Mouse0))
            {
                IceGunParticle.Emit(1);
                if (FreezeShoot == 0)
                {
                    DelayHelper.DelayAction(this, Shoot, IceGunCooldown);
                    //Shoot();
                    SwapMode    = 0;
                    FreezeShoot = 1;

                    //play sound
                    if (audioSwapGun.isPlaying == false)
                    {
                        // ... play them.
                        if (audioSwapGun.clip != audioClipFreezeGun)
                        {
                            audioSwapGun.clip = audioClipFreezeGun;
                        }
                        audioSwapGun.Play();
                    }
                }
            }
            else if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                if (CanRegShoot == true)
                {
                    DelayHelper.DelayAction(this, RegGunOnCooldown, RegGunCooldown);
                    SwapMode = 1;
                    Shoot();
                    //Debug.Log("doing regular shot");
                    CanRegShoot = false;
                    //noises and particles
                    MuzzleFlash.Play();
                    //Sound

                    if (audioSwapGun.clip != audioClipRegGun)
                    {
                        audioSwapGun.clip = audioClipRegGun;
                    }
                    audioSwapGun.Play();
                }
            }
            else
            {
                if (audioSwapGun.clip == audioClipFreezeGun)
                {
                    if (SwapMode == 0)
                    {
                        audioSwapGun.Stop();
                    }
                }
            }
            if (Input.GetKey(KeyCode.F))
            {
                if (CanIceWall == true)
                {
                    //DelayHelper.DelayAction(this, IceWallOnCooldown, IceWallCooldown);
                    IceWallMaker();
                    CanIceWall = false;

                    //Play sound
                }
            }

            if (CanIceWall == false)
            {
                BackgroundIceCounter.enabled = true;
                IceWallTimer += Time.deltaTime;
                int IceWallTimerConverted = (int)IceWallTimer;
                IceWallTimerConverted = (int)IceWallCooldown - IceWallTimerConverted;
                CounterIceWall.text   = IceWallTimerConverted.ToString();
                if (IceWallTimer >= IceWallCooldown)
                {
                    IceWallOnCooldown();
                }
            }

            /*
             * NothingHitTimer += Time.deltaTime;
             * if (NothingHitTimer >= .6f)
             * {
             *  HitCircle.color = Color.white;
             *  NothingHitTimer = 0f;
             * }
             */
        }
    }
Exemplo n.º 19
0
    bool hasCollided; //prevents duplicate collisions

    public void Start()
    {
        velocityVector = Vector3.forward * velocity;
        DelayHelper.DelayAction(this, Despawn, lifespan);
    }
Exemplo n.º 20
0
 private void Awake()
 {
     _rb = GetComponent <Rigidbody>();
     DelayHelper.DelayAction(this, DestroyBullet, _bulletDuration);
 }
Exemplo n.º 21
0
 //TeleporterPowers
 public void SetTeleportBoost(bool activeState)
 {
     trail2.enabled = activeState;
     AudioHelper.PlayClip2D(PowerUpTeleporter, 0.4f);
     DelayHelper.DelayAction(this, Trail2Off, .2f);
 }
Exemplo n.º 22
0
 void RegressSpeed()
 {
     moveSpeed = DodgeSpeed * .25f;
     DelayHelper.DelayAction(this, ChangeSpeedToNormal, .25f);
 }
Exemplo n.º 23
0
    private void Update()
    {
        if (IsPlaying == true)
        {
            if (Input.GetKeyDown(KeyCode.LeftShift) && Input.GetKey(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftShift) && Input.GetKey(KeyCode.D) || Input.GetKeyDown(KeyCode.LeftShift) && Input.GetKey(KeyCode.S))
            {
                if (Input.GetKey(KeyCode.W) == false && isRolling != true)
                {
                    //motor.Dodge();
                    moveSpeed = DodgeSpeed;
                    isRolling = true;
                    IsImmune  = true;
                    DelayHelper.DelayAction(this, RegressSpeed, .5f);
                    AudioMovement.clip = AudioDodge;
                    AudioMovement.Play();
                }
            }
            else if (Input.GetKey(KeyCode.LeftShift) && isRolling != true)
            {
                moveSpeed = .2f;
            }
            else if (Input.GetKeyUp(KeyCode.LeftShift))
            {
                moveSpeed = OGmoveSpeed;
            }


            /*
             * if (Input.GetKeyDown(KeyCode.Mouse1))
             * {
             *  //Debug.Log("Shoot!");
             *  //MuzzleFlash.Play();
             *  //Sound
             *  //GunShot.Play();
             * }*/
        }

        if (HP <= 0)
        {
            if (IsPlaying == true)
            {
                IsImmune       = true;
                AudioHits.clip = AudioDeath;
                AudioHits.Play();
            }
            IsPlaying    = false;
            YouLose.text = "You Lose! Press Escape and click restart!";
        }

        if (isRolling == true)
        {
            BackgroundDodgeCounter.enabled = true;
            DodgeTimer += Time.deltaTime;
            int DodgeTimerConverted = (int)DodgeTimer;
            DodgeTimerConverted = (int)DodgeCooldown - DodgeTimerConverted;
            CounterDodge.text   = DodgeTimerConverted.ToString();
            if (DodgeTimer >= DodgeCooldown)
            {
                RollingCooldown();
            }
        }
    }
Exemplo n.º 24
0
 void Shield()
 {
     _shieldObject.SetActive(true);
     _shieldActive = true;
     DelayHelper.DelayAction(this, InvertShield, 0.5f);
 }
 protected virtual void PowerupDuration(Player player)
 {
     DelayHelper.DelayAction(this, powerDown, 3.0f);
 }