public override bool CanUse() { if (base.CanUse() == false) { return(false); } Rectangle area = new Rectangle(); int range = missileRange - 1; if (Owner.LastDir == Dir.Up) { area = new Rectangle(Owner.CurRawPos.X, Owner.CurRawPos.Y - range * Globals.TileSize, Globals.TileSize, range * Globals.TileSize); } else if (Owner.LastDir == Dir.Down || Owner.LastDir == Dir.Stand) { area = new Rectangle(Owner.CurRawPos.X, Owner.CurRawPos.Y + Owner.charType.Size.Y, Globals.TileSize, range * Globals.TileSize); } else if (Owner.LastDir == Dir.Left) { area = new Rectangle(Owner.CurRawPos.X - range * Globals.TileSize, Owner.CurRawPos.Y, range * Globals.TileSize, Globals.TileSize); } else if (Owner.LastDir == Dir.Right) { area = new Rectangle(Owner.CurRawPos.X + Owner.charType.Size.X, Owner.CurRawPos.Y, range * Globals.TileSize, Globals.TileSize); } if (GamePlay.GetEnemies(area, Owner.team).Count > 0) { return(true); } return(false); }
private void Explode(Missile m) { SoundManager.PlayByFileName(explodeSFX); Rectangle area = new Rectangle(m.curPos.X - 12, m.curPos.Y - 12, 56, 56); Art explosion = new Art(); explosion.SrcImage = contactArt; explosion.AutoRemove = true; explosion.Frames = contactArtFrames; explosion.FrameInterval = 50; explosion.SrcRect = new Rectangle(0, 0, Globals.TileSize * 2, Globals.TileSize * 2); explosion.Position = area; Game.World.AfterCharArts.Add(explosion); List <Character> hitTargets = GamePlay.GetEnemies(area, team); foreach (Character c in hitTargets) { if (GamePlay.CheckHit(Owner, c, this)) { GamePlay.InfictDamage(Owner, c, GamePlay.DamageCalculation(Owner, c, this)); } } }
public override bool CanUse() { if (base.CanUse() == false) { return(false); } Rectangle area = new Rectangle(); int range = 10 - 1; //area = new Rectangle(Owner.CurRawPos.X, Owner.CurRawPos.Y - range * Globals.TileSize, Globals.TileSize, range * Globals.TileSize); //if (GamePlay.GetEnemies(area, Owner.team).Count > 0) return true; //area = new Rectangle(Owner.CurRawPos.X, Owner.CurRawPos.Y + Owner.charType.Size.Y, Globals.TileSize, range * Globals.TileSize); //if (GamePlay.GetEnemies(area, Owner.team).Count > 0) return true; //area = new Rectangle(Owner.CurRawPos.X - range * Globals.TileSize, Owner.CurRawPos.Y, range * Globals.TileSize, Globals.TileSize); //if (GamePlay.GetEnemies(area, Owner.team).Count > 0) return true; //area = new Rectangle(Owner.CurRawPos.X + Owner.charType.Size.X, Owner.CurRawPos.Y, range * Globals.TileSize, Globals.TileSize); //if (GamePlay.GetEnemies(area, Owner.team).Count > 0) return true; area = new Rectangle(Owner.CurRawPos.X - range * Globals.TileSize, Owner.CurRawPos.Y - range * Globals.TileSize, Owner.charType.Size.X + 2 * range * Globals.TileSize, Owner.charType.Size.Y + 2 * range * Globals.TileSize); if (GamePlay.GetEnemies(area, Owner.team).Count > 0) { return(true); } return(false); }
public override bool CanUse() { if (base.CanUse() == false) { return(false); } Rectangle area = new Rectangle(Owner.CurRawPos.X + 12, Owner.CurRawPos.Y + 12, Owner.charType.Size.X - 24, Owner.charType.Size.Y - 24); if (Owner.LastDir == Dir.Up) { area.Y -= 3 * 4; } else if (Owner.LastDir == Dir.Down) { area.Y += 3 * 4; } else if (Owner.LastDir == Dir.Left) { area.X -= 3 * 4; } else if (Owner.LastDir == Dir.Right) { area.X += 3 * 4; } if (GamePlay.GetEnemies(area, Owner.team).Count > 0) { return(true); } return(false); }
public void Act() { if (IsCasting) { return; } Rectangle area = new Rectangle(CurRawPos.X - charType.Range * Globals.TileSize, CurRawPos.Y - charType.Range * Globals.TileSize, charType.Range * 2 * Globals.TileSize + charType.Size.X, charType.Range * 2 * Globals.TileSize + charType.Size.Y); List <Character> EnemiesInRange = GamePlay.GetEnemies(area, team); if (EnemiesInRange.Count > 0) { //Có kẻ dịch trong phạm vi BaseSkill SkillCanAct = GetCanActSkill(); if (SkillCanAct != null) { //Có skill xài được --> gọi hàm Cast() của skill SkillCanAct.Cast(); } else { //TH2: không có skill xài dc --> tiến đến kẻ địch. (dùng thuật toán A*) //Set target (kẻ địch) gần nhất SetTarget(EnemiesInRange); FindNewPathTimer += Game.ElapsedGameTime; if (FindNewPathTimer >= Globals.AI_FIND_NEW_PATH_INTERVAL) { FindNewPathTimer = 0; if (Globals.Mode == HardMode.Hard) { AIPath = PathFinding.Find(CurPos, Target.CurPos, this); } } else { if (AIPath == null || AIPath.Count == 0) { AIPath = null; MoveTo(Target.CurPos); } else { MoveTo(AIPath[0]); } } } } else { //Không có kẻ địch trong phạm vi AIPath = null; Move(GetRandomDir()); } }
public override void Casting() { int forORback; if (CurCastingStage <= 3) { forORback = 1; } else { forORback = -1; } Owner.AniFrame += 1; if (Owner.LastDir == Dir.Up) { Owner.OffSet.Y -= forORback * 4; } else if (Owner.LastDir == Dir.Down) { Owner.OffSet.Y += forORback * 4; } else if (Owner.LastDir == Dir.Left) { Owner.OffSet.X -= forORback * 4; } else if (Owner.LastDir == Dir.Right) { Owner.OffSet.X += forORback * 4; } if (CurCastingStage == 1) { SoundManager.PlayByFileName("Attack"); } else if (CurCastingStage == 3) { Rectangle area = new Rectangle(Owner.CurRawPos.X + 12, Owner.CurRawPos.Y + 12, Owner.charType.Size.X - 24, Owner.charType.Size.Y - 24); List <Character> hitTargets = GamePlay.GetEnemies(area, Owner.team); foreach (Character c in hitTargets) { if (GamePlay.CheckHit(Owner, c, this)) { GamePlay.InfictDamage(Owner, c, GamePlay.DamageCalculation(Owner, c, this)); } } } else if (CurCastingStage >= CastingStages) { Owner.FrameNum = 2; Owner.AniFrame = Owner.AniFrame; Finished = true; Owner.IsCasting = false; } }
public override bool CanUse() { if (base.CanUse() == false) { return(false); } Rectangle area = new Rectangle(); area = new Rectangle(Owner.CurRawPos.X + 6, Owner.CurRawPos.Y - 20, 20, 20); if (GamePlay.GetEnemies(area, Owner.team).Count > 0) { Owner.LastDir = Dir.Up; return(true); } area = new Rectangle(Owner.CurRawPos.X + 6, Owner.CurRawPos.Y + Owner.charType.Size.Y, 20, 20); if (GamePlay.GetEnemies(area, Owner.team).Count > 0) { Owner.LastDir = Dir.Down; return(true); } area = new Rectangle(Owner.CurRawPos.X - 20, Owner.CurRawPos.Y + 6, 20, 20); if (GamePlay.GetEnemies(area, Owner.team).Count > 0) { Owner.LastDir = Dir.Left; return(true); } area = new Rectangle(Owner.CurRawPos.X + Owner.charType.Size.X, Owner.CurRawPos.Y + 6, 20, 20); if (GamePlay.GetEnemies(area, Owner.team).Count > 0) { Owner.LastDir = Dir.Right; return(true); } return(false); }
public override void Casting() { if (CurCastingStage == 1) { SoundManager.PlayByFileName("Dash"); ChangeFrameWhenCharging(); } if (GamePlay.IsBlocked(Owner, distance, Owner.LastDir)) { CurCastingStage = CastingStages; } else { if (Owner.LastDir == Dir.Up) { Owner.OffSet.Y -= distance; } else if (Owner.LastDir == Dir.Down) { Owner.OffSet.Y += distance; } else if (Owner.LastDir == Dir.Left) { Owner.OffSet.X -= distance; } else if (Owner.LastDir == Dir.Right) { Owner.OffSet.X += distance; } Owner.SetPos(); Owner.AniFrame += 1; List <Character> hitTargets = GamePlay.GetEnemies(Owner.HitBox, Owner.team); if (hitTargets.Count > 0) { SoundManager.PlayByFileName("Explosion"); Rectangle area = new Rectangle(Owner.CurRawPos.X - 12, Owner.CurRawPos.Y - 12, 56, 56); Art explosion = new Art(); explosion.SrcImage = "Explosion"; explosion.AutoRemove = true; explosion.Frames = 7; explosion.FrameInterval = 50; explosion.SrcRect = new Rectangle(0, 0, Globals.TileSize * 2, Globals.TileSize * 2); explosion.Position = area; Game.World.AfterCharArts.Add(explosion); List <Character> targets = GamePlay.GetEnemies(area, Owner.team); foreach (Character c in hitTargets) { if (GamePlay.CheckHit(Owner, c, this)) { GamePlay.InfictDamage(Owner, c, GamePlay.DamageCalculation(Owner, c, this)); } } CurCastingStage = CastingStages; } } if (CurCastingStage >= CastingStages) { Owner.ResetPos(); Finished = true; Owner.IsCasting = false; } }
public override void Casting() { Owner.AniFrame += 1; foreach (Art a in ArtList) { a.Position.Y += Globals.TileSize * 2; a.SkillCounter += 1; if (a.SkillCounter >= 5 && !a.remove) { a.remove = true; SoundManager.PlayByFileName("Explosion"); Rectangle area = new Rectangle(a.Position.X + 8, a.Position.Y + 8, a.Position.Width - 16, a.Position.Height - 16); Art explosion = new Art(); explosion.SrcImage = "Explosion"; explosion.AutoRemove = true; explosion.Frames = 7; explosion.FrameInterval = 50; explosion.SrcRect = new Rectangle(0, 0, Globals.TileSize * 2, Globals.TileSize * 2); explosion.Position = a.Position; Game.World.AfterCharArts.Add(explosion); List <Character> hitTargets = GamePlay.GetEnemies(area, Team.Enemy); foreach (Character c in hitTargets) { if (GamePlay.CheckHit(Owner, c, this)) { GamePlay.InfictDamage(Owner, c, GamePlay.DamageCalculation(Owner, c, this)); } } } } if (CurCastingStage % 5 == 0 && CurCastingStage < CastingStages - 10) { SoundManager.PlayByFileName("ThrowBomb"); Art newArt = new Art(); newArt.SrcImage = "Ball"; newArt.SrcRect = new Rectangle(0, 0, Globals.TileSize * 4, Globals.TileSize * 4); Rectangle loc = new Rectangle( Globals.gen.Next(Game.Player.CurRawPos.X - 3 * Globals.TileSize, Game.Player.CurRawPos.X + Game.Player.charType.Size.X + 2 * Globals.TileSize), Globals.gen.Next(Game.Player.CurRawPos.Y - 3 * Globals.TileSize, Game.Player.CurRawPos.Y + Game.Player.charType.Size.Y + 2 * Globals.TileSize), Globals.TileSize * 4, Globals.TileSize * 4); newArt.Position = new Rectangle(loc.X, loc.Y - 10 * Globals.TileSize, loc.Width, loc.Height); ArtList.Add(newArt); Game.World.AfterCharArts.Add(newArt); } if (CurCastingStage % 20 == 0) { SoundManager.PlayByFileName("Laugh"); } if (CurCastingStage >= CastingStages) { Finished = true; foreach (Art a in ArtList) { a.remove = true; } ArtList.Clear(); Owner.IsCasting = false; Owner.charType.Source.srcPos.Y = 0; } }
public void Act() { if (IsCasting) { return; } tmrCast += Game.ElapsedGameTime; if (tmrCast >= tmrCastInterval) { tmrCast = 0; canCast = true; MoveAround = false; tmrCastInterval = Globals.gen.Next(WaitAfterAttack.X, WaitAfterAttack.Y + 1); if (Globals.Mode == HardMode.Hard && charType.Index != 7 && charType.Index != 10) { tmrCast = tmrCastInterval; } } if (canCast) { Rectangle area = new Rectangle(CurRawPos.X - charType.Range * Globals.TileSize, CurRawPos.Y - charType.Range * Globals.TileSize, charType.Range * 2 * Globals.TileSize + charType.Size.X, charType.Range * 2 * Globals.TileSize + charType.Size.Y); List <Character> EnemiesInRange = GamePlay.GetEnemies(area, team); if (MoveAround) { EnemiesInRange.Clear(); } if (EnemiesInRange.Count > 0) { //Có kẻ dịch trong phạm vi BaseSkill SkillCanAct = GetCanActSkill(); if (SkillCanAct != null) { //Có skill xài được --> gọi hàm Cast() của skill if (canCast) { SkillCanAct.Cast(); canCast = false; } else if (Globals.Mode == HardMode.Easy) { MoveAround = true; Move(GetRandomDir()); } } else { //TH2: không có skill xài dc --> tiến đến kẻ địch. (dùng thuật toán A*) //Set target (kẻ địch) gần nhất SetTarget(EnemiesInRange); FindNewPathTimer += Game.ElapsedGameTime; if (FindNewPathTimer >= Globals.AI_FIND_NEW_PATH_INTERVAL) { FindNewPathTimer = 0; if (Globals.Mode == HardMode.Hard || Globals.Mode == HardMode.Normal) { AIPath = PathFinding.Find(CurPos, Target.CurPos, this); } } else { if (AIPath == null || AIPath.Count == 0) { AIPath = null; MoveTo(Target.CurRawPos); } else { while (AIPath.Count > 0 && HitBox.IntersectsWith(new Rectangle(AIPath[0].X * Globals.TileSize, AIPath[0].Y * Globals.TileSize, Globals.TileSize, Globals.TileSize))) { AIPath.RemoveAt(0); } if (AIPath.Count > 1) { MoveTo(new Point(AIPath[0].X * Globals.TileSize, AIPath[0].Y * Globals.TileSize)); } else { AIPath = null; MoveTo(Target.CurRawPos); } } } } } else { //Không có kẻ địch trong phạm vi AIPath = null; Move(GetRandomDir()); } } else { AIPath = null; Move(GetRandomDir()); } }
public override void Casting() { if (CurCastingStage == 0) { //Tạo art Art newArt = new Art(); newArt.SrcImage = swordArt; newArt.SrcRect = new Rectangle(0, 0, Globals.TileSize, Globals.TileSize); newArt.Position = new Rectangle(Owner.CurRawPos.X, Owner.CurRawPos.Y, Globals.TileSize, Globals.TileSize); //newArt.Angle = Game.GetAngleByCharacterFacing(Owner, true, true); newArt.Angle = Owner.LastDir; ArtList.Add(newArt); if (Owner.LastDir == Dir.Up) { Game.World.BeforeCharArts.Add(newArt); } else { Game.World.AfterCharArts.Add(newArt); } } else if (CurCastingStage <= 5) { //Di chuyển art của cây kiếm đi về phía trước if (Owner.LastDir == Dir.Up) { ArtList[0].Position.Y -= 4; } else if (Owner.LastDir == Dir.Down) { ArtList[0].Position.Y += 4; } else if (Owner.LastDir == Dir.Left) { ArtList[0].Position.X -= 4; } else if (Owner.LastDir == Dir.Right) { ArtList[0].Position.X += 4; } } else { //Di chuyển art của cây kiếm lùi ra sau if (Owner.LastDir == Dir.Up) { ArtList[0].Position.Y += 4; } else if (Owner.LastDir == Dir.Down) { ArtList[0].Position.Y -= 4; } else if (Owner.LastDir == Dir.Left) { ArtList[0].Position.X += 4; } else if (Owner.LastDir == Dir.Right) { ArtList[0].Position.X -= 4; } } if (CurCastingStage == 5) { //Gây damage Rectangle area = new Rectangle(); if (Owner.LastDir == Dir.Up) { area = new Rectangle(Owner.CurRawPos.X + 6, Owner.CurRawPos.Y - 20, 20, 20); } else if (Owner.LastDir == Dir.Down) { area = new Rectangle(Owner.CurRawPos.X + 6, Owner.CurRawPos.Y + Owner.charType.Size.Y, 20, 20); } else if (Owner.LastDir == Dir.Left) { area = new Rectangle(Owner.CurRawPos.X - 20, Owner.CurRawPos.Y + 6, 20, 20); } else if (Owner.LastDir == Dir.Right) { area = new Rectangle(Owner.CurRawPos.X + Owner.charType.Size.X, Owner.CurRawPos.Y + 6, 20, 20); } List <Character> targets = GamePlay.GetEnemies(area, Owner.team); foreach (Character c in targets) { if (GamePlay.CheckHit(Owner, c, this)) { int damage = GamePlay.DamageCalculation(Owner, c, this); GamePlay.InfictDamage(Owner, c, damage); Owner.MP += (int)(Owner.MPMax * PercentManaRecover); } } } if (CurCastingStage >= CastingStages) { Finished = true; ArtList[0].remove = true; Owner.IsCasting = false; } }
public override void Casting() { if (CurCastingStage == 1) { SoundManager.PlayByFileName("Dash"); } if (GamePlay.IsBlocked(Owner, distance, Owner.LastDir)) { CurCastingStage = CastingStages; } else { if (Owner.LastDir == Dir.Up) { Owner.OffSet.Y -= distance; } else if (Owner.LastDir == Dir.Down) { Owner.OffSet.Y += distance; } else if (Owner.LastDir == Dir.Left) { Owner.OffSet.X -= distance; } else if (Owner.LastDir == Dir.Right) { Owner.OffSet.X += distance; } Owner.SetPos(); Owner.AniFrame += 1; SetShieldByOwnerPos(); List <Character> hitTargets = GamePlay.GetEnemies(Owner.HitBox, Owner.team); foreach (Character c in hitTargets) { if (GamePlay.CheckHit(Owner, c, this) && targetList.Contains(c) == false) { targetList.Add(c); SoundManager.PlayByFileName("Charge"); Art slash = new Art(); slash.SrcImage = "Slash"; slash.AutoRemove = true; slash.Frames = 6; slash.FrameInterval = 30; slash.SrcRect = new Rectangle(0, 0, Globals.TileSize * 2, Globals.TileSize * 2); slash.Position = new Rectangle(c.CurRawPos.X - 16, c.CurRawPos.Y - 16, Globals.TileSize * 2, Globals.TileSize * 2); ArtList.Add(slash); Game.World.AfterCharArts.Add(slash); GamePlay.InfictDamage(Owner, c, GamePlay.DamageCalculation(Owner, c, this)); } } } if (CurCastingStage >= CastingStages) { Owner.ResetPos(); Finished = true; ArtList[0].remove = true; ArtList.Clear(); targetList.Clear(); Owner.IsCasting = false; } }
public override void Casting() { if (CurCastingStage == 0) { //Tạo art Art newArt = new Art(); newArt.SrcImage = "Bite"; newArt.Frames = 5; newArt.FrameInterval = 10000; newArt.SrcRect = new Rectangle(0, 0, Globals.TileSize, Globals.TileSize); if (Owner.LastDir == Dir.Up) { newArt.Position = new Rectangle(Owner.CurRawPos.X, Owner.CurRawPos.Y - Globals.TileSize, Globals.TileSize, Globals.TileSize); } else if (Owner.LastDir == Dir.Down) { newArt.Position = new Rectangle(Owner.CurRawPos.X, Owner.CurRawPos.Y + Owner.charType.Size.Y, Globals.TileSize, Globals.TileSize); } else if (Owner.LastDir == Dir.Left) { newArt.Position = new Rectangle(Owner.CurRawPos.X - Globals.TileSize, Owner.CurRawPos.Y, Globals.TileSize, Globals.TileSize); } else if (Owner.LastDir == Dir.Right) { newArt.Position = new Rectangle(Owner.CurRawPos.X + Owner.charType.Size.X, Owner.CurRawPos.Y, Globals.TileSize, Globals.TileSize); } ArtList.Add(newArt); Game.World.AfterCharArts.Add(newArt); } else { ArtList[0].CurFrame += 1; } if (CurCastingStage == 3) { //Gây damage Rectangle area = new Rectangle(); if (Owner.LastDir == Dir.Up) { area = new Rectangle(Owner.CurRawPos.X + 6, Owner.CurRawPos.Y - 20, 20, 20); } else if (Owner.LastDir == Dir.Down) { area = new Rectangle(Owner.CurRawPos.X + 6, Owner.CurRawPos.Y + Owner.charType.Size.Y, 20, 20); } else if (Owner.LastDir == Dir.Left) { area = new Rectangle(Owner.CurRawPos.X - 20, Owner.CurRawPos.Y + 6, 20, 20); } else if (Owner.LastDir == Dir.Right) { area = new Rectangle(Owner.CurRawPos.X + Owner.charType.Size.X, Owner.CurRawPos.Y + 6, 20, 20); } List <Character> targets = GamePlay.GetEnemies(area, Owner.team); foreach (Character c in targets) { if (GamePlay.CheckHit(Owner, c, this)) { GamePlay.InfictDamage(Owner, c, GamePlay.DamageCalculation(Owner, c, this)); } } } if (CurCastingStage >= CastingStages) { Finished = true; ArtList[0].remove = true; Owner.IsCasting = false; } }