Exemplo n.º 1
0
    public override void InteractWithPlayer()
    {
        if (ignoreKnockUpTimeLeft > 0)
        {
            ignoreKnockUpTimeLeft -= Time.deltaTime;
        }
        if (_enemyCurrentState == EnemyState.Standing && !AnimationPlaying())
        {
            FaceBasedOnPlayerPosition();

            if (autoAttackRange.playerInRange())
            {
                if (attackCooldownUp())
                {
                    rb.velocity = new Vector3(0, rb.velocity.y, 0);
                    animator.SetTrigger("Attack");

                    nextAttackTime = Time.time + 1 / attackSpeed;
                }
            }

            specialAttackTimeRemains -= Time.deltaTime;
            if (specialAttackTimeRemains <= 0)
            {
                SpecialAttack();
            }
        }

        animator.SetFloat("HorizontalVelocity", rb.velocity.x);
    }
    // Update is called once per frame
    void Update()
    {
        if (_enemyDetector.playerInRange() && !elevatorHasOperated)
        {
            responseDelay -= Time.deltaTime;
            if (responseDelay < 0)
            {
                print("Try to shake the camera");
                _cameraEffect.ShakeForSeconds(0.5f);
                elevatorHasOperated = true;
            }
        }

        if (elevatorHasOperated)
        {
            if (currentSpeed < maxSpeed)
            {
                currentSpeed = Mathf.Lerp(currentSpeed, maxSpeed, speedIncreaseRate);
            }
            rb.velocity = new Vector3(0, currentSpeed, 0);
        }

        if (Math.Abs(currentSpeed - maxSpeed) < 0.5f)
        {
            toNextLevelDelay -= Time.deltaTime;
            if (toNextLevelDelay <= 0)
            {
                Camera.main.GetComponent <CameraFollow>().enabled = false;

                LevelChanger.Instance.FadeToNextLevel();
            }
        }
    }
Exemplo n.º 3
0
 public void DealDamageInStrikeHitBoxBack()
 {
     if (StrikeHitBoxBack.playerInRange())
     {
         PlayerProperty.playerClass.TakeDamage(damageStrikeBack);
     }
 }
Exemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (playerDetector && playerDetector.playerInRange())
     {
         GetComponent <FloatingPanel>().enabled = true;
     }
 }
Exemplo n.º 5
0
 public override void Move()
 {
     /*
      * if (moveTimeRemainsThisRound > 0)
      * {
      *  if (moveTowardsPlayer)
      *  {
      *      rb.velocity = new Vector3(PlayerDirectionInPlane().x * moveSpeed, rb.velocity.y);
      *      moveTimeRemainsThisRound -= Time.fixedDeltaTime;
      *  }
      *  else
      *  {
      *      rb.velocity = new Vector3(-PlayerDirectionInPlane().x * moveSpeed, rb.velocity.y);
      *
      *
      *      moveTimeRemainsThisRound -= Time.fixedDeltaTime;
      *  }
      * }
      * else
      * {
      *  ChangeBossMovementDirectionInRandom();
      * }
      */
     if (!playerInRangeDetector.playerInRange())
     {
         rb.velocity = new Vector3(PlayerDirectionInPlane().x *moveSpeed, rb.velocity.y, PlayerDirectionInPlane().z *moveSpeed);
     }
 }
    private void FixedUpdate()
    {
        if (transform.parent.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("PiercingSpear"))
        {
            if (piercingSpearHitBox.playerInRange() && !GameManager.Instance.PlayerDying && PlayerProperty.playerClass.invincibleTimeRemains <= 0)
            {
                LevelManager.Instance.piercingPlayer = true;
                AudioManager.instance.PlaySound(AudioGroup.FirstBoss, "PierceHitPlayer");
                PlayerProperty.playerClass.GetKnockOff(transform.parent.position);
                PlayerProperty.playerClass.TakeDamage(5);
                PlayerProperty.playerClass.invincibleTimeRemains = 5f;
//                PlayerProperty.playerClass.GetKnockOff(transform.position);

                PlayerProperty.player.GetComponent <Rigidbody>().velocity = Vector3.zero;
            }
            if (pierceRight)
            {
                if (LevelManager.Instance.piercingPlayer)
                {
                    if (piercingSpearHitBox.playerInRange() && !GameManager.Instance.PlayerDying)
                    {
                        PlayerProperty.playerClass.GetKnockOff(transform.parent.position);
                        PlayerProperty.player.transform.position = transform.position + new Vector3(3, 1, 0);
                    }
                }

                transform.parent.GetComponent <FirstStageBoss>().Flip(true);
                rb.AddForce(new Vector3(pierceSpeed, 0, 0));
            }
            if (!pierceRight)
            {
                if (LevelManager.Instance.piercingPlayer)
                {
                    if (piercingSpearHitBox.playerInRange() && !GameManager.Instance.PlayerDying)
                    {
                        PlayerProperty.playerClass.GetKnockOff(transform.parent.position);
                        PlayerProperty.player.transform.position = transform.position + new Vector3(-3, 1, 0);
                    }
                }


                transform.parent.GetComponent <FirstStageBoss>().Flip(false);
                rb.AddForce(new Vector3(-pierceSpeed, 0, 0));
            }
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (enemyDetector.playerInRange() && !hasExplode)
     {
         Explode();
         hasExplode = true;
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (playerDetector.playerInRange())
     {
         AudioManager.instance.ChangeBgm(bgmName);
         enabled = false;
     }
 }
Exemplo n.º 9
0
    public void DealDamageInStrikeHitBoxFront()
    {
        AudioManager.instance.PlaySound(AudioGroup.SecondBoss, "BaseballImpactWave");

        if (StrikeHitBoxFront.playerInRange())
        {
            PlayerProperty.playerClass.TakeDamage(damageStrikeFront);
        }
    }
Exemplo n.º 10
0
 private void Update()
 {
     transform.Rotate(0, 0, rotationSpeed * Time.deltaTime);
     if (enemyDetector.playerInRange())
     {
         playerScript.GetKnockOff(transform.position);
         playerScript.TakeDamage(damage);
     }
 }
Exemplo n.º 11
0
 // Update is called once per frame
 public override void Update()
 {
     base.Update();
     if (fullCharge && enemyDetector.playerInRange() && !hasKnockedOffPlayer)
     {
         hasKnockedOffPlayer = true;
         PlayerProperty.playerClass.GetKnockOff(transform.position, new Vector3(300, 200, 0));
     }
 }
Exemplo n.º 12
0
 private void OnCollisionEnter(Collision other)
 {
     if (other.gameObject == PlayerProperty.player && playerDetector.playerInRange())
     {
         PlayerProperty.player.transform.SetParent(transform.parent.Find("PlatformNode"));
         print("set player parent to platform node");
         lastTouchTime = Time.time;
         PlayerProperty.player.GetComponent <Rigidbody>().velocity = new Vector3(PlayerProperty.player.GetComponent <Rigidbody>().velocity.x, 0, PlayerProperty.player.GetComponent <Rigidbody>().velocity.z);
     }
 }
 public void HitPlayerIfItIsInHitBox()
 {
     AudioManager.instance.PlaySound(AudioGroup.SecondBoss, "HitGround");
     startJumping = false;
     if (RollingStrikeHitBoxPlayerDetector.playerInRange())
     {
         PlayerProperty.playerClass.GetKnockOff(transform.position);
         PlayerProperty.playerClass.TakeDamage(damage);
     }
 }
Exemplo n.º 14
0
    public void DealDamageInImpactWaveHitBox()
    {
        AudioManager.instance.PlaySound(AudioGroup.SecondBoss, "BaseballImpactWave");

        if (ImpactWaveHitBox.playerInRange())
        {
            PlayerProperty.playerClass.GetKnockOff(transform.position);
            PlayerProperty.playerClass.TakeDamage(damageImpactWave);
        }
    }
 public void HomeRunHitPlayer()
 {
     AudioManager.instance.PlaySound(AudioGroup.SecondBoss, "DragonFistStrike");
     print("Home run hits player");
     animator.SetBool("DragonFistHitPlayer", false);
     if (homeRunHitBox.playerInRange())
     {
         PlayerProperty.playerClass.GetKnockOff(knockOffForce);
         PlayerProperty.playerClass.TakeDamage(100);
     }
 }
Exemplo n.º 16
0
    public override void InteractWithPlayer()
    {
        if (HP <= 0)
        {
            return;
        }
        if (ignoreKnockUpTimeLeft > 0)
        {
            ignoreKnockUpTimeLeft -= Time.deltaTime;
        }
        if (_enemyCurrentState == EnemyState.Standing)
        {
            if (autoAttackRange.playerInRange())
            {
                if (attackCooldownUp() && !AnimationPlaying())
                {
                    rb.velocity = new Vector3(0, rb.velocity.y, 0);
                    animator.SetTrigger("Attack");
                    AudioManager.instance.PlaySound(AudioGroup.FirstBoss, "BasicAttack");

                    nextAttackTime = Time.time + 1 / attackSpeed;
                }
            }

            specialAttackTimeRemains -= Time.deltaTime;
            if (specialAttackTimeRemains <= 0 && !AnimationPlaying())
            {
                SpecialAttack();
            }
        }
        if (!AnimationPlaying() && !IsHitOnAirOrLayDown())
        {
            ReleaseEnemyMove();
            ChangeFacing(rb.velocity.x);
        }
        else
        {
            LockEnemyMove();
        }
        animator.SetFloat("HorizontalVelocity", rb.velocity.x);
    }
 // Update is called once per frame
 void Update()
 {
     if (LevelManager.Instance.isDashingForward)
     {
         if (isDashingRight)
         {
             transform.Translate(new Vector3(dashingSpeed * Time.deltaTime, 0, 0));
             if (dragonFistDashHitBox.playerInRange())
             {
                 if (!hasBumpPlayer)
                 {
                     bool playerIsKnockOff = PlayerProperty.playerClass.GetKnockOff(PlayerProperty.playerPosition - new Vector3(2, 0, 0), new Vector3(-20, 0, 0));
                     if (playerIsKnockOff)
                     {
                         PlayerProperty.playerClass.ResetInvincibleTime();
                         hasBumpPlayer = true;
                     }
                 }
             }
         }
         else
         {
             transform.Translate(new Vector3(-dashingSpeed * Time.deltaTime, 0, 0));
             if (dragonFistDashHitBox.playerInRange())
             {
                 if (!hasBumpPlayer)
                 {
                     bool playerIsKnockOff = PlayerProperty.playerClass.GetKnockOff(PlayerProperty.playerPosition + new Vector3(2, 0, 0), new Vector3(-20, 0, 0));
                     if (playerIsKnockOff)
                     {
                         PlayerProperty.playerClass.ResetInvincibleTime();
                         hasBumpPlayer = true;
                     }
                 }
             }
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (!hasInteracted && playerDetector.playerInRange())
        {
            hasInteracted = true;
        }

        if (hasInteracted && delay > 0)
        {
            delay -= Time.deltaTime;
            if (delay <= 0)
            {
                bossGreetingDialogue.enabled       = true;
                bossGreetingDialogue.playerInRange = true;
            }
        }
    }
 public void DragonFistStrike()
 {
     LevelManager.Instance.isDashingForward = false;
     hasBumpPlayer = false;
     AudioManager.instance.PlaySound(AudioGroup.SecondBoss, "DragonFistStrike");
     if (isDashingRight && dragonFistHitBoxRight.playerInRange() || !isDashingRight && dragonFistHitBoxLeft.playerInRange())
     {
         if (PlayerProperty.playerClass.GetKnockOff(transform.position, new Vector3(0, dragonFistFlyKnockUpForce, 0))
             )
         {
             PlayerProperty.playerClass.TakeDamage(10);
             Camera.main.GetComponent <CameraEffect>().EnlargeCamera(Camera.main.orthographicSize / 0.7f);
             GetComponent <SecondStageBoss>().hasEnlargedCameraDragonFist = true;
             PlayerProperty.playerClass.ResetInvincibleTime();    // Player not invincible after it is knocked up by dragon fist
             animator.SetBool("DragonFistHitPlayer", true);
         }
     }
 }
    private void FixedUpdate()
    {
        if (!fullCharge)
        {
            startTime         += Time.deltaTime;
            transform.rotation = Quaternion.Lerp(start, end, (Mathf.Sin(startTime * speed + Mathf.PI / 2) + 1.0f) / 2.0f);
        }
        else
        {
            transform.Rotate(new Vector3(0, 0, speed * Time.fixedDeltaTime));
        }


        if (enemyDetector.playerInRange())
        {
            PlayerProperty.playerClass.GetKnockOff(transform.TransformDirection(transform.position));
            PlayerProperty.playerClass.TakeDamage(damageToPlayer);
        }
    }
Exemplo n.º 21
0
    // Update is called once per frame
    void Update()
    {
        if (enemyDetector.playerInRange())
        {
            canAttack = true;
            transform.LookAt(PlayerProperty.player.transform);
        }
        else
        {
            canAttack = false;
        }

        if (canAttack)
        {
            nextCannonBallTimeRemains -= Time.deltaTime;
            if (nextCannonBallTimeRemains <= 0)
            {
                nextCannonBallTimeRemains = spawnCannonBallInterval;
                Instantiate(cannonBall, exampleCannonBallPosition, exampleCannonBallQuaternion);
            }
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (playerDetector.playerInRange())
     {
         playerWasInRiver = true;
         if (direction == RiverOfSandTilingDirection.Positive)
         {
             PlayerProperty.player.GetComponent <Rigidbody>().AddForce(new Vector3(0, 0, speed));
         }
         else
         {
             PlayerProperty.player.GetComponent <Rigidbody>().AddForce(new Vector3(0, 0, -speed));
         }
     }
     else
     {
         if (playerWasInRiver)
         {
             playerWasInRiver = false;
             PlayerProperty.player.GetComponent <Rigidbody>().velocity = new Vector3(PlayerProperty.player.GetComponent <Rigidbody>().velocity.x, PlayerProperty.player.GetComponent <Rigidbody>().velocity.y, 0);
         }
     }
 }
    private void Update()
    {
        if (playerDetector.playerInRange() && !hasSpawned)
        {
            Spawn();
            if (!isBossSpawner)
            {
                if (SceneManager.GetActiveScene().buildIndex == 5)
                {
                    AudioManager.instance.ChangeBgm("EnemySpawner");
                }
                else if (SceneManager.GetActiveScene().buildIndex == 6)
                {
                    AudioManager.instance.ChangeBgm("EnemySpawnerLevel2");
                }
            }
        }

        if (hasSpawned)
        {
            if (isAllEnemiesDead())
            {
                if (!hasInteractedWithBarrier)
                {
                    if (!isBossSpawner)
                    {
                        AudioManager.instance.ChangeBgm(AudioManager.instance.prevBgm);
                    }
                    hasInteractedWithBarrier = true;
                    if (barrier != null)
                    {
                        barrier.GetComponent <EnemySpawnerComponent>().OnEnemyDie();
                    }
                }
            }
        }
    }