예제 #1
0
    //技能计时、判断和伤害
    public void AttackDamage(EntityBase entity, int skillId)
    {
        SkillCfg   skillData      = resSvc.GetSkillCfg(skillId);
        List <int> skillActionLst = skillData.skillActionLst;

        long timeSum = 0;

        //计算多段伤害
        for (int i = 0; i < skillActionLst.Count; i++)
        {
            SkillActionCfg sac   = resSvc.GetSkillActionCfg(skillActionLst[i]);
            int            index = i;
            timeSum += sac.delayTime;
            if (sac.delayTime > 0)
            {
                //有延迟
                int taskId = timerSvc.AddTimeTask((id) =>
                {
                    AttackAction(entity, skillData, index);
                    entity.RemoveActionTask(id);
                }, timeSum /*延迟时间*/);
                entity.AddActionTask(taskId);
            }
            else
            {
                //无延迟
                AttackAction(entity, skillData, index);
            }
        }
    }
예제 #2
0
    public virtual void AttackDamage(EntityBase entity, int skillID)
    {
        SkillCfg skillData      = resSvc.GetSkillCfg(skillID);
        var      skillActionLst = skillData.skillActionLst;

        int sum = 0;

        for (int i = 0; i < skillActionLst.Count; i++)
        {
            SkillActionCfg skillActionCfg = resSvc.GetSkillActionCfg(skillActionLst[i]);
            sum += skillActionCfg.delayTime;
            int index = i;
            if (sum > 0)
            {
                int actid = timerSvc.AddTimeTask((int tid) =>
                {
                    if (entity != null)
                    {
                        SkillAction(entity, skillData, index);
                        entity.RemoveActionCB(tid);
                    }
                }, sum);
                entity.skActCBLst.Add(actid);
            }
            else
            {
                //瞬时技能
                SkillAction(entity, skillData, index);
            }
        }
    }
예제 #3
0
    /// <summary>
    /// 技能效果表现
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="skillID"></param>
    public void AttackEffect(EntityBase entity, int skillID)
    {
        SkillCfg skillCfg = resSvc.GetSkillCfg(skillID);

        // 判断玩家的技能是否忽略碰撞效果
        if (skillCfg.isCollide == false)
        {
            // 忽略掉Player 和 Monster 层的碰撞
            Physics.IgnoreLayerCollision(9, 10);

            // 技能释放完成后恢复碰撞
            TimerSvc.Instance.AddTimeTask((tid) => {
                Physics.IgnoreLayerCollision(9, 10, false);
            }, skillCfg.skillTime);
        }

        // 玩家才进行方向锁定攻击,怪物不需要(避免怪物攻击抖动)
        if (entity.entityType == EntityType.Player)
        {
            // player 为了连招中的方向控制
            if (entity.GetCurDirInput() == Vector2.zero)
            {
                // 搜索最近怪物攻击
                Vector2 dir = entity.CalcTargetDir();
                if (dir != Vector2.zero)
                {
                    entity.SetAtkRotation(dir);
                }
            }
            else
            {
                entity.SetAtkRotation(entity.GetCurDirInput(), true);
            }
        }


        entity.SetAction(skillCfg.aniAction);
        entity.SetFX(skillCfg.fx, skillCfg.skillTime);


        CalcSkillMove(entity, skillCfg);

        // 是否可操作
        entity.canControll = false;
        entity.SetDir(Vector2.zero);    // 方向移动失效

        // 判断攻击是否事可中断的,不是,则进入霸体状态
        if (skillCfg.isBreak == false)
        {
            entity.entityState = EntityState.BatiState;
        }


        entity.skCBID = timerSvc.AddTimeTask((tid) => {
            entity.Idle();
        }, skillCfg.skillTime);
    }
예제 #4
0
    /// <summary>
    /// 技能效果表现
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="skillID"></param>
    public void AttackEffect(EntityBase entity, int skillID)
    {
        SkillCfg skillData = resSvc.GetSkillCfg(skillID);

        if (!skillData.isCollide)
        {
            //忽略刚体碰撞
            Physics.IgnoreLayerCollision(9, 11);
            timeSvc.AddTimeTask((int tid) =>
            {
                Physics.IgnoreLayerCollision(9, 11, false);
            }, skillData.skillTime);
        }

        if (!skillData.isBreak)
        {
            entity.entityState = EntityState.StoicState;
        }

        if (entity.entityType == EntityType.Player)
        {
            if (entity.battleMgr.GetCurrentDirInput() == Vector2.zero)
            {
                //自动寻找怪物
                Vector2 targetDir = entity.CalcTargetDir();
                if (targetDir != Vector2.zero)
                {
                    entity.SetAtkDirLocal(targetDir);
                }
            }
            else
            {
                entity.SetAtkDirCam(entity.battleMgr.GetCurrentDirInput());
            }
        }


        entity.SetAction(skillData.aniAction);
        entity.SetFx(skillData.fx, skillData.skillTime);


        entity.canControl = false;
        entity.SetDir(Vector2.zero);

        CalcSkillMove(entity, skillData);

        int endID = timeSvc.AddTimeTask((int tid) =>
        {
            entity.skillEndID = -1;
            entity.Idle();
        }, skillData.skillTime);

        entity.skillEndID = endID;
    }
예제 #5
0
    public void AttackEffect(EntityBase entity, int skillId)
    {
        SkillDataCfg skillData = resSvc.GetSkillCfg(skillId);

        //判断技能能不能碰撞
        if (!skillData.bCollide)
        {
            //忽略掉刚体碰撞
            Physics.IgnoreLayerCollision(Constants.cLayerPlayer, Constants.cLayerMonster);
            timeSvc.AddTimeTask((int tid) =>
            {
                //技能播放完给恢复
                Physics.IgnoreLayerCollision(Constants.cLayerPlayer, Constants.cLayerMonster, false);
            }, skillData.skillTime);
        }

        if (entity._entityType == Constants.EntityType.Player)
        {
            if (entity.GetCurrentDirection() == Vector2.zero)
            {
                //搜索最近的怪物
                Vector2 dir = entity.CalcTargetDirection();
                if (dir != Vector2.zero)
                {
                    entity.SetAttackDirection(dir);
                }
            }
            else
            {
                entity.SetAttackDirection(entity.GetCurrentDirection(), true);
            }
        }

        entity.SetAction(skillData.aniAction);
        entity.SetFx(skillData.fx, skillData.skillTime);

        skillMoveLogical(entity, skillData);

        entity._bCanControl = false;
        entity.SetDirection(Vector2.zero);

        if (!skillData.bBreak)
        {
            entity._entityState = Constants.EntitiyState.NoEffectHit;
        }

        entity._skillEndCallbackID = timeSvc.AddTimeTask((int tid) =>
        {
            entity.Idle();
        }, skillData.skillTime);
    }
예제 #6
0
    /// <summary>
    /// 技能效果表现
    /// </summary>
    public void AttackEffect(EntityBase entity, int skillID)
    {
        SkillCfg skillData = resSvc.GetSkillCfg(skillID);

        // 忽略掉刚体碰撞,只是角色间的环境碰撞
        if (!skillData.isCollide)
        {
            // 忽略 Player 和 Monster 层
            Physics.IgnoreLayerCollision(9, 10);
            // 释放完技能后,设置回来
            timeSvc.AddTimeTask((int tid) => {
                Physics.IgnoreLayerCollision(9, 10, false);
            }, skillData.skillTime);
        }
        // 玩家,智能锁定最近的敌人
        if (entity.entityType == EntityType.Player)
        {
            // 没有方向输入
            if (entity.GetDirInput() == Vector2.zero)
            {
                // 搜索最近的怪物
                Vector2 dir = entity.CalcTargetDir();
                if (dir != Vector2.zero)
                {
                    entity.SetAtkRotation(dir);
                }
            }
            // 有方向输入
            else
            {
                entity.SetAtkRotation(entity.GetDirInput(), true);
            }
        }
        entity.SetAction(skillData.aniAction);
        entity.SetFX(skillData.fx, skillData.skillTime);

        CalcSkillMove(entity, skillData);
        entity.canControl = false;   // 释放技能的时候,禁止操控角色
        entity.SetDir(Vector2.zero); // 防止移动对技能产生影响

        if (!skillData.isBreak)
        {
            entity.entityState = EntityState.BatiState;
        }

        // 回到 Idel 状态
        entity.skEndCB = timeSvc.AddTimeTask((int tid) => {
            entity.Idle();
        }, skillData.skillTime);
    }
예제 #7
0
파일: SkillMgr.cs 프로젝트: RedAWM/DarkGod
    /// <summary>
    /// 技能效果表现
    /// </summary>
    public void AttackEffect(EntityBase entity, int skillID)
    {
        SkillCfg skillData = resSvc.GetSkillCfg(skillID);

        entity.SetAction(skillData.aniAction);
        entity.SetFX(skillData.fx, skillData.skillTime);

        CalcSkillMove(entity, skillData);

        entity.canControl = false;
        entity.SetDir(Vector2.zero);

        timeSvc.AddTimeTask((int tid) => {
            entity.Idle();
        }, skillData.skillTime);
    }