public virtual void OnAbilitySetActivate(AbilityBase inAbility, bool inIsActive)
    {
        if (inIsActive)
        {
            // 移除cancel列表的技能
            CancelAbilityByOther(inAbility);
            // 触发该Tag对应事件
            TriggerEventByAbility(inAbility);
            // 添加至激活列表
            activityAbilities.Add(inAbility);

            if (inAbility.IsBlockingOtherAbilities)
            {
                AddBlockTags(inAbility.blockAbilitiesWithTags);
            }
            AddActivateTags(inAbility.abilityTags);
            AddActivateTags(inAbility.activationOwnedTags);
        }
        else
        {
            if (inAbility.IsBlockingOtherAbilities)
            {
                RemoveBlockTags(inAbility.blockAbilitiesWithTags);
            }
            RemoveActivateTags(inAbility.abilityTags);
            RemoveActivateTags(inAbility.activationOwnedTags);
        }
    }
Exemplo n.º 2
0
    private void FindAndEquipAbility(string abilityId, Guid sourceId, AbilitySourceType sourceType, int slot)
    {
        AbilityBase ability = ResourceManager.Instance.GetAbilityBase(abilityId);

        if (sourceType == AbilitySourceType.ARCHETYPE)
        {
            foreach (HeroArchetypeData archetypeData in archetypeList)
            {
                if (archetypeData == null || archetypeData.Id != sourceId || !archetypeData.ContainsAbility(ability))
                {
                    continue;
                }
                else
                {
                    EquipAbility(ability, slot, archetypeData);
                    return;
                }
            }
        }
        else if (sourceType == AbilitySourceType.ABILITY_CORE)
        {
            foreach (AbilityCoreItem abilityCore in GameManager.Instance.PlayerStats.AbilityInventory)
            {
                if (abilityCore.SourceId != sourceId)
                {
                    continue;
                }
                else
                {
                    EquipAbility(ability, slot, abilityCore);
                    return;
                }
            }
        }
    }
Exemplo n.º 3
0
    private string createErrorText(Character character, AbilityBase ability)
    {
        List <string> errors = new List <string>();

        if (!ability.CharacterHasEnoughMana(character))
        {
            errors.Add("not enough mana");
        }

        if (!ability.CharacterHasSkill(character))
        {
            errors.Add(ability.GetRequirementString(character));
        }

        if (!ability.usableOutOfCombat)
        {
            errors.Add(string.Format("cannot use out of combat", ability.label));
        }

        string errorString = string.Join(", ", errors.ToArray());

        if (!string.IsNullOrEmpty(errorString))
        {
            errorString = errorString.First().ToString().ToUpper() + errorString.Substring(1);
        }

        return(errorString);
    }
Exemplo n.º 4
0
    public void Init(MovementBase _movement, AbilityBase _ability, AttackBase _attack, DeathBase _death, HitBase _hit)
    {
        _anim = GetComponent <Animator>();

        if (_movement != null)
        {
            _movement.OnMovement += HandleMovement;
        }
        if (_ability != null)
        {
            _ability.OnAbility += HandleAbility;
        }
        if (_attack != null)
        {
            _attack.OnAttack += HandleAttack;
        }
        if (_death != null)
        {
            _death.OnDeath += HandleDeath;
        }
        if (_hit != null)
        {
            _hit.OnHit += HandleHit;
        }
    }
Exemplo n.º 5
0
 public void UnequipFromCurrentHero(AbilityBase abilityBase)
 {
     if (EquippedHero != null)
     {
         EquippedHero.UnequipAbility(EquippedSlot);
     }
 }
Exemplo n.º 6
0
    public void Created()
    {
        if (created)
        {
            return;
        }

        if (GetComponentInChildren <AbilityBase>() != null)
        {
            AbilityBase ability = GetComponentInChildren <AbilityBase>();

            abilityName   = ability.GetAbilityName();
            abilityText   = ability.GetInfo();
            abilitySprite = ability.GetInventoryImageSprite();

            if (ability.GetComponent <Animator>() != null)
            {
                ability.GetComponent <Animator>().enabled = false;
            }

            //ability.GetBattleImageHolder().GetComponent<Image>().sprite = yellowBox;

            //ability.GetBattleImageHolder().GetComponent<Image>().enabled = false;
            //ability.GetInventoryImageHolder().GetComponent<Image>().enabled = true;

            created = true;
        }
    }
Exemplo n.º 7
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));
    }
Exemplo n.º 8
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;
        }
    }
Exemplo n.º 9
0
 public DirectEffectAbility(AbilityBase baseAbility) : base(baseAbility)
 {
     _maxLevel   = 1;
     _experience = 0;
     _level      = 1;
     _pureValue  = base.baseValue;
 }
Exemplo n.º 10
0
    //Modified from normal shield
    private new void OnTriggerEnter(Collider other)
    {
        //dont collide if absorbamount is less than 1
        if (AbsorbAmount < 1)
        {
            return;
        }
        //if not an ability dont collide
        if (other.gameObject.GetComponent <AbilityBase>() == null)
        {
            return;
        }
        //can only hit enemy projectiles
        if (other.gameObject.GetComponent <AbilityBase>().GetTeam() != GetTeam())
        {
            AbilityBase tempAbilityBase = other.gameObject.GetComponent <AbilityBase>();
            tempAbilityBase.SetTeam(GetTeam());

            //Check for if projectile does not have a sender
            if (tempAbilityBase.GetSender() == null)
            {
                other.gameObject.SetActive(false);
            }
            else
            {
                //send projectile back to sender, with replaced sender and target
                GameObject tempTarget = tempAbilityBase.GetSender();
                tempAbilityBase.SetSender(tempAbilityBase.GetTarget());
                tempAbilityBase.SetTarget(tempTarget);
            }

            AbsorbAmount--;
            weakenShield();//Set how transparent the shield should be based on how many charges it has left
        }
    }
Exemplo n.º 11
0
 public void SetSlot(AbilityBase ability, IAbilitySource source, int level)
 {
     this.ability = ability;
     this.source  = source;
     abilityLevel = level;
     UpdateSlot();
 }
Exemplo n.º 12
0
    private void FillPos(AbilityBase ab, Transform parent)
    {
        if (parent.childCount == 0)
        {
            GameObject go = (GameObject)GameObject.Instantiate(ResMgr.Instance.LoadAssetFromResource("Prefabs/UI/HeroAbility/abilityIcon"));
            go.GetComponent <UISprite>().spriteName = string.Format(CommonDefine.RoleAbilityDic[RoleManager.Instance.SelectedHero.m_roleInfo.type], ab.Index);
            go.transform.parent        = parent;
            go.transform.localPosition = Vector3.zero;
            go.transform.localScale    = Vector3.one;
        }
        else
        {
            parent.GetChild(0).GetComponent <UISprite>().spriteName = string.Format(CommonDefine.RoleAbilityDic[RoleManager.Instance.SelectedHero.m_roleInfo.type], ab.Index);
        }

        //判断这个技能是否可用,如果不可用就灰态
        if (ab.IsValid())
        {
            parent.GetChild(0).GetComponent <UISprite>().color      = Color.white;
            parent.GetChild(0).GetComponent <BoxCollider>().enabled = true;
        }
        else
        {
            parent.GetChild(0).GetComponent <UISprite>().color      = Color.black;
            parent.GetChild(0).GetComponent <BoxCollider>().enabled = false;
        }

        UIEventListener.Get(parent.GetChild(0).gameObject).onClick = (go) => { m_logic.onSelectAbility(ab); };
    }
Exemplo n.º 13
0
    /// <summary>
    /// 被攻击,中毒等的动画播放
    /// </summary>
    public void PlayOnBeSkilled(AbilityBase ability)
    {
        switch (ability.AbilityType)
        {
        case AbilityType.Blood:
            m_stateMachine.State = m_bloodState;
            break;

        case AbilityType.Buffer:
            m_stateMachine.State = m_bufferState;
            break;

        case AbilityType.Debuffer:
            m_stateMachine.State = m_debufferState;
            break;

        case AbilityType.NormalAttack:
            m_stateMachine.State = m_normalHitState;
            break;

        case AbilityType.Poison:
            m_stateMachine.State = m_posionState;
            break;

        case AbilityType.Pressure:
            m_stateMachine.State = m_pressureState;
            break;
        }
    }
Exemplo n.º 14
0
    public void Invoke(EAbilities ability, Vector2 _direction, Vector2 _pos, int _targetLayer)
    {
        AbilityBase newAbility = null;

        if (cooldown.IsStopped())
        {
            switch (ability)
            {
            case EAbilities.FIREBALL:
                newAbility = new Fireball(_direction, _pos, _targetLayer);
                break;

            case EAbilities.PYROBLAST:
                newAbility = new Pyroblast(_direction, _pos, _targetLayer);
                break;

            case EAbilities.CHAIN_LIGHTNING:
                newAbility = new ChainLightning(_direction, _pos, _targetLayer);
                break;

            default:
                newAbility = new Fireball(_direction, _pos, _targetLayer);
                break;
            }
            cooldown.WaitTime = newAbility.cooldown;
            cooldown.Start();
            AddChild(newAbility);
        }
    }
Exemplo n.º 15
0
    private AbilityBase[] validate(AbilityBase[] abilities)
    {
        List <AbilityBase> validAbilities = new List <AbilityBase>();

        foreach (AbilityBase interaction in abilities)
        {
            if (interaction == null)
            {
                Debug.LogWarning("Ability is null on " + gameObject.name);
                continue;
            }

            AbilityBase instance = Instantiate(interaction) as AbilityBase;

            if (instance.Initialize(gameObject))
            {
                validAbilities.Add(instance);
            }
            else
            {
                Destroy(instance);
                Debug.LogWarning("Failed to initialize " + interaction.ToString() + " on " + gameObject.name);
            }
        }

        return(validAbilities.ToArray());
    }
Exemplo n.º 16
0
    private ExtractableAbilitySlot AddExtractSlot(AbilityBase ability)
    {
        if (ability == null)
        {
            return(null);
        }

        ExtractableAbilitySlot slot;

        if (unusedSlots.Count > 0)
        {
            slot = unusedSlots.Dequeue();
            slot.gameObject.SetActive(true);
        }
        else
        {
            slot = Instantiate(slotPrefab, scrollViewContent.transform);
        }
        slot.transform.SetParent(scrollViewContent.transform, true);
        slot.GetComponent <Button>().onClick.RemoveAllListeners();
        slot.textField.text = ability.LocalizedName;
        slot.GetComponent <Button>().onClick.AddListener(delegate { ExtractableSlotOnClick(ability); });
        slotsInUse.Add(slot);
        return(slot);
    }
        public void SetAbility(int comboIndex)
        {
            currentAbility = comboIndex;
            comboIndicator.SetActive(comboIndex > 0);
            if (comboIndex >= abilities.Length)
            {
                ClearUi();
                return;
            }

            if (abilities.Length <= 0)
            {
                ClearUi();
                return;
            }

            AbilityBase abilityBase = abilities[comboIndex];

            if (abilityBase == null)
            {
                ClearUi();
                return;
            }

            image.sprite = abilityBase.Icon;
            image.color  = Color.white;

            keybindingText.text = GetKeyBindingText();
        }
Exemplo n.º 18
0
    public OnCastStartedAbilityEvent(AbilityBase parentAbility, AbilityActionBase bindedAction)
        : base(bindedAction)
    {
        Parentability = parentAbility;

        Bind();
    }
 public void AcquireAbilityByTag(FAbilityTagContainer inTag)
 {
     if (!abilitiesMap.ContainsKey(inTag))
     {
         AbilityBase ability = AbilityManager.Instance.CreateAbility(inTag, this);
         AcquireAbility(ability);
     }
 }
        /// <summary>
        /// Returns the selected character ability
        /// </summary>
        /// <returns>A character ability corresponding to the ability selection</returns>
        private AbilityBase GetCharacterAbility()
        {
            Dropdown.OptionData optionData = GetSelectedDropdownOption(_characterAbility);

            AbilityBase characterAbility = CharacterCreator.FindCharacterAbility(optionData.text);

            return(characterAbility);
        }
Exemplo n.º 21
0
 public Ability(AbilityBase abilityBase, EAttackType type, MobaEntity entity)
 {
     m_abilityBase = abilityBase;
     m_mobaEntity  = entity;
     //Only basic abilities starts at level 1
     m_attackType = type;
     Level        = m_attackType == EAttackType.Basic ? 1 : 0;
 }
Exemplo n.º 22
0
    private void abilityClicked(AbilityBase ability)
    {
        UIQuickMenuAbilityView instance = Instantiate(abilityViewPrefab);

        instance.ability = ability;

        menu.NavigateInto(instance);
    }
Exemplo n.º 23
0
    public void SetAbilityData(List <AbilityBase> currentAbilites, AbilityBase newAbility)
    {
        for (int i = 0; i < currentAbilites.Count; ++i)
        {
            abilityText[i].text = currentAbilites[i].Name;
        }

        abilityText[currentAbilites.Count].text = newAbility.Name;
    }
Exemplo n.º 24
0
 public void onSelectAbility(AbilityBase ability)
 {
     if (ability != null &&
         ability.IsValid() &&
         GameData.Instance.BattleSceneActionFlag.HasFlag((long)StateDef.BattleActionFlag.OnChoosingSkill))
     {
         ability.onSelect();
     }
 }
Exemplo n.º 25
0
    public OnCollisionEnterAbilityEvent(InteractableCollider targetInteractableCollider, AbilityBase bindedAbility, AbilityActionBase bindedAction)
        : base(bindedAction)
    {
        _targetInteractableCollider = targetInteractableCollider;

        _bindedAbility = bindedAbility;

        Bind();
    }
Exemplo n.º 26
0
 protected AbilityBase(AbilityBase baseAbility)
 {
     _name         = baseAbility.name;
     _description  = baseAbility.description;
     _relative     = baseAbility.relative;
     _proportional = baseAbility.proportional;
     _baseValue    = baseAbility.baseValue;
     _baseRound    = baseAbility.baseRound;
 }
Exemplo n.º 27
0
 private void ResetPanel()
 {
     archetypeSlot.GetComponentInChildren <TextMeshProUGUI>().text = "SELECT ARCHETYPE";
     selectedArchetypeItem      = null;
     selectedAbilityBase        = null;
     confirmButton.interactable = false;
     abilitySlot.ClearSlot();
     ClearSlotsInUse();
 }
 public virtual void RemoveAbility(AbilityBase inAbility)
 {
     if (activityAbilities.Contains(inAbility))
     {
         inAbility.CancelAbility();
     }
     abilitiesMap.Remove(inAbility.abilityTags);
     AbilityManager.Instance.DestroyAbility(inAbility);
 }
Exemplo n.º 29
0
    protected Vector3Int m_tileIndex = Vector3Int.zero;         // Index of tile the action was used on

    public void initAbilityAction(AbilityBase abilityInstance, PlayerController controller, BoardManager board, Vector3 position, Vector3Int tileIndex)
    {
        m_ability   = abilityInstance;
        m_position  = position;
        m_tileIndex = tileIndex;

        // This would also get set by Photon, but no harm in also setting it here
        m_board      = board;
        m_instigator = controller;
    }
Exemplo n.º 30
0
 /// <summary>
 /// 切換能力
 /// </summary>
 /// <param name="nextAbility">下一個能力</param>
 private void SwitchAbility(AbilityBase nextAbility)
 {
     CurrentAbility.Exit();
     CurrentAbility = nextAbility;
     CurrentAbility.Enter();
     if (_animatorManager != null)
     {
         _animatorManager.AnimClip = (int)nextAbility.AnimClip;
     }
 }
    public void changeAbility(string abilityName)
    {
        if(currentAbility != null){
            Destroy(currentAbility);
        }

        currentAbility = gameObject.AddComponent(abilityName) as AbilityBase;

        if(GLOBAL.myWizard != null &&
           GLOBAL.myWizard.GetComponent<PlayerController>() != null &&
           GLOBAL.myWizard.GetComponent<PlayerController>().networkedProperties.ContainsKey("Ability")
        ){
            GLOBAL.myWizard.GetComponent<PlayerController>().networkedProperties["Ability"] = AbilityManagerScript.currentAbility.getAbilityName();
            PhotonNetwork.player.SetCustomProperties(GLOBAL.myWizard.GetComponent<PlayerController>().networkedProperties);
        }
    }