private void UseAttack() { var boomerangOffset = new Point(4, 4); switch (_statusDirection) { case Direction.Up: boomerangOffset.Y -= 16; break; case Direction.Down: boomerangOffset.Y += 16; break; case Direction.Left: boomerangOffset.X -= 16; break; case Direction.Right: boomerangOffset.X += 16; break; default: throw new ArgumentOutOfRangeException(); } Projectiles.Add(new GoriyaBoomerang(Location + boomerangOffset, _statusDirection)); _timeSinceBoomerangThrown = 0; }
public void AddProjectileTarget(string nameMissile, ITarget target, bool isServerOnly = false) { ISpellData projectileSpellData = this._game.Config.ContentManager.GetSpellData(nameMissile); var p = new Projectile( _game, Owner.X, Owner.Y, (int)projectileSpellData.LineWidth, Owner, target, this, projectileSpellData.MissileSpeed, nameMissile, projectileSpellData.Flags, _futureProjNetId ); Projectiles.Add(p.NetId, p); _game.ObjectManager.AddObject(p); if (!isServerOnly) { _game.PacketNotifier.NotifyMissileReplication(p); } _futureProjNetId = _networkIdManager.GetNewNetId(); }
private void InitProjectiles() { { Projectile fragNade = new Projectile(null); Projectiles.Add("FragNade", fragNade); } }
/// <summary> /// Shoot method with starting conditions to compensate for network delay /// </summary> /// <param name="target">Where is bulet traveling to</param> /// <param name="shootOrgin">Where shot was fired</param> /// <param name="shootRotation">How was weapon rotated during shoot</param> public void Shoot(Vector2f target, Vector2f shootOrgin, float shootRotation, Player player, bool sendToServer) { if (Ammo != 0 && Reloading != true && ShootTimer.ElapsedTime.AsMilliseconds() > AttackSpeed) { ShootTimer.Restart(); // maybe figure out how to make this Vector2f -> Vector2 -> Vector2f mess cleaner later const float projectileSpeed = 10f; Vector2 normalizedTarget = new Vector2(target.X, target.Y); normalizedTarget = Vector2.Normalize(normalizedTarget); Vector2f myTarget = new Vector2f(normalizedTarget.X, normalizedTarget.Y); Projectile bullet = new Projectile(myTarget * projectileSpeed, ProjectileSprite, shootOrgin, shootRotation); Projectiles.Add(bullet); ChangeAmmo(-1); Sound sound = ResourceHolderFacade.GetInstance().Sounds.Get(SoundIdentifier.GenericGun); sound.Volume = ResourceHolderFacade.GetInstance().CurrentVolume.GetVolume(); sound.Play(); if (sendToServer) { var shootEventData = new ShootEventData(player.ToDTO(), target, this.Position, this.Rotation); //GameState.GetInstance().ConnectionManager.Connection.SendAsync("ShootEventServer", shootEventData); GameState.GetInstance().ConnectionManagerProxy.Connection.SendAsync("ShootEventServer", shootEventData); } } }
private void UseAttack() { var fbLLocation = Location + FireballLeftOffset; var fbRLocation = Location + FireballRightOffset; Projectiles.Add(new Fireball(fbLLocation, GenerateFireballVector(fbLLocation), false)); Projectiles.Add(new Fireball(fbRLocation, GenerateFireballVector(fbRLocation), false)); }
public void AddProjectile(ISimulatedEntity entity) { Projectiles.Add(entity); solver.AddEntity(entity); entity.Destroyed += () => { Projectiles.Remove(entity); solver.RemoveEntity(entity); }; }
private void RollBolder(Canvas canvas, Map map) { Point rollingPosition = GetPositionInCanvas(); rollingPosition.Left += 200; rollingPosition.Top += 350; Bolder bolder = new Bolder(rollingPosition, canvas, map, _isLookingRight, this); Projectiles.Add(bolder); }
private void CreateProjectiles(GameTime gameTime) { if (Projectiles.Count < projectileCount && (lastProjectile + projectileInterval) < gameTime.TotalGameTime.TotalMilliseconds) { var projectile = new Projectile(Art.Lazer, GameRoot.ScaleToHighDPI(projectileSize * ScaleX), GameRoot.ScaleToHighDPI(projectileSize * ScaleY)); projectile.SetPosition(new Vector2(Position.X, Position.Y - (Height / 2)), new Vector2(0, -3 * projectileSpeed)); Projectiles.Add(projectile); lastProjectile = gameTime.TotalGameTime.TotalMilliseconds; } }
private void UseAttack() { const double velocityScalar = -1.5; var fb0Location = new Point(Location.X, Location.Y - 4); var fb2Location = new Point(Location.X, Location.Y + 4); Projectiles.Add(new Fireball(fb0Location, GenerateFireballVector(velocityScalar, -0.5), true)); Projectiles.Add(new Fireball(Location, GenerateFireballVector(velocityScalar, 0), true)); Projectiles.Add(new Fireball(fb2Location, GenerateFireballVector(velocityScalar, 0.5), true)); }
public override void Update(GameTime gameTime) { var removeQueue = new List <BGameObject>(); foreach (var target in mForcedTargets) { if (target == null || target.Health < 0) { removeQueue.Add(target); } } foreach (var target in removeQueue) { mForcedTargets.Remove(target); } if (mForcedTargets.Count == 0) { mForceTargets = false; } // Create projectiles mTimeSinceLastProjectileSpawn += gameTime.ElapsedGameTime.Milliseconds; if (mTimeSinceLastProjectileSpawn > mProjectileSpawnCooldownInSeconds * 1000 && !mTargetToFar && mTarget != null) { var shootPosition = new Vector2 { X = Position.X + (Width / 2f / 32) + TextureOffset.X, Y = Position.Y + (Height / 2f / 32) + TextureOffset.Y }; var rotation = -Math.Atan2(mTargetPosition.Y - shootPosition.Y, mTargetPosition.X - shootPosition.X); var nextDirection = new Vector2((float)Math.Cos(rotation), -(float)Math.Sin(rotation)); Projectiles.Add(new Projectile(mProjectileTexture, shootPosition.X, shootPosition.Y, nextDirection)); mTimeSinceLastProjectileSpawn = 0; } foreach (var projectile in Projectiles) { projectile.Update(gameTime); } if (Projectiles.Count > MaxProjectiles) { Projectiles.RemoveAt(0); } if (mForceTargets) { SetTargets(mForcedTargets); } }
public void PickObject() { this.lastUse = Game.TotalElapsedGameTime; this.pickupTrigger = ((IObjectTrigger)Game.CreateObject( "AreaTrigger", this.controller.GetWorldPosition() + new Vector2(this.controller.FacingDirection * 15f, 2f), 0 )); this.pickupTrigger.CustomId = this.id; this.pickupTrigger.SetScriptMethod("TryPickup"); Projectiles.Add(new Projectile(pickupTrigger, 100)); }
/// <summary> /// Creates a new projectile. /// </summary> private void CreateProjectile() { var projectile = new Projectile(_projectileTexture) { Position = new Vector2(Player.Position.X + 119, Player.Position.Y + 33) }; Projectiles.Add(projectile); #if AUDIO_ENABLED new Task(() => { _laserFire.Play(); }).Start(); #endif }
private void FireProjectile() { int top = Batwing.Position.Top; int left = Batwing.Position.Left; var projectileTop = projectilesFactory.Get(left, top); var projectileBottom = projectilesFactory.Get(left, top + Batwing.Bounds.Height); Projectiles.Add(projectileTop); Projectiles.Add(projectileBottom); GameObjects.Add(projectileTop); GameObjects.Add(projectileBottom); }
public void Attack(Enemy target) { Vector2 direction = target.Drawbox.Center.ToVector2() - Drawbox.Center.ToVector2(); direction.Normalize(); if (Ptype == ProjectileType.pierce) { Projectiles.Add(new PierceProjectile(ProjectileDrawbox, ProjectileTexture, ProjectileRadius, direction, ProjectileEffect)); } else if (Ptype == ProjectileType.splash) { Projectiles.Add(new SplashProjectile(ProjectileDrawbox, ProjectileTexture, ProjectileRadius, direction, ProjectileEffect)); } }
public static void SpawnDoot(int direction) { Doot doot; if (direction == 0) { doot = new Doot(Sprites.Doot, boss.Pos, !boss.FacingLeft); } else { doot = new Doot(Sprites.Doot, direction); } Projectiles.Add(doot); }
public void CreateProjectile(Projectile protoProjectile, Tile tile, Enemy target) { if (protoProjectile == null || tile == null || target == null) { return; } var projectileToCreate = new Projectile(protoProjectile) { Target = target, }; projectileToCreate.SetPosition(tile.X, tile.Y); Projectiles.Add(projectileToCreate); OnChange(); }
/// <summary> /// Adding / updating projectiles /// </summary> /// <param name="obj"></param> /// <param name="message"></param> public void AddProjectile(JObject obj, string message) { int id = (int)obj.First; Projectile proj = JsonConvert.DeserializeObject <Projectile>(message); if (!Projectiles.ContainsKey(id)) { Projectiles.Add(id, proj); } else { Projectiles[id] = Projectiles[id].Update(proj); } }
private void ReturnFire(Canvas canvas, Map map) { Point shootingPosition = GetPositionInCanvas(); Shot shot1 = new Shot(new Point(shootingPosition.Top + 100, shootingPosition.Left), canvas, map, _isLookingRight, this); Shot shot2 = new Shot(new Point(shootingPosition.Top + 120, shootingPosition.Left), canvas, map, _isLookingRight, this); Shot shot3 = new Shot(new Point(shootingPosition.Top + 140, shootingPosition.Left), canvas, map, _isLookingRight, this); Shot shot4 = new Shot(new Point(shootingPosition.Top + 160, shootingPosition.Left), canvas, map, _isLookingRight, this); Shot shot5 = new Shot(new Point(shootingPosition.Top + 180, shootingPosition.Left), canvas, map, _isLookingRight, this); Projectiles.Add(shot1); Projectiles.Add(shot2); Projectiles.Add(shot3); Projectiles.Add(shot4); Projectiles.Add(shot5); }
private void Shoot(Canvas canvas, Map map) { Point RightShootingPosition = new Point(GetPositionInCanvas().Top + _shootingVerticalOffset, GetPositionInCanvas().Left + _shootingHorizontalOffset); Point lefttShootingPosition = new Point(GetPositionInCanvas().Top + _shootingVerticalOffset, GetPositionInCanvas().Left - _shootingHorizontalOffset / 2); if (_isLookingRight) { Shot shot = new Shot(RightShootingPosition, canvas, map, true, this); Projectiles.Add(shot); } else { Shot shot = new Shot(lefttShootingPosition, canvas, map, false, this); Projectiles.Add(shot); } }
public void Attack(Prop attack, InputManager playerInputs, Camera pCam = null) { switch (attack.Name.ToLower()) { case "attack-melee": switch ((int)attack.Level) { case 1: Projectile tProj = new Projectile(attack); tProj.Init(position, playerInputs.MousePosition() + pCam.Position); Projectiles.Add(tProj); break; case 2: break; case 3: break; } break; case "attack-ranged": switch ((int)attack.Level) { case 1: break; case 2: break; case 3: break; } break; } }
public void AddLaser(string effectName, float toX, float toY, bool affectAsCastIsOver = true) { var l = new Laser( _game, Owner.X, Owner.Y, (int)SpellData.LineWidth, Owner, new Target(toX, toY), this, effectName, SpellData.Flags, affectAsCastIsOver, _futureProjNetId ); Projectiles.Add(l.NetId, l); _game.ObjectManager.AddObject(l); _futureProjNetId = _networkIdManager.GetNewNetId(); }
void process_Elapsed(object sender, ElapsedEventArgs e) { CanvasGame.Dispatcher.Invoke(new Action(() => { IsMoveTank = false; switch (FirstKeystroke) { case Key.Right: UserTank.Rotation(true); break; case Key.Left: UserTank.Rotation(false); break; case Key.Up: IsMoveTank = true; break; case Key.Down: break; case Key.Space: var pro = new Projectile(this.CanvasGame, UserTank.Position, UserTank.Direction); Projectiles.Add(pro); break; } if (CanMove(UserTank) && IsMoveTank) { UserTank.MoveForward(); } else { IsMoveTank = false; } })); FirstKeystroke = null; }
public void AddCone(string effectName, float toX, float toY, float angleDeg, bool affectAsCastIsOver = true) { var c = new Cone( _game, Owner.X, Owner.Y, (int)SpellData.LineWidth, Owner, new Target(toX, toY), this, effectName, SpellData.Flags, affectAsCastIsOver, angleDeg, _futureProjNetId ); Projectiles.Add(c.NetId, c); _game.ObjectManager.AddObject(c); _futureProjNetId = _networkIdManager.GetNewNetId(); }
//Shooting action public void Shoot(Canvas canvas, Map map) { Point RightShootingPosition = new Point(GetPositionInCanvas().Top + _shootingPositionVerticalOffset, GetPositionInCanvas().Left + _shootingPositionHotizontalOffset); Point lefttShootingPosition = new Point(GetPositionInCanvas().Top + _shootingPositionVerticalOffset, GetPositionInCanvas().Left - _shootingPositionHotizontalOffset / 2); if (_isLookingRight) //right shot { Shot shot = new Shot(RightShootingPosition, canvas, map, true, this); Projectiles.Add(shot); } if (!_isLookingRight) //left shot { Shot shot = new Shot(lefttShootingPosition, canvas, map, false, this);; Projectiles.Add(shot); } if (map.GetBoss() == null) { _ammo--; } }
private void DoWithTanks() { Array values = Enum.GetValues(typeof(Direction)); Direction tankDir = (Direction)values.GetValue(random.Next(values.Length)); //выстрелы танков foreach (var t in Tanks) { if (random.Next(100) < 1) { switch (t.TankDirection) { case Direction.Left: Projectiles.Add(new Projectile(t.X - 22, t.Y - 5, t.TankDirection)); break; case Direction.Right: Projectiles.Add(new Projectile(t.X + 12, t.Y - 5, t.TankDirection)); break; case Direction.Up: Projectiles.Add(new Projectile(t.X - 5, t.Y - 22, t.TankDirection)); break; case Direction.Down: Projectiles.Add(new Projectile(t.X - 5, t.Y + 12, t.TankDirection)); break; } } } //расчёт нового направления танка foreach (var a in Walls) { for (int i = 0; i < Tanks.Count; i++) { bool wallFlag = false; if (random.Next(100) < 1) { Tanks[i].Turn(tankDir); } switch (Tanks[i].TankDirection) { case Direction.Left: if (AllCollision.BoxCollides(Tanks[i].X - 1, Tanks[i].Y, 20, 20, a.XLeft, a.YUp, a.XRight - a.XLeft, a.YDown - a.YUp)) { wallFlag = true; } break; case Direction.Right: if (AllCollision.BoxCollides(Tanks[i].X + 1, Tanks[i].Y, 20, 20, a.XLeft, a.YUp, a.XRight - a.XLeft, a.YDown - a.YUp)) { wallFlag = true; } break; case Direction.Up: if (AllCollision.BoxCollides(Tanks[i].X, Tanks[i].Y - 1, 20, 20, a.XLeft, a.YUp, a.XRight - a.XLeft, a.YDown - a.YUp)) { wallFlag = true; } break; case Direction.Down: if (AllCollision.BoxCollides(Tanks[i].X, Tanks[i].Y + 1, 20, 20, a.XLeft, a.YUp, a.XRight - a.XLeft, a.YDown - a.YUp)) { wallFlag = true; } break; } if (wallFlag) { Tanks[i].TurnAround(); } } } //проверка на разворот перед границей танка foreach (var element in Tanks) { switch (element.TankDirection) { case Direction.Left: if (element.X - 1 < 0) { element.TurnAround(); } break; case Direction.Right: if (element.X + 21 > _fieldWidth) { element.TurnAround(); } break; case Direction.Up: if (element.Y - 1 < 0) { element.TurnAround(); } break; case Direction.Down: if (element.Y + 21 > _fieldHeight) { element.TurnAround(); } break; } } //столкновение танков for (int i = 0; i < Tanks.Count; i++) { for (int j = 0; j < Tanks.Count; j++) { switch (Tanks[i].TankDirection) { case Direction.Left: if (AllCollision.BoxCollides(Tanks[i].X - 2, Tanks[i].Y, 20, 20, Tanks[j].X, Tanks[j].Y, 20, 20) && (i != j)) { Tanks[i].TurnAround(); Tanks[j].TurnAround(); } break; case Direction.Right: if (AllCollision.BoxCollides(Tanks[i].X + 2, Tanks[i].Y, 20, 20, Tanks[j].X, Tanks[j].Y, 20, 20) && (i != j)) { Tanks[i].TurnAround(); Tanks[j].TurnAround(); } break; case Direction.Up: if (AllCollision.BoxCollides(Tanks[i].X, Tanks[i].Y - 2, 20, 20, Tanks[j].X, Tanks[j].Y, 20, 20) && (i != j)) { Tanks[i].TurnAround(); Tanks[j].TurnAround(); } break; case Direction.Down: if (AllCollision.BoxCollides(Tanks[i].X, Tanks[i].Y + 2, 20, 20, Tanks[j].X, Tanks[j].Y, 20, 20) && (i != j)) { Tanks[i].TurnAround(); Tanks[j].TurnAround(); } break; } } } //столкновение танков с пулей foreach (var a in PackmanProjectiles) { for (int i = 0; i < Tanks.Count; i++) { if (AllCollision.BoxCollides(Tanks[i].X, Tanks[i].Y, 20, 20, a.X, a.Y, 10, 10)) { Tanks.Remove(Tanks[i]); CreateTanks(); break; } } } //движение foreach (var t in Tanks) { t.Run(); } }
/// <summary> /// Register a projectile /// </summary> /// <param name="projectile"></param> public void RegisterProjectile(Projectile projectile) { Projectiles.Add(projectile); }
public void AddProjectile(Projectile projectile) // Adds a projectiles to the projectile list { Projectiles.Add(projectile); }
public void Add(Projectile p) { Projectiles.Add(p); }
public void AddProjectile(Projectile proj) { Projectiles.Add(proj); }
public void isPlayerHit() { double distance; for (int j = Projectiles.Count - 1; j >= 0; j--) { if (!(CurrentPlayer.Location != null)) { continue; } if (!(Projectiles[j].Location != null)) { continue; } if (Projectiles[j].Owner == 0) { continue; } distance = Math.Sqrt((CurrentPlayer.Location.X - Projectiles[j].Location.X) * (CurrentPlayer.Location.X - Projectiles[j].Location.X) + (CurrentPlayer.Location.Y - Projectiles[j].Location.Y) * (CurrentPlayer.Location.Y - Projectiles[j].Location.Y)); if (distance < CurrentPlayer.HitRadius + Projectiles[j].HitRadius) { CurrentPlayer.Health -= Projectiles[j].Damage; for (int i = 0; i < Projectiles[j].Buffs.Count; i++) { CurrentPlayer.Buffs.Add(new Buff(Projectiles[j].Buffs[i])); } if (!(CurrentPlayer.Health > 0)) { Time.Stop(); DForm.DeathCall(); } if (CurrentPlayer.Location != null) { Effect NewEffect = new Effect(); NewEffect.ArtIndex = 0; NewEffect.Lifetime = 25; NewEffect.Location = Projectiles[j].Location; Effects.Add(NewEffect); } for (int k = 0; k < Projectiles[j].Summons.Count; k++) { if (Projectiles[j].Summons[k].Event == SummonActivationType.OnHit || Projectiles[j].Summons[k].Event == SummonActivationType.OnBoth) { if (Projectiles[j].Summons[k].Type == SummonType.Projectile) { Projectile P = new Projectile(Projectiles[j].Summons[k].Projectile); P.Location += Projectiles[j].Location; P.Facing += Projectiles[j].Facing + Projectiles[j].Summons[k].Facing; P.Owner = Projectiles[j].Owner; Projectiles.Add(P); } else if (Projectiles[j].Summons[k].Type == SummonType.Enemy) { Enemy E = new Enemy(_DataPool.Enemies[Projectiles[j].Summons[k].Enemy]); E.Location += Projectiles[j].Location; E.Facing = Projectiles[j].Facing; this._Enemies.Add(E); } } } if (Projectiles[j].Behave.Sustainable) { Projectiles[j].Health -= Projectiles[j].Damage; if (Projectiles[j].Health <= 0) { Projectiles[j].Location = null; } } else { Projectiles[j].Location = null; } } } }