コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        MovePlayer();

        // Can't do anything dumb f**k
        if (isStunned)
        {
            return;
        }

        if (player.GetButtonDown("Spit") || player.GetAxis("Spit") > 0)
        {
            if (Time.time >= shootTimer)
            {
                anim.SetTrigger("Shoot");

                FindObjectOfType <AudioManager>().Play("Spit");

                var projectile = Instantiate(projectilePrefab, transform);

                projectile.GetComponent <SpitController>().shooter = gameObject;
                projectile.transform.parent     = null;
                projectile.transform.localScale = GlobalVariables.GlobalVariablesInstance.SHOOT_BASE_SCALE;

                var cooldown = 0.0f;
                if (infiniteShoot)
                {
                    cooldown = GlobalVariables.GlobalVariablesInstance.BULLET_TIME_REDUCED_COOLDOWN;
                }
                else
                {
                    cooldown = GlobalVariables.GlobalVariablesInstance.SHOOT_COOLDOWN_TIME;
                }
                shootTimer = Time.time + cooldown;
                recharge.PutOnCooldown(cooldown);
            }
        }

        if (player.GetButtonDown("BitchSlap") || player.GetAxis("BitchSlap") > 0)
        {
            if (Time.time >= stunCooldown)
            {
                anim.SetTrigger("Slap");
                StartCoroutine(WaitToStunOnSlap());
                StartCoroutine(WaitToFinishSlap());
                stunCooldown = Time.time + GlobalVariables.GlobalVariablesInstance.SLAP_COOLDOWN_TIME;
                FindObjectOfType <AudioManager>().Play("Attack");
            }
        }
    }