Пример #1
0
 public void PlayStep()
 {
     if (IsGrounded())
     {
         AudioLibrary.Play(AudioName.Footstep);
     }
 }
Пример #2
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        enemy = animator.GetComponent <Enemy>();
        rb    = animator.GetComponent <Rigidbody2D>();

        float dir = enemy.facingRight ? 1 : -1;

        rb.AddForce(new Vector2(dir * AttackForce, 0));
        AudioLibrary.Play(AudioName.EnemySlash);
    }
Пример #3
0
 /// <summary>
 /// When damage is taken, actors flash red.
 /// All actors will recieve a knockback effect from the damage recieved
 /// </summary>
 /// <param name="damageVal">Amount of damage recieved</param>
 protected virtual void RegisterDamage(int damageVal)
 {
     AudioLibrary.Play(AudioName.ActorHit);
     if (!hasSpriteMesh)
     {
         StartCoroutine(FlashRed());
     }
     else
     {
         smc.FlashRed(hitTimePeriod);
     }
 }
Пример #4
0
    /// <summary>
    /// Enemies have a certain amount of health and will die when health reaches 0.
    /// Hope is also restored when enemy is hit in its vulnerable state.
    /// </summary>
    /// <param name="damageVal">Amount of Damage recieved</param>
    protected override void RegisterDamage(int damageVal)
    {
        base.RegisterDamage(damageVal);
        health -= damageVal;

        if (isVulnerable)
        {
            RaiseHope();
        }

        if (health <= 0)
        {
            AudioLibrary.Play(AudioName.EnemyDefeated);
            GameManager.s.RaiseKillCount();
            Destroy(gameObject);
        }
    }
Пример #5
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="collision"></param>
    private void OnTriggerEnter2D(Collider2D collision)
    {
        GameObject other = collision.gameObject;

        if (other.GetComponent <Enemy>() != null)
        {
            if (Mathf.Abs(rb.velocity.x) == 1)
            {
                if (HopeManager.GetInstance().state == HopeState.High)
                {
                    AudioLibrary.Play(AudioName.CrowdCheer);
                    Camera.main.gameObject.GetComponent <CameraMovement>().ZoomCamera();
                    HopeManager.GetInstance().Hope -= 1;
                }
            }
        }
    }
Пример #6
0
    private void RecieveDamage(GameObject other)
    {
        AnimatorStateInfo asi = other.GetComponent <Animator>().GetNextAnimatorStateInfo(0);

        if (asi.IsName("Attack") ||
            asi.IsName("Idle"))
        {
            RegisterDamage(5);
            HopeManager.GetInstance().Hope += -2;
            AudioLibrary.Play(AudioName.CrowdGasp);
        }
        else
        {
            RegisterDamage(5);
            HopeManager.GetInstance().Hope += -1;
        }
        Knockback(transform.position - other.transform.position);
    }
Пример #7
0
 protected override void OnTalk(AudioLibrary audioLibrary)
 {
     audioLibrary.Play("sweet-cat");
 }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeScale != 0)
        {
            horizontal = Input.GetAxis("Horizontal");
            vertical   = Input.GetAxis("Vertical");

            if (horizontal != 0)
            {
                Move();
            }
            else
            {
                anim.SetBool("isMoving", false);
            }


            if (Input.GetButtonDown("Jump"))
            {
                if (IsGrounded())
                {
                    jumpTime = Time.time;
                    anim.SetBool("jumpCharge", true);
                }
            }

            if (Input.GetButtonUp("Jump"))
            {
                if (IsGrounded())
                {
                    if (Time.time - jumpTime <= jumpTimeThreshold)
                    {
                        rb.AddForce(Vector2.up * jumpForce);
                        AudioLibrary.Play(AudioName.LowJump);
                    }
                    else
                    {
                        rb.AddForce(Vector2.up * jumpForce * longJumpMultiplier);
                        AudioLibrary.Play(AudioName.HighJump);
                    }
                    jumpTime = float.MaxValue;
                    anim.SetBool("jumpCharge", false);
                }
            }

            if (rangedAttackTime + rangedAttackCooldown < Time.time &&
                rangedAttackedRecently)
            {
                rangedAttackedRecently = false;
            }

            if (!anim.GetCurrentAnimatorStateInfo(1).IsName("Slash"))
            {
                if (Input.GetButtonDown("Slash"))
                {
                    Slash(1f);
                    rangedAttackedRecently = false;
                }


                if (Input.GetButtonDown("Slash2"))
                {
                    if (rangedAttackedRecently)
                    {
                        GameManager.s.PopUpRangedNotification();
                        AudioLibrary.Play(AudioName.CrowdBoo);
                        HopeManager.GetInstance().Hope -= 1;
                    }
                    rangedAttackedRecently = true;
                    rangedAttackTime       = Time.time;
                    Slash(slashSpeed);
                }
            }
        }
    }
Пример #9
0
    /// <summary>
    /// Fires a Slash from player based on speed and direction of movement.
    /// </summary>
    void Slash(float speed)
    {
        anim.SetTrigger("Slash");
        GameObject go    = Instantiate(Resources.Load <GameObject>("Prefabs/Slash"));
        Vector2    dir   = Vector2.right;
        Slash      slash = go.GetComponent <Slash>();

        if (speed == 1)
        {
            slash.slashType     = SlashType.Melee;
            go.transform.parent = tr;
        }
        else
        {
            slash.slashType = SlashType.Ranged;
        }
        go.transform.position = tr.position;

        if (horizontal == 0 && vertical == 0)
        {
            if (facingRight)
            {
                dir = Vector2.right;
            }
            else
            {
                dir = Vector2.left;
            }
        }
        else if (vertical != 0)
        {
            dir = new Vector2(0,
                              vertical / (vertical == 0 ? 1 : Mathf.Abs(vertical)));
        }
        else
        {
            dir = new Vector2(
                horizontal / (horizontal == 0 ? 1 : Mathf.Abs(horizontal)),
                0);
        }

        if (slash.slashType == SlashType.Ranged)
        {
            slash.damage = 1;
            AudioLibrary.Play(AudioName.PlayerSlash);
        }
        else
        {
            switch (HopeManager.GetInstance().state)
            {
            case HopeState.Low:
                slash.damage = 0;
                AudioLibrary.Play(AudioName.PlayerSlash);
                break;

            case HopeState.Normal:
                slash.damage = 5;
                AudioLibrary.Play(AudioName.PlayerSlash);
                break;

            case HopeState.High:
                slash.damage = 20;
                AudioLibrary.Play(AudioName.PlayerHighSlash);
                break;
            }
        }

        slash.SetRotationAndMove(dir * speed);
    }