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; }
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); }
public void ReturnAllBullets() { for (int i = 0; i < allBullets.Count; i++) { AmmoPool.Pull(allBullets[i].GetComponent <Bullet>()); } }
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); } }
private IEnumerator ReturnIfNotCollidedWith() { yield return(new WaitForSeconds(lifeTime)); AmmoPool.Pull(this); yield return(null); }
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(); } }
public void FireProjectile() { if (clipSize > 0) { clipSize--; AmmoPool.Push(null, ammoPool.transform, shotPoint.position, Quaternion.identity); } }
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); }
public static AmmoPool GetAmmoPool() { if (ammoPool = null) { ammoPool = Resources.Load("AmmoPool") as AmmoPool; ammoPool.Init(); } return(ammoPool); }
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; }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
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; }); }
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); }
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); }
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); }
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); } }
//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; }
private void Awake() { instance = this; }
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(); }
void Awake() { Instance = this; }
public bool RegisterAmmoPool(AmmoPool pool) { if (!AmmoPools.ContainsKey(pool.id)) { AmmoPools.Add(pool.id, pool); return true; } return false; }
// Set homeLodge when created void INotifyCreated.Created(Actor self) { ammoPool = self.TraitsImplementing <AmmoPool>().FirstOrDefault(la => la.Info.Name == "Food"); whatAmmo = ammoPool.GetAmmoCount(); }