コード例 #1
0
        void TargetHighlight()
        {
            // get ability type
            switch (SelectedAbility.GetTargetType())
            {
            // if attack - targets will be enemies
            case TargetType.Enemy:
                // Get list of all Enemies currently in the battle
                List <GameObject> enemyList = CombatManager.Instance.battlefieldController.FindAllCurrentEnemies();
                // Standard attacks can only hit a charcater if the space infront of them in empty,
                // I.E. you can't hit a back line character if there is a character protecting it in the slot DIRECTLY infront of it
                PossibleTargets = TargetingHelper.GetPossibleTargets(enemyList);
                // Loop through targets, adding them to the pannel
                foreach (var enemy in PossibleTargets)
                {
                    enemy.GetComponent <Character>().MakeClickable();
                }
                break;

            // if support - targets will be Friendlies
            case TargetType.Friendly:
                // Get list of all Friendlies currently in the battle
                List <GameObject> friendlyList = CombatManager.Instance.battlefieldController.FindAllCurrentFriendlies();
                PossibleTargets = friendlyList;
                // Loop through targets, adding them to the pannel
                foreach (var friend in friendlyList)
                {
                    friend.GetComponent <Character>().MakeClickable();
                }
                break;

            // if summon - Targets will be unOccupied character slots on your side
            case TargetType.SummonSlot:
                // Get List of Unoccupied frindly unitslots
                List <GameObject> unitSlotList = CombatManager.Instance.battlefieldController.FindAllCurrentUnoccupiedFriendlySlots();
                PossibleTargets = unitSlotList;
                // Loop through targets, adding them to the pannel
                foreach (var unitSlot in unitSlotList)
                {
                    unitSlot.GetComponent <UnitSlot>().MakeClickable();
                }
                break;

            case TargetType.None:
                // TODO... look into more robust error handling
                Debug.Log("Not exactly sure what should happen here, this is probably an error!");
                break;

            default:
                // TODO... look into more robust error handling
                Debug.Log("Not exactly sure what should happen here, this is probably an error!");
                break;
            }
        }
コード例 #2
0
        protected void Attack()
        {
            // get list of enemies
            List <GameObject> mobList = new List <GameObject>();

            foreach (Transform child in enemyTeam.transform)
            {
                mobList.Add(child.gameObject);
            }
            mobList = TargetingHelper.GetPossibleTargets(mobList);
            // attack Random enemy in list - AI (temp solution)
            // TODO....
            // Split AI/Player attack code
            if (mobList.Count > 0)
            {
                int targetIndex  = Random.Range(0, mobList.Count);
                int abilityIndex = Random.Range(0, Abilities.Count);

                Abilities.ElementAt(abilityIndex).Value.NewAction(this.gameObject, mobList[targetIndex]);
                //UseAbilityOn(Abilities.ElementAt(abilityIndex).Value, mobList[targetIndex]);
            }
        }