コード例 #1
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);
            }
        }
    }
コード例 #2
0
ファイル: SkillMgr.cs プロジェクト: wangzeping1998/-
    //技能计时、判断和伤害
    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);
            }
        }
    }
コード例 #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
ファイル: SkillMgr.cs プロジェクト: yoyo-sincerely/DarkGod
    /// <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
ファイル: BattleMgr.cs プロジェクト: wangzeping1998/-
 //显示当前批次的怪物
 public void SetActiveCurrentBatchMonsters()
 {
     timerSvc.AddTimeTask((taskId) =>
     {
         foreach (var monster in monsterDic)
         {
             monster.Value.SetActive();
             monster.Value.Born();
             timerSvc.AddTimeTask((ttid) =>
             {
                 monster.Value.Idle();
             }, 1000);
         }
     }, 500);
 }
コード例 #8
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);
    }
コード例 #9
0
 public void Init()
 {
     timerSvc = TimerSvc.Instance;
     cacheSvc = CacheSvc.Instance;
     timerSvc.AddTimeTask(CalcPowerAdd, PECommon.PowerAddMinute, PETimeUnit.Second, 0);
     PECommon.Log("PowerSys Init Done");
 }
コード例 #10
0
    public override void SetFX(string name, float delay)
    {
        GameObject go;

        if (fxDic.TryGetValue(name, out go))
        {
            go.SetActive(true);
            TimerSvc.AddTimeTask((int tid) =>
            {
                go.SetActive(false);
            }, delay);
        }
    }
コード例 #11
0
    public void SetChatacterShootBullet(AllSyncBullet bulletInfo)
    {
        PECommon.Log("在自己的客户端上实例化一个子弹。");

        Vector3 pos = UnityTools.GetV3Value(bulletInfo.originPos);
        Vector3 rot = UnityTools.GetV3Value(bulletInfo.originRot);
        Vector3 dir = UnityTools.GetV3Value(bulletInfo.dir);
        //-----------------------发射子弹
        GameObject tempBullet = null;

        if (bulletPool.Data())
        {
            tempBullet = bulletPool.GetObject();
            tempBullet.transform.position    = pos;
            tempBullet.transform.eulerAngles = rot;
            tempBullet.gameObject.SetActive(true);
        }
        else
        {
            tempBullet      = GameObject.Instantiate(Resources.Load <GameObject>(bulletInfo.prefabName), pos, Quaternion.Euler(rot), bulletParent);
            tempBullet.name = "Bullet";
        }

        if (tempBullet.GetComponent <Bullet>() == null)
        {
            tempBullet.AddComponent <Bullet>();
        }
        Bullet bullet = tempBullet.GetComponent <Bullet>();

        PECommon.Log("这颗子弹的ID从" + bullet.damageID + "改变到" + (bullet.damageID + 1));
        if (bullet.damageID <= lastShootBulletID)
        {
            bullet.damageID = lastShootBulletID + 1;
        }
        else
        {
            bullet.damageID += 1;
        }
        lastShootBulletID = bullet.damageID;
        bullet.SetCasterRoleType(bulletInfo.roleType);
        bullet.PlayAudio();
        if (bulletInfo.shootSky == 1)
        {
            bulletInfo.force *= 10;
        }
        bullet.Shoot(dir, bulletInfo.force, bulletInfo.damage, bulletPool);

        //-------------------------------开火特效
        GameObject fireEffect = null;

        if (fireEffectPool.Data())
        {
            fireEffect = fireEffectPool.GetObject();
            fireEffect.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
            fireEffect.transform.position   = pos;
            //fireEffect.transform.eulerAngles = rot;
            fireEffect.gameObject.SetActive(true);
        }
        else
        {
            fireEffect      = GameObject.Instantiate(Resources.Load <GameObject>(bulletInfo.fireEffect), pos, Quaternion.identity, effectParent);
            fireEffect.name = "FireEffect";
            fireEffect.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
        }
        timerSvc.AddTimeTask((int tid) =>
        {
            fireEffect.gameObject.SetActive(false);
            fireEffectPool.AddObject(fireEffect);
        }, 500);
        //-------------------------------弹壳特效
        GameObject shellEffect = null;
        Vector3    newPos      = new Vector3(pos.x, pos.y, pos.z - 0.5f);

        if (shellEffectPool.Data())
        {
            shellEffect = shellEffectPool.GetObject();
            shellEffect.transform.position    = newPos;
            shellEffect.transform.eulerAngles = rot;
            shellEffect.GetComponent <ShellEffect>().ShellFly(new Vector3(0, 1, Random.Range(0.05f, 0.2f)), 300);
            shellEffect.gameObject.SetActive(true);
        }
        else
        {
            shellEffect      = GameObject.Instantiate(Resources.Load <GameObject>(bulletInfo.shellEffect), newPos, Quaternion.Euler(rot), effectParent);
            shellEffect.name = "ShellEffect";
            shellEffect.GetComponent <ShellEffect>().ShellFly(new Vector3(0, 1, Random.Range(0.05f, 0.2f)), 300);
        }
        if (shellEffect.GetComponent <ShellEffect>() != null)
        {
            shellEffect.GetComponent <ShellEffect>().PlayAudio();
        }
        timerSvc.AddTimeTask((int tid) =>
        {
            shellEffect.gameObject.SetActive(false);
            shellEffectPool.AddObject(shellEffect);
        }, 500);
    }