예제 #1
0
 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;
 }
예제 #2
0
    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;
    }
예제 #3
0
    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);
    }
예제 #4
0
    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);
    }
예제 #5
0
 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;
 }
예제 #6
0
파일: ChaosAid.cs 프로젝트: qipa/BattleCard
    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);
    }
예제 #7
0
파일: MainUI.cs 프로젝트: qipa/BattleCard
    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);
    }
예제 #8
0
        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);
        }
예제 #9
0
    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);
    }
예제 #10
0
 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;
 }