Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     actor = Global.GetActorManager().GetPlayerActor();
     if (actor != null)
     {
         if (index >= actor.skillIDList.Count)
         {
             return;
         }
         //更新技能CD效果
         int skillID = actor.skillIDList[index];
         if (Global.SkillData.Contains(skillID))
         {
             SkillItem it   = Global.SkillData[skillID] as SkillItem;
             Type      type = Type.GetType("MobaGame." + it.skillName);
             if (type != null)
             {
                 BaseSkill skill = actor.GetComponent(type.ToString()) as BaseSkill;
                 if (skill != null)
                 {
                     imageButton.fillAmount = (it.coolDownTime - skill.coolDownTimer) / it.coolDownTime;
                     //Debug.Log("更新技能"+ index +"CD效果!"+ imageButton.fillAmount);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public override void run()
        {
            if (m_caster.GetState() != ActorState.DEAD)
            {
                //这里设置使用当前技能槽的索引,更新状态时会做判断
                if (m_targetUnit != null)
                {
                    m_caster.transform.LookAt(new Vector3(m_targetUnit.transform.position.x, m_caster.transform.position.y, m_targetUnit.transform.position.z));
                    m_caster.agent.SetDestination(m_targetUnit.transform.position);
                }
                else
                {
                    return;
                }
                BaseSkill skill = null;
                m_caster.GetSkill(m_skillIndex, ref skill);
                if (skill == null)
                {
                    return;
                }
                if (skill.attributes.cost > m_caster.mana)
                {
                    Debug.Log(m_caster.creatureName + "魔法值不够!");
                    return;
                }
                m_caster.mana -= skill.attributes.cost;
                m_caster.SetCurUseSkillIndex(m_skillIndex);

                AnimationControlParamter paramter = m_caster.GetAnimationParamter("CastSpell");
                if (paramter != null)
                {
                    float AniTimeLen = m_caster.GetAnimationLength("CastSpell");
                    Debug.Log("施法动作长度" + AniTimeLen);
                    float time = skill.attributes.castTime;
                    if (time < Global.MinCastSpellTime)
                    {
                        time = Global.MinCastSpellTime;
                    }
                    paramter.timeScale = AniTimeLen / time;
                    m_caster.SetAnimationParamter("CastSpell", paramter);
                }
                else
                {
                    Debug.Log("没找到CastSpell动画参数!");
                }
                skill.targetUnit = m_targetUnit.GetComponent <Actor>();
                if (!skill.VerifyAllowType())
                {
                    return;
                }
                skill.CastSkill();
                m_caster.SetState(new CastSpellActorState(m_caster));
            }
            m_isRunning = true;
        }
Ejemplo n.º 3
0
        //获取技能
        public void GetSkill(int index, ref BaseSkill skill)
        {
            int skillId = skillIDList[index];

            if (Global.SkillData.ContainsKey(skillId))
            {
                SkillItem item = Global.SkillData[skillId] as SkillItem;
                Type      type = Type.GetType("MobaGame." + item.skillName);
                if (type != null)
                {
                    skill = gameObject.GetComponent(type.ToString()) as BaseSkill;
                }
            }
        }
Ejemplo n.º 4
0
 public void beginSkillEffect()
 {
     if (curUseSkillIndex != -1)
     {
         BaseSkill skill = null;
         GetSkill(curUseSkillIndex, ref skill);
         skill.BeginSkillEffect();
         SetState(new IdleActorState(this));
         //重置技能索引
         curUseSkillIndex = -1;
     }
     else
     {
         Debug.LogWarning("当前使用技能索引无效!");
     }
 }
        public override void run()
        {
            if (m_caster.GetState() != ActorState.DEAD)
            {
                Debug.Log(m_caster.creatureName + "使用了一个无目标的技能");
                BaseSkill skill = null;
                m_caster.GetSkill(m_skillIndex, ref skill);
                if (skill == null)
                {
                    return;
                }
                if (skill.attributes.cost > m_caster.mana)
                {
                    Debug.Log(m_caster.creatureName + "魔法值不够!");
                    return;
                }
                m_caster.mana -= skill.attributes.cost;
                m_caster.SetCurUseSkillIndex(m_skillIndex);

                AnimationControlParamter paramter = m_caster.GetAnimationParamter("CastSpell");
                if (paramter != null)
                {
                    float AniTimeLen = m_caster.GetAnimationLength("CastSpell");
                    Debug.Log("施法动作长度" + AniTimeLen);
                    float time = skill.attributes.castTime;
                    if (time < Global.MinCastSpellTime)
                    {
                        time = Global.MinCastSpellTime;
                    }
                    paramter.timeScale = AniTimeLen / time;
                    m_caster.SetAnimationParamter("CastSpell", paramter);
                }
                else
                {
                    Debug.Log("没找到CastSpell动画参数!");
                }
                if (!skill.VerifyAllowType())
                {
                    return;
                }
                skill.CastSkill();
                m_caster.SetState(new CastSpellActorState(m_caster));
            }
            this.m_isRunning = true;
        }
Ejemplo n.º 6
0
 //设置技能到角色技能槽
 public void SetSkill(int index, int skillId)
 {
     if (Global.SkillData.ContainsKey(skillId))
     {
         SkillItem item = Global.SkillData[skillId] as SkillItem;
         Type      type = Type.GetType("MobaGame." + item.skillName);
         if (type != null)
         {
             //改变技能列表对应的ID
             skillIDList[index] = skillId;
             //为角色挂上该技能脚本
             gameObject.AddComponent(type);
             BaseSkill skill = gameObject.GetComponent(type.ToString()) as BaseSkill;
             skill.caster     = this;
             skill.attributes = item;
             skill.reset();
         }
     }
     //
 }
Ejemplo n.º 7
0
        public void OnButtonDown()
        {
            Debug.Log("点击技能" + index + "按钮!");
            if (imageButton.fillAmount <= 0.1F)
            {
                actor.curSkillSlot = index;
                BaseSkill skill = null;
                actor.GetSkill(index, ref skill);
                if (skill != null)
                {
                    CommandManager cmdMgr = actor.GetCommandManager();

                    switch (skill.attributes.targetType)
                    {
                    case SkillTargetType.Unit:
                    {
                        //设置鼠标光标
                        Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.Auto);
                        //交由ActorControl去选择目标
                        actor.SetCurUseSkillIndex(index);
                        break;
                    }

                    case SkillTargetType.NoTarget:
                    {
                        cmdMgr.Clear();
                        cmdMgr.AddCommand(new SpellCastNoTargetCommand(actor, index));
                        //actor.CastSpellNoTarget (actor.curSkillSlot);
                        break;
                    }
                    }
                }
            }
            else
            {
                Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
                Debug.Log("技能还没有准备好");
            }
        }
Ejemplo n.º 8
0
        // Update is called once per frame
        void Update()
        {
            BaseSkill parent = (BaseSkill)this;

            parent.Update();
        }