示例#1
0
    private List <Target> GetGroupTargets(Combatant actor, FactionMap combatants)
    {
        var targets = new List <Target>();

        switch (validTargets)
        {
        case ETargetType.Enemies:
            foreach (var faction in combatants)
            {
                if (faction.Key != actor.Faction)
                {
                    AddGroupTarget(faction.Value, targets);
                }
            }
            break;

        case ETargetType.Allies:
            AddGroupTarget(combatants[actor.Faction], targets);
            break;

        case ETargetType.Both:
            foreach (var faction in combatants.Values)
            {
                AddGroupTarget(faction, targets);
            }
            break;

        default:
            break;
        }
        return(targets);
    }
 public override void Setup(FactionMap factionMap)
 {
     this.factionMap = factionMap;
     actionMenu.Populate(
         Actor,
         actionData => SelectTarget(actionData)
         );
     stateMachine.SetState(actionMenuState);
 }
示例#3
0
    private FactionMap GenerateFactionMap(EncounterRoster roster)
    {
        var factionMap = new FactionMap {
            { HERO_FACTION, baseCombatant.Spawn(roster.Heroes, HERO_FACTION, transform) },
            { ENEMY_FACTION, baseCombatant.Spawn(roster.Enemies, ENEMY_FACTION, transform) }
        };

        return(factionMap);
    }
    public void Populate(ActionData actionData, Combatant owner, FactionMap factionMap, TargetSelectDelegate selectionDelegate)
    {
        var targets        = actionData.Targeter.GetTargets(owner, factionMap);
        var selectorPrefab = actionData.Targeter.SelectorPrefab;

        foreach (var target in targets)
        {
            var selector = Instantiate(selectorPrefab, transform);
            selector.Populate(target, selectionDelegate);
            selector.transform.localScale = selectorPrefab.transform.localScale;
            activeSelectors.AddLast(selector);
        }
    }
示例#5
0
    private void Start()
    {
        var heroes  = combatantPrefab.Spawn(roster.Heroes, Encounter.HERO_FACTION, transform);
        var enemies = combatantPrefab.Spawn(roster.Enemies, Encounter.ENEMY_FACTION, transform);

        factionMap = new FactionMap {
            { Encounter.HERO_FACTION, heroes },
            { Encounter.ENEMY_FACTION, enemies }
        };

        arena.Populate(factionMap);

        InvokeRepeating("ShuffleHeroes", 1.0f, 1f);
        InvokeRepeating("ShuffleEnemies", 1.5f, 1f);
    }
示例#6
0
    public override void Populate(FactionMap combatants)
    {
        if (heroRegion != null || enemyRegion != null)
        {
            Debug.LogWarning("Should not be populating an arena more than once: Use an 'add' method");
            return;
        }

        var heroes  = combatants[Encounter.HERO_FACTION];
        var enemies = combatants[Encounter.ENEMY_FACTION];

        heroRegion  = Instantiate(SelectRegion(heroRegionPrefabs, heroes.Count), transform);
        enemyRegion = Instantiate(SelectRegion(enemyRegionPrefabs, enemies.Count), transform);

        heroRegion.Populate(heroes);
        enemyRegion.Populate(enemies);
    }
示例#7
0
    // Initializer
    public void Populate(EncounterRoster roster, Arena arenaPrefab)       // Eventually should add 'Script'
    {
        animationQueue = GetComponentInChildren <AnimationQueue>();

        combatants = GenerateFactionMap(roster);

        turnCounter = new TurnCounter <Combatant>(
            (a, b) => b.Character.Speed.Current.CompareTo(a.Character.Speed.Current)
            );
        turnCounter.Add(combatants[HERO_FACTION]);
        turnCounter.Add(combatants[ENEMY_FACTION]);
        turnCounter.Reset();

        arena = Instantiate(arenaPrefab, transform);
        arena.Populate(combatants);

        stateEngine = new StateEngine <Encounter>(this, new SetupState());
    }
示例#8
0
    private List <Target> GetAllTarget(FactionMap combatants)
    {
        var targetableCombatants = new List <Combatant>();

        foreach (var faction in combatants.Values)
        {
            foreach (var combatant in faction)
            {
                if (CanTarget(combatant))
                {
                    targetableCombatants.Add(combatant);
                }
            }
        }

        return(new List <Target> {
            new Target(targetableCombatants)
        });
    }
示例#9
0
    public List <Target> GetTargets(Combatant actor, FactionMap combatants)
    {
        switch (targetingRange)
        {
        case EGroupType.Self:
            return(GetSelfTarget(actor));

        case EGroupType.Single:
            return(GetSingleTargets(actor, combatants));

        case EGroupType.Group:
            return(GetGroupTargets(actor, combatants));

        case EGroupType.All:
            return(GetAllTarget(combatants));

        default:
            return(new List <Target>());
        }
    }
示例#10
0
 public override void Cleanup()
 {
     factionMap     = null;
     selectedAction = null;
     stateMachine.SetState(null);
 }
示例#11
0
 public override void Cleanup()
 {
     factionMap = null;
 }
示例#12
0
 public override void Setup(FactionMap factionMap)
 {
     this.factionMap = factionMap;
 }
示例#13
0
 public abstract void Populate(FactionMap combatants);
示例#14
0
 public abstract void Setup(FactionMap factionMap);