public new void Attack(Soldier Enemy) { if (Enemy.isEnemy && (Enemy.POSITION - this.POSITION) <= this.RANGE) Enemy.HP -= this.ATK; if (Enemy.HP <= 0) { if (Enemy.GetType() == typeof(Saber)) { EXP += 1; } else if (Enemy.GetType() == typeof(Saber)) { EXP += 1; } else if (Enemy.GetType() == typeof(Archer)) { EXP += 1; } else if (Enemy.GetType() == typeof(Caster)) { EXP += 1; } else if (Enemy.GetType() == typeof(Berserker)) { EXP += 1; } else if (Enemy.GetType() == typeof(Rider)) { EXP += 1; } else if (Enemy.GetType() == typeof(Lancer)) { EXP += 1; } else if (Enemy.GetType() == typeof(Assassin)) { EXP += 1; } else if (Enemy.GetType() == typeof(HERO)) { EXP += 1; } else if (Enemy.GetType() == typeof(BOSS)) { EXP += 1; } } }
//攻擊敵方 public bool Attack(Soldier Enemy) { //兩個兵陣營不相同 && 兩兵間距離小於攻擊範圍 if ((Enemy.isEnemy!=this.isEnemy) && Math.Abs(Enemy.POSITION - this.POSITION) <= this.RANGE) { Enemy.GetHurt(ATK, null); if (!isAttack) //判斷是否需要換gif圖 { if (imgSourceAttack == null) imgSourceAttack = imgSourceMove.Replace("Move", "Attack"); //MessageBox.Show(imgSourceAttack); var _image = new BitmapImage(); _image.BeginInit(); _image.UriSource = new Uri(imgSourceAttack, UriKind.Absolute); _image.EndInit(); ImageBehavior.SetAnimatedSource(Image, _image); isAttack = true; } return true; } return false; }