예제 #1
0
    public void Jump()
    {
        //Jump for mobile input
        if (extraJumpsLeft > 0 || extraJumpsLeft <= 0 && isGrounded)
        {
            rb.velocity = new Vector2(rb.velocity.x, jumpSpeed);
            extraJumpsLeft--;
            anim.SetBool("jumped", true);
            //jump = false;
        }



        //jump using keyboard
        rb.velocity = new Vector2(rb.velocity.x, jumpSpeed);
        extraJumpsLeft--;
        audioManager.Play("jump grunt");
        anim.SetBool("jumped", true);
        jump = false;
        //anim.SetBool("isStomping", false);



        StartCoroutine(ToggleStompPermission());
        //anim.SetBool("isGrounded", true);
    }
예제 #2
0
 public void StartDialogue(Dialogue_game dialogue)
 {
     animator.SetBool("isopen", true);
     nameText.text = dialogue.name;
     sentences.Clear();
     Audio_manager.Play(0);
     foreach (string sentence in dialogue.sentences)
     {
         sentences.Enqueue(sentence);
     }
     DisplayNextSentence();
 }
예제 #3
0
 void OnEnable()
 {
     if (HaveSound)
     {
         audiomanager.Play(Sound);
     }
     if (haveLight)
     {
         StartCoroutine(Flash());
     }
     if (IsStunEnemy)
     {
         Collider2D[] ThingsGotDamage = Physics2D.OverlapCircleAll(transform.position, flashRange, whoGetFlashed);
         for (int i = 0; i < ThingsGotDamage.Length; i++)
         {
             if (ThingsGotDamage[i].GetComponent <EnemyAttack>())
             {
                 ThingsGotDamage[i].GetComponent <EnemyAttack>().GotKnocked(0, stunTime);
             }
         }
     }
 }
예제 #4
0
 public void KillEnemy()
 {
     audiomanager.Play("enemy kill");
     Destroy(gameObject);
 }
예제 #5
0
 void Update()
 {
     if (CanControl)
     {
         if (Time.timeScale > 0)
         {
             SpreadIndicator();
             if (ShotgunCanReloading && currentammo < maxammo && currentBulletInMagazine > 0 && haveJustShot == false && napDanTungVienHayCaBang)
             {
                 ShotgunCanReloading = false;
                 StartCoroutine(ReloadTungVien1());
                 return;
             }
             if (isreloading == true && currentammo == maxammo)
             {
                 isreloading = false;
                 StopCoroutine(Reload());
             }
             if (isreloading == true)
             {
                 return;
             }
             if (fireTime < 0)
             {
                 fireTime = 0;
             }
             if (fireTime > timeTillMaxSpreadAngle)
             {
                 fireTime = timeTillMaxSpreadAngle;
             }
             transform.position = transform.parent.parent.Find("Guns").position;
             transform.rotation = transform.parent.parent.Find("Guns").rotation;
             if (Input.GetButtonDown("Fire2" + index.ToString()) && ChuotPhaiCoTacDung)
             {
                 if (chuotphaiChuyenModeTrueHayScopeFalse)
                 {
                     Burst = !Burst;
                     audiomanager.Play(BurstSound);
                 }
                 else
                 {
                     cam.GetComponent <CameraController>().scope = !cam.GetComponent <CameraController>().scope;
                     audiomanager.Play(scopeSound);
                 }
             }
             if ((currentammo <= 0 && Input.GetButton("Fire1" + index.ToString())) || (Input.GetKeyDown(KeyCode.R) && currentammo < maxammo) && currentBulletInMagazine > 0)
             {
                 if (!isreloadingShotgun)
                 {
                     haveJustShot        = false;
                     ShotgunCanReloading = true;
                 }
                 StartCoroutine(Reload());
                 return;
             }
             if (AutoTrueHayOnetapFalse)
             {
                 if (Burst)
                 {
                     if (Input.GetButton("Fire1" + index.ToString()))
                     {
                         fireTime += Time.deltaTime;
                         if (Time.time >= nexttimetofire)
                         {
                             nexttimetofire = Time.time + 1 / burstFireRate;
                             StartCoroutine(BurstShoot());
                         }
                     }
                     else
                     {
                         fireTime -= Time.deltaTime * coolDownMultiplier;
                     }
                 }
                 else
                 {
                     if (Input.GetButton("Fire1" + index.ToString()))
                     {
                         fireTime += Time.deltaTime;
                         if (Time.time >= nexttimetofire)
                         {
                             nexttimetofire = Time.time + 1 / firerate;
                             Shoot();
                         }
                     }
                     else
                     {
                         fireTime -= Time.deltaTime * coolDownMultiplier;
                     }
                 }
             }
             else
             {
                 if (Burst)
                 {
                     if (Input.GetButtonDown("Fire1" + index.ToString()))
                     {
                         fireTime += Time.deltaTime;
                         if (Time.time >= nexttimetofire)
                         {
                             nexttimetofire = Time.time + 1 / burstFireRate;
                             StartCoroutine(BurstShoot());
                         }
                     }
                     else
                     {
                         fireTime -= Time.deltaTime * coolDownMultiplier;
                     }
                 }
                 else
                 {
                     if (Input.GetButtonDown("Fire1" + index.ToString()))
                     {
                         fireTime += Time.deltaTime;
                         if (Time.time >= nexttimetofire)
                         {
                             nexttimetofire = Time.time + 1 / firerate;
                             Shoot();
                         }
                     }
                     else
                     {
                         fireTime -= Time.deltaTime * coolDownMultiplier;
                     }
                 }
             }
         }
     }
 }
예제 #6
0
 private void gameover2()
 {
     audiomng.Play("win");
     gameover.SetActive(true);
 }
예제 #7
0
 void soundPlay()
 {
     audiomanager.Play(shotSound);
 }