public IList GetSelectionRange() { IList selectionRange = new List<Transform>(); AttackCalculation atkCal = new AttackCalculation(attacker); foreach(Transform map in atkCal.GetMagicTarget(atkCal.Attacker)){ selectionRange.Add(map); } return selectionRange; }
public Transform GetAttackTarget(Transform chess) { Transform target = null; IList attackableList = new List<Transform>(); CharacterProperty chessProperty = chess.GetComponent<CharacterProperty>(); AttackCalculation aCal = new AttackCalculation(chess); attackableList = aCal.GetAttableTarget(aCal.Attacker); if(attackableList.Count > 0){ foreach(Transform map in attackableList){ Transform gf = MapHelper.GetMapOccupiedObj(map); if(chessProperty.Damage >= gf.GetComponent<CharacterProperty>().Hp){ target = gf; break; }else{ target = null; } } if(target == null){ foreach(Transform map in attackableList){ Transform gf = MapHelper.GetMapOccupiedObj(map); AttackCalculation atkCal = new AttackCalculation(gf); IList fightBackList = atkCal.GetAttableTarget(atkCal.Attacker); if(fightBackList != null && fightBackList.Count>0){ bool fightBack = false; foreach(Transform nMap in fightBackList){ Transform ngf = MapHelper.GetMapOccupiedObj(nMap); if(ngf == chess){ fightBack = true; break; }else{ fightBack = false; } } if(!fightBack){ target = gf; break; }else{ target = null; } }else{ continue; } } } if(target == null){ foreach(Transform map in attackableList){ Transform gf = MapHelper.GetMapOccupiedObj(map); if(chessProperty.Hp > gf.GetComponent<CharacterProperty>().Damage){ target = gf; break; } } } } return target; }
bool KillAble(Transform chess, int mode, int damage) { bool killSomeone = false; IList attackableList = new List <Transform>(); CharacterProperty chessProperty = chess.GetComponent <CharacterProperty>(); AttackCalculation aCal = new AttackCalculation(chess); attackableList = aCal.GetAttableTarget(aCal.Attacker); if (mode == 0) { foreach (Transform map in attackableList) { Transform target = MapHelper.GetMapOccupiedObj(map); CharacterProperty targetProperty = target.GetComponent <CharacterProperty>(); if (damage >= targetProperty.Hp) { killSomeone = true; break; } else { killSomeone = false; } } } else if (mode == 1) { foreach (Transform map in attackableList) { Transform target = MapHelper.GetMapOccupiedObj(map); AttackCalculation atkCal = new AttackCalculation(target); IList fightBackList = atkCal.GetAttableTarget(atkCal.Attacker); if (fightBackList != null && fightBackList.Count > 0) { foreach (Transform mapX in fightBackList) { Transform gf = MapHelper.GetMapOccupiedObj(mapX); if (gf == chess) { killSomeone = false; break; } else { killSomeone = true; } } } else { killSomeone = true; } } } return(killSomeone); }
public IList GetSelectionRange() { IList selectionRange = new List <Transform>(); AttackCalculation atkCal = new AttackCalculation(attacker); foreach (Transform map in atkCal.GetMagicTarget(atkCal.Attacker)) { selectionRange.Add(map); } return(selectionRange); }
public static bool Attackable(Transform chess) { MoveCharacter mc = Camera.main.GetComponent<MoveCharacter>(); bool able = false; if(!mc.MoveMode){ AttackCalculation atc = new AttackCalculation(chess); able = (atc.GetAttableTarget(atc.Attacker).Count>0); }else{ able = false; } return able; }
public IList GetSelectionRange() { IList selectionRange = new List <Transform>(); AttackCalculation atkCal = new AttackCalculation(attacker); foreach (Transform map in atkCal.GetMagicTarget(atkCal.Attacker)) { Transform chess = MapHelper.GetMapOccupiedObj(map); if (!chess.GetComponent <CharacterProperty>().Summoner) { selectionRange.Add(map); } } return(selectionRange); }
bool attackable(Transform chess) { MoveCharacter mc = transform.GetComponent <MoveCharacter>(); bool able = false; if (!mc.MoveMode) { AttackCalculation atc = new AttackCalculation(chess); able = (atc.GetAttableTarget(atc.Attacker).Count > 0); } else { able = false; } return(able); }
public void TestOnNormalAttack() { // Create Mock var random = new Mock <IRandom>(); random.Setup(r => r.Random()).Returns(1); var actorRepository = new Mock <IActorRepository>(); var skillRepository = new Mock <ISkillRepository>(); var attackerId = new ActorId("Attacker"); var attacker = CreateActor(attackerId); var victimId = new ActorId("Victim"); var victim = CreateActor(victimId); var skill = CreateSkill(); actorRepository.Setup(repo => repo.Find(attackerId)) .Returns(attacker); actorRepository.Setup(repo => repo.Find(victimId)) .Returns(victim); skillRepository.Setup(repo => repo.Find(It.IsAny <SkillId>())) .Returns(skill); // Create Builders var innerBuilder = new AttackPowerBuilderInner(); var attackPowerBuilder = new AttackPowerBuilder(innerBuilder); var defenseBuilder = new DefenseRateBuilder(); // Create Attack Calculation var damageRate = new Rate(0.06f); var attackCalculation = new AttackCalculation( actorRepository.Object, skillRepository.Object, attackPowerBuilder, defenseBuilder, random.Object, damageRate); var damage = attackCalculation.ExecuteCalculation( attackerId, victimId, new SkillId("Dummy")); // Check Damage var damageListener = new Mock <IDamageListener>(); damageListener.Setup(l => l.ListenDamage(It.IsAny <int>())) .Callback <int>(val => Assert.AreEqual(300, val)); damage.NotifyDamage(damageListener.Object); }
public Transform GetAttackTarget(Transform chess) { Transform target = null; IList attackableList = new List <Transform>(); CharacterProperty chessProperty = chess.GetComponent <CharacterProperty>(); AttackCalculation aCal = new AttackCalculation(chess); attackableList = aCal.GetAttableTarget(aCal.Attacker); if (attackableList.Count > 0) { foreach (Transform map in attackableList) { Transform gf = MapHelper.GetMapOccupiedObj(map); if (chessProperty.Damage >= gf.GetComponent <CharacterProperty>().Hp) { target = gf; break; } else { target = null; } } if (target == null) { foreach (Transform map in attackableList) { Transform gf = MapHelper.GetMapOccupiedObj(map); AttackCalculation atkCal = new AttackCalculation(gf); IList fightBackList = atkCal.GetAttableTarget(atkCal.Attacker); if (fightBackList != null && fightBackList.Count > 0) { bool fightBack = false; foreach (Transform nMap in fightBackList) { Transform ngf = MapHelper.GetMapOccupiedObj(nMap); if (ngf == chess) { fightBack = true; break; } else { fightBack = false; } } if (!fightBack) { target = gf; break; } else { target = null; } } else { continue; } } } if (target == null) { foreach (Transform map in attackableList) { Transform gf = MapHelper.GetMapOccupiedObj(map); if (chessProperty.Hp > gf.GetComponent <CharacterProperty>().Damage) { target = gf; break; } } } } return(target); }
bool KillAble(Transform chess, int mode, int damage) { bool killSomeone = false; IList attackableList = new List<Transform>(); CharacterProperty chessProperty = chess.GetComponent<CharacterProperty>(); AttackCalculation aCal = new AttackCalculation(chess); attackableList = aCal.GetAttableTarget(aCal.Attacker); if(mode == 0){ foreach(Transform map in attackableList){ Transform target = MapHelper.GetMapOccupiedObj(map); CharacterProperty targetProperty = target.GetComponent<CharacterProperty>(); if(damage >= targetProperty.Hp){ killSomeone = true; break; }else{ killSomeone = false; } } }else if(mode == 1){ foreach(Transform map in attackableList){ Transform target = MapHelper.GetMapOccupiedObj(map); AttackCalculation atkCal = new AttackCalculation(target); IList fightBackList = atkCal.GetAttableTarget(atkCal.Attacker); if(fightBackList != null && fightBackList.Count>0){ foreach(Transform mapX in fightBackList){ Transform gf = MapHelper.GetMapOccupiedObj(mapX); if(gf == chess){ killSomeone = false; break; }else{ killSomeone = true; } } }else{ killSomeone = true; } } } return killSomeone; }