コード例 #1
0
ファイル: UnitSet.cs プロジェクト: UpdateShu/ForceFury_Unity5
    public BaseUnitBehaviour GetTarget(BaseUnitBehaviour unit, BaseUnitBehaviour currentTarget,
                                       ArrayRO <BaseUnitBehaviour> possibleUnits)
    {
        UnitPlace currentTargetPlace = currentTarget != null ? currentTarget.Place
            : new UnitPlace()
        {
            Range = EUnitRange.None, Position = EUnitPosition.Middle
        };
        UnitPlace nextTargetPlace = GetNextTargetPlace(unit.Place, currentTargetPlace);

        while (!nextTargetPlace.Equals(currentTargetPlace))
        {
            if (nextTargetPlace.Range != EUnitRange.None || nextTargetPlace.Position != EUnitPosition.None)
            {
                BaseUnitBehaviour nextUnit = GetPlaceBaseUnitBehaviour(possibleUnits, nextTargetPlace);
                if (nextUnit != null && !nextUnit.UnitData.IsDead)
                {
                    return(nextUnit);
                }
            }
            nextTargetPlace = GetNextTargetPlace(unit.Place, nextTargetPlace);
        }
        if (currentTarget != null)
        {
            return(currentTarget);
        }
        else
        {
            BaseUnitBehaviour nextUnit = GetPlaceBaseUnitBehaviour(possibleUnits, currentTargetPlace);
            return(nextUnit != null && !nextUnit.UnitData.IsDead ? nextUnit : null);
        }
    }
コード例 #2
0
ファイル: UnitSet.cs プロジェクト: UpdateShu/ForceFury_Unity5
    public BaseUnitBehaviour GetNextAttackUnit(BaseUnitBehaviour attackUnit)
    {
        bool      currentIsAllyAttack = attackUnit != null && attackUnit.IsAlly;
        UnitPlace currentAttackPlace  = attackUnit != null ? attackUnit.Place
            : new UnitPlace()
        {
            Range = EUnitRange.Melee, Position = EUnitPosition.Middle
        };

        bool      nextIsAllyAttack = !currentIsAllyAttack;
        UnitPlace nextAttackPlace  = nextIsAllyAttack && attackUnit != null
            ? GetNextAttackPlace(currentAttackPlace) : currentAttackPlace;

        while (!(nextIsAllyAttack == currentIsAllyAttack && nextAttackPlace.Equals(currentAttackPlace)))
        {
            if (nextAttackPlace.Range != EUnitRange.None || nextAttackPlace.Position != EUnitPosition.None)
            {
                BaseUnitBehaviour nextUnit = GetPlaceBaseUnitBehaviour(nextIsAllyAttack
                    ? FightManager.SceneInstance.AllyUnits : FightManager.SceneInstance.EnemyUnits, nextAttackPlace);
                if (nextUnit != null && !nextUnit.UnitData.IsDead)
                {
                    return(nextUnit);
                }
            }
            nextIsAllyAttack = attackUnit != null ? !nextIsAllyAttack : nextIsAllyAttack;
            nextAttackPlace  = nextIsAllyAttack ? GetNextAttackPlace(nextAttackPlace) : nextAttackPlace;
            if (attackUnit == null && nextIsAllyAttack.Equals(currentAttackPlace))
            {
                nextIsAllyAttack = false;
            }
        }
        return(null);
    }
コード例 #3
0
 UIUnitSlot GetUIUnitSlot(UnitPlace place)
 {
     for (int i = 0; i < UnitSlotsRO.Length; i++)
     {
         UIUnitSlot slot = UnitSlotsRO[i];
         if (slot != null && slot.Place.Range == place.Range && slot.Place.Position == place.Position)
         {
             return(slot);
         }
     }
     return(null);
 }
コード例 #4
0
 UIUnitSlot GetUIUnitSlot(UnitPlace place)
 {
     for (int i = 0; i < UnitSlotsRO.Length; i++)
     {
         UIUnitSlot slot = UnitSlotsRO[i];
         if (slot != null && slot.Place.Range == place.Range && slot.Place.Position == place.Position)
             return slot;
     }
     return null;
 }
コード例 #5
0
ファイル: UnitSet.cs プロジェクト: UpdateShu/ForceFury_Unity5
 string GetPlaceName(UnitPlace place)
 {
     return place.Range + " " + place.Position;
 }
コード例 #6
0
ファイル: UnitSet.cs プロジェクト: UpdateShu/ForceFury_Unity5
    UnitPlace GetNextTargetPlace(UnitPlace attackPlace, UnitPlace currentPlace)
    {
        switch (attackPlace.Position)
        {
            case EUnitPosition.Middle:
                if (attackPlace.Range == EUnitRange.Ranged || attackPlace.Range == EUnitRange.Melee)
                {
                    if (currentPlace.Range == EUnitRange.Melee)
                        return new UnitPlace() { Range = EUnitRange.Ranged, Position = currentPlace.Position };
                    else if (currentPlace.Range == EUnitRange.Ranged)
                    {
                        if (currentPlace.Position == EUnitPosition.Middle)
                            return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Top };
                        else if (currentPlace.Position == EUnitPosition.Top)
                            return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Bottom };
                        else if (currentPlace.Position == EUnitPosition.Bottom)
                            return new UnitPlace() { Range = EUnitRange.None, Position = EUnitPosition.Middle };
                    }
                    else
                        return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Middle };
                }
                else
                {
                    if (currentPlace.Position == EUnitPosition.Middle)
                    {
                        if (currentPlace.Range == EUnitRange.Ranged || currentPlace.Range == EUnitRange.Melee)
                            return new UnitPlace() { Range = currentPlace.Range, Position = EUnitPosition.Top };
                        else
                            return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Middle };
                    }
                    else if (currentPlace.Position == EUnitPosition.Top)
                        return new UnitPlace() { Range = currentPlace.Range, Position = EUnitPosition.Bottom };
                    else if (currentPlace.Position == EUnitPosition.Bottom)
                    {
                        if (currentPlace.Range == EUnitRange.Melee)
                            return new UnitPlace() { Range = EUnitRange.Ranged, Position = EUnitPosition.Middle };
                        else if (currentPlace.Range == EUnitRange.Ranged)
                            return new UnitPlace() { Range = EUnitRange.None, Position = EUnitPosition.Middle };
                    }
                }
                break;

            case EUnitPosition.Top:
                if (currentPlace.Range == EUnitRange.Melee)
                    return new UnitPlace() { Range = EUnitRange.Ranged, Position = currentPlace.Position };
                else if (currentPlace.Range == EUnitRange.Ranged)
                {
                    if (currentPlace.Position == EUnitPosition.Top)
                        return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Middle };
                    else if (currentPlace.Position == EUnitPosition.Middle)
                        return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Bottom };
                    else if (currentPlace.Position == EUnitPosition.Bottom)
                        return new UnitPlace() { Range = EUnitRange.None, Position = EUnitPosition.Middle };
                }
                else
                    return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Top };
                break;

            case EUnitPosition.Bottom:
                if (currentPlace.Range == EUnitRange.Melee)
                    return new UnitPlace() { Range = EUnitRange.Ranged, Position = currentPlace.Position };
                else if (currentPlace.Range == EUnitRange.Ranged)
                {
                    if (currentPlace.Position == EUnitPosition.Bottom)
                        return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Middle };
                    else if (currentPlace.Position == EUnitPosition.Middle)
                        return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Top };
                    else if (currentPlace.Position == EUnitPosition.Top)
                        return new UnitPlace() { Range = EUnitRange.None, Position = EUnitPosition.Middle };
                }
                else
                    return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Bottom };
                break;
        }
        return new UnitPlace() { Range = EUnitRange.None, Position = EUnitPosition.None };
    }
コード例 #7
0
ファイル: UnitSet.cs プロジェクト: UpdateShu/ForceFury_Unity5
 BaseUnitBehaviour GetPlaceBaseUnitBehaviour(ArrayRO<BaseUnitBehaviour> units, UnitPlace place)
 {
     for (int i = 0; i < units.Length; i++)
     {
         BaseUnitBehaviour possibleUnit = units[i];
         if (possibleUnit.Place.Range == place.Range && possibleUnit.Place.Position == place.Position)
             return possibleUnit;
     }
     return null;
 }
コード例 #8
0
ファイル: UnitSet.cs プロジェクト: UpdateShu/ForceFury_Unity5
    UnitPlace GetNextAttackPlace(UnitPlace attackPlace)
    {
        switch (attackPlace.Range)
        {
            case EUnitRange.Melee:
                return new UnitPlace() { Range = EUnitRange.Ranged, Position = attackPlace.Position };

            case EUnitRange.Ranged:
                if (attackPlace.Position == EUnitPosition.Middle)
                    return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Top };
                else if (attackPlace.Position == EUnitPosition.Top)
                    return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Bottom };
                else if (attackPlace.Position == EUnitPosition.Bottom)
                    return new UnitPlace() { Range = EUnitRange.None, Position = EUnitPosition.Middle };
                break;

            case EUnitRange.None:
                if (attackPlace.Position == EUnitPosition.Middle)
                    return new UnitPlace() { Range = EUnitRange.Melee, Position = EUnitPosition.Middle };
                break;
        }
        return new UnitPlace() { Range = EUnitRange.None, Position = EUnitPosition.None };
    }
コード例 #9
0
 public UnitSlot(UnitPlace place, EUnitKey unit)
 {
     _place = place;
     _unit = unit;
 }
コード例 #10
0
ファイル: UnitSet.cs プロジェクト: UpdateShu/ForceFury_Unity5
    UnitPlace GetNextTargetPlace(UnitPlace attackPlace, UnitPlace currentPlace)
    {
        switch (attackPlace.Position)
        {
        case EUnitPosition.Middle:
            if (attackPlace.Range == EUnitRange.Ranged || attackPlace.Range == EUnitRange.Melee)
            {
                if (currentPlace.Range == EUnitRange.Melee)
                {
                    return new UnitPlace()
                           {
                               Range = EUnitRange.Ranged, Position = currentPlace.Position
                           }
                }
                ;
                else if (currentPlace.Range == EUnitRange.Ranged)
                {
                    if (currentPlace.Position == EUnitPosition.Middle)
                    {
                        return new UnitPlace()
                               {
                                   Range = EUnitRange.Melee, Position = EUnitPosition.Top
                               }
                    }
                    ;
                    else if (currentPlace.Position == EUnitPosition.Top)
                    {
                        return new UnitPlace()
                               {
                                   Range = EUnitRange.Melee, Position = EUnitPosition.Bottom
                               }
                    }
                    ;
                    else if (currentPlace.Position == EUnitPosition.Bottom)
                    {
                        return new UnitPlace()
                               {
                                   Range = EUnitRange.None, Position = EUnitPosition.Middle
                               }
                    }
                    ;
                }
                else
                {
                    return new UnitPlace()
                           {
                               Range = EUnitRange.Melee, Position = EUnitPosition.Middle
                           }
                };
            }
            else
            {
                if (currentPlace.Position == EUnitPosition.Middle)
                {
                    if (currentPlace.Range == EUnitRange.Ranged || currentPlace.Range == EUnitRange.Melee)
                    {
                        return new UnitPlace()
                               {
                                   Range = currentPlace.Range, Position = EUnitPosition.Top
                               }
                    }
                    ;
                    else
                    {
                        return new UnitPlace()
                               {
                                   Range = EUnitRange.Melee, Position = EUnitPosition.Middle
                               }
                    };
                }
                else if (currentPlace.Position == EUnitPosition.Top)
                {
                    return new UnitPlace()
                           {
                               Range = currentPlace.Range, Position = EUnitPosition.Bottom
                           }
                }
                ;
                else if (currentPlace.Position == EUnitPosition.Bottom)
                {
                    if (currentPlace.Range == EUnitRange.Melee)
                    {
                        return new UnitPlace()
                               {
                                   Range = EUnitRange.Ranged, Position = EUnitPosition.Middle
                               }
                    }
                    ;
                    else if (currentPlace.Range == EUnitRange.Ranged)
                    {
                        return new UnitPlace()
                               {
                                   Range = EUnitRange.None, Position = EUnitPosition.Middle
                               }
                    }
                    ;
                }
            }
            break;

        case EUnitPosition.Top:
            if (currentPlace.Range == EUnitRange.Melee)
            {
                return new UnitPlace()
                       {
                           Range = EUnitRange.Ranged, Position = currentPlace.Position
                       }
            }
            ;
            else if (currentPlace.Range == EUnitRange.Ranged)
            {
                if (currentPlace.Position == EUnitPosition.Top)
                {
                    return new UnitPlace()
                           {
                               Range = EUnitRange.Melee, Position = EUnitPosition.Middle
                           }
                }
                ;
                else if (currentPlace.Position == EUnitPosition.Middle)
                {
                    return new UnitPlace()
                           {
                               Range = EUnitRange.Melee, Position = EUnitPosition.Bottom
                           }
                }
                ;
                else if (currentPlace.Position == EUnitPosition.Bottom)
                {
                    return new UnitPlace()
                           {
                               Range = EUnitRange.None, Position = EUnitPosition.Middle
                           }
                }
                ;
            }
            else
            {
                return new UnitPlace()
                       {
                           Range = EUnitRange.Melee, Position = EUnitPosition.Top
                       }
            };
            break;

        case EUnitPosition.Bottom:
            if (currentPlace.Range == EUnitRange.Melee)
            {
                return new UnitPlace()
                       {
                           Range = EUnitRange.Ranged, Position = currentPlace.Position
                       }
            }
            ;
            else if (currentPlace.Range == EUnitRange.Ranged)
            {
                if (currentPlace.Position == EUnitPosition.Bottom)
                {
                    return new UnitPlace()
                           {
                               Range = EUnitRange.Melee, Position = EUnitPosition.Middle
                           }
                }
                ;
                else if (currentPlace.Position == EUnitPosition.Middle)
                {
                    return new UnitPlace()
                           {
                               Range = EUnitRange.Melee, Position = EUnitPosition.Top
                           }
                }
                ;
                else if (currentPlace.Position == EUnitPosition.Top)
                {
                    return new UnitPlace()
                           {
                               Range = EUnitRange.None, Position = EUnitPosition.Middle
                           }
                }
                ;
            }
            else
            {
                return new UnitPlace()
                       {
                           Range = EUnitRange.Melee, Position = EUnitPosition.Bottom
                       }
            };
            break;
        }
        return(new UnitPlace()
        {
            Range = EUnitRange.None, Position = EUnitPosition.None
        });
    }

    #endregion

    string GetUnitName(BaseUnitBehaviour unit)
    {
        return(unit != null ? unit.name : string.Empty);
    }

    string GetPlaceName(UnitPlace place)
    {
        return(place.Range + " " + place.Position);
    }
}
コード例 #11
0
ファイル: UnitSet.cs プロジェクト: UpdateShu/ForceFury_Unity5
    UnitPlace GetNextAttackPlace(UnitPlace attackPlace)
    {
        switch (attackPlace.Range)
        {
        case EUnitRange.Melee:
            return(new UnitPlace()
            {
                Range = EUnitRange.Ranged, Position = attackPlace.Position
            });

        case EUnitRange.Ranged:
            if (attackPlace.Position == EUnitPosition.Middle)
            {
                return new UnitPlace()
                       {
                           Range = EUnitRange.Melee, Position = EUnitPosition.Top
                       }
            }
            ;
            else if (attackPlace.Position == EUnitPosition.Top)
            {
                return new UnitPlace()
                       {
                           Range = EUnitRange.Melee, Position = EUnitPosition.Bottom
                       }
            }
            ;
            else if (attackPlace.Position == EUnitPosition.Bottom)
            {
                return new UnitPlace()
                       {
                           Range = EUnitRange.None, Position = EUnitPosition.Middle
                       }
            }
            ;
            break;

        case EUnitRange.None:
            if (attackPlace.Position == EUnitPosition.Middle)
            {
                return new UnitPlace()
                       {
                           Range = EUnitRange.Melee, Position = EUnitPosition.Middle
                       }
            }
            ;
            break;
        }
        return(new UnitPlace()
        {
            Range = EUnitRange.None, Position = EUnitPosition.None
        });
    }

    BaseUnitBehaviour GetPlaceBaseUnitBehaviour(ArrayRO <BaseUnitBehaviour> units, UnitPlace place)
    {
        for (int i = 0; i < units.Length; i++)
        {
            BaseUnitBehaviour possibleUnit = units[i];
            if (possibleUnit.Place.Range == place.Range && possibleUnit.Place.Position == place.Position)
            {
                return(possibleUnit);
            }
        }
        return(null);
    }
コード例 #12
0
ファイル: UnitSlot.cs プロジェクト: zuzundra/HCClone_Unity
 public UnitSlot(UnitPlace place, EUnitKey unit)
 {
     _place = place;
     _unit  = unit;
 }
コード例 #13
0
 private void Awake()
 {
     myUnitPlace = transform.GetComponentInParent <UnitPlace>();
     myColor     = GetComponent <Image>().color;
 }