// Use this for initialization void Start() { isDashing = false; isDualWielding = false; maxDashDistance = 1.5f; dashSpeed = 20.0f; audio = GetComponent<AudioSource>(); weapons = new RangedWeapon[2]; current_weapon = (uint)WEAPON.DUAL_PISTOLS; switch_weapon_sound = Resources.Load("Sounds/Weapons/SwitchWeapon") as AudioClip; weapons[0] = new Pistol(audio, transform); weapons[0].timeBetweenShots = 0.45f; weapons[0].weaponDamage = 20; weapons[0].shotSound = Resources.Load("Sounds/Weapons/Pistol") as AudioClip; weapons[0].parent = this; /*weapons[1] = new RangedWeapon(audio); weapons[1].timeBetweenShots = 1.5f; weapons[1].weaponDamage = 30; weapons[1].shotSound = Resources.Load("Sounds/Weapons/Shotgun") as AudioClip;*/ //weapons[1].parent = this; weapons[1] = new RocketLauncher(audio, transform); weapons[1].timeBetweenShots = 1.5f; weapons[1].weaponDamage = 40; weapons[1].shotSound = Resources.Load("Sounds/Weapons/RocketShoot") as AudioClip; weapons[1].parent = this; }
public string AddGun(string type, string name, int bulletsCount) { if (!this._gunTypes.Contains(type)) { throw new ArgumentException(ExceptionMessages.InvalidGunType); } IGun currGun = null; switch (type) { case "Pistol": currGun = new Pistol(name, bulletsCount); break; case "Rifle": currGun = new Rifle(name, bulletsCount); break; } if (this._guns.Models.Any(g => g.Name == name)) { return(null); } this._guns.Add(currGun); return($"Successfully added gun {currGun.Name}."); }
public void SwapWorksCorrectly() { IWeapon freshWeapon = null; switch (this._savedWeapon.Category) { case Category.Light: freshWeapon = new Pistol(21, 500, 400); break; case Category.Medium: freshWeapon = new Minigun(21, 500, 500); break; case Category.Heavy: freshWeapon = new Cannon(21, 100, 80); break; default: break; } this._inventory.Add(freshWeapon); Assert.AreEqual(21, this._inventory.Capacity); var allWeapons = this._inventory.RetrieveAll(); int firstIndex = allWeapons.IndexOf(this._savedWeapon); int secondIndex = allWeapons.IndexOf(freshWeapon); this._inventory.Swap(this._savedWeapon, freshWeapon); allWeapons = this._inventory.RetrieveAll(); Assert.AreEqual(firstIndex, allWeapons.IndexOf(freshWeapon)); Assert.AreEqual(secondIndex, allWeapons.IndexOf(this._savedWeapon)); }
public string AddGun(string type, string name) { if (type != nameof(Pistol) && type != nameof(Rifle)) { return(OutputMessages.InvalidGun); } IGun gun = null; switch (type) { case "Rifle": gun = new Rifle(name); break; case "Pistol": gun = new Pistol(name); break; default: break; } this.gunRepository.Add(gun); return(string.Format(OutputMessages.SuccessfullAddedGun, gun.Name, gun.GetType().Name)); }
public string AddGun(string type, string name) { bool addSuccess = true; IGun gun = null; switch (type) { case "Pistol": gun = new Pistol(name); break; case "Rifle ": gun = new Rifle(name); break; default: addSuccess = false; break; } if (!addSuccess) { return("Invalid gun type"); } this.gunRepository.Add(gun); return($"Successfully added {name} of type: {type}."); }
public string AddGun(string type, string name, int bulletsCount) { IGun gun; if (type == "Pistol") { gun = new Pistol(name, bulletsCount); } else if (type == "Rifle") { gun = new Rifle(name, bulletsCount); } else { throw new ArgumentException(ExceptionMessages.InvalidGunType); } //REFLECTION: 2 errors tho /*Type gunType = Assembly.GetExecutingAssembly() * .GetTypes() * .FirstOrDefault(t => t.Name == type); * if (type == null) * { * throw new ArgumentException(ExceptionMessages.InvalidGunType); * } * var constructorParams = new object[2] { name, bulletsCount }; * * gun = (IGun)Activator.CreateInstance(gunType, constructorParams);*/ this.guns.Add(gun); return(String.Format(OutputMessages.SuccessfullyAddedGun, name)); }
public string AddGun(string type, string name) { IGun gun = null; string message = string.Empty; if (type != "Pistol" && type != "Rifle") { message = $"Invalid gun type!"; } else { if (type == "Pistol") { gun = new Pistol(name); } else if (type == "Rifle") { gun = new Rifle(name); } gunRepository.Add(gun); message = $"Successfully added {name} of type: {type}"; } return(message); }
private void Update() { RaycastHit hit; Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward); if (Physics.Raycast(ray, out hit, m_InteractDistance)) { Transform ObjectHit = hit.transform; if (ObjectHit.name.Contains("Barricade")) // Repair Barricade { Barricade Barricade = ObjectHit.GetComponent <Barricade>(); if (Barricade.Repairable()) { m_RepairText.text = "Press E To Repair Barricade"; if (Input.GetKeyDown(KeyCode.E)) { Barricade.StartRepair(); } } else { m_RepairText.text = null; } } if (ObjectHit.name.Contains("Weapon")) // Buy Weapon { if (ObjectHit.name.Contains("Pistol")) { BuyPistol BuyPistol = ObjectHit.GetComponent <BuyPistol>(); if (GetComponent <Pistol>() == null) { m_BuyText.text = "Press E To Buy Pistol $" + BuyPistol.m_GunCost; if (Input.GetKeyDown(KeyCode.E) && m_Points >= BuyPistol.m_GunCost) { m_Points -= BuyPistol.m_GunCost; gameObject.AddComponent <Pistol>(); } } else { m_BuyText.text = "Press E To Buy Pistol Ammo $" + BuyPistol.m_AmmoCost; if (Input.GetKeyDown(KeyCode.E) && m_Points >= BuyPistol.m_AmmoCost) { m_Points -= BuyPistol.m_AmmoCost; Pistol Pistol = GetComponent <Pistol>(); Pistol.m_Ammo = Pistol.m_MaxAmmo; Pistol.m_AmmoText.text = Pistol.m_Clip + "/" + Pistol.m_Ammo; } } } } Debug.DrawLine(ray.origin, hit.point, Color.blue); } else { m_RepairText.text = null; m_BuyText.text = null; } }
/// <inheritdoc /> public Weapon Convert(ItemDTO value, object state) { var entity = new Pistol(); this.Merge(entity, value, state); return(entity); }
public string AddGun(string type, string name) { IGun newGun; switch (type) { case "Pistol": newGun = new Pistol(name); break; case "Rifle": newGun = new Rifle(name); break; default: newGun = null; break; } if (newGun is null) { return("Invalid gun type!"); } else { this.gunsQueue.Enqueue(newGun); return($"Successfully added {name} of type: {type}"); } }
public override IEnumerable <AGameEvent> Do(AGameObject obj, List <AGameObject> newObjects, long time) { var res = new List <AGameEvent>(base.Do(obj, newObjects, time)); Bonuses.AGameBonus mirror = null; if (obj.Is(EnumObjectType.Player)) { var afflicted = obj as MainSkyShootService; //Ради проверки на наличие зеркала if (afflicted != null) { mirror = afflicted.GetBonus(EnumObjectType.Mirror); } } if (obj.Is(EnumObjectType.LivingObject) && (obj.HealthAmount >= Constants.POISON_BULLET_DAMAGE) && (mirror == null) && (obj.TeamIdentity != Owner.TeamIdentity) && !obj.Is(EnumObjectType.Turret)) { var wp = new Pistol(Guid.NewGuid()); //Просто для конструктора. Заглушка. var poison = new Poisoning(Constants.POISONING_TICK_TIMES, wp, obj) { ObjectType = EnumObjectType.Poisoning, }; //Время жизни--через здоровье newObjects.Add(poison); } //Отравление реализовано через создание моба. Он отправляется за край карты, и оттуда крадёт здоровье у своей жертвы. return(res); }
public string AddGun(string type, string name, int bulletsCount) { if (type == nameof(Pistol) || type == nameof(Rifle)) { IGun gun; if (type == nameof(Pistol)) { gun = new Pistol(name, bulletsCount); guns.Add(gun); } else { gun = new Rifle(name, bulletsCount); guns.Add(gun); } return(String.Format(OutputMessages.SuccessfullyAddedGun, name)); } else { throw new ArgumentException(String.Format(ExceptionMessages.InvalidGunType)); } }
public string AddGun(string type, string name) { string message = string.Empty; IGun gun = null; switch (type) { case "Pistol": gun = new Pistol(name); break; case "Rifle": gun = new Rifle(name); break; default: return("Invalid gun type!"); } this.gunRepository.Add(gun); message = $"Successfully added {name} of type: {type}"; return(message); }
public string AddGun(string type, string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Name cannot be null or a white space!"); } if (type != "Pistol" && type != "Rifle") { throw new ArgumentException("Invalid gun type!"); } else { if (type == "Pistol") { var gun = new Pistol(name); this.guns.Enqueue(gun); } else { var gun = new Rifle(name); this.guns.Enqueue(gun); } } return($"Successfully added {name} of type: {type}"); }
public string AddGun(string type, string name) { IGun gun = null; switch (type) { case "Pistol": gun = new Pistol(name); break; case "Rifle": gun = new Rifle(name); break; default: return(OutputMessages.InvalidGunType); } this.gunRepository.Add(gun); return(string.Format( OutputMessages.SuccessfullyAddedGun, name, type)); }
private void LevelComplete() { // Display GameOver screen with score based on ammo left int score = Pistol.GetAmmoCount() + Cannon.GetAmmoCount() * 5 + Shotgun.GetAmmoCount() / 5; timer.gameOver = true; gameOverText.text = "Good job!"; scoreText.text = "Score: " + score; }
// Start is called before the first frame update void Start() { pistol = GetComponentInChildren <Pistol>(); shotgun = GetComponentInChildren <Shotgun>(); rifle = GetComponentInChildren <AssaultRifle>(); ReloadStatus(); SelectWeapon(); }
// Start is called before the first frame update void Start() { Text = this.gameObject; handgun = GameObject.Find("M1911_R(Clone)"); pistol = handgun.GetComponent <Pistol>(); tama1 = pistol.Mag; tama2 = tama1.ToString(); Text.GetComponent <TextMesh>().text = tama2; }
private void OnTriggerEnter(Collider other) { Pistol Pistol = pistol.GetComponent <Pistol>(); if (other.CompareTag("Player") && isTriggerPickup && Pistol.currentPistolAmmo != Pistol.maxPistolAmmo) { TakeAmmo(); AudioSource.PlayClipAtPoint(pickup, transform.position, volume); } }
protected override void Awake() { base.Awake(); m_rgb2d = GetComponent <Rigidbody2D>(); Pistol weapon = new Pistol(this, "bulletPistol", BulletStartPosition); SetWeapon(weapon); }
public static void ResetGame() { Scoring.blocksLeft = 7; timer.Reset(); mode.currentMode = mode.savedMode; buildHeightCheck.buildHeightReached = false; Pistol.ResetAmmo(); Cannon.ResetAmmo(); Shotgun.ResetAmmo(); }
// Update is called once per frame void Update() { GameObject Pistol = GameObject.Find("PistolOff"); if (Pistol != null) { Pistol Shoot = GameObject.Find("PShooT").GetComponent <Pistol>(); Shoot.Holders = globalAmmo; } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { // get the weapons of the player, even if they are inactive Pistol pistol = player.GetComponentInChildren(typeof(Pistol), true) as Pistol; AssaultRifle rifle = player.GetComponentInChildren(typeof(AssaultRifle), true) as AssaultRifle; Shotgun shotgun = player.GetComponentInChildren(typeof(Shotgun), true) as Shotgun; if (ammoSprite == sprites[0]) { WeaponAmmo ammo = pistol.GetComponent <WeaponAmmo>(); if (ammo.currentReserveAmmo != ammo.maxReserveAmmo) { pickUpSound.Play(); ammo.currentReserveAmmo = ammo.currentReserveAmmo + (ammoMultiplier * ammo.maxMag); if (ammo.currentReserveAmmo > ammo.maxReserveAmmo) { ammo.currentReserveAmmo = ammo.maxReserveAmmo; } StartCoroutine(DeleteObject()); } } else if (ammoSprite == sprites[1]) { WeaponAmmo ammo = rifle.GetComponent <WeaponAmmo>(); if (ammo.currentReserveAmmo != ammo.maxReserveAmmo) { pickUpSound.Play(); ammo.currentReserveAmmo = ammo.currentReserveAmmo + (ammoMultiplier * ammo.maxMag); if (ammo.currentReserveAmmo > ammo.maxReserveAmmo) { ammo.currentReserveAmmo = ammo.maxReserveAmmo; } StartCoroutine(DeleteObject()); } } else if (ammoSprite == sprites[2]) { WeaponAmmo ammo = shotgun.GetComponent <WeaponAmmo>(); if (ammo.currentReserveAmmo != ammo.maxReserveAmmo) { pickUpSound.Play(); ammo.currentReserveAmmo = ammo.currentReserveAmmo + (ammoMultiplier * ammo.maxMag); if (ammo.currentReserveAmmo > ammo.maxReserveAmmo) { ammo.currentReserveAmmo = ammo.maxReserveAmmo; } StartCoroutine(DeleteObject()); } } } }
private void Update() { CheckFireInput(); CheckMovementInput(); if (Input.GetKeyDown(KeyCode.R)) { Rifle.Reload(); Pistol.Reload(); } }
IEnumerator WaitForStartRefill() { yield return new WaitWhile(()=>!pistol.GetComponent<Pistol>().isWork); pistol.SetActive(false); ChangeAZSSprite(true); shlang.SetActive(true); Pistol pistolComp = pistol.GetComponent<Pistol>(); pistol.transform.localPosition = pistolComp.spawnLocalPosition; pistolComp.isWork = false; StartCoroutine(MoneyTransform()); StartCoroutine(FillTheTank()); }
public int DamageEnemy(Pistol pistol) { m_health -= pistol.m_damage; //If enemy's health is less than 0 then destroy it if (m_health <= 0) { Destroy(gameObject); return(1); //returns +1 to score } return(0); }
void TakeAmmo() { Pistol Pistol = pistol.GetComponent <Pistol>(); Pistol.currentPistolAmmo += quantity; if (Pistol.currentPistolAmmo > Pistol.maxPistolAmmo) { Pistol.currentPistolAmmo = Pistol.maxPistolAmmo; } Pistol.SetUI(); Destroy(gameObject); }
private static IGun TryCreateGun(string type, string name, int bulletsCount, IGun gun) { if (type == "Pistol") { gun = new Pistol(name, bulletsCount); } else if (type == "Rifle") { gun = new Rifle(name, bulletsCount); } return(gun); }
static void Main(string[] args) { Console.WriteLine("This is Tyra Oberholzer's Quiz 07."); IFirearm s = new Shotgun(); s.doWhat("shotgun", "BOOM"); IFirearm r = new Rifle(); r.doWhat("rifle", "BANG"); IFirearm p = new Pistol(); p.doWhat("pistol", "POP"); }
static void Main(string[] args) { Console.WriteLine("Quiz 7"); IFirearm s = new Shotgun(); s.stuff("shotgun", "Boom"); IFirearm r = new Rifle(); r.stuff("rifle", "Bang"); IFirearm p = new Pistol(); p.stuff("Pistol", "Pop"); }
public void addGun(int gunType) { if (PlayerData.Instance.gunList.Contains(gunType) == false) { PlayerData.Instance.addGun(gunType); } switch (gunType) { case (int)GunPickup.GunType.Pistol: Pistol pistol = new Pistol(this, firePoint, hitEffects[0], gunSounds[0], GetComponent <LineRenderer>(), gunAnimControllers[0], ejected_shell, ejectPt, gunicons[0]); gunList.Add(pistol); break; case (int)GunPickup.GunType.RPG: RPG rpg = new RPG(this, firePoint, hitEffects[0], bulletObjs[1], gunSounds[1], gunAnimControllers[2], gunicons[2]); gunList.Add(rpg); break; case (int)GunPickup.GunType.Shotgun: Shotgun shotgun = new Shotgun(this, firePoint, hitEffects[0], gunSounds[1], bulletObjs[3], gunAnimControllers[1], gunicons[1]); gunList.Add(shotgun); break; case (int)GunPickup.GunType.DualPistols: DualPistols dualPistols = new DualPistols(this, firePoint, DPLeftFirePoint, hitEffects[0], gunSounds[0], GetComponent <LineRenderer>(), dualPistolsLeftFirePoint, gunAnimControllers[3], ejected_shell, ejectPt, gunicons[3]); gunList.Add(dualPistols); break; case (int)GunPickup.GunType.RailGun: RailGun railgun = new RailGun(this, firePoint, hitEffects[0], bulletObjs[4], gunSounds[4], gunAnimControllers[4], gunicons[4]); gunList.Add(railgun); break; case (int)GunPickup.GunType.TVGun: TVGun tvgun = new TVGun(this, firePoint, hitEffects[0], bulletObjs[2], gunSounds[0], gunAnimControllers[5], gunicons[5]); gunList.Add(tvgun); break; case (int)GunPickup.GunType.ColtPython: PythonGun pythonGun = new PythonGun(this, firePoint, hitEffects[0], bulletObjs[5], gunSounds[0], gunAnimControllers[6], gunicons[6]); gunList.Add(pythonGun); break; } if (gunHUDSlots != null) { SetPlayerCurrentGun(currentGun); } playSound(gunSounds[6]); }
public void addWeapon(Types type, int efficiencyPercentage) { switch (type) { case Types.Pistol: weapons[(int)type] = new Pistol(efficiencyPercentage); break; case Types.Shotgun: weapons[(int)type] = new Shotgun(efficiencyPercentage); break; case Types.RocketLauncher: weapons[(int)type] = new RocketLauncher(efficiencyPercentage); break; } }
// Use this for initialization public void Init () { weapons = new ArrayList (); Pistol pistol = new Pistol (); pistol.bulletType = bulletType; weapons.Add (pistol); Shotgun shotgun = new Shotgun (); shotgun.bulletType = bulletType; weapons.Add (shotgun); currentWeaponIndex = 0; ammo = new ArrayList (); ammo.Add (new Ammo (17, 34, 17)); ammo.Add (new Ammo (3, 9, 3)); updateAmmoLabel (); }
public void addWeapon(Types type, float[] characteristics) { switch (type) { case Types.Pistol: weapons[(int)type] = new Pistol(characteristics); GameObject.Find("__GUIDisplayer").GetComponent<GUIDisplayer>().pistolIndicator.enabled = true; break; case Types.Shotgun: weapons[(int)type] = new Shotgun(characteristics); GameObject.Find("__GUIDisplayer").GetComponent<GUIDisplayer>().shotgunIndicator.enabled = true; break; case Types.RocketLauncher: weapons[(int)type] = new RocketLauncher(characteristics); GameObject.Find("__GUIDisplayer").GetComponent<GUIDisplayer>().rocketLauncherIndicator.enabled = true; break; } changeSelectedWeapon(type); }