private void Start() { weapons = GameObject.Find("God").GetComponent <AvailableWeapons>(); changeColor = Color.yellow; initialColor = Color.white; ReadyIcons = GameObject.FindGameObjectsWithTag("Ready"); }
protected void selectWeapon(AvailableWeapons weaponToSelect) { GameObject weapon = this.weaponStash.getWeapon(weaponToSelect, this.weaponSlot); this.currentWeapon = weapon.GetComponent <Weapon>(); this.currentWeapon.select(); }
// Use this for initialization void Awake() { id = GetComponentInParent <PlayerController>()._playerID; weapons = GameObject.Find("God").GetComponent <AvailableWeapons>(); weaponIndex = weapons.GetWeaponIndex(hand, id); currentWeaponObject = weapons.weapons[weaponIndex]; SwitchWeapon(); }
/// <summary> /// Called when the turn of this ball is over /// </summary> public virtual void OnTurnEnd() { AvailableWeapons.ForEach(w => w.OnTurnEnd()); if (Ball.AttachedRope != null) { Match.Physics.RemoveRope(Ball.AttachedRope); Ball.AttachedRope = null; Match.World.Ropes.Remove(Ball.AttachedRope); } }
private void Execute(EquipWeaponTurnAction equipWeapon) { if (!AvailableWeapons.Contains(equipWeapon.Weapon)) { return; } if (EquippedWeapon == equipWeapon.Weapon) { return; } myWeapon = (Weapon)equipWeapon.Weapon; }
public UserControl(Ballz game, Session match, Ball ball) : base(game, match, ball) { AvailableWeapons.Add(new Weapons.Potato(ball, game)); AvailableWeapons.Add(new Weapons.Grenade(ball, game)); AvailableWeapons.Add(new Weapons.RopeTool(ball, game)); AvailableWeapons.Add(new Weapons.Bazooka(ball, game)); AvailableWeapons.Add(new Weapons.Pistol(ball, game)); AvailableWeapons.Add(new Weapons.Waterbomb(ball, game)); AvailableWeapons.Add(new Weapons.Drill(ball, game)); Weapon = AvailableWeapons[SelectedWeaponIndex]; Ball.HoldingWeapon = AvailableWeapons[SelectedWeaponIndex].Icon; }
private void PickUpWeapon(Weapon weaponToPickUp) { var weapon = AvailableWeapons.SingleOrDefault(w => w.Name == weaponToPickUp.Name); if (weapon != null) { (weapon.Ammunition as Ammunition)?.Add(weaponToPickUp.Ammunition.Remaining); } else { myAvailableWeapons.Add(weaponToPickUp); } myWeapon = weaponToPickUp; Battlefield.Remove(weaponToPickUp); OnWeaponPicked(weaponToPickUp); }
public void DropItem(ItemType type, bool spawn_drop) { if (AvailableItems.Contains(type)) { int slot = AvailableItems.IndexOf(type); AvailableItems[slot] = ItemType.None; if (spawn_drop) { Pickup pick = type.Spawn(1f, NPCPlayer.Position + new Vector3(0, 0.5f, 0)); if (AvailableWeapons.ContainsKey(type)) { pick.durability = AvailableWeapons[type]; AvailableWeapons.Remove(type); } } } }
protected void switchWeapon() { AvailableWeapons newWeapon = AvailableWeapons.EnergyPulseGun; switch (currentWeapon.weaponType) { case AvailableWeapons.EnergyPulseGun: newWeapon = AvailableWeapons.Flashlight; break; case AvailableWeapons.Flashlight: newWeapon = AvailableWeapons.LaserGun; break; case AvailableWeapons.LaserGun: newWeapon = AvailableWeapons.EnergyPulseGun; break; } Destroy(currentWeapon.gameObject); selectWeapon(newWeapon); }
public GameObject getWeapon(AvailableWeapons weaponToFetch, Transform weaponSlot) { GameObject weapon = null; foreach (GameObject item in weaponList) { if (item.name.Contains(weaponToFetch.ToString())) { weapon = item; } } if (weapon == null) { throw new TypeLoadException("Weapon " + weaponToFetch.ToString() + " not found!"); } GameObject newWeapon = Instantiate(weapon, weaponSlot.position, weaponSlot.rotation) as GameObject; newWeapon.transform.parent = weaponSlot; return(newWeapon); }
public void TakeItem(ItemType item) { if (item == ItemType.None) { return; } if (FreeSlots > 0) { int free_slot = AvailableItems.IndexOf(ItemType.None); AvailableItems[free_slot] = item; if (item.IsWeapon()) { WeaponManager.Weapon[] weapons = NPCPlayer.ReferenceHub.weaponManager.weapons; for (int i = 0; i < weapons.Length; i++) { if (weapons[i].inventoryID == item) { AvailableWeapons.Add(item, (int)NPCPlayer.ReferenceHub.weaponManager.weapons[i].maxAmmo); break; } } } } }
/// <summary> /// Called when the turn of this ball is started /// </summary> public virtual void OnTurnStart() { CanSwitchWeapons = true; AvailableWeapons.ForEach(w => w.OnTurnStart()); ballMadeAction = false; }
public void TakeItem(Pickup item) { /* if (item.ItemId.IsAmmo()) * { * uint delta = 0; * uint limit; * switch (item.ItemId) * { * case ItemType.Ammo556: * limit = NPCPlayer.ReferenceHub.searchCoordinator.ConfigPipe.GetLimitAmmo((byte)AmmoType.Nato556); * NPCPlayer.Ammo[(int)AmmoType.Nato556] += (uint)item.durability; * if (NPCPlayer.Ammo[(int)AmmoType.Nato556] > limit) * { * delta = NPCPlayer.Ammo[(int)AmmoType.Nato556] - limit; * NPCPlayer.Ammo[(int)AmmoType.Nato556] = limit; * } * break; * * case ItemType.Ammo762: * limit = NPCPlayer.ReferenceHub.searchCoordinator.ConfigPipe.GetLimitAmmo((byte)AmmoType.Nato762); * NPCPlayer.Ammo[(int)AmmoType.Nato762] += (uint)item.durability; * if (NPCPlayer.Ammo[(int)AmmoType.Nato762] > limit) * { * delta = NPCPlayer.Ammo[(int)AmmoType.Nato762] - limit; * NPCPlayer.Ammo[(int)AmmoType.Nato762] = limit; * } * break; * * case ItemType.Ammo9mm: * limit = NPCPlayer.ReferenceHub.searchCoordinator.ConfigPipe.GetLimitAmmo((byte)AmmoType.Nato9); * NPCPlayer.Ammo[(int)AmmoType.Nato9] += (uint)item.durability; * if (NPCPlayer.Ammo[(int)AmmoType.Nato9] > limit) * { * delta = NPCPlayer.Ammo[(int)AmmoType.Nato9] - limit; * NPCPlayer.Ammo[(int)AmmoType.Nato9] = limit; * } * break; * } * if (delta > 0) * { * item.durability = delta; * } * else * { * item.Delete(); * } * } * else * {*/ if (FreeSlots > 0) // If there are free slots... { //Take it int free_slot = AvailableItems.IndexOf(ItemType.None); AvailableItems[free_slot] = item.itemId; if (item.itemId.IsWeapon()) { AvailableWeapons.Add(item.itemId, (int)item.durability); } item.Delete(); } else //Otherwise we are probably went there from smart target... { //Try drop old item and take new one if (CurrentAIItemGroupTarget == "keycard" && AvailableKeycards.Length != 0) { DropItem(AvailableKeycards[0], true); TakeItem(item); item.Delete(); } else if (CurrentAIItemGroupTarget == "weapon" && AvailableWeapons.Count != 0) { DropItem(AvailableWeapons.Keys.ElementAt(0), true); TakeItem(item); AvailableWeapons[item.itemId] = (int)item.durability; item.Delete(); } } // } }
public bool TryGet <T>(out T weapon) where T : Weapon { weapon = (T)AvailableWeapons.Where(w => w is T).SingleOrDefault(); return(weapon != null); }