예제 #1
0
        public override void Launch()
        {
            //base.Launch();
            //Debug.Log("近战击中,计算伤害");
            // 检测,播放受击动作
            Vector2d pos = CCreatureMgr.Get(m_curSkillCmd.m_casterUid).GetPos();
            Vector2d dir = m_curSkillCmd.m_dir;

            List <long> list = CCreatureMgr.GetCreatureList();

            for (int i = 0; i < list.Count; i++)
            {
                CCreature creature = CCreatureMgr.Get(list[i]);
                if (GetCaster().bCamp(creature) || creature.IsDie())
                {
                    continue;
                }

                Vector2d focusPos = creature.GetPos();
                FPSector sec      = new FPSector();
                sec.pos   = pos;
                sec.dir   = dir;
                sec.angle = new FixedPoint(m_skillInfo.width);
                sec.r     = new FixedPoint(m_skillInfo.length);

                if (FPCollide.bSectorInside(sec, focusPos))
                {
                    //Debug.Log("近战检测:" + item.GetUid());
                    //OnHit(creature, i++);
                    OnCasterAddBuff(GetCaster(), creature);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 通过BUFF区域检测触发
        /// </summary>
        public virtual void Trigger()
        {
            if (m_triggerData.ShapeType == (int)eBuffTriggerShapeType.Circle)
            {
                FPSphere tSphere = new FPSphere();
                tSphere.c = GetPos();
                tSphere.r = new FixedPoint(m_triggerData.Length);

                List <long> list = CCreatureMgr.GetCreatureList();
                for (int i = 0; i < list.Count; i++)
                {
                    CCreature creature = CCreatureMgr.Get(list[i]);
                    if (m_caster.bCamp(creature) || creature.IsDie())
                    {
                        continue;
                    }

                    FPSphere playerS = new FPSphere();
                    playerS.c = creature.GetPos();
                    playerS.r = creature.GetR();

                    if (FPCollide.bSphereSphere(tSphere, playerS))
                    {
                        OnHitAddBuff(m_caster, creature);
                    }
                }
            }
            else if (m_triggerData.ShapeType == (int)eBuffTriggerShapeType.Sector)
            {
                List <long> list = CCreatureMgr.GetCreatureList();
                for (int i = 0; i < list.Count; i++)
                {
                    CCreature creature = CCreatureMgr.Get(list[i]);
                    if (m_caster.bCamp(creature) || creature.IsDie())
                    {
                        continue;
                    }

                    FPSphere playerS = new FPSphere();
                    playerS.c = creature.GetPos();
                    playerS.r = creature.GetR();

                    FPSector sec = new FPSector();
                    sec.pos   = GetPos();
                    sec.dir   = GetDir();
                    sec.angle = new FixedPoint(m_triggerData.Width);
                    sec.r     = new FixedPoint(m_triggerData.Length);

                    if (FPCollide.bSectorInside(sec, creature.GetPos()))
                    {
                        OnHitAddBuff(m_caster, creature);
                    }
                }
            }
            else if (m_triggerData.ShapeType == (int)eBuffTriggerShapeType.Rect)
            {
                List <long> list = CCreatureMgr.GetCreatureList();
                for (int i = 0; i < list.Count; i++)
                {
                    CCreature creature = CCreatureMgr.Get(list[i]);
                    if (m_caster.bCamp(creature) || creature.IsDie())
                    {
                        continue;
                    }

                    FPSphere playerS = new FPSphere();
                    playerS.c = creature.GetPos();
                    playerS.r = creature.GetR();

                    Vector2d pos   = GetPos();
                    int      angle = (int)FPCollide.GetAngle(GetDir()).value;
                    FPObb    obb   = new FPObb(pos, new Vector2d(m_triggerData.Width, m_triggerData.Length), angle);
                    if (FPCollide.bSphereOBB(playerS, obb))
                    {
                        OnHitAddBuff(m_caster, creature);
                    }
                }
            }

            if (m_triggerData.PosType == (int)eBuffTriggerPosType.CasterStartPos_SkillDir)
            {
                // 障碍碰撞
                if (CMapMgr.m_map.IsblockNotAirWal((int)m_curPos.x.value, (int)m_curPos.y.value))
                {
                    Destory();
                    return;
                }
                if (PhysicsManager.Inst.IsblockNotAirWal((int)m_curPos.x, (int)m_curPos.y))
                {
                    Destory();
                    return;
                }

                // 子弹碰撞
                FPSphere cur = new FPSphere();
                cur.c = GetPos();
                cur.r = GetR();
                foreach (KeyValuePair <long, CBuffTrigger> item in CBuffTriggerMgr.m_dicSkill)
                {
                    CBuffTrigger tri = item.Value;
                    if (tri.m_triggerData.PosType == (int)eBuffTriggerPosType.CasterStartPos_SkillDir && tri != this && tri.m_caster != m_caster)
                    {
                        FPSphere triItem = new FPSphere();
                        triItem.c = tri.GetPos();
                        triItem.r = tri.GetR();

                        if (FPCollide.bSphereSphere(cur, triItem))
                        {
                            Destory();
                            tri.Destory();
                        }
                    }
                }
            }
        }