Beispiel #1
0
 IEnumerator GunReloading()
 {
     if (PV.IsMine)
     {
         gunState = GunStateMachine.RELOADING;
         while (reloading.fillAmount < 1)
         {
             reloading.fillAmount += 0.1f;
             yield return(new WaitForSeconds(GunsSetup.GunsS.myGunInfo.reloadTime / 10f));
         }
         GunsSetup.GunsS.myGunInfo.bullets += GunsSetup.GunsS.myGunInfo.bulletsLeft;
         if (GunsSetup.GunsS.myGunInfo.bullets < GunsSetup.GunsS.myGunInfo.bulletsCapacity)
         {
             GunsSetup.GunsS.myGunInfo.bulletsLeft = GunsSetup.GunsS.myGunInfo.bullets;
             GunsSetup.GunsS.myGunInfo.bullets     = 0;
         }
         else
         {
             GunsSetup.GunsS.myGunInfo.bulletsLeft = GunsSetup.GunsS.myGunInfo.bulletsCapacity;
             GunsSetup.GunsS.myGunInfo.bullets    -= GunsSetup.GunsS.myGunInfo.bulletsCapacity;
         }
         reloading.fillAmount = 0;
         gunState             = GunStateMachine.IDLE;
         StopCoroutine("GunReloading");
     }
 }
Beispiel #2
0
 public void AssignGun()
 {
     if (PV.IsMine)
     {
         gunState = GunStateMachine.IDLE;
     }
 }
Beispiel #3
0
 protected override void Start()
 {
     base.Start();
     //Attached to same GameObject as Player script
     playerState = GetComponent <PlayerStateMachine>();
     gunState    = GetComponent <GunStateMachine>();
     viewCamera  = Camera.main;
 }
Beispiel #4
0
 void Start()
 {
     PV = GetComponent <PhotonView>();
     if (!PV.IsMine)
     {
         return;
     }
     healthDisplay    = GameSetup.GS.playerHealth;
     healthBarDisplay = GameSetup.GS.playerHealthBar;
     avatarSetup      = GetComponent <AvatarSetup>();
     gunState         = GunStateMachine.NONE;
     reloading        = GameSetup.GS.reloading;
     bulletsLeft      = GameSetup.GS.bulletsLeft;
     bullets          = GameSetup.GS.bullets;
 }
Beispiel #5
0
 IEnumerator GunStatement()
 {
     if (PV.IsMine)
     {
         gunState = GunStateMachine.SHOOTING;
         while (GunsSetup.GunsS.myGunInfo.bulletsLeft > 0 && ShopController.SC.isShopping == false)
         {
             if (Input.GetKeyDown(KeyCode.R))
             {
                 StartCoroutine("GunReloading");
                 StopCoroutine("GunStatement");
             }
             if (Input.GetMouseButton(0))
             {
                 PV.RPC("RPC_Shooting", RpcTarget.All, GunsSetup.GunsS.myGunInfo.damage);
                 GunsSetup.GunsS.myGunInfo.bulletsLeft--;
                 bulletsLeft.text = GunsSetup.GunsS.myGunInfo.bulletsLeft.ToString();
                 bullets.text     = "/" + GunsSetup.GunsS.myGunInfo.bullets.ToString();
                 GunsSetup.GunsS.myGun.GetComponent <Animation>().Play("Shoot");
                 yield return(new WaitForSeconds(GunsSetup.GunsS.myGunInfo.delay));
             }
             if (Input.GetMouseButtonUp(0))
             {
                 gunState = GunStateMachine.IDLE;
                 StopCoroutine("GunStatement");
                 yield return(null);
             }
             yield return(null);
         }
         if (ShopController.SC.isShopping == false)
         {
             StartCoroutine("GunReloading");
         }
         yield return(new WaitForSeconds(GunsSetup.GunsS.myGunInfo.reloadTime));
     }
 }