Example #1
0
    void Update()
    {
        // Update available characters, could be done with some death event
        _targetCharacters = FindObjectOfType <CharacterPositioning>().InstantiatedCharacters;

        //Choose which skill to use
        AbilityType chosenAbility;

        if (Random.value < 0.10)
        {
            chosenAbility = AbilityType.Nuke;
        }
        else if (Random.value < 0.30)
        {
            chosenAbility = AbilityType.Stun;
        }
        else
        {
            chosenAbility = AbilityType.Poke;
        }
        _boss.SetAbility(chosenAbility);
        if (AbilityCast != null && _boss.CanCastAbility && _targetCharacters.Count > 0)
        {
            var targetEnemy = _targetCharacters[(++_iteration) % _targetCharacters.Count];
            AbilityCast.Invoke(this, new AbilityCastEventArgs
            {
                //Position = Camera.main.ScreenToWorldPoint(Input.mousePosition),
                TargetEnemy = targetEnemy
            });
        }
    }
Example #2
0
    public Ability(AbilityBase abilityBase, Texture icon, int level, AbilityCast abilityCast, Dictionary <string, int> variables)
    {
        _baseAbility = abilityBase;
        _icon        = icon;
        _level       = level;
        _abilityCast = abilityCast;
//		_effectCard=effectCard;
        _variableValues = variables;
        if (_variableValues.ContainsKey(AbilityVariable.mana))
        {
            _mana = _variableValues [AbilityVariable.mana];
        }
        else
        {
            _mana = 0;
        }
        if (_variableValues.ContainsKey(AbilityVariable.cooldown))
        {
            _cooldown = _variableValues [AbilityVariable.cooldown];
        }
        else
        {
            _cooldown = 0;
        }
    }
Example #3
0
    Ability GeneAbility(AbilityBase abilityBase, int level = 1)
    {
        if (level > abilityBase.maxLevel)
        {
            Debug.Log(string.Format("Level of ability '{0}' should not be larger than maxLevel", abilityBase.name));
            throw new System.ArgumentException(string.Format("Level of ability '{0}' should not be larger than maxLevel", abilityBase.name));
        }

        string iconName = abilityBase.icon;

        if (iconName == null)
        {
            iconName = abilityBase.name;
        }
        Texture     icon        = _abilityIconTable[iconName];
        AbilityCast abilityCast = AbilityCastStatic.GetAbilityCast(abilityBase.abilityCast);
//		EffectCard effectCard=EffectCardStatic.GetEffectCard(abilityBase.effectCard);
        Dictionary <string, int> variables    = new Dictionary <string, int>();
        List <string>            variableName = abilityBase._variables;
        List <int> variableValue = abilityBase._variableValueTable[level - 1];

        for (int i = 0; i < variableName.Count; i++)
        {
            variables.Add(variableName[i], variableValue[i]);
        }
        return(new Ability(abilityBase, icon, level, abilityCast, variables));
    }
Example #4
0
    // Casts two abilities with a delay between each
    private IEnumerator DelayedAbility(AbilityCast abilityA, AbilityCast abilityB, float delayOne, float delayTwo)
    {
        abilityA();
        yield return(new WaitForSeconds(delayOne));

        abilityB();
        yield return(new WaitForSeconds(delayTwo));
    }
Example #5
0
    // Cast a motion ability then wait until the target position is reached before executing the next ability
    private IEnumerator DelayedMotionAbility(AbilityCast ability, AbilityCast abilityTwo)
    {
        positionReached = false;
        ability();
        yield return(new WaitUntil(() => positionReached));

        abilityTwo();
    }
Example #6
0
 private void CastAbility(AbilityKey key)
 {
     AbilityCast?.Invoke(this, key);
     if (AbilityCastModes[key].HasRecast)
     {
         StartRecastTimer(key);
     }
     else
     {
         StartCooldownTimer(key);
     }
     SelectedAbility = AbilityKey.None;
 }
        public bool Cast(ICharacterFinder characterFinder, IAbility ability, Vector2 targetPosition)
        {
            if (ActionPoints < ability.ActionPoints)
            {
                return(false);
            }

            bool didCast = ability.Cast(characterFinder, this, targetPosition);

            if (didCast)
            {
                ActionPoints -= ability.ActionPoints;
                AbilityCast?.Invoke(this, ability, targetPosition);
            }

            return(didCast);
        }
Example #8
0
 private void CastAbility(AbilityKey key)
 {
     Task.Run(async() =>
     {
         /*if (AbilityCastModes[key].IsPointAndClick)
          * {
          *  // check if mana was substracted, right after casting the ability
          *
          *  lastManaAmount = LeagueOfLegendsModule.CurrentGameState.ActivePlayer.Stats.ResourceValue;
          * // Debug.WriteLine("A: " + lastManaAmount);
          *  // TODO: Find an alternative method for point and click
          *  await Task.Delay(300); // This is very slow, but if you put less time, the mana change won't be detected. There seems to be about 300ms delay in stats.
          * //  Debug.WriteLine("B: " + LeagueOfLegendsModule.CurrentGameState.ActivePlayer.Stats.ResourceValue);
          *
          *  if (LeagueOfLegendsModule.CurrentGameState.ActivePlayer.Stats.ResourceValue >= lastManaAmount)
          *  {
          *      // mana wasn't consumed, so no ability was cast. Maybe this trick doesn't always work. E.g. Anivia E while having R enabled?
          *      SelectedAbility = AbilityKey.None;
          *      return;
          *  }
          * }*/
         AbilityCast?.Invoke(this, key);
         if (AbilityCastModes[key].HasRecast)
         {
             StartRecastTimer(key);
         }
         else
         {
             if (!AbilityCastModes[key].IsPointAndClick) // no cooldown for point and clicks
             {
                 StartCooldownTimer(key);
             }
         }
         if (AbilityCastModes[key].RecastMode != null && AbilityCastModes[key].RecastMode.RecastOnKeyUp)
         {
             SelectedAbility = key;
         }
         else
         {
             SelectedAbility = AbilityKey.None;
         }
     });
 }
Example #9
0
 private void CastAbility(AbilityKey key)
 {
     AbilityCast?.Invoke(this, key);
     if (AbilityCastModes[key].HasRecast)
     {
         StartRecastTimer(key);
     }
     else
     {
         StartCooldownTimer(key);
     }
     if (AbilityCastModes[key].RecastMode != null && AbilityCastModes[key].RecastMode.RecastOnKeyUp)
     {
         SelectedAbility = key;
     }
     else
     {
         SelectedAbility = AbilityKey.None;
     }
 }