private DamageResult ResolveWeaponAttack(WeaponSystem weapon, int range, ScreenRating screenRating, int evasion = 0, int otherDRM = 0, Constants.DamageType damageTypeModifier = Constants.DamageType.None, AttackSpecialProperties attackPropertiesModifier = AttackSpecialProperties.None) { AttackSpecialProperties effectiveAttackProperties = weapon.FinalizeAttackProperties(attackPropertiesModifier); // Weapons with a hight TrackRating can ignore Evasion, offsetting up to the full Evasion DRM int totalDRM = weapon.FinalizeEvasionDRM(evasion) + otherDRM; // Weapons can ignore certain kinds of shields but not others int totalScreenRating = weapon.FinalizeScreenValue(screenRating, effectiveAttackProperties); Constants.DamageType effectiveDamageType = weapon.FinalizeDamageType(weapon.GetDamageType(), damageTypeModifier, effectiveAttackProperties.HasFlag(AttackSpecialProperties.Overrides_Weapon_DamageType)); // Roll dice here this.Logger.LogInformation($"Attack roll! {weapon.SystemName} -- range {range} | screen {screenRating.ToString()} | net DRM {totalDRM} | {effectiveDamageType.ToString()}-type damage | rating {weapon.Rating}"); /* "Basic" weapon behavior is to shoot like a non-penetrating beam: * 1D per Rating, diminishing with range * 1 damage on a 4 unless screened * 1 damage on a 5, always * 2 damage on a 6, unless double-screened -- then 1 */ DamageResult damageMatrix = FullThrustDieRolls.RollFTDamage(this.DiceUtility, weapon.GetAttackDice(), totalDRM, totalScreenRating, effectiveDamageType.HasFlag(Constants.DamageType.Penetrating)); return(damageMatrix); }
/** * <summary>Fires Paper object in the direction of that the character is facing</summary> */ public void Fire( float damagePoints = 0.1f, Constants.DamageType damageType = Constants.DamageType.Static, Vector2 fireToPoint = new Vector2() ) { Debug.Log("NPC PAPER FIRE"); if (ammo > 0) { // Create the paper prefab var paper = (GameObject)Instantiate( npcPaperPrefab, transform.position, transform.rotation ); Physics2D.IgnoreCollision(npcObject.GetComponent <BoxCollider2D>(), paper.GetComponent <CircleCollider2D>()); // Determine the velocity the paper is fired at paper.GetComponent <Rigidbody2D>().velocity = npcObject.GetComponent <Rigidbody2D>().transform.right *MAX_FIREPOWER + new Vector3(npcObject.GetComponent <Rigidbody2D>().velocity.x, npcObject.GetComponent <Rigidbody2D>().velocity.y); // Set damage the prefab will deal paper.GetComponent <PaperPrefabDamage>().DealDamage = Damage; // Set the lifetime of the paper prefab Destroy(paper, .75f); this.Ammo--; } }
/** <summary>Damage starts at .1 and weapon must be charged to do full damage.</summary> */ public void Fire(float damagePoints = .1f, Constants.DamageType damageType = Constants.DamageType.Static) { if (ammo > 0) { if (beginCharge == false) { Debug.Log("Textbook charging"); beginCharge = true; chargePercent = 1f; } else { beginCharge = false; Debug.Log("Textbook firing with charge: " + chargePercent.ToString()); var textbook = (GameObject)Instantiate( textbookPrefab, transform.position, playerObject.transform.rotation ); // This is how we set the damage of the prefabs textbook.GetComponent <TextbookPrefab>().DealDamage = this.Damage; textbook.GetComponent <TextbookPrefab>().rotateSpeed = chargePercent / 10; textbook.GetComponent <Rigidbody2D>().velocity = playerObject.GetComponent <Rigidbody2D>().transform.up *(MAX_FIREPOWER * (chargePercent / 100)) + new Vector3(playerObject.GetComponent <Rigidbody2D>().velocity.x, playerObject.GetComponent <Rigidbody2D>().velocity.y); textbook.GetComponent <TextbookPrefab>().DealDamage = Damage; Destroy(textbook, .75f); this.Ammo--; } } }
/** * <summary>Spawns a new pencil object in * the direction of that the character is facing</summary> * */ public void Fire(float damagePoints = 0.1f, Constants.DamageType damageType = Constants.DamageType.Static) { Debug.Log("Pencil- received Fire() command - JG"); this.isLive = true; Vector2 mousePosition = Input.mousePosition; mousePosition = Camera.main.ScreenToWorldPoint(mousePosition); Vector2 directionToMouse = new Vector2( mousePosition.x - transform.position.x, mousePosition.y - transform.position.y ); if (countdown <= 0) { this.Countdown = TIMEOUT; var pencilFab = (GameObject)Instantiate( pencilPrefab, playerBody.position, playerBody.transform.rotation, playerBody.transform ); Physics2D.IgnoreCollision(pencilPrefab.transform.GetComponent <Collider2D>(), playerBody.transform.GetComponent <Collider2D>(), true); pencilFab.GetComponent <PencilPrefab>().DealDamage = this.Damage; //transform.Translate((playerBody.transform.position - transform.position).normalized * 5 * Time.deltaTime); Destroy(pencilFab, lifetime); } }
public void Fire(float damagePoints = 0.3f, Constants.DamageType damageType = Constants.DamageType.Static) { this.Damage = damagePoints; if (ammo > 0) { // Create the paper prefab var paper = (GameObject)Instantiate( paperPrefab, transform.position, transform.rotation ); // Compute the velocity to fire the paper prefab paper.GetComponent <Rigidbody2D>().velocity = playerObject.GetComponent <Rigidbody2D>().transform.up *MAX_FIREPOWER + new Vector3(playerObject.GetComponent <Rigidbody2D>().velocity.x, playerObject.GetComponent <Rigidbody2D>().velocity.y); // Set prefab's damage property float dealDamage = .3f; paper.GetComponent <PaperPrefabDamage>().DealDamage = dealDamage; // Set the prefabs lifetime Destroy(paper, .75f); this.Ammo--; } else { // Need More Ammo Debug.Log("Paper- Need More Ammo"); } }
public void Fire(float damagePoints = 0.1f, Constants.DamageType damageType = Constants.DamageType.Static) { Debug.Log("Ruler- received Fire() command - JG"); isLive = true; if (countdown <= 0) { this.Countdown = TIMEOUT; } }
public virtual Constants.DamageType FinalizeDamageType(Constants.DamageType weaponDamageType, Constants.DamageType damageTypeModifier = Constants.DamageType.None, bool modifierOverridesWeaponDamageType = false) { if (modifierOverridesWeaponDamageType) { return(damageTypeModifier); } else { return(weaponDamageType | damageTypeModifier); } }
/** * <summary>Spawns a new pencil object in * the direction of that the character is facing</summary> * */ public void Fire( float damagePoints = 0.1f, Constants.DamageType damageType = Constants.DamageType.Static, Vector2 fireToPoint = new Vector2() ) { // Enable the pencil to be live this.isLive = true; // Enable box collider and sprite npcPencilBody.GetComponent <SpriteRenderer>().enabled = true; npcPencilBody.GetComponent <PolygonCollider2D>().enabled = true; }
/** <summary>Damage starts at .1 and weapon must be charged to do full damage.</summary> */ public void Fire(float damagePoints = .1f, Constants.DamageType damageType = Constants.DamageType.Static) { Debug.Log("Notebook Fired"); DealDamage = Damage; pausePosition = playerObject.GetComponent <Rigidbody2D>().position; if (ammo > 0 && countdown <= 0) { begin = true; fireCountdown = 100; this.GetComponent <Rigidbody2D>().position = pausePosition; this.GetComponent <PolygonCollider2D>().enabled = true; this.GetComponent <SpriteRenderer>().enabled = true; countdown = 5; } }
public void updateStats() { foreach (TowerWeaponModual elm in towerWeapon) { //TODO Do some mixing of types damageType = elm.weaponSlot.damageType; range += elm.weaponSlot.range; attackSpeed += elm.weaponSlot.attackSpeed; Destroy(weaponModual); switch (damageType) { case Constants.DamageType.Magic: weaponModual = Instantiate((GameObject)Resources.Load("Prefabs/turrets/turret_cannon", typeof(GameObject))); weaponModual.transform.parent = modualSlot.transform; weaponModual.transform.localPosition = Vector3.zero; break; case Constants.DamageType.Elementel: break; case Constants.DamageType.Primal: break; case Constants.DamageType.mix1: break; case Constants.DamageType.mix2: break; case Constants.DamageType.mix3: break; } bulletModel = ((GameObject)Resources.Load("Prefabs/projectiles/" + elm.bulletModual)); barrel = weaponModual.transform.FindChild("turret_barrel"); mount = weaponModual.transform.FindChild("turret_mount"); StopCoroutine(Attack()); StartCoroutine(Attack()); } }
protected override IList <GameEvent> ReceiveWeaponAttackEvent(GameEvent arg) { var result = new List <GameEvent>(); var evt = arg as WeaponAttackEvent ?? throw ReceiverArgumentMismatch(nameof(arg), arg.GetType(), MethodBase.GetCurrentMethod().Name, typeof(AttackEvent)); // Unit receives event if: // a) WeaponAttack is assigned to this Unit's Formation // b) Attack's percentile roll is within this Unit's PercentileRange if (evt.TargetingData.Target.FormationId == this.unitFormationInfo.FormationId && this.unitFormationInfo.CoversPercentile(evt.UnitAssignmentPercentile)) { var target = evt.TargetingData.Target.UnitActor.unitFormationInfo; GameFormation targetFormation = target.GetFormationReference(); GameUnit targetUnit = target.GetUnitReference(); GameFormation attackerFormation = this.unitFormationInfo.GetFormationReference(); GameUnit attackerUnit = this.unitFormationInfo.GetUnitReference(); int firingRange = evt.TargetingData.FormationRange; result.Add(new UnitStatusEvent() { Description = $"UnitStatus: [{this.UnitId}]{this.UnitName}", Message = $"[{targetFormation.FormationId}]{targetFormation.FormationName}:[{targetUnit.IdNumeric}]{targetUnit.Name}" + $" covers percentile range {this.unitFormationInfo.PercentileLowerBound}-{this.unitFormationInfo.PercentileUpperBound}," + $" so incoming attack with percentile roll {evt.UnitAssignmentPercentile} targets it.", Exchange = evt.Exchange, Volley = evt.Volley }); WeaponSystem weapon = evt.AttackData.Weapon; // TODO: Add ability to override this from AttackData and/or TargetingData? Constants.DamageType effectiveDamageType = weapon.GetDamageType(); int evasionDRM = -1 * targetFormation.GetOrdersForVolley(evt.Volley).EvasionSuccesses; int otherDRM = targetFormation.GetDRMVersusWeaponType(weapon.GetType()) + targetUnit.GetDRMVersusWeaponType(weapon.GetType()); var localScreens = targetUnit.GetLocalScreenRating(); var areaScreens = targetFormation.GetFormationAreaScreenRating(); ScreenRating totalScreenRating = ScreenRating.Combine(localScreens, areaScreens); DamageResult weaponAttackResult = this.ResolveWeaponAttack(weapon, firingRange, totalScreenRating, evasionDRM, otherDRM); var statusMsg = $"[{attackerUnit.IdNumeric}]{attackerUnit.Name} fires [{weapon.Id}]{weapon.SystemName} at [{targetUnit.IdNumeric}]{targetUnit.Name}" + $"\n\t\t -- Net modifiers: Range {firingRange}" + $", Screen {weapon.FinalizeScreenValue(totalScreenRating)}" + $", Evasion DRM {weapon.FinalizeEvasionDRM(evasionDRM)}" + $", Other DRM {otherDRM}" + $"\n\t\t -- Rolls {weaponAttackResult.RollString()}" + $"\n\t\t -- Deals {weaponAttackResult.ToString()}"; result.Add(new UnitStatusEvent() { Description = $"UnitStatus: [{this.UnitId}]{this.UnitName}", Message = statusMsg, Exchange = evt.Exchange, Volley = evt.Volley }); } return(result); }
public void Fire(float damagePoints = 0.1f, Constants.DamageType damageType = Constants.DamageType.Static) { // Call the overloaded Fire function Fire(damagePoints, damageType, new Vector2()); }