示例#1
0
 public ReloadAmmoWhenEnabled(Actor self, ReloadAmmoWhenEnabledInfo info)
     : base(info)
 {
     this.info = info;
     pool      = self.TraitsImplementing <AmmoPool>().First(p => p.Info.Name == info.Name);
     delay     = info.ReloadDelay;
 }
示例#2
0
 protected override void Created(Actor self)
 {
     ammoPool       = self.TraitsImplementing <AmmoPool>().Single(ap => ap.Info.Name == Info.AmmoPool);
     modifiers      = self.TraitsImplementing <IReloadAmmoModifier>().ToArray();
     remainingTicks = Info.Delay;
     base.Created(self);
 }
示例#3
0
 public void ReturnAllBullets()
 {
     for (int i = 0; i < allBullets.Count; i++)
     {
         AmmoPool.Pull(allBullets[i].GetComponent <Bullet>());
     }
 }
示例#4
0
        void Reload(Actor self, AmmoPool ammoPool)
        {
            if (--ammoPool.RemainingTicks == 0)
            {
                // HACK to check if we are on the helipad/airfield/etc.
                var hostBuilding = self.World.ActorMap.GetActorsAt(self.Location)
                                   .FirstOrDefault(a => a.Info.HasTraitInfo <BuildingInfo>());

                if (hostBuilding == null || !hostBuilding.IsInWorld)
                {
                    return;
                }

                foreach (var host in hostBuilding.TraitsImplementing <INotifyRearm>())
                {
                    host.Rearming(hostBuilding, self);
                }

                ammoPool.RemainingTicks = ammoPool.Info.ReloadDelay;
                if (!string.IsNullOrEmpty(ammoPool.Info.RearmSound))
                {
                    Game.Sound.PlayToPlayer(SoundType.World, self.Owner, ammoPool.Info.RearmSound, self.CenterPosition);
                }

                ammoPool.GiveAmmo(self, ammoPool.Info.ReloadCount);
            }
        }
示例#5
0
    private IEnumerator ReturnIfNotCollidedWith()
    {
        yield return(new WaitForSeconds(lifeTime));

        AmmoPool.Pull(this);
        yield return(null);
    }
示例#6
0
        public WithReloadingSpriteTurret(Actor self, WithReloadingSpriteTurretInfo info)
            : base(self, info)
        {
            ammoPool = self.TraitsImplementing <AmmoPool>().FirstOrDefault(a => a.Info.Name == info.AmmoPoolName);
            if (ammoPool == null)
            {
                throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a valid ammo pool for its reloading turret.");
            }

            sequence     = Info.Sequence;
            reloadStages = info.ReloadStages;

            var initialAmmo      = ammoPool.Info.InitialAmmo;
            var ammo             = ammoPool.Info.Ammo;
            var initialAmmoStage = initialAmmo >= 0 && initialAmmo != ammo ? initialAmmo : ammo;

            if (ammoPool != null && reloadStages < 0)
            {
                ammoSuffix = initialAmmoStage.ToString();
            }
            if (ammoPool != null && reloadStages >= 0)
            {
                ammoSuffix = (initialAmmoStage * reloadStages / ammo).ToString();
            }
        }
示例#7
0
 public void FireProjectile()
 {
     if (clipSize > 0)
     {
         clipSize--;
         AmmoPool.Push(null, ammoPool.transform, shotPoint.position, Quaternion.identity);
     }
 }
示例#8
0
        protected override void Created(Actor self)
        {
            ammoPool = self.TraitsImplementing <AmmoPool>().FirstOrDefault(la => la.Info.Name == Info.AmmoPoolName);
            maxAmmo  = ammoPool.Info.Ammo;

            conditionManager = self.TraitOrDefault <ConditionManager>();
            base.Created(self);
        }
示例#9
0
 public static AmmoPool GetAmmoPool()
 {
     if (ammoPool = null)
     {
         ammoPool = Resources.Load("AmmoPool") as AmmoPool;
         ammoPool.Init();
     }
     return(ammoPool);
 }
示例#10
0
 public void SetupGun()
 {
     ammoPool    = AmmoPool.CreateAmmoPool(transform.GetComponent <GunObject>());
     gunName     = gunScriptableObj.gunName;
     bullet      = gunScriptableObj.bullet.GetComponent <Bullet>();
     description = gunScriptableObj.description;
     ammoCount   = gunScriptableObj.ammoCount;
     clipSize    = gunScriptableObj.clipSize;
     isAutomatic = gunScriptableObj.isAutomatic;
 }
示例#11
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
示例#12
0
        protected override void Created(Actor self)
        {
            ammoPool  = self.TraitsImplementing <AmmoPool>().Single(ap => ap.Info.Name == Info.AmmoPool);
            modifiers = self.TraitsImplementing <IReloadAmmoModifier>().ToArray();
            base.Created(self);

            self.World.AddFrameEndTask(w =>
            {
                remainingTicks = Util.ApplyPercentageModifiers(Info.Delay, modifiers.Select(m => m.GetReloadAmmoModifier()));
                remainingDelay = Info.DelayAfterReset;
            });
        }
示例#13
0
    public void SetValue()
    {
        //ammo pool
        the_Player_Manager = FindObjectOfType <PlayerManager>();
        the_Ammo_Pool      = FindObjectOfType <AmmoPool>();

        gun_current_Mag_Capacity = gun_Total_Mag_Capacity;
        //set up Weapon UI
        the_Player_UI_HUD = FindObjectOfType <PlayerUIHUD>();
        the_Player_UI_HUD.current_Weapon = this;
        the_Player_UI_HUD.AmmoUpdate(the_Player_Manager.current_Weapon);
        the_Player_UI_HUD.WeaponNameUpdate(the_Player_Manager.current_Weapon);
    }
示例#14
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.layer == 10) // layer 10 should be "Enemy"
        {
            collision.gameObject.GetComponent <TakeDamage>().DealDamage(bulletDamage);
        }

        if (collision.gameObject.tag != "Player")
        {
            AmmoPool.Pull(this);
        }

        Instantiate(feedbackObj, collision.contacts[0].point, Quaternion.identity, null);
    }
示例#15
0
    public static AmmoPool CreateAmmoPool(GunObject parentObj)
    {
        Transform poolObj = new GameObject($"({parentObj.gunName}) Ammo Pool").transform;
        AmmoPool  res     = poolObj.gameObject.AddComponent(typeof(AmmoPool)) as AmmoPool;

        for (int i = 0; i < parentObj.ammoCount; i++)
        {
            GameObject bullet = Instantiate(parentObj.gunScriptableObj.bullet, poolObj);
            bullet.AddComponent <AmmoTag>();
            res.GetComponent <AmmoPool>().allBullets.Add(bullet);
            bullet.SetActive(false);
        }


        return(res);
    }
示例#16
0
        void Reload(Actor self, Actor host, AmmoPool ammoPool)
        {
            if (--ammoPool.RemainingTicks <= 0)
            {
                foreach (var notify in host.TraitsImplementing <INotifyRearm>())
                {
                    notify.Rearming(host, self);
                }

                ammoPool.RemainingTicks = ammoPool.Info.ReloadDelay;
                if (!string.IsNullOrEmpty(ammoPool.Info.RearmSound))
                {
                    Game.Sound.PlayToPlayer(SoundType.World, self.Owner, ammoPool.Info.RearmSound, self.CenterPosition);
                }

                ammoPool.GiveAmmo(self, ammoPool.Info.ReloadCount);
            }
        }
示例#17
0
 //Set homeLodge when created
 void INotifyCreated.Created(Actor self)
 {
     ammoPool = self.TraitsImplementing <AmmoPool>().FirstOrDefault(la => la.Info.Name == "Food");
     maxAmmo  = ammoPool.Info.Ammo;
     whatAmmo = ammoPool.CurrentAmmo;
 }
 private void Start()
 {
     the_Ammo_Pool = FindObjectOfType <AmmoPool>();
     timer         = time_Before_Reset;
 }
示例#19
0
 private void Awake()
 {
     instance = this;
 }
示例#20
0
 protected override void Created(Actor self)
 {
     ammoPool = self.TraitsImplementing <AmmoPool>().FirstOrDefault(la => la.Info.Name == Info.AmmoPoolName);
 }
 // Use this for initialization
 void Start()
 {
     Instance = this;
     LoadInBlasterPool();
 }
示例#22
0
 void Awake()
 {
     Instance = this;
 }
	public bool RegisterAmmoPool(AmmoPool pool)
	{
		if (!AmmoPools.ContainsKey(pool.id))
		{
			AmmoPools.Add(pool.id, pool);
			return true;
		}
		return false;
	}
示例#24
0
 // Set homeLodge when created
 void INotifyCreated.Created(Actor self)
 {
     ammoPool = self.TraitsImplementing <AmmoPool>().FirstOrDefault(la => la.Info.Name == "Food");
     whatAmmo = ammoPool.GetAmmoCount();
 }