public static int DamageCalculation(Character attacker, Character target, BaseSkill skill) { //chạy code tính damage int damage; if (skill.Type == SkillType.Normal) { damage = attacker.ATK * skill.Power / (100 + target.DEF) * Globals.gen.Next(80, 121) / 100; } else { damage = attacker.SATK * skill.Power / (100 + target.SDEF) * Globals.gen.Next(80, 121) / 100; } if (target == Game.Player && damage < target.HPMax / 40) { damage = Globals.gen.Next(target.HPMax / 100, target.HPMax / 40); } if (attacker.team == Team.Enemy && target == Game.Player) { damage = damage * (int)Globals.Mode / 100; } return(damage); }
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 static Brush GetSkillStringColor(BaseSkill s) { if (s.Cooldown > 0) { return(Brushes.Gray); } else { return(Brushes.Gold); } }
public static bool CheckHit(Character attacker, Character target, BaseSkill skill) { if (Globals.gen.Next(0, 100) <= skill.Accuracy) { return(true); } else { return(false); } }
public Missile(TileLayer Source, int Width, int Height, Character Owner, BaseSkill FromSkill, Point StartPos, Dir Direction, int Speed, int Range, double Angle = 0) { this.Source = Source; this.Size = new Point(Width, Height); this.Owner = Owner; this.FromSkill = FromSkill; this.Dir = Direction; this.Angle = Angle; this.curPos = StartPos; this.Range = Range; this.Speed = Speed; MovedDistance = 0; }
public static bool CheckHit(Character attacker, Character target, BaseSkill skill) { //Thay code kiểm tra xem có miss hay không dựa vào accuracy của skill int hit = Globals.gen.Next(1, 101); if (hit < 20) { return(false); } else { return(true); } return(true); }
public static int DamageCalculation(Character attacker, Character target, BaseSkill skill) { //chạy code tính damage return(10); }
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()); } }