Exemple #1
0
 void Update()
 {
     preGun     = currentGun;
     currentGun = gun.GetComponentInChildren <PlayerTopDownShooting>();
     if (preGun != currentGun)
     {
         disableAll();
         if (currentGun)
         {
             //Debug.Log("havetop");
             if (gun.transform.GetChild(0).gameObject.name == "Tay Không")
             {
                 //                    Debug.Log("tk");
                 handLeft.enabled  = true;
                 handRight.enabled = true;
             }
             else
             {
                 //                    Debug.Log("cogun");
                 if (gun.GetComponentInChildren <PlayerTopDownShooting>().holdOneHandTrueTwoHandFalse)
                 {
                     //                        Debug.Log("oh");
                     OneHand.enabled = true;
                 }
                 else
                 {
                     //                        Debug.Log("full");
                     twoHandRight.enabled = true;
                     TwoHandLeft.enabled  = true;
                 }
             }
         }
     }
 }
    void Update()
    {
        if (StillAlive)
        {
            if (Player != null)
            {
                //string OnlyName = Player.gameObject.name;
                gunName.text = Player.gameObject.name.Replace("(Clone)", "");
                gunAmmo.text = Player.currentammo.ToString() + "/" + Player.currentBulletInMagazine.ToString();
                if (Player.ChuotPhaiCoTacDung)
                {
                    if (Player.chuotphaiChuyenModeTrueHayScopeFalse)
                    {
                        Scope.enabled = false;
                        Burst.enabled = true;
                        if (Player.Burst)
                        {
                            Burst.transform.localScale = new Vector3(1, 1, 1);
                        }
                        else
                        {
                            Burst.transform.localScale = new Vector3(.75f, .75f, .75f);
                        }
                    }
                    else
                    {
                        Scope.enabled = true;
                        Burst.enabled = false;
                        if (Camera.scope)
                        {
                            Scope.transform.localScale = new Vector3(1, 1, 1);
                        }
                        else
                        {
                            Scope.transform.localScale = new Vector3(.75f, .75f, .75f);
                        }
                    }
                }
                else
                {
                    Scope.enabled = false;
                    Burst.enabled = false;
                }
                if (Player.napDanTungVienHayCaBang)
                {
                    updateImage(Player.sound);

                    if (Player.isreloadingShotgun)
                    {
                        currentReloadingTime      += Time.deltaTime;
                        currentAmmoType.fillAmount = currentReloadingTime / Player.reloadTime;
                        if (currentReloadingTime > Player.reloadTime)
                        {
                            currentReloadingTime = 0;
                        }
                    }
                    else
                    {
                        currentReloadingTime       = 0;
                        currentAmmoType.fillAmount = (float)Player.currentammo / (float)Player.maxammo;
                    }
                }
                else
                {
                    updateImage(Player.sound);
                    if (Player.isreloading)
                    {
                        currentReloadingTime      += Time.deltaTime;
                        currentAmmoType.fillAmount = currentReloadingTime / Player.reloadTime;
                        //Debug.Log(currentReloadingTime + "/" + Player.reloadTime + "=" + currentReloadingTime / Player.reloadTime);
                    }
                    else
                    {
                        currentReloadingTime       = 0;
                        currentAmmoType.fillAmount = (Player.currentammo * 1.0f) / (Player.maxammo * 1.0f);
                    }
                }
            }
            else
            {
                GameObject Character = GameObject.FindGameObjectWithTag("Player");
                if (Character != null)
                {
                    Player = Character.GetComponentInChildren <PlayerTopDownShooting>();
                }
                else
                {
                    StillAlive = false;
                }
            }
        }
    }