예제 #1
0
    public override IEnumerator TakeDamage()
    {
        if (!immortal)
        {
            HealthStat.CurrentValue -= 10;

            GameManager.Instance.CollectedCoins--;


            if (!IsDead)
            {
                if (GameManager.Instance.CollectedCoins <= 0)
                {
                    GameManager.Instance.CollectedCoins = 0;
                }
                MyAnimator.SetTrigger("damage");
                immortal = true;
                StartCoroutine(IndicateImmortal());
                yield return(new WaitForSeconds(immortalTime));

                immortal = false;
            }
            else
            {
                MyAnimator.SetLayerWeight(1, 0);
                MyAnimator.SetTrigger("die");
            }
        }
    }
예제 #2
0
    IEnumerator HurtBlinker(float hurtTime)
    {
        MyAnimator.SetLayerWeight(1, 1f);
        yield return(new WaitForSeconds(hurtTime));

        MyAnimator.SetLayerWeight(1, 0f);
    }
예제 #3
0
    public override IEnumerator TakeDamage()
    {
        if (!immortal)
        {
            healthStat.CurrentVal -= 10;

            if (!IsDead)
            {
                MyAnimator.SetTrigger("damage");
                audio.PlayOneShot(damageSound);
                immortal = true;
                StartCoroutine(IndicateImmortal());
                yield return(new WaitForSeconds(immmortalTime));

                immortal = false;
            }
            else
            {
                GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
                GetComponent <Rigidbody2D>().gravityScale = 0;
                GetComponent <BoxCollider2D>().enabled    = false;
                MyAnimator.SetLayerWeight(1, 0);
                MyAnimator.SetTrigger("die");

                audio.PlayOneShot(deadSound);
            }
        }
    }
    public override IEnumerator TakeDamage()
    {
        if (!immortal)
        {
            healthStat.CurrentValue -= 10;

            if (!IsDead)
            {
                MyAnimator.SetTrigger("damage");
                immortal = true;

                StartCoroutine(IndicateImmortal());
                yield return(new WaitForSeconds(immortalTime));

                immortal = false;
            }
            else
            {
                MyAnimator.SetLayerWeight(1, 0);
                MyAnimator.SetTrigger("die");
                for (int i = 0; i < all.Length; i++)
                {
                    all [i].enabled = false;
                }
            }
        }
    }
예제 #5
0
    public override IEnumerator TakeDamage()
    {
        if (!immortal)
        {
            healthStat.CurrentVal -= 10;
            gruntFx.Play();

            if (!IsDead)
            {
                MyAnimator.SetTrigger("damage");
                immortal = true;
                StartCoroutine(IndicateImmortal());

                yield return(new WaitForSeconds(immortalTime));

                immortal = false;
            }
            else
            {
                playerDie.Play();
                MyAnimator.SetLayerWeight(1, 0);
                MyAnimator.SetTrigger("die");
            }
        }
    }
예제 #6
0
파일: Player.cs 프로젝트: EdTech101/Yare
    public override IEnumerator TakeDamage()
    {
        if (!inmortal)
        {
            health.CurrentVal -= 10;
            if (!IsDead)
            {
                SoundManager.Instance.PlaySfx("12");
                MyAnimator.SetTrigger("damage");
                inmortal = true;
                StartCoroutine(IndicateInmortal());
                yield return(new WaitForSeconds(inmortalTime));

                inmortal = false;
            }
            else
            {
                SoundManager.Instance.PlaySfx("goblinLaught");

                SoundManager.Instance.PlaySfx("death");
                DeleteLife();
                MyAnimator.SetLayerWeight(1, 0);
                MyAnimator.SetTrigger("die");
                MyAnimator.SetTrigger("tomb");
            }
        }
    }
예제 #7
0
    public override IEnumerator TakeDamage(string source)
    {
        if (!immortal)
        {
            if (source == "EnemySword")
            {
                healthStat.CurrentVal -= 20;
            }
            else
            if (source == "EnemyKnife")
            {
                healthStat.CurrentVal -= 20;
            }


            if (!IsDead)
            {
                MyAnimator.SetTrigger("damage");
                immortal = true;

                StartCoroutine(IndicateImmortal());

                yield return(new WaitForSeconds(immortalTime));

                immortal = false;
            }
            else
            {
                MyAnimator.SetLayerWeight(1, 0);
                MyAnimator.SetTrigger("die");
            }
        }
    }
    public override IEnumerator TakeDamage()
    {
        if (!immortal)
        {
            health.CurrentVal -= 10;

            if (!IsDead)
            {
                MyAnimator.SetTrigger("damage");
                immortal = true;
                StartCoroutine(Immortality());
                yield return(new WaitForSeconds(immortalTime));

                immortal = false;
            }
            else
            {
                MyAnimator.SetLayerWeight(1, 0);
                turnOffCollisions();
                MyAnimator.SetTrigger("die");

                yield return(new WaitForSeconds(0.2f));

                deathCount++;
                Debug.Log(deathCount);
            }
        }
    }
예제 #9
0
    public override IEnumerator TakeDamage()
    {
        if (!immortal)
        {
            if (actState != ActState.Defence)
            {
                stat.Health.CurrentVal -= 10;

                if (!IsDead)
                {
                    MyAnimator.SetTrigger("damage");
                    //immortal = true;
                    //StartCoroutine(IndicateImmortal());
                    yield return(new WaitForSeconds(immortalTime));

                    immortal = false;
                }
                else
                {
                    MyAnimator.SetLayerWeight(1, 0);
                    MyAnimator.SetTrigger("die");
                }
            }
            else
            {
                MyAnimator.SetBool("defence", false);
                actState = ActState.Delayed;
                yield return(new WaitForSeconds(0.05f));

                actState = ActState.StandBy;
            }
        }
    }
예제 #10
0
 public void ActivateLayer(string layerName)
 {
     for (int i = 0; i < MyAnimator.layerCount; i++)
     {
         MyAnimator.SetLayerWeight(i, 0);
     }
     MyAnimator.SetLayerWeight(MyAnimator.GetLayerIndex(layerName), (1));
 }
예제 #11
0
 //Handles the animator layers
 private void HandleLayers()
 {
     if (!OnGround)
     {
         MyAnimator.SetLayerWeight(1, 1); //Layer weight is set to 1 and Layer number 1 refers to AirLayer
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0); //0 refers to GroundLayer
     }
 }
 void ChangeLayerWeight()
 {
     if (!OnGround)
     {
         MyAnimator.SetLayerWeight(1, 1);
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
     }
 }
예제 #13
0
 // Switches the animation layers between ground and air.
 private void HandleLayers()
 {
     if (!OnGround)
     {
         MyAnimator.SetLayerWeight(1, 1); // Sets layer to Air
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);    // sets layer to ground.
     }
 }
예제 #14
0
 private void HandleLayer()
 {
     if (!OnGround)
     {
         MyAnimator.SetLayerWeight(1, 1);
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
     }
 }
예제 #15
0
 private void HandleLayers() // Schimba layer-ul de animatii in cel de Airlayer daca playerul nu este pe pamant
 {
     if (!OnGround)
     {
         MyAnimator.SetLayerWeight(1, 1);
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
     }
 }
예제 #16
0
 private void AnimationControl() // 공격상태에 따른 애니메이션 레이어 컨트롤러
 {
     if (DataController.instance.gameData.P2_Attack_Shot)
     {
         MyAnimator.SetLayerWeight(1, 1);
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
     }
 }
예제 #17
0
 private void HandleLayers()
 {
     //When Otter is not on ground, Air Layer is played
     if (!OnGround)
     {
         MyAnimator.SetLayerWeight(1, 1);
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
     }
 }
예제 #18
0
 private void HandleLayers()
 {
     if (!OnGround)
     {
         // sets the layer to one
         MyAnimator.SetLayerWeight(1, 1);
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
     }
 }
예제 #19
0
 // Layers
 private void HandleLayers()
 {
     // If not grounded then start using layer 1 = air layer
     if (!OnGround)
     {
         MyAnimator.SetLayerWeight(1, 1);
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
     }
 }
예제 #20
0
 public override void OnTriggerEnter2D(Collider2D other)
 {
     //calls the base on trigger enter
     base.OnTriggerEnter2D(other);
     //if player touches spike traps he dies instantly
     if (other.tag == "Spike")
     {
         healthStat.CurrentVal = 0;
         MyAnimator.SetLayerWeight(1, 0);
         MyAnimator.SetTrigger("die");
     }
 }
예제 #21
0
    public void ActivateLayer(string layerName)
    {
        //this is a Looping structure.  initially i is set to 0 (inactive).  Then the loop runs while i is less than the number of layers
        // adding 1 to i in each loop
        for (int i = 0; i < MyAnimator.layerCount; i++)
        {
            //sets layer weight to 0 for every layer as the loop runs. this "resets" all the layers
            MyAnimator.SetLayerWeight(i, 0);
        }

        //sets the Layer Weight for the layer specified in layername to 1 (active)
        MyAnimator.SetLayerWeight(MyAnimator.GetLayerIndex(layerName), 1);
    }
예제 #22
0
 private void HandleLayers()     // sets the layers for the player state machine so they can change layers depending on actions
 {
     if (!OnGround)
     {
         MyAnimator.SetLayerWeight(1, 1);
         MyAnimator.SetLayerWeight(0, 0);
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
         MyAnimator.SetLayerWeight(0, 1);
     }
 }
예제 #23
0
파일: Player.cs 프로젝트: yt/2d-Platformer
 public override IEnumerator Hit()
 {
     energy -= 10;
     if (!isDead)
     {
         MyAnimator.SetTrigger("hit");
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
         MyAnimator.SetTrigger("death");
     }
     yield return(null);
 }
예제 #24
0
    //Changes the weight of animator layers
    private void HandleLayers()
    {
        //If the player is in the air, AirLayer is the main layer
        if (!isGrounded)
        {
            MyAnimator.SetLayerWeight(1, 1);
        }

        //If the player is on the ground, the ground layer is the main layer
        else
        {
            MyAnimator.SetLayerWeight(1, 0);
        }
    }
예제 #25
0
 public override IEnumerator TakeDamage()
 {
     Health -= 10;        // we can change later
     if (!IsDead)
     {
         MyAnimator.SetTrigger("damage");
     }
     else
     {
         MyAnimator.SetLayerWeight(1, 0);
         MyAnimator.SetTrigger("die");
         Destroy(gameObject, 1);
     }
     yield return(null);
 }
예제 #26
0
파일: Player.cs 프로젝트: yt/2d-Platformer
    private IEnumerator MovementLayers()
    {
        if (!OntheGround)
        {
            yield return(new WaitForSeconds(0.1f));

            MyAnimator.SetLayerWeight(1, 1);
        }
        else
        {
            yield return(new WaitForSeconds(0.1f));

            MyAnimator.SetLayerWeight(1, 0);
        }
    }
예제 #27
0
파일: Player.cs 프로젝트: EdTech101/Yare
 private void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.tag == "coin")
     {
         SoundManager.Instance.PlaySfx("coin");
         GameManager.Instance.collectedCoins++;
         Destroy(other.gameObject);
     }
     else if (other.gameObject.tag == "Cross")
     {
         starPos = transform.position;
         SoundManager.Instance.PlaySfx("live");
         health.CurrentVal += 30;
         Destroy(other.gameObject);
     }
     else if (other.gameObject.tag == "Maraca")
     {
         SoundManager.Instance.PlaySfx("pick");
         GameManager.Instance.collectedCollectibles++;
         MaracasCount++;
         Destroy(other.gameObject);
     }
     else if (other.gameObject.tag == "Cave")
     {
         GameManager.Instance.LoadLevel1();
     }
     else if (other.gameObject.tag == "Key")
     {
         HasKey = true;
         GameManager.Instance.ShowKey();
         Destroy(other.gameObject);
     }
     else if (other.gameObject.tag == "Spikes" && !diying)
     {
         SoundManager.Instance.PlaySfx("spikes");
         SoundManager.Instance.PlaySfx("death");
         diying = true;
         DeleteLife();
         health.CurrentVal -= health.MaxVal;
         MyAnimator.SetLayerWeight(1, 0);
         MyAnimator.SetTrigger("die");
         MyAnimator.SetTrigger("tomb");
     }
     else if (other.gameObject.tag == "Gate" && HasKey)
     {
         GameManager.Instance.ShowWinMenu();
     }
 }
예제 #28
0
    void FixedUpdate()
    {
        float horizontal = Input.GetAxis("Horizontal");

        OnGround = IsGrounded() && !MyAnimator.GetCurrentAnimatorStateInfo(1).IsTag("JumpUp");
        HandleMovement(horizontal);
        Flip(horizontal);
        //HandleAttacks ();
        HandleLayers();
        //ResetValue ();
        if (IsDead)
        {
            MyAnimator.SetLayerWeight(1, 0);
            MyAnimator.SetTrigger("die");
            Freeze = true;
        }
    }
예제 #29
0
    public override IEnumerator TakeDamage(float _damage)
    {
        float result;

        if (stat.def.CurrentVal >= _damage)
        {
            result = 1;
        }
        else
        {
            result = _damage - stat.def.CurrentVal;
        }

        if (actState != ActState.Defence)
        {
            stat.Health.CurrentVal -= result;

            if (!IsDead)
            {
                MyAnimator.SetTrigger("damage");
                //immortal = true;
                //StartCoroutine(IndicateImmortal());
                yield return(new WaitForSeconds(immortalTime));

                immortal = false;
            }
            else
            {
                MyAnimator.SetLayerWeight(1, 0);
                MyAnimator.SetTrigger("die");
            }
        }
        else
        {
            actState = ActState.Delayed;
            MyAnimator.SetBool("defence", false);
            yield return(new WaitForSeconds(result * 0.01f));

            actState = ActState.StandBy;
        }
    }
예제 #30
0
    public override IEnumerator TakeDamage(string currentDmgSrc)
    {
        if (!immortal)
        {
            if (currentDmgSrc == "erd")
            {
                currentReceiveDamage = GameManager.Instance.EnemyRangedDmg;
                source.PlayOneShot(takeDmgSound, 0.2F);
            }
            else if (currentDmgSrc == "emd")
            {
                currentReceiveDamage = GameManager.Instance.EnemyMeleeDmg;
                source.PlayOneShot(takeDmgSound, 0.2F);
            }

            healthStat.CurrentVal -= currentReceiveDamage;
            CombatTextManager.Instance.CreateText(transform.position, Convert.ToString(currentReceiveDamage), Color.white, false, 0f, true);

            if (!IsDead)
            {
                MyAnimator.SetTrigger("damage");
                immortal = true;

                StartCoroutine(IndicateImmortal());
                yield return(new WaitForSeconds(immortalTime));

                immortal = false;
            }
            else
            {
                MyAnimator.SetLayerWeight(1, 0);
                MyAnimator.SetTrigger("die");
                CombatTextManager.Instance.CreateAnnounceText(new Vector3(Camera.main.gameObject.transform.position.x, Camera.main.gameObject.transform.position.y + 1f, 0), "You Died x_x" + "\n Respawning...", Color.cyan, true, 5f, true);

                GameManager.Instance.DeathCount++;
                GameManager.Instance.CollectedCoins -= 10;
                GameManager.Instance.KillCount      -= 10;
            }
            yield return(null);
        }
    }