Пример #1
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;
    }
Пример #2
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);
    }
Пример #3
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;
 }
Пример #4
0
    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);
    }
Пример #5
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);
    }
Пример #6
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;
 }