Exemplo n.º 1
0
        private void InitItem()
        {
            ActiveSkillData[] activeSkillDataList = new ActiveSkillData[SkillLogic.GetInstance().ActiveSkillDict.Count];
            SkillLogic.GetInstance().ActiveSkillDict.Values.CopyTo(activeSkillDataList, 0);

            items = new ActiveSkillItem[SKILL_ITEM_COUNT];                      //建立数组
            for (int i = 0; i < SKILL_ITEM_COUNT; i++)
            {
                items[i] = NGUITools.AddChild <ActiveSkillItem>(gameObject);
                ActiveSkillItem item = items[i];

                if (i < SkillLogic.GetInstance().ActiveSkillDict.Count)
                {
                    item.SkillData = activeSkillDataList[i];

                    if (item.gameObject.collider == null)
                    {
                        NGUITools.AddWidgetCollider(item.gameObject);
                    }
                    UIEventListener.Get(item.gameObject).onClick += OnClickItem;
                }
                else
                {
                    item.SkillData = null;
                }
                item.gameObject.transform.localPosition = new Vector3(-223 + i * 88, 104, 0);
            }
            //显示第一个
            if (SkillLogic.GetInstance().ActiveSkillDict.Count > 1)
            {
                OnClickItem(items[0].gameObject);
            }
        }
    public static async ETVoid Execute(this ActiveSkillComponent self, string skillId)
    {
        ActiveSkillData activeSkillData = Game.Scene.GetComponent <SkillConfigComponent>().GetActiveSkill(skillId);

        SkillHelper.ExecuteSkillParams excuteSkillParams = new SkillHelper.ExecuteSkillParams();
        excuteSkillParams.skillId    = skillId;
        excuteSkillParams.source     = self.GetParent <Unit>();
        excuteSkillParams.skillLevel = 1;

        self.currUsingSkillId = skillId;

        //TODO: 暂时先直接取消之前的行动

        self.cancelToken?.Cancel();
        Game.EventSystem.Run(EventIdType.CancelPreAction, self.GetParent <Unit>());
        CharacterStateComponent characterStateComponent = self.GetParent <Unit>().GetComponent <CharacterStateComponent>();

        characterStateComponent.Set(SpecialStateType.NotInControl, true);
        self.cancelToken = new CancellationTokenSource();
        excuteSkillParams.cancelToken = self.cancelToken;

        await SkillHelper.ExecuteActiveSkill(excuteSkillParams);

        self.cancelToken = null;
        characterStateComponent.Set(SpecialStateType.NotInControl, false);
        self.currUsingSkillId = string.Empty;
    }
Exemplo n.º 3
0
        void Update()
        {
            if (Input.GetKeyDown(keyCode))
            {
                ClickItemHandler(button.gameObject);
            }
            if (itemType == SHORTCUTITEM.SKILL)
            {
                ActiveSkillData data = SkillLogic.GetInstance().GetActiveSkillVOByID((ushort)itemId);
                float           _v   = data.cdTicket.GetTimeNormal();
                if (_v >= 1)
                {
                    _v = SkillLogic.GetInstance().GetAllSkillCDNormal();
                }
                if (_v > 1)
                {
                    _v = 1;
                }


                if (cdValue != _v)
                {
                    if (null != mark)
                    {
                        mark.fillAmount = 1f - _v;
                    }
                    cdValue = _v;
                }
            }
        }
Exemplo n.º 4
0
        private void UpdateSkillDesc(ActiveSkillData skillData)
        {
            KActiveSkill currSkillSetting = KConfigFileManager.GetInstance().GetActiveSkill(skillData.SkillID, skillData.Level);
            KActiveSkill nextSkillSetting = KConfigFileManager.GetInstance().GetActiveSkill(skillData.SkillID, skillData.Level + 1);

            if (currSkillSetting != null)
            {
                skillNameTxt.text = "<fff1cc>" + currSkillSetting.Text + "<->";
                curDescTxt.text   = "<949393>" + currSkillSetting.Desc + "<->";
            }
            if (nextSkillSetting != null)
            {
                nextDescTxt.text    = "<ebba10>" + nextSkillSetting.Desc + "<->";
                reqLevelTxt.text    = "<ebba10>" + nextSkillSetting.LearnLevel + "<->";
                reqMoneyTxt.text    = "<ebba10>" + nextSkillSetting.CostMoney + "<->";
                proBarSp.fillAmount = ((float)skillData.SkillExp) / nextSkillSetting.MaxSkillExp;
            }
            else
            {
                nextDescTxt.text    = "<ff0000>已达最高等级<->";
                reqLevelTxt.text    = "<ff0000>--<->";
                reqMoneyTxt.text    = "<ff0000>--<->";
                proBarSp.fillAmount = 1.0f;
            }
        }
Exemplo n.º 5
0
    static void AddEffectCache(EffectCacheComponent effectCacheComponent, AudioCacheComponent audioCacheComponent, ActiveSkillComponent skillComponent)
    {
        foreach (var skill in skillComponent.skillList)
        {
            ActiveSkillData skillData = Game.Scene.GetComponent <SkillConfigComponent>().GetActiveSkill(skill.Key);
            Game.Scene.GetComponent <ResourcesComponent>().LoadBundle(skillData.skillAssetsABName.StringToAB());
            GameObject skillAssetsPrefabGo = Game.Scene.GetComponent <ResourcesComponent>().GetAsset(skillData.skillAssetsABName.StringToAB(), skillData.skillAssetsABName) as GameObject;

            var buffList = skillData.GetAllBuffs(BuffIdType.EmitObj, BuffIdType.HitEffect, BuffIdType.PlayEffect, BuffIdType.PlaySound, BuffIdType.AddBuff);
            if (buffList.Count > 0)
            {
                //循环检测每一个Buff,看是否是播放特效的,如果是,那就找到对应的Buff 缓存起来
                foreach (var buff in buffList)
                {
                    AddEffectCache(effectCacheComponent, buff, skillAssetsPrefabGo);
                    AddAudioCache(audioCacheComponent, buff, skillAssetsPrefabGo);
                    if (buff.GetBuffIdType() == BuffIdType.AddBuff)
                    {
                        Buff_AddBuff buff_AddBuffOnSkillEnd = (Buff_AddBuff)buff;
                        if (buff_AddBuffOnSkillEnd.buffGroup.buffList == null)
                        {
                            continue;
                        }
                        foreach (var buff_onSkillEnd in buff_AddBuffOnSkillEnd.buffGroup.buffList)
                        {
                            AddEffectCache(effectCacheComponent, buff_onSkillEnd, skillAssetsPrefabGo);
                            AddAudioCache(audioCacheComponent, buff_onSkillEnd, skillAssetsPrefabGo);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
    public async ETVoid Execute(string skillId)
    {
        try
        {
            if (usingSkill)
            {
                return;
            }
            if (!skillList.ContainsKey(skillId))
            {
                return;
            }
            if (!SkillHelper.CheckIfSkillCanUse(skillId, GetParent <Unit>()))
            {
                return;
            }
            ActiveSkillData activeSkillData = Game.Scene.GetComponent <SkillConfigComponent>().GetActiveSkill(skillId);
            SkillHelper.ExecuteSkillParams excuteSkillParams = new SkillHelper.ExecuteSkillParams();
            excuteSkillParams.skillId    = skillId;
            excuteSkillParams.source     = GetParent <Unit>();
            excuteSkillParams.skillLevel = 1;
            usingSkill = true;
            bool canUse = await SkillHelper.CheckInput(excuteSkillParams);

            if (GetParent <Unit>() == UnitComponent.Instance.MyUnit)
            {
                //联网模式玩家主动使用技能需要等待服务器确认消息,以决定技能是否真的可以使用

                tcs        = new ETTaskCompletionSource <bool>();
                canUse     = await tcs.Task;
                tcs        = null;
                usingSkill = false;
            }
            if (!canUse)
            {
                return;
            }
            usingSkill       = false;
            currUsingSkillId = skillId;
            // 联网模式非玩家单位使用技能直接跳过检测,因为是收到使用技能的确定消息了才开始执行技能.
            //TODO: 暂时先直接取消之前的行动
            cancelToken?.Cancel();
            Game.EventSystem.Run(EventIdType.CancelPreAction, GetParent <Unit>());
            CharacterStateComponent characterStateComponent = GetParent <Unit>().GetComponent <CharacterStateComponent>();
            characterStateComponent.Set(SpecialStateType.NotInControl, true);
            cancelToken = new CancellationTokenSource();
            excuteSkillParams.cancelToken = cancelToken;

            await SkillHelper.ExecuteActiveSkill(excuteSkillParams);

            cancelToken = null;
            characterStateComponent.Set(SpecialStateType.NotInControl, false);
            currUsingSkillId = string.Empty;
        }
        catch (Exception e)
        {
            Log.Error(e.ToString());
        }
    }
    public static void AddSkill(this ActiveSkillComponent self, string skillId)
    {
        ActiveSkillData activeSkillData = Game.Scene.GetComponent <SkillConfigComponent>().GetActiveSkill(skillId);

        if (activeSkillData.isNormalAttack)
        {
            self.Skill_NormalAttack = skillId;
        }
        if (!self.skillList.ContainsKey(skillId))
        {
            self.skillList.Add(skillId, new BaseSkill_AppendedData()
            {
                level = 1
            });
        }
    }
Exemplo n.º 8
0
        public override void UpdateView(params object[] objs)
        {
            uint            skillId = (uint)objs[1];
            ActiveSkillData newSkillData;

            if (SkillLogic.GetInstance().ActiveSkillDict.TryGetValue(skillId, out newSkillData) == false)
            {
                return;
            }
            ActiveSkillData skill     = null;
            int             firstNull = -1;

            for (int i = 0; i < SKILL_ITEM_COUNT; i++)
            {
                skill = items[i].SkillData;
                if (skill != null && skill.SkillID == newSkillData.SkillID)
                {
                    items[i].SkillData = newSkillData;
                    if (currentItem != null && currentItem == items[i])
                    {
                        UpdateSkillDesc(newSkillData);
                        firstNull = -1;
                        break;
                    }
                }
                if (skill == null && firstNull < 0)
                {
                    firstNull = i;
                }
            }
            if (firstNull >= 0)//学习技能
            {
                items[firstNull].SkillData = newSkillData;
                if (items[firstNull].gameObject.collider == null)
                {
                    NGUITools.AddWidgetCollider(items[firstNull].gameObject);
                }
                UIEventListener.Get(items[firstNull].gameObject).onClick += OnClickItem;
                OnClickItem(items[firstNull].gameObject);
            }
        }
Exemplo n.º 9
0
 private void ParseActiveSkillTable(DataTable activeSkillTable)
 {
     this.m_ActiveSkillDic = new Dictionary <int, ActiveSkillData>();
     foreach (DataRow row in activeSkillTable.Rows)
     {
         ActiveSkillData data = new ActiveSkillData();
         this.ParseSkillDataBase(row, data);
         data.SelectionTarget = (SelectionTargetType)Enum.Parse(typeof(SelectionTargetType), row["SelectionTarget"].ToString());
         if (data.SelectionTarget == SelectionTargetType.Attribute ||
             data.SelectionTarget == SelectionTargetType.MinAttribute ||
             data.SelectionTarget == SelectionTargetType.MaxAttribute)
         {
             data.SelectionTargetRefrenceAttribute = row.IsNull("SelectionTargetRefrenceAttribute") ? (AttributeType?)null : (AttributeType)Enum.Parse(typeof(AttributeType), row["SelectionTargetRefrenceAttribute"].ToString());
         }
         data.SkillRange = (SkillRangeType)Enum.Parse(typeof(SkillRangeType), row["SkillRange"].ToString());
         string[] strArr = row["RangeValue"].ToString().Split(ConfigConst.SplitChar);
         data.RangeValue = new byte[strArr.Length];
         for (int i = 0; i < strArr.Length; i++)
         {
             data.RangeValue[i] = byte.Parse(strArr[i]);
         }
         data.CD = byte.Parse(row["CD"].ToString());
         data.CostRateOrValue = (RateOrValueType)Enum.Parse(typeof(RateOrValueType), row["CostRateOrValue"].ToString());
         data.CostValue       = float.Parse(row["CostValue"].ToString());
         string[] buffs = row["TriggerBuffs"].ToString().Split(ConfigConst.SplitChar);
         data.TriggerBuffs = new int[buffs.Length];
         for (int i = 0; i < buffs.Length; i++)
         {
             data.TriggerBuffs[i] = int.Parse(buffs[i]);
         }
         data.DamageType       = (DamageType)Enum.Parse(typeof(DamageType), row["DamageType"].ToString());
         data.Fluctuation      = float.Parse(row["Fluctuation"].ToString());
         data.DamageRate       = row.IsNull("DamageRate") ? (float?)null : float.Parse(row["DamageRate"].ToString());
         data.RestoreHPeSource = row.IsNull("RestoreHPeSource") ? (bool?)null : byte.Parse(row["RestoreHPeSource"].ToString()) == 1;
         this.m_ActiveSkillDic.Add(data.ID, data);
     }
 }
Exemplo n.º 10
0
 private void ParseActiveSkillTable(DataTable activeSkillTable)
 {
     this.m_ActiveSkillDic = new Dictionary<int, ActiveSkillData>();
     foreach (DataRow row in activeSkillTable.Rows)
     {
         ActiveSkillData data = new ActiveSkillData();
         this.ParseSkillDataBase(row, data);
         data.SelectionTarget = (SelectionTargetType)Enum.Parse(typeof(SelectionTargetType), row["SelectionTarget"].ToString());
         if (data.SelectionTarget == SelectionTargetType.Attribute
             || data.SelectionTarget == SelectionTargetType.MinAttribute
             || data.SelectionTarget == SelectionTargetType.MaxAttribute)
         {
             data.SelectionTargetRefrenceAttribute = row.IsNull("SelectionTargetRefrenceAttribute") ? (AttributeType?)null : (AttributeType)Enum.Parse(typeof(AttributeType), row["SelectionTargetRefrenceAttribute"].ToString());
         }
         data.SkillRange = (SkillRangeType)Enum.Parse(typeof(SkillRangeType), row["SkillRange"].ToString());
         string[] strArr = row["RangeValue"].ToString().Split(ConfigConst.SplitChar);
         data.RangeValue = new byte[strArr.Length];
         for (int i = 0; i < strArr.Length; i++)
         {
             data.RangeValue[i] = byte.Parse(strArr[i]);
         }
         data.CD = byte.Parse(row["CD"].ToString());
         data.CostRateOrValue = (RateOrValueType)Enum.Parse(typeof(RateOrValueType), row["CostRateOrValue"].ToString());
         data.CostValue = float.Parse(row["CostValue"].ToString());
         string[] buffs = row["TriggerBuffs"].ToString().Split(ConfigConst.SplitChar);
         data.TriggerBuffs = new int[buffs.Length];
         for (int i = 0; i < buffs.Length; i++)
         {
             data.TriggerBuffs[i] = int.Parse(buffs[i]);
         }
         data.DamageType = (DamageType)Enum.Parse(typeof(DamageType), row["DamageType"].ToString());
         data.Fluctuation = float.Parse(row["Fluctuation"].ToString());
         data.DamageRate = row.IsNull("DamageRate") ? (float?)null : float.Parse(row["DamageRate"].ToString());
         data.RestoreHPeSource = row.IsNull("RestoreHPeSource") ? (bool?)null : byte.Parse(row["RestoreHPeSource"].ToString()) == 1;
         this.m_ActiveSkillDic.Add(data.ID, data);
     }
 }
Exemplo n.º 11
0
 public override void Init(ActorBevBase actor, SkillLogicDataBase logicData, SkillDataBase configData)
 {
     base.Init(actor, logicData, configData);
     this.m_ActiveSkillLogicData = (ActiveSkillLogicData)logicData;
     this.m_ActiveSkillData      = (ActiveSkillData)configData;
 }
Exemplo n.º 12
0
 public override void Init(ActorBevBase actor, SkillLogicDataBase logicData, SkillDataBase configData)
 {
     base.Init(actor, logicData, configData);
     this.m_ActiveSkillLogicData = (ActiveSkillLogicData)logicData;
     this.m_ActiveSkillData = (ActiveSkillData)configData;
 }