public Spaceman(Vector2 startPosition) : base(AstronautData) { thrusterParticleEffect = new ParticleEffect(THRUSTER_EFFECT_NAME); _lifeState = LifeState.Living; //astronaut starts pre-spawned Position = startPosition; }
protected ProjectileWeapon(ProjectileWeaponData data, PhysicalUnit owner) : base(TimeSpan.FromSeconds(1.0 / data.FireRate), owner) { _name = data.Name; _projectilesPerFire = data.ProjectilesPerFire; _projectileInfo = data.ProjectileInfo; _spread = data.Spread; _contactEffect = _projectileInfo.ContactEffect == null ? ProjectileEffect.NullEffect : new ProjectileEffect(_projectileInfo.ContactEffect); _proximityEffect = _projectileInfo.ProximityEffect == null ? ProjectileEffect.NullEffect : new ProjectileEffect(_projectileInfo.ProximityEffect); _destinationEffect = _projectileInfo.DestinationEffect == null ? ProjectileEffect.NullEffect : new ProjectileEffect(_projectileInfo.DestinationEffect); _fireParticleEffect = data.FireParticleEffectName == null ? null : new ParticleEffect(data.FireParticleEffectName); float maxProjLife = data.ProjectileInfo.SecondsToLive + Math.Max((float)_contactEffect.Duration.TotalSeconds, (float)_destinationEffect.Duration.TotalSeconds); float maxProjectiles = data.FireRate * maxProjLife * data.ProjectilesPerFire; maxProjectiles = Math.Max(maxProjectiles, _projectilesPerFire); _projectiles = new Projectile[(int)maxProjectiles + 1]; for (int i = 0; i < _projectiles.Length; i++) { _projectiles[i] = new Projectile(data.ProjectileInfo.SpriteName); } }
public Gadget(GadgetData data) { MaxEnergy = data.MaxEnergy; Energy = MaxEnergy; if (data.ParticleEffectName != null) _activeParticleEffect = new ParticleEffect(data.ParticleEffectName); }
TimeSpan _panicTimer; //time till next direction switch #endregion Fields #region Constructors /// <summary> /// Create a new physical sprite from data /// </summary> /// <param name="pd">data from which to construct unit</param> protected PhysicalUnit(PhysicalData pd) : base(pd, Sprite.SpriteType.Unit) { MoveDirection = Vector2.Zero; LookDirection = Vector2.Zero; if (pd.MovementParticleEffectName != null) _movementParticleEffect = new ParticleEffect(pd.MovementParticleEffectName); }
/// <summary> /// Construct a new black hole /// </summary> /// <param name="position">location of black hole center</param> /// <param name="gravMagnitude">strength of gravitational force</param> /// <param name="radius">max distance that black hole will consume units</param> public BlackHole(Vector2 position, float gravMagnitude, float radius, float capacity) { Position = position; Gravity = new Gravity(position, gravMagnitude); _radius = radius; _particleEffect = new ParticleEffect("BlackHoleEffect"); _totalCapacity = capacity; _capacityUsed = 0.0f; _overdriveTimer = TimeSpan.FromSeconds(SECONDS_FOR_OVERDRIVE); }
/// <summary> /// Construct a new black hole /// </summary> /// <param name="position">location of black hole center</param> /// <param name="gravMagnitude">strength of gravitational force</param> /// <param name="radius">max distance that black hole will consume units</param> public BlackHole(BlackHoleData data) { Position = new Vector2(data.X, data.Y); Gravity = new Gravity(Position, data.Gravity); _radius = data.Radius; _particleEffect = new ParticleEffect("BlackHoleEffect"); _totalCapacity = data.Capacity; _capacityUsed = 0.0f; _overdriveTimer = TimeSpan.FromSeconds(SECONDS_FOR_OVERDRIVE); }
TimeSpan _restTimer; //how long to wait after activation before spawning #endregion Fields #region Constructors public BurstWave(BurstWaveData data, Rectangle levelBounds, BurstWave previousWave) : base(data, false, levelBounds) { //set up enemies //activation delay is zero for trickle waves _restTimer = TimeSpan.FromSeconds(data.RestDelay); //assign a portal particle effect if it is a burst wave _portalEffect = new ParticleEffect(c_portalEffectName); _previousWave = previousWave; _allDestroyed = false; }
protected MeleeWeapon(MeleeWeaponData data, PhysicalUnit owner) : base(data, owner, data.Name) { _damage = data.Damage; _force = data.Impact; _recoil = data.Recoil; _hitArc = data.HitArc; _range = data.Range; _attackParticleEffect = (data.AttackParticleEffect == null) ? null : new ParticleEffect(data.AttackParticleEffect); _hitParticleEffect = (data.HitParticleEffect == null) ? null : new ParticleEffect(data.HitParticleEffect); }
protected MeleeWeapon(MeleeWeaponData data, PhysicalUnit owner) : base(TimeSpan.FromSeconds(1.0 / data.FireRate), owner) { _damage = data.Damage; _force = data.Impact; _recoil = data.Recoil; _hitArc = data.HitArc; _range = data.Range; _attackParticleEffect = (data.AttackParticleEffect == null) ? null : new ParticleEffect(data.AttackParticleEffect); _hitParticleEffect = (data.HitParticleEffect == null) ? null : new ParticleEffect(data.HitParticleEffect); }
public Unicorn(UnicornData data) { _startTime = TimeSpan.FromSeconds(data.StartTime); _endTime = TimeSpan.FromSeconds(data.EndTime); _spawnTime = TimeSpan.FromSeconds(data.SpawnTime); _timer = _spawnTime; _standingEffect = new ParticleEffect(STAND_PARTICLE_EFFECT); _chargeEffect = new ParticleEffect(MOVE_PARTICLE_EFFECT); _explodeEffect = new ParticleEffect(EXPLODE_PARTICLE_EFFECT); _sprite = new Sprite(SPRITE_NAME, Sprite.SpriteType.Unit); _state = State.Dormant; _gravity = new Gravity(_position, UNICORN_GRAVITY); _hitRect = new Rectangle(0, 0, (int)_sprite.Width, (int)_sprite.Height); _spawnEnable = true; }
TimeSpan _tillNextSpawn; //how long till spawning a new enemy #endregion Fields #region Constructors public Wave(WaveData data, bool trickleWave) { string[] enemyNames = data.EnemyNames; _enemies = new Enemy[enemyNames.Length]; for (int j = 0; j < _enemies.Length; j++) { _enemies[j] = new Enemy(enemyNames[j]); } _numEnemies = _enemies.Length; _spawnedSoFar = 0; _tillNextSpawn = data.SpawnInterval; _spawnInterval = data.SpawnInterval; _startTimer = data.StartTime; _isTrickleWave = trickleWave; _spawnLocation = Vector2.Zero; //activation delay is zero for trickle waves _activationDelay = _isTrickleWave ? TimeSpan.Zero : TimeSpan.FromSeconds((double)ACTIVATION_DELAY_SECONDS); //assign a portal particle effect if it is a burst wave _portalEffect = (trickleWave) ? null : new ParticleEffect(PORTAL_EFFECT_NAME1); }
/// <summary> /// Create a new physical sprite /// </summary> /// <param name="unitName">key to find SpriteData and PhysicalData</param> public PhysicalUnit(string unitName) { _unitName = unitName; _sprite = new Sprite(unitName); PhysicalData pd = Data[unitName]; if (pd.MovementParticleEffectName != null) _movementParticleEffect = new ParticleEffect(pd.MovementParticleEffectName); _mass = pd.Mass; _moveForce = pd.MoveForce; _maxSpeed = pd.MaxSpeed; _health = pd.Health; _decelerationFactor = pd.DecelerationFactor; _lifeState = LifeState.Dormant; //not yet spawned _hitRect = new Rectangle(0, 0, (int)_sprite.Width, (int)_sprite.Height); MoveDirection = Vector2.Zero; LookDirection = Vector2.Zero; }
protected ProjectileWeapon(ProjectileWeaponData data, PhysicalUnit owner) : base(TimeSpan.FromSeconds(1.0 / data.FireRate), data.MaxAmmo, data.AmmoConsumption, owner) { _maxProjectiles = data.MaxProjectiles; _projectiles = new Projectile[_maxProjectiles]; for (int i = 0; i < _maxProjectiles; i++) { _projectiles[i] = new Projectile(); _projectiles[i].ProjectileSprite = new Sprite(data.ProjectileSpriteName); } _projectileDamage = data.Damage; _projectileForce = data.ProjectileForce; _recoilForce = data.Recoil; _projectileSpeed = data.ProjectileSpeed; _projectileAcceleration = data.ProjectileAcceleration; _dissipateOnHit = data.DissipateOnHit; _projectileSpread = MathHelper.ToRadians(data.ProjectileSpread); _projectilesPerFire = data.ProjectilesPerFire; _projectileLife = data.ProjectileLife; _splashDamage = data.SplashDamage; _splashRadius = data.SplashRadius; _splashForce = data.SplashForce; Sprite projectileSprite = _projectiles[0].ProjectileSprite; if (projectileSprite.Width <= _splashRadius * 2) { _splashScaleRate = (projectileSprite.Width / _splashRadius); _splashScaleRate /= (float)projectileSprite.FullAnimationTime.TotalSeconds; } _hitDetectionRect = new Rectangle(0,0, (int)(projectileSprite.Width), (int)projectileSprite.Height); if (data.MovementParticleEffect != null) _movementParticleEffect = new ParticleEffect(data.MovementParticleEffect); if (data.SplashParticleEffect != null) _splashParticleEffect = new ParticleEffect(data.SplashParticleEffect); }
public ProjectileEffect(ProjectileEffectData data) { _radius = data.Radius; _damage = data.Damage; _particleEffect = data.ParticleEffectName == null ? null : new ParticleEffect(data.ParticleEffectName); _force = data.Force; _statEffects = new StatEffect(data.FireEffect, data.CryoEffect, data.ShockEffect); Duration = TimeSpan.FromSeconds(data.Duration); }
/// <summary> /// Create a new physical sprite from data /// </summary> /// <param name="pd">data from which to construct unit</param> protected PhysicalUnit(PhysicalData pd) { _unitName = pd.Name; _sprite = new Sprite(_unitName); if (pd.MovementParticleEffectName != null) _movementParticleEffect = new ParticleEffect(pd.MovementParticleEffectName); _burningParticleEffect = new ParticleEffect("Burning"); _mass = pd.Mass; _moveForce = pd.MoveForce; _maxSpeed = pd.MaxSpeed; _maxHealth = pd.Health; _health = _maxHealth; _decelerationFactor = pd.DecelerationFactor; _lifeState = LifeState.Dormant; //not yet spawned _hitRect = new Rectangle(0, 0, (int)_sprite.Width, (int)_sprite.Height); Position = Vector2.Zero; MoveDirection = Vector2.Zero; LookDirection = Vector2.Zero; _statusEffects = new StatEffect(0, 0, 0); _statusResist = new StatEffect(pd.FireResist, pd.CryoResist, pd.ShockResist); _fragments = new IceFragment[ICE_DIVISIONS, ICE_DIVISIONS]; }
/// <summary> /// Create a new physical sprite from data /// </summary> /// <param name="pd">data from which to construct unit</param> protected PhysicalBody(PhysicalData pd, Sprite.SpriteType spriteType) { _unitName = pd.Name; if (spriteType == Sprite.SpriteType.Unit) { _sprite = new UnitSprite(pd.Name, (PhysicalUnit)this); } else { _sprite = new Sprite(pd.Name, spriteType); } _burningParticleEffect = new ParticleEffect("Burning"); _mass = pd.Mass; _gravitySensitivity = pd.GravitySensitivity; _moveForce = pd.MoveForce; _maxSpeed = pd.MaxSpeed; _maxHealth = pd.Health; _health = _maxHealth; _decelerationFactor = pd.DecelerationFactor; _lifeState = LifeState.Dormant; //not yet spawned _hitRect = new Rectangle(0, 0, (int)_sprite.Width, (int)_sprite.Height); Position = Vector2.Zero; _statusEffects = new StatEffect(0, 0, 0); _statusResist = new StatEffect(pd.FireResist, pd.CryoResist, pd.ShockResist); _fragments = new IceFragment[c_shatterDivisions, c_shatterDivisions]; }