private void ComboSystem() { CurrentRagedWeapon = playerController.playerShooting.CurrentRagedWeapon; if (CurrentRagedWeapon.CurrentAmmo <= 0) { livelloCombo = 0; } //Debug.Log("Scalo" + tempoPerScalare); LivelloCombo.text = livelloCombo.ToString("F0"); if (livelloCombo > 0f) { tempoPerScalare -= Time.deltaTime; if (tempoPerScalare < 0f) { livelloCombo = livelloCombo - 1; tempoPerScalare = tempoRestart; if (livelloCombo <= 0f) { livelloCombo = 0; } } } }
public void TestNewWeapon() { RangedWeapon longBow = new RangedWeapon() { Name = "Longbow" }; longBow.WeaponDamages.Add(new Damage() { DefaultDamage = 4, QuantityOfDice = 1, SidesOfDice = 8, DamageType = "Piercing" }); Character talen = new Character(10, 17, 13, 15, 12, 8) { Alignment = "Neutral", Name = "Talen Il'Marin", ArmorClass = 15, Class = "Ranger: Horizon Walker", HitPoints = 39, CurrentHitPoints = 39, Race = "High Elf", ProficiencyBonus = 3, Speed = 30, ExperiencePoints = 6500 }; talen.Weapons.Add(longBow); Assert.AreEqual(1, talen.Weapons.Count); }
/// <summary> /// Updates weapon stats to reflect most recently selected weapon. /// </summary> private void DisplayWeaponStats( RangedWeapon rangedWeapon = null, MeleeWeapon meleeWeapon = null) { if (rangedWeapon == null && meleeWeapon == null) { return; } Weapon weapon = rangedWeapon != null ? (Weapon)rangedWeapon : (Weapon)meleeWeapon; weaponStatToText["DMG"].text = $"DMG: {weapon.dmg}"; weaponStatToText["PEN"].text = $"PEN: {weapon.ap}"; Text speedText = weaponStatToText["SPEED"]; if (weapon is RangedWeapon) { Text clipText = weaponStatToText["CLIP"]; clipText.gameObject.SetActive(true); clipText.text = $"CLIP: {rangedWeapon.clipSize}"; speedText.text = $"SPEED: {10 - (rangedWeapon.chargeTime * 10)}"; } else { weaponStatToText["CLIP"].gameObject.SetActive(false); speedText.gameObject.SetActive(true); speedText.text = $"SPEED: {5 - Math.Floor(meleeWeapon.cooldown / 0.25f)}"; } }
public override void AIShoot(RangedWeapon currentWeapon) { GameObject BulletInstance = Instantiate(currentWeapon.WeaponBulletPrefab, currentWeapon.GunBarrel.position, Quaternion.identity); BulletInstance.GetComponent <EnemyBullet>().Damage = currentWeapon.weaponData.Damage; BulletInstance.GetComponent <Rigidbody>().AddForce(transform.forward * currentWeapon.weaponData.ShootingForce, ForceMode.Impulse); }
public void PopulateWeaponWheel(RangedWeapon rw, int firingModeIndex) { selectorWeaponName.text = rw.name; selectorWeaponFiringMode.text = rw.firingModes[firingModeIndex].name; selectorWeaponRemainingAmmunition.text = AmmoInfo(rw, firingModeIndex); selectorWeaponImage.sprite = rw.weaponModel.GetComponent <SpriteRenderer>().sprite; // Substitute for finding object mesh if weapon has a 3D model }
void ChangeWeapon() { RangedWeapon otherWeapon; if (currentWeapon == primaryWeapon && baseWeapon != null) { otherWeapon = baseWeapon; anim.SetBool("Primary", false); } else if (currentWeapon == baseWeapon && primaryWeapon != null) { otherWeapon = primaryWeapon; anim.SetBool("Primary", true); } else { return; } //Deactivate current weapon currentWeapon.OnAmmoChanaged -= CurrentWeapon_AmmoChanged; currentWeapon.IsBeingUsed(false); currentWeapon = otherWeapon; //Activate new weapon currentWeapon.Reset(); currentWeapon.OnAmmoChanaged += CurrentWeapon_AmmoChanged; currentWeapon.IsBeingUsed(true); OnAmmoChanged?.Invoke(CurrentWeapon.Magazine); }
void Awake() { anim = GetComponent <Animator>(); col = GetComponent <Collider>(); rb = GetComponent <Rigidbody>(); //To drag in character and test easier if (Player == null) { Player = new Player(); SetupPlayer(Player); } //Subscribe to stat events stats.OnDeath += Stats_OnDeath; stats.OnStatChanged += Stats_OnStatChanged; //Equip base weapon if any if (baseWeapon != null) { baseWeapon.Equip(weaponParent); currentWeapon = baseWeapon; baseWeapon.OnAmmoChanaged += CurrentWeapon_AmmoChanged; OnAmmoChanged?.Invoke(baseWeapon.Magazine); } }
//TODO: Make one Equip method for each type of equippable /// <summary> /// Returns false if Weapon is null /// </summary> public bool EquipWeapon(Weapon weap) { if (weap == null) { return(false); } if (weap is RangedWeapon) { //Equip new weapon RangedWeapon rangedWeap = weap as RangedWeapon; anim.SetBool("Primary", true); currentWeapon?.IsBeingUsed(false); rangedWeap.Equip(weaponParent); if (PrimaryWeapon != null) { Destroy(PrimaryWeapon.gameObject); } currentWeapon = primaryWeapon = rangedWeap; primaryWeapon.OnAmmoChanaged += CurrentWeapon_AmmoChanged; OnAmmoChanged?.Invoke(primaryWeapon.Magazine); return(true); } return(false); }
public void UpdateAmmo(RangedWeapon weapon) { SetAmmoType(weapon.ammoType); foreach (AmmoIconObject obj in ammoObjects) { Destroy(obj.gameObject); } ammoObjects.Clear(); if (ammoType != WeaponClassType.Thrower) { for (int i = 0; i < weapon.ammunitionCount; i++) { AmmoIconObject temp = Instantiate(prefab, transform); temp.icon.sprite = currentIcon; ammoObjects.Add(temp); } } else if (ammoType == WeaponClassType.Thrower) { fuelDisplay.SetFuel(weapon); } }
private Weapon RandomWeapon() { int weaponType = r.Next(0, 4); Weapon weapon = null; switch (weaponType) { case 0: weapon = new MeleeWeapon(MeleeWeapon.Types.Dagger); break; case 1: weapon = new MeleeWeapon(MeleeWeapon.Types.LongSword); break; case 2: weapon = new RangedWeapon(RangedWeapon.Types.Longbow); break; case 3: weapon = new RangedWeapon(RangedWeapon.Types.Rifle); break; } return(weapon); }
/// <summary> /// Attempts use the current weapon to attack/fire /// </summary> /// <returns>bool: true, if the attempted attack was successful(bullets fired for ranged weapons)</returns> public bool Attack() { if (_weapon.Properties.weaponGroup == WeaponGroup.Main || _weapon.Properties.weaponGroup == WeaponGroup.Secondary) { RangedWeapon weapon = _weapon as RangedWeapon; if (weapon.CurrentAmmo == 0) { weapon.Attack(CurrentSpread, true); return(false); } else { weapon.Attack(CurrentSpread, false); _currentSpread += weapon.SpreadStep; if (OnWeaponAttack != null) { OnWeaponAttack.Invoke(); } return(true); } } else { MeleeWeapon weapon = _weapon as MeleeWeapon; weapon.Attack(); return(true); } }
void Awake() { gun = GetComponentInChildren <RangedWeapon>(); myHealth = GetComponentInParent <HumanHealth>(); HumanHealth.OnHumanDied += HumanHealth_OnHumanDied; PlayerPhysicalMovement.OnCollidedWithSomething += PlayerPhysicalMovement_OnCollidedWithSomething; }
void Update() { if (_weapon != null) { if (_weapon.Properties.weaponGroup == WeaponGroup.Main || _weapon.Properties.weaponGroup == WeaponGroup.Secondary) { RangedWeapon rangedWeapon = Weapon as RangedWeapon; if (_currentSpread < rangedWeapon.MinSpread) { _currentSpread = rangedWeapon.MinSpread; } else { _currentSpread = Mathf.Lerp(_currentSpread, rangedWeapon.MinSpread, Mathf.Abs(_currentSpread - rangedWeapon.MinSpread) * spreadDecrement * GameTime.deltaTime); } } else { _currentSpread = 0f; } } else { _currentSpread = 0f; } }
public Scene(Main game) { this.game = game; LiveEntities = new List <Entity>(); bullets = new List <Bullet>(); LoadScene(); camera = new Camera(game.GraphicsDevice.Viewport); testWeapon = new RangedWeapon(this, 0, 10, 5, 1, 5, game.textureHandler.rayGun, game.textureHandler.rayGun, game.textureHandler.basicBullet); //setup mask for the map mapMask = new Texture2D(game.GraphicsDevice, (int)map.GetMapDimensions().X, (int)map.GetMapDimensions().X); Color[] Data = new Color[mapMask.Width * mapMask.Height]; int[] depth = map.GetDepthMap(); for (int i = 0; i < map.GetDepthMap().Length; i++) { int x = i % (int)map.GetMapDimensions().X; int y = i / (int)map.GetMapDimensions().X; if (map.GetDepthMap()[i] == 1) { Data[(y * (int)map.GetMapDimensions().X) + x] = Color.White * 0.005f; } else { Data[(y * (int)map.GetMapDimensions().X) + x] = Color.Transparent; } } mapMask.SetData(0, null, Data, 0, Data.Length); }
void Awake() // Вообще говоря, безоружный человек должен пытаться убежать { myHealth = GetComponentInParent <HumanHealth>(); gun = GetComponentInChildren <RangedWeapon>(); HumanHealth.OnHumanDied += HumanHealth_OnHumanDied; Walker.OnWalkerDied += Walker_OnWalkerDied; }
void HumanGunReloader_OnStartedToReload(RangedWeapon e) { if (e == playersGun && ReloadLabel != null) // проверка на магию { ReloadLabel.text = "Reloading!"; } }
private void Awake() { RangedWeapon = Instantiate(prefab); RangedWeapon.transform.SetParent(rangedWeaponOrigin, false); enabled = false; }
public void loadWeaponData(unitScript u, bool ally) { var WeaponPanel = transform.FindChild(ally?"WeaponPanel":"EnemyWeaponPanel"); WeaponPanel.gameObject.SetActive(true); var weapon = u.getCurrentWeapon(); WeaponPanel.transform.Find("Weapon").GetComponent <Text>().text = weapon.name; WeaponPanel.transform.Find("Damage").GetComponent <Text>().text = weapon.damage.ToString(); var rangedPanel = WeaponPanel.transform.Find("Ranged"); switch (weapon.type) { case WeaponType.ranged: rangedPanel.gameObject.SetActive(true); RangedWeapon current = (RangedWeapon)weapon; rangedPanel.Find("ShortRange").GetComponent <Text>().text = current.minRange.ToString(); rangedPanel.Find("LongRange").GetComponent <Text>().text = current.maxRange.ToString(); break; default: rangedPanel.gameObject.SetActive(false); break; } }
string AmmoInfo(RangedWeapon rw, int firingModeIndex) { AmmunitionStats a = rw.GetAmmunitionStats(firingModeIndex); MagazineStats m = rw.GetMagazineStats(firingModeIndex); string s = ""; if (a == null) { if (m == null) { s = "INFINITE"; } else { s = m.magazine.current + "/INF"; } } else { if (m == null) { s = ph.a.GetStock(a.ammoType).ToString(); } else { s = m.magazine.current + "/" + (ph.a.GetStock(a.ammoType) - m.magazine.current); } } return(s); }
private bool SalvageWeaponForAmmo(RangedWeapon itemToSalvage) { bool salvagedSuccess = false; if (itemToSalvage != null) { salvagedSuccess = player.Ammunition.Add((itemToSalvage).AmmoClip.CurrentAmmoRaw); if (salvagedSuccess) { if (itemToSalvage == player.CurrentWeapon) { player.UpdatePlayerCurrentWeapon(null); } EventAggregator.GetInstance().Publish <OnPlayerAmmoChangedEvent>(new OnPlayerAmmoChangedEvent(player.playerNumber, player.Ammunition)); AudioManager.Play("SalvagedWeapon"); ItemFocused = false; player.InteractionPanel.RemoveInteractionPanel(); Debug.Log("InventoryHandler: " + itemToSalvage.GetType() + " weapon salvaged for ammo."); Destroy(itemToSalvage.gameObject); if (InventoryHUDFocused) { InventoryHUD.OnItemRemove(0); player.InteractionPanel.RemoveLoadBar(); } } else { Debug.Log("InventoryHandler: Cannot salvage weapon, Im already maxed out on ammo"); player.InteractionPanel.ShowRejectedLoadBar(); } } return(salvagedSuccess); }
public override void Shoot(RangedWeapon currentWeapon) { Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); if (Physics.Raycast(ray, out RaycastHit hit)) { ShootingTargetPoint = hit.point; } else { ShootingTargetPoint = ray.GetPoint(80); } Vector3 ShootingDirection = ShootingTargetPoint - currentWeapon.GunBarrel.position; GameObject BulletInstance = Instantiate(currentWeapon.WeaponBulletPrefab, currentWeapon.GunBarrel.position, Quaternion.identity); BulletInstance.transform.forward = ShootingDirection.normalized; anim.SetBool("Sparo", true); BulletInstance.GetComponent <Rigidbody>().AddForce(ShootingDirection.normalized * currentWeapon.weaponData.ShootingForce, ForceMode.Impulse); //Audio Luca AudioManager.instance.Play(Suono); //Shake Luca FindObjectOfType <CameraShake>().StartShake(testProperties); }
void PlayerShooting_OnPickedUpGun(RangedWeapon e) { if (GetComponentInParent <PlayerShooting>() != null) { gun = e; } }
IEnumerator SwitchWeapon(int index) { isSwitching = true; index = Mathf.Clamp(index, 0, equippedWeapons.Length - 1); for (int i = 0; i < equippedWeapons.Length; i++) { RangedWeapon rw = equippedWeapons[i]; if (equippedWeapons[i].gameObject.activeSelf == true) { StartCoroutine(rw.Holster()); print(rw.name + " has been holstered."); } } yield return(new WaitUntil(() => AllOtherWeaponsHolstered())); StartCoroutine(equippedWeapons[index].Draw()); print(equippedWeapons[index].name + " has been drawn."); currentWeaponIndex = index; yield return(new WaitUntil(() => equippedWeapons[index].isSwitchingWeapon == false)); isSwitching = false; }
/// <summary> /// Generation function designed to build specifically a ranged weapon. /// </summary> /// <param name="seed">Seed to use for generation, useful for testing. Set this to system time during playtime.</param> /// <param name="quality">Quality modifier for items. Essentially represents how deep in the dungeon the player is. Pass this from the map class ideally.</param> /// <param name="rarity">Minimum item rarity, defaults to common. Higher rarity items have better stats implicitly.</param> /// <returns>A ranged weapon with pre-set name and description.</returns> public static RangedWeapon GenerateRangedWeapon(int seed, int quality, double damage, double range, double rof, int rareVal, bool useSeed = true) { // Note we are using the system's random, and not Unity's in order to use a seed. Random random = GetRandom(seed, useSeed); // Get Penetration Value (how many enemies an attack can pierce before self deleting); higher rarities increase this value. int[] penMin = { 1, 1, 2, 2, 3 }; int[] penMax = { 2, 3, 4, 5, 6 }; int penetration = random.Next(penMin[rareVal], penMax[rareVal] + 1); // Now assemble and do the other important steps. RangedWeapon newItem = new RangedWeapon(penetration) { Rarity = (GameItem.ItemRarity)rareVal, Damage = (float)damage, ROF = rof, AttackRange = range }; // Generate a name. newItem.Name = GenerateWeaponName(seed, newItem, useSeed); // Generate a description. newItem.Description = GenerateWeaponDesc(seed, newItem, useSeed); // Pick a value rating. (Should probably be another utility method). newItem.Value = GenerateItemValue(newItem); // Generate a unique ID (this might require some internal memory somewhere to keep track of what IDs have already been assigned, probably another utility function). newItem.ItemID = GenerateItemID(); // Return the finished item. return(newItem); }
private void Start() { //MVC linking model = GetComponent <EnemyModel>(); view = GetComponent <EnemyView>(); if (model.isBoss) { bossHealthScript = GameObject.Find("HealthBarStorage").GetComponent <BossHealthUI>(); } //Setup melee if (model.meleeEnabled == true) { melee = gameObject.GetComponent <MeleeWeapon>(); melee.AttackDamage = model.meleeAttackDamage; melee.attackRange = model.meleeAttackRange; } //Setup ranged if (model.rangedEnabled == true) { ranged = gameObject.GetComponent <RangedWeapon>(); ranged.damage = model.rangedAttackDamage; ranged.speed = model.rangedAttackProjectileSpeed; } //Increase the enemy counter GameObject.Find("CounterCanvas").GetComponentInChildren <EnemyCounter>().increaseCount(); }
public Dictionary <Position, List <List <Position> > > GetShotOptions(Position Shooter) { Unit unit = GetUnitAtPos(Shooter); Dictionary <Position, List <List <Position> > > ShotOptions = new Dictionary <Position, List <List <Position> > >(); RangedWeapon rangedWeapon = unit.GetRangedWeapon(); if (rangedWeapon != null) //should always be true. because game should only forward requests of units with a ranged weapon { for (int i = 0; i < Rows; i++) { for (int j = 0; j < Columns; j++) { Square square = board[i][j]; if (square.Unit != Config.NullUnit && square.Unit.Player != unit.Player) { Position pos = new Position(i, j); List <List <Position> > ShotDetails = GetShotPathDetails(Shooter, pos); if (ShotDetails[2].Count == 0 && rangedWeapon.Range >= Shooter.Distance(pos) - Utils.epsilon) { ShotOptions[pos] = ShotDetails; } } } } return(ShotOptions); } throw new ArgumentException(); }
public void OnUpgradeButtonPressed(string weaponName, UpgradeRow row) { RangedWeapon weapon = WeaponManager.Instance.GetWeapon(weaponName); if (Player.Instance.Coins >= weapon.stats.currentUpgradeCost && weapon != null) { weapon.Upgrade(); row.SetText(weapon.stats.name, weapon.stats.currentUpgradeCost, weapon.stats.upgradeLevel); } else if (weapon == null) { Debug.LogWarning("Weapon: " + name + " can not be found"); } else { Sequence sequence = DOTween.Sequence() .Append(notEnoughCoinsText.DOFade(1, 0.5f)) .AppendInterval(1f) .Append(notEnoughCoinsText.DOFade(0, 0.5f)); } if (weapon.stats.upgradeLevel == MaxUpgradeLevel) { row.OnUpgradeLimitReached(); } }
public void TestRangedWeaponAttack() { RangedWeapon longBow = new RangedWeapon() { Name = "Longbow" , WeaponType = "Martial Ranged", AmmunitionType = "Arrow", CloseRange = 150, MaxRange = 600, Cost = new CoinPurse() { Gold = 50 }, Weight = 2, Properties = new [] { "heavy", "two-handed" } }; longBow.WeaponDamages.Add(new Damage() { DefaultDamage = 4, QuantityOfDice = 2, SidesOfDice = 8, DamageType = "piercing" }); Ammunition basicArrows = new Ammunition() { AmmunitionType = "Arrow", Name = "Basic Arrows", Quantity = 20 }; DamageRealized attack = longBow.WeaponHit(ref basicArrows); Console.WriteLine(attack.DamageDescription); Assert.AreEqual(19, basicArrows.Quantity); }
void HumanGunReloader_OnReloaded(RangedWeapon e) { if (e == playersGun && ReloadLabel != null) { ReloadLabel.text = ""; } }
// Putting weapon to the weapon slot private IEnumerator SetWeapon(float waitingTimer) { currentRangedWeapon = null; currentMeleeWeapon = null; if (currentWeaponInstance.GetType() == typeof(RangedWeapon)) { currentRangedWeapon = (RangedWeapon)currentWeaponInstance; } else if (currentWeaponInstance.GetType() == typeof(MeleeWeapon)) { aimScript.solver.IKPositionWeight = 0; currentMeleeWeapon = (MeleeWeapon)currentWeaponInstance; } aimScript.solver.transform = weaponSlot.transform.GetChild(currentWeaponNumber).GetChild(0).transform; currentWeaponObject = currentWeaponInstance.weaponType; // Put into the hand the next weapon model SetWeaponConditionForAnimator(currentWeaponNumber); animator.SetBool("EquipWeapon", true); Invoke("PickUpWeapon", currentWeaponInstance.equipRate / 4); // Waiting, when animation of picking up new weapon will be finished yield return(new WaitForSeconds(waitingTimer)); animator.SetBool("EquipWeapon", false); this.isChangingWeapon = false; }
/// <summary> /// Equips the weapon of 'name' by getting it from WeaponManager /// </summary> /// <param name="name">The weapon to equip</param> public void EquipWeapon(string name) { RangedWeapon weapon = WeaponManager.Instance.GetWeapon(name); if (weapon != null) { GameObject currentWeapon = null; if (hand.transform.childCount > 0) { currentWeapon = hand.GetChild(0).gameObject; } if (currentWeapon != null) { currentWeapon.transform.SetParent(WeaponManager.Instance.transform, false); currentWeapon.SetActive(false); } weapon.gameObject.SetActive(true); weapon.transform.SetParent(hand, false); GetComponent <PlayerMovementController>().weapon = weapon.transform; weapon.CallAmmoEvent(); } else { Debug.LogWarning("Weapon: " + name + " can not be found");// } }
private void Initialize() { this.currentWeapon = new Pistol(); this.bulletFactory = new BulletFactory(); }
void GeneratePartyMember(string memberName) { MapRegion startingRegion = MapManager.main.GetTown(); var classtypes=System.Enum.GetValues(typeof(MercClass)); myClass = (MercClass)classtypes.GetValue(Random.Range(0,classtypes.Length)); combatDeck = GenerateClassCombatDeck(myClass); classPrepCards = GenerateClassPrepCards(myClass); weaponPrepCards = GenerateDefaultWeaponPrepCards(); SetClassStats(myClass); //Pick color out of ones left //worldCoords=startingCoords; currentRegion=startingRegion; startingRegion.localPartyMembers.Add(this); color = GetPortraitColor(); //Randomly pick out a specialty List<Trait> possibleSpecialtyPerks=Trait.GenerateRandomSkillTree(5); //Pick out a starting specialty perk Skill startingLearnedSkill=possibleSpecialtyPerks[Random.Range(0,possibleSpecialtyPerks.Count)] as Skill; startingLearnedSkill.learned=true; traits.Add(startingLearnedSkill); //Fill out trait list List<Trait> possibleGenericPerks=Trait.GetTraitList(); //Deactivate the opposite traits of the starting perk foreach(Trait genericPerk in possibleGenericPerks) { if (genericPerk.GetType()==startingLearnedSkill.oppositePerk) { if (possibleGenericPerks.Contains(genericPerk)) possibleGenericPerks.Remove(genericPerk); break; } } //Randomly pick out generic perks int necessaryPerkCount=2; int addedPerksCount=0; while (addedPerksCount<necessaryPerkCount && possibleGenericPerks.Count>0) { Trait newPerk=possibleGenericPerks[Random.Range(0,possibleGenericPerks.Count)]; traits.Add(newPerk); addedPerksCount++; possibleGenericPerks.Remove(newPerk); if (newPerk.oppositePerk!=null) { foreach (Trait possibleGenericPerk in possibleGenericPerks) { if (possibleGenericPerk.GetType()==newPerk.oppositePerk) { if (possibleGenericPerks.Contains(possibleGenericPerk)) possibleGenericPerks.Remove(possibleGenericPerk); break; } } foreach (Trait possibleSpecialtyPerk in possibleSpecialtyPerks) { if (possibleSpecialtyPerk.GetType()==newPerk.oppositePerk) { if (possibleSpecialtyPerks.Contains(possibleSpecialtyPerk)) possibleSpecialtyPerks.Remove(possibleSpecialtyPerk); break; } } } } name=memberName; baseMaxStamina=10; armorValue=0; maxCarryCapacity=4;// hasLight=false; isCook=false; isMedic=false; isLockExpert=false; isScout=false; foreach (Trait myPerk in traits) { if (myPerk.GetType().BaseType==typeof(Trait)) myPerk.ActivateEffect(this); else { Skill mySkill=myPerk as Skill; if (mySkill.learned) mySkill.ActivateEffect(this); } } //make sure perks trigger before these to properly use modified values of maxHealth and maxStamina health = healthMax; currentMaxStamina=baseMaxStamina; UpdateCurrentCarryCapacity(); equippedRangedWeapon=null; }
public void armRanged(RangedWeapon toArm) { ranged = toArm; }