Esempio n. 1
0
    /// <summary>
    /// Moves player horizontally
    /// </summary>
    void Move()
    {
        Vector3 newPos = new Vector3(horizontal, 0);

        float finalSpeed = speed;

        if (HopeManager.GetInstance().state == HopeState.Low)
        {
            finalSpeed *= lowHopeSpeedMultiplier;
        }
        if (canMove)
        {
            transform.position += newPos * finalSpeed * Time.deltaTime;
        }

        if (facingRight && horizontal < 0)
        {
            facingRight = false;
            flipX(true);
        }
        else if (horizontal > 0)
        {
            facingRight = true;
            flipX(false);
        }

        anim.SetBool("isMoving", true);
    }
Esempio n. 2
0
    private void RaiseHope()
    {
        HopeManager.GetInstance().Hope += 1;

        GameObject go = Instantiate(upHope);

        go.transform.position = new Vector3(transform.position.x + (Random.value * 2), transform.position.y + (Random.value * 2),
                                            transform.position.z);
    }
Esempio n. 3
0
    public static HopeManager GetInstance()
    {
        material = Resources.Load <Material>("Greyscale");

        if (h == null)
        {
            h = new HopeManager();
        }
        return(h);
    }
Esempio n. 4
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;
                }
            }
        }
    }
Esempio n. 5
0
    // Start is called before the first frame update
    void Start()
    {
        if (s != null)
        {
            Destroy(gameObject);
        }
        else
        {
            s = this;
        }

        timer = GameObject.Find("Timer").GetComponent <Timer>();
        hm    = HopeManager.GetInstance();

        CountEnemies();

        StartCoroutine(AdjustHope());
    }
Esempio n. 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);
    }
Esempio n. 7
0
 private void Start()
 {
     Time.timeScale = 1;
     HopeManager.GetInstance().Hope = 5;
 }
Esempio n. 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);
                }
            }
        }
    }
Esempio n. 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);
    }