//////////////// public static bool IsSpamProjectile(Projectile projectile) { var config = UPMod.Instance.Config; int projType = projectile.type; if (!UPMod.AreSpamProjectileLikelyToExist()) { return(false); } if (projType >= 0) { if (Main.projPet.Length > projType && Main.projPet[projType]) { return(false); } if (ProjectileID.Sets.LightPet.Length > projType && ProjectileID.Sets.LightPet[projType]) { return(false); } } var projDef = new ProjectileDefinition(projType); if (config.NotSpamProjectiles.Contains(projDef)) { return(false); } return((config.AreFriendlyProjectilesLikelySpam && projectile.friendly) || (config.AreHostileProjectilesLikelySpam && projectile.hostile) || (config.AreFriendlyAndHostileProjectilesLikelySpam && projectile.friendly && projectile.hostile) || (config.AreUnfriendlyAndUnhostileProjectilesLikelySpam && !projectile.friendly && !projectile.hostile)); }
public static IDictionary <ProjectileDefinition, (int radius, int damage)> GetExplosivesStats() { var projectiles = new Dictionary <ProjectileDefinition, (int, int)>(); int inactivePos = 0; for (int i = 0; i < Main.projectile.Length; i++) { if (Main.projectile[i] == null || !Main.projectile[i].active) { inactivePos = i; break; } } for (int i = 0; i < Main.projectileTexture.Length; i++) { (int, int)? stats = DestructibleTilesProjectile.CalculateExplosiveStats(inactivePos, i); if (stats.HasValue) { var projDef = new ProjectileDefinition(i); projectiles[projDef] = stats.Value; } } Main.projectile[inactivePos] = new Projectile(); return(projectiles); }
//This method is subscribed to the player's tank's ammo type change event, and switches the ammo icon on the HUD when fired private void UpdateShellInfo(int newShell) { ProjectileDefinition projectileDefinition = SpecialProjectileLibrary.s_Instance.GetProjectileDataForIndex(newShell); m_AmmoIcon.sprite = projectileDefinition.weaponIcon; m_AmmoIcon.color = projectileDefinition.weaponColor; m_RadialAmmoCount.color = projectileDefinition.weaponColor; }
public FireballVolley() { Name = "Fireball Volley"; Range = new Range(20); DamageType = DamageTypes.Cleave; Duration = 3.0f; TargettingType = TargettingTypes.Hostile; SpawnsProjectile = new ProjectileDefinition() { ModelName = "rocket1", TextureName = "rocket1_diffuse", Speed = 16 }; }
//////////////// public override void Kill(Projectile projectile, int timeLeft) { if (timeLeft > 3) { return; } var config = DestructibleTilesConfig.Instance; var projDef = new ProjectileDefinition(projectile.type); bool isExplosive = config.ProjectilesAsAoE.ContainsKey(projDef); if (isExplosive) { this.BehaviorAsAoE(projectile); } }
/// <summary> /// Call this to initialize a Behaviour with data supplied in a file. /// </summary> /// <param name="fileName">The file to load from.</param> public override void LoadContent(String fileName) { base.LoadContent(fileName); ProjectileDefinition def = GameObjectManager.pInstance.pContentManager.Load <ProjectileDefinition>(fileName); mDamageAppliedTo = new List <GameObjectDefinition.Classifications>(); for (Int32 i = 0; i < def.mDamageAppliedTo.Count; i++) { mDamageAppliedTo.Add(def.mDamageAppliedTo[i]); } mObjectsInRange = new List <GameObject>(16); mApplyDamageMsg = new Health.ApplyDamageMessage(); mApplyDamageMsg.mDamageAmount_In = def.mDamageCaused; }
public void Initialize(ProjectileDefinition projectileDefintion, Vector2 startingPoint, Vector2 direction, Quaternion rotation) { TypeDefinition = projectileDefintion; gameObject.transform.position = startingPoint; gameObject.transform.rotation = rotation; Damage = TypeDefinition.Damage; gameObject.layer = projectileDefintion.Layer; GetComponent <SpriteRenderer>().sprite = projectileDefintion.sprite; Vector2 projectileForce = direction * TypeDefinition.Speed; GetComponent <Rigidbody2D>().AddForce(projectileForce * 2.0f, ForceMode2D.Impulse); speedBurstTimer = SpeedBurstDuration; slowDownForce = projectileForce * -1; awaitingSlowdown = true; }
public static EntityDefinition GetEntDef(HologramMode mode, string rawDef) { switch (mode) { case HologramMode.NPC: return(NPCDefinition.FromString(rawDef)); case HologramMode.Item: return(ItemDefinition.FromString(rawDef)); case HologramMode.Projectile: return(ProjectileDefinition.FromString(rawDef)); default: throw new NotImplementedException("No such mode.."); } }
//////////////// public override bool OnTileCollide(Projectile projectile, Vector2 oldVelocity) { var config = DestructibleTilesConfig.Instance; var projDef = new ProjectileDefinition(projectile.type); // Explosives are handled elsewhere if (config.ProjectilesAsAoE.ContainsKey(projDef)) { return(base.OnTileCollide(projectile, oldVelocity)); } bool _; if (!DestructibleTilesProjectile.CanHitTiles(projectile, out _)) { return(base.OnTileCollide(projectile, oldVelocity)); } this.BehaviorAsKinetic(projectile, oldVelocity); return(base.OnTileCollide(projectile, oldVelocity)); }
public static bool CanHitTiles(Projectile projectile, out bool hasCooldown) { var config = DestructibleTilesConfig.Instance; var projDef = new ProjectileDefinition(projectile.type); string timerName = "PTH_" + projectile.type + "_" + projectile.whoAmI; bool isRepeatHit = Timers.GetTimerTickDuration(timerName) > 0; hasCooldown = config.ProjectilesAsConsecutiveHitters.ContainsKey(projDef); Timers.SetTimer(timerName, 2, false, () => false); if (isRepeatHit) { if (hasCooldown) { DestructibleTilesProjectile.CanHitTilesAgain(projectile, projDef, timerName, ref isRepeatHit); } } return(!isRepeatHit); }
public void BehaviorAsAoE(Projectile projectile) { var config = DestructibleTilesConfig.Instance; var projDef = new ProjectileDefinition(projectile.type); ProjectileStateDefinition projExploDef = config.ProjectilesAsAoE[projDef]; if (!projExploDef.IsProjectileMatch(projectile)) { return; } int tileX = (int)projectile.position.X >> 4; int tileY = (int)projectile.position.Y >> 4; int damage = DestructibleTilesProjectile.ComputeProjectileDamage(projectile); if (config.DebugModeInfo) { Main.NewText("RADIUS - " + projDef.ToString() + ", radius:" + projExploDef.Amount + ", damage:" + damage); } DestructibleTilesProjectile.HitTilesInRadius(tileX, tileY, projExploDef.Amount, damage); }
private static void CanHitTilesAgain( Projectile projectile, ProjectileDefinition projDef, string timerName, ref bool isHit) { var config = DestructibleTilesConfig.Instance; ProjectileStateDefinition projConsec = config.ProjectilesAsConsecutiveHitters[projDef]; if (!projConsec.IsProjectileMatch(projectile)) { return; } string repeatTimerName = timerName + "_repeat"; int cooldown = config.ProjectilesAsConsecutiveHitters[projDef].Amount; if (Timers.GetTimerTickDuration(repeatTimerName) <= 0) { Timers.SetTimer(repeatTimerName, cooldown, false, () => false); isHit = false; } }
public static int ComputeProjectileDamage(Projectile projectile) { var config = DestructibleTilesConfig.Instance; var projDef = new ProjectileDefinition(projectile.type); if (projectile.minion && config.MinionsCannotHitTiles) { return(0); } if (config.ProjectileTileDamageUltimate.ContainsKey(projDef)) { ProjectileStateDefinition projDmgOver = config.ProjectileTileDamageUltimate[projDef]; if (projDmgOver.IsProjectileMatch(projectile)) { return(projDmgOver.Amount); } } if (projectile.damage > 0) { return((int)((float)projectile.damage * config.AllDamagesScale)); } if (config.ProjectileTileDamageDefaults.ContainsKey(projDef)) { ProjectileStateDefinition projDmgDef = config.ProjectileTileDamageDefaults[projDef]; if (projDmgDef.IsProjectileMatch(projectile)) { return((int)((float)projDmgDef.Amount * config.AllDamagesScale)); } } return((int)((float)projectile.damage * config.AllDamagesScale)); }
public void SpawnNewProjectile(ProjectileDefinition projectileDefintion, Vector2 pos, Vector2 direction, Quaternion rotation) { var newProjectile = projectilePool.InitNewObject(); newProjectile.GetComponent <Projectile>().Initialize(projectileDefintion, pos, direction, rotation); }