예제 #1
0
        private IEnumerator ReloadWeapon(Unit.UnitController unit)
        {
            BulletsQuantityUnit bulletsQuantity = unit.bulletsQuantity;
            ShootingCheck       shootingCheck   = unit.shootingCheck;
            Animator            animator        = unit.animator;

            //m_LinkManager.shootingController.StopAllCoroutines();

            shootingCheck.DisableShooting();
            shootingCheck.isShoot  = false;
            shootingCheck.isNoAmmo = true;
            shootingCheck.StopAllCoroutines();

            animator.SetTrigger("ReloadGun");

            m_AudioSource.PlayOneShot(m_SoundReload);

            yield return(new WaitForSeconds(bulletsQuantity.currentWeapon.ReloadTime));

            if (!bulletsQuantity.currentWeapon.InfinityBullets)
            {
                bulletsQuantity.allBulletsWeapon -= bulletsQuantity.defaultBulletsInClip;
            }

            m_AudioSource.Stop();

            bulletsQuantity.quantityBulletsInClip = bulletsQuantity.defaultBulletsInClip;

            SetUIWeaponParameters(unit);
            shootingCheck.isNoAmmo = false;
            shootingCheck.isShoot  = true;
        }
예제 #2
0
 private void SetUIWeaponParameters(Unit.UnitController unit)
 {
     if (!unit.isBot)
     {
         m_LinkManager.uiManager.SetQuantityBullets(unit.bulletsQuantity);
     }
 }
예제 #3
0
 private void PlayerDead(Unit.UnitController unit)
 {
     m_LinkManager.uiManager.DeadPanel(true);
     m_LinkManager.uiManager.DarkPanel(0.8f, true);
     m_LinkManager.uiManager.Interface(false);
     m_LinkManager.unitsHolder.DeleteUnitFromHolder(unit);
     m_LinkManager.mobileGrenadeController.isCanMove = false;
     ReturnUnits(unit);
 }
예제 #4
0
 public void UnitDead(Unit.UnitController unit, Unit.UnitController damagedUnit, DataWeapons weapon)
 {
     m_LinkManager.killListController.AddKillToList(unit, damagedUnit, weapon);
     if (!damagedUnit.isBot)
     {
         PlayerDead(damagedUnit);
     }
     else
     {
         BotDead(damagedUnit);
     }
 }
        public IEnumerator Respawn(Unit.UnitController unit, float timeRespawn)
        {
            yield return(new WaitForSeconds(timeRespawn));

            if (unit.isBot)
            {
                SpawnUnit(unit.pointForSpawn, unit);
            }
            else
            {
                SpawnUnit(unit.pointForSpawn, unit);
            }
        }
        private void NextWeapon(Unit.UnitController unit)
        {
            BulletsQuantityUnit bulletsQuantity = unit.bulletsQuantity;

            m_AudioSource.PlayOneShot(m_NextWeapon);
            bulletsQuantity.lastWeapon = bulletsQuantity.currentWeapon.IdWeapon;
            bulletsQuantity.nextWeapon = bulletsQuantity.currentWeapon.IdWeapon + 1;

            if (bulletsQuantity.nextWeapon >= m_DataWeapons.Length)
            {
                bulletsQuantity.nextWeapon = 0;
            }

            SetWeaponParameters(bulletsQuantity.nextWeapon, unit);
        }
예제 #7
0
        public void SetShootLogic(Unit.UnitController unit)
        {
            BulletsQuantityUnit bulletsQuantityUnit = unit.bulletsQuantity;
            var currentWeaponId = bulletsQuantityUnit.currentWeapon.IdWeapon;

            switch (unit.bulletsQuantity.currentWeapon.TypeShooting)
            {
            case DataWeapons.ChoiceTypeShooting.Automatic:
                m_ShotLogic = bulletsQuantityUnit.allWeaponUnit[currentWeaponId].GetComponent <AutoWeapon>();
                break;

            case DataWeapons.ChoiceTypeShooting.Shotgun:
                m_ShotLogic = bulletsQuantityUnit.allWeaponUnit[currentWeaponId].GetComponent <ShotgunWeapon>();
                break;
            }

            m_ShotLogic.shootingCheck = this;
        }
        public void SetWeaponParameters(int idWeapon, Unit.UnitController unit)
        {
            LinkManager         linkManager     = LinkManager.instance;
            DataWeapons         weapon          = m_DataWeapons[idWeapon];
            BulletsQuantityUnit bulletsQuantity = unit.bulletsQuantity;

            SetBullets(bulletsQuantity, weapon);
            unit.shootingCheck.SetShootLogic(unit);

            if (unit.isBot)
            {
                return;
            }

            SetUIWeaponParameters(linkManager, bulletsQuantity, weapon);
            bulletsQuantity.allWeaponUnit[bulletsQuantity.lastWeapon].SetActive(false);
            bulletsQuantity.allWeaponUnit[bulletsQuantity.currentWeapon.IdWeapon].SetActive(true);
        }
예제 #9
0
 public void StartShooting(Unit.UnitController unit)
 {
     if (!isNoAmmo)
     {
         if (canShooting == ModeCanShooting.Shooting)
         {
             m_ShotLogic.Shooting(unit);
             m_ShotLogic.TakeBulletFromPool(unit);
             m_ShotLogic.DelayForNextShot();
         }
     }
     else
     {
         if (canShooting == ModeCanShooting.NoAmmo)
         {
             StartCoroutine(m_ShotLogic.NoAmmo(unit));
             isShoot = false;
         }
     }
 }
예제 #10
0
        public void BulletsCount(Unit.UnitController unit)
        {
            BulletsQuantityUnit bulletsQuantity = unit.bulletsQuantity;

            if (bulletsQuantity.quantityBulletsInClip == 0)
            {
                return;
            }

            bulletsQuantity.quantityBulletsInClip--;

            if (bulletsQuantity.quantityBulletsInClip == 0 & bulletsQuantity.allBulletsWeapon != 0)
            {
                StartCoroutine(ReloadWeapon(unit));
            }

            if (bulletsQuantity.quantityBulletsInClip == 0 & bulletsQuantity.allBulletsWeapon == 0)
            {
                NoBullets(unit);
            }

            SetUIWeaponParameters(unit);
        }
예제 #11
0
 private void NoBullets(Unit.UnitController unit)
 {
     unit.shootingCheck.isNoAmmo = true;
     unit.shootingCheck.NoAmmo();
 }
예제 #12
0
 public void AddUnitInHolder(UnitController unit)
 {
     Units.Add(unit);
 }
예제 #13
0
        public void DeleteUnitFromHolder(UnitController unitDelete)
        {
            var find = Units.Find(unit => unit == unitDelete);

            Units.Remove(find);
        }
예제 #14
0
 private void BotDead(Unit.UnitController unit)
 {
     Respawn(unit);
     m_LinkManager.unitsHolder.DeleteUnitFromHolder(unit);
     ReturnUnits(unit);
 }
예제 #15
0
 private void Respawn(Unit.UnitController unit)
 {
     StartCoroutine(m_LinkManager.respawnController.Respawn(unit, m_DefalutTimeRespawn));
 }