Example #1
0
        public override void PrepareTargets(AbstractActionAbility ability)
        {
            if (ability == null) return;

            //Remove any existing pointers
            foreach (var item in _friendlyPointers)
            {
                Destroy(item.Value);
            }

            _friendlyPointers.Clear();

            foreach (var item in _enemyPointers)
            {
                Destroy(item.Value);
            }

            _enemyPointers.Clear();

            List<AbstractBattleCharacter> sortedFriendly = AbstractBattleCharacter.Friendlies.OrderBy(x => x.transform.localPosition.x).ToList();
            List<AbstractBattleCharacter> sortedEnemy = AbstractBattleCharacter.Enemies.OrderBy(x => x.transform.localPosition.x).ToList();
            AbstractBattleCharacter.Friendlies.PrintList();
            foreach (var character in AbstractBattleCharacter.Friendlies)
            {

                //Spawn a pointer at the character
                GameObject pointer = (GameObject)Instantiate(_allyPointerPrefab);
                pointer.transform.SetParent(character.gameObject.transform);
                pointer.transform.localPosition = character.General.PointerLocation;
                _friendlyPointers.Add(character,pointer);
            }

            foreach (var character in AbstractBattleCharacter.Enemies)
            {
                //Spawn a pointer at the character
                GameObject pointer = (GameObject)Instantiate(_enemyPointerPrefab);
                pointer.transform.SetParent(character.gameObject.transform);
                pointer.transform.localPosition = character.General.PointerLocation;
                _enemyPointers.Add(character, pointer);
            }

            foreach (var character in AbstractBattleCharacter.Friendlies)
            {
                SetButtonNavigation(_friendlyPointers[character],character,sortedFriendly,_enemyPointers, sortedEnemy);
                SetButtonEvent(_friendlyPointers[character], AbstractBattleCharacter.ActiveBattleCharacter, new List<AbstractBattleCharacter> {character}, ability);
            }

            foreach (var character in AbstractBattleCharacter.Enemies)
            {
                SetButtonNavigation(_enemyPointers[character], character, sortedEnemy,_friendlyPointers, sortedFriendly);
                SetButtonEvent(_enemyPointers[character], AbstractBattleCharacter.ActiveBattleCharacter, new List<AbstractBattleCharacter> { character }, ability);
            }

            SelectFirst(ability as AbstractActionAbility, sortedFriendly,sortedEnemy);
        }
Example #2
0
 private void SelectFirst(AbstractActionAbility ability, List<AbstractBattleCharacter> sortedFriendly, List<AbstractBattleCharacter> sortedEnemy)
 {
     switch (ability.DefaultTarget)
     {
         case DefaultTargetType.Self:
             _friendlyPointers[AbstractBattleCharacter.ActiveBattleCharacter].GetComponentInChildren<Button>().Select();
             break;
         case DefaultTargetType.Allies:
             _friendlyPointers[sortedFriendly[0]].GetComponentInChildren<Button>().Select();
             break;
         case DefaultTargetType.Enemy:
             _enemyPointers[sortedEnemy[0]].GetComponentInChildren<Button>().Select();
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
Example #3
0
 private void SetButtonEvent(GameObject pointer, AbstractBattleCharacter caster, List<AbstractBattleCharacter> targets, AbstractActionAbility ability)
 {
     pointer.GetComponentInChildren<Button>().onClick.AddListener(delegate {EventAggregator.RaiseEvent(new SubmitAbilityAtTarget() {Ability = ability,Caster = caster,Targets = targets});});
     EventTrigger trigger = pointer.GetComponentInChildren<EventTrigger>();
     EventTrigger.Entry entry = new EventTrigger.Entry();
     entry.eventID = EventTriggerType.Select;
     entry.callback = new EventTrigger.TriggerEvent();
     entry.callback.AddListener(
         delegate { OnTargetChange(targets[0]);});
     trigger.triggers.Add(entry);
 }
 // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
 public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     _projectileShooting = false;
     Ability = null;
     Targets = null;
 }