Ejemplo n.º 1
0
    ///通过多次释放技能来切换技能的多段攻击
    public EmPlaySKillResult PlaySKill(float timer, float statusDuration, float attackSpeed)
    {
        if (curAttackIndex < skillConf.attackList.Count - 1)
        {
            if (curAttackConf.autoNextAttack)
            {
                return(EmPlaySKillResult.None);
            }

            if (timer >= statusDuration)
            {
                curAttackIndex++;                                     //开始下个攻击
                curAttackConf = skillConf.attackList[curAttackIndex]; //actor需要判断当前攻击是否释放时间
                return(EmPlaySKillResult.PlayNext);
            }
            else
            {
                if (timer >= curAttackConf.comboStartTime * attackSpeed)
                {
                    return(EmPlaySKillResult.WaitToCombo);
                }
            }
        }
        return(EmPlaySKillResult.None);
    }
Ejemplo n.º 2
0
 public void Init(ActorBase actor, int skillID)
 {
     skillConf      = DBSkillTable.GetRecord(skillID);
     this.actor     = actor;
     curAttackIndex = 0;
     curAttackConf  = skillConf.attackList[curAttackIndex];       //actor需要判断当前攻击是否释放时间
     isActive       = true;
 }
Ejemplo n.º 3
0
 public void PlaySkill_AutoNextAttack()
 {
     if (curAttackIndex < skillConf.attackList.Count - 1)
     {
         curAttackIndex++;                                     //开始下个攻击
         curAttackConf = skillConf.attackList[curAttackIndex]; //actor需要判断当前攻击是否释放时间
         DoCurAttack();
     }
 }
Ejemplo n.º 4
0
    //获取记录,如果不存在返回null
    public static DBSkillAttackConf GetRecord(int ID, bool errorMsg = true)
    {
        if (instance == null)
        {
            Debug.LogError("表DBSkillAttackTable未加载");
            return(null);
        }
        DBSkillAttackConf record = null;

        if (recordDict.TryGetValue(ID, out record))
        {
            return(record);
        }
        if (errorMsg)
        {
            Debug.LogErrorFormat("表DBSkillAttackTable没有ID = {0}的记录", ID);
        }
        return(null);
    }
Ejemplo n.º 5
0
 public void Init()
 {
     //如果recordDict不为null,说明已经初始化了
     if (recordDict != null)
     {
         return;
     }
     recordDict = new Dictionary <int, DBSkillAttackConf>();
     for (int i = 0; i < recordArray.Length; i++)
     {
         DBSkillAttackConf record = recordArray[i];
         if (!recordDict.ContainsKey(record.ID))
         {
             recordDict.Add(record.ID, record);
         }
         else
         {
             Debug.LogErrorFormat("表DBSkillAttackTable有重复的记录,id = {0}", record.ID);
         }
     }
 }
Ejemplo n.º 6
0
    public static void Init()
    {
        if (DBSkillAttackTable.instance == null)
        {
            Debug.LogError("DBAttackTable has not initalized");
            return;
        }
        if (attackDict != null)
        {
            Debug.LogError("DBAttackTableWrap has been initalized");
            return;
        }

        attackDict = new Dictionary <int, DBSkillConf>();
        DBSkillAttackConf[] recordArray = DBSkillAttackTable.instance.recordArray;
        DBSkillConf         skill;

        for (int i = 0; i < recordArray.Length; i++)
        {
            DBSkillAttackConf conf = recordArray[i];
            if (!attackDict.TryGetValue(conf.skillID, out skill))
            {
                skill         = new DBSkillConf();
                skill.skillID = conf.skillID;
                attackDict.Add(conf.skillID, skill);
            }
            skill.attackList.Add(conf);
        }

        /*log
         * foreach(DBAttackGroup g  in attackDict.Values)
         * {
         *      Debug.Log("Group " + g.attackID);
         *      for(int i = 0; i < g.childAttackList.Count; i++)
         *      {
         *              Debug.Log("   " + i + " " + g.childAttackList[i].ID);
         *      }
         * }
         * */
    }
Ejemplo n.º 7
0
    public void StartAttack(SkillBase skill, ActorBase actor, DBSkillAttackConf attackConf)
    {
        //Debug.Log("Do attack: " + attackConf.ID);
        isAttackObjectMoving = false;
        isAllDamageEnd       = false;
        isEffectPlayEnd      = false;

        this.skill = skill;

        damageConfArray = new DBSkillDamageConf[attackConf.damages.Length];
        for (int i = 0; i < attackConf.damages.Length; i++)
        {
            damageConfArray[i] = DBSkillDamageTable.GetRecord(attackConf.damages[i]);
        }

        if (!string.IsNullOrEmpty(attackConf.attackObjectName))
        {
            eo = EffectManager.GetEffect(attackConf.attackObjectName, null);
            eo.effectObject.gameObject.SetActive(attackConf.attackObjectAppearTime <= 0);            //需要倒计时显示的话,先隐藏
            X2DEffect effect = eo.x2dEffect;
            if (effect != null)
            {
                effect.Play();
                Vector3 pos = Vector3.zero;
                pos.x = attackConf.attackObjectAppearPos.x;
                pos.y = attackConf.attackObjectAppearPos.y;
                pos   = actor.objectbase.GetFaceBasedPos(pos);

                if (attackConf.attackObjectMoveMode == EmAttackObjectMoveMode.FollowCaster)
                {
                    eo.effectObject.transform.parent        = actor.transform;
                    eo.effectObject.transform.localRotation = Quaternion.identity;
                    eo.effectObject.realLocalPos            = pos;
                }
                else
                {
                    eo.effectObject.realPos = actor.objectbase.realLocalPos + pos;
                }
                eo.effectObject.isFacingRight = actor.objectbase.isFacingRight;

                //攻击物体移动
                if (attackConf.attackObjectMoveMode == EmAttackObjectMoveMode.AutoMove_Vector)
                {
                    //向量移动
                    isAttackObjectMoving     = true;
                    attackObjectMoveTimer    = 0;
                    attackObjectMoveDuration = attackConf.attackObjectMoveDuration;
                    //
                    attackObjectMoveCurve    = AnimationCurveCollection.GetAnimationCurve(attackConf.attackObjectMoveVectorCurve);
                    attackObjectMoveVector   = attackConf.attackObjectMoveVector;
                    attackObjectMoveStartPos = eo.effectObject.realLocalPos;
                    if (!eo.effectObject.isFacingRight)
                    {
                        attackObjectMoveVector.x = -attackObjectMoveVector.x;
                    }
                }
                else if (attackConf.attackObjectMoveMode == EmAttackObjectMoveMode.AutoMove_Speed)
                {
                    //曲线移动
                    isAttackObjectMoving     = true;
                    attackObjectMoveTimer    = 0;
                    attackObjectMoveDuration = attackConf.attackObjectMoveDuration;
                    //
                    attackObjectMoveSpeed = attackConf.attackObjectMoveSpeed;
                    if (!eo.effectObject.isFacingRight)
                    {
                        attackObjectMoveSpeed.x = -attackObjectMoveSpeed.x;
                    }
                }
            }
        }

        //音效
        if (!string.IsNullOrEmpty(attackConf.actorCastSoundName))
        {
            actor.audioSource.clip = ResourceLoader.LoadCharactorSound(attackConf.actorCastSoundName);
            actor.audioSource.Play();
        }

        this.actor      = actor;
        this.attackConf = attackConf;
        damageTimer     = 0f;
        attackTimer     = 0f;
        attackTimes     = 0;
        showTimer       = 0;
        damageIndex     = 0;
        isFinished      = false;
        isCurDamageEnd  = false;
        isBuffEnabled   = false;
        isInCollision   = false;
        isLifeTimeEnd   = false;
        isShowed        = false;
    }