Beispiel #1
0
        public int GetTarget(int lookDis)
        {
            int         targetUid = 0;
            FixedPoint  m_minDis2 = new FixedPoint(999999);
            List <long> list      = CCreatureMgr.GetCreatureList();

            for (int i = 0; i < list.Count; i++)
            {
                CCreature  cc     = CCreatureMgr.Get(list[i]);
                FixedPoint abDis2 = FPCollide.GetDis2(GetPos(), cc.GetPos());
                if (abDis2 > new FixedPoint(lookDis * lookDis))
                {
                    continue;
                }

                if (cc.IsDie() || cc.GetUid() == GetUid())
                {
                    continue;
                }

                if (abDis2 < new FixedPoint(lookDis * lookDis))    // 如果目标在视线范围内
                {
                    if (abDis2 < m_minDis2)
                    {
                        m_minDis2 = abDis2;
                        targetUid = (int)cc.GetUid();
                    }
                }
            }
            return(targetUid);
        }
Beispiel #2
0
        public override BtResult Execute()
        {
            int       buffId = m_dataBase.GetData <int>((int)eAIParam.INT_BUFF_ID);
            CCreature buff   = CCreatureMgr.Get(buffId);

            if (buff != null)
            {
                //float dis2 = Collide.GetDis2(buff.GetPos(), m_creature.GetPos());
                //if (dis2 < 1.0f)
                //{
                //    return BtResult.Ended;
                //}
                //else
                //{
                //    m_curTime += FSPParam.clientFrameMsTime;
                //    if (m_curTime >= 30 * FSPParam.clientFrameMsTime)
                //    {
                //        m_curTime = 0;
                //        Vector2 target = buff.GetPos();
                //        m_creature.GoTo(target);
                //    }
                //    return BtResult.Running;
                //}
            }
            else
            {
                m_curTime = 0;
                return(BtResult.Ended);
            }
            return(BtResult.Ended);
        }
Beispiel #3
0
        public override void Update(float fTime, float fDTime)
        {
            float   h       = Input.GetAxis("Horizontal");
            float   v       = Input.GetAxis("Vertical");
            Vector2 moveVec = new Vector2(h, v);

            if (moveVec != Vector2.zero)
            {
                JoyStickModule ctr = (JoyStickModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelJoyStick);
                ctr.OnMove(false, moveVec);
                m_bMove = true;
            }
            else
            {
                if (m_bMove)
                {
                    JoyStickModule ctr = (JoyStickModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelJoyStick);
                    ctr.OnMove(true, moveVec);
                    m_bMove = false;
                }
            }

            if (Input.GetKey(KeyCode.Alpha7))
            {
                m_ai = !m_ai;
                CCreature cc = CCreatureMgr.GetMaster();
                cc.StartAi(m_ai);
            }
        }
Beispiel #4
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);
                }
            }
        }
Beispiel #5
0
        public static bool SendSkill(CCreature m_creature, BtDatabase m_dataBase, bool bDown = false)
        {
            int targetUid = m_dataBase.GetData <int>((int)eAIParam.INT_TARGET_UID);

            if (targetUid == m_creature.GetUid())
            {
                return(false);
            }
            CCreature targetCc = CCreatureMgr.Get(targetUid);

            if (targetCc != null)
            {
                Vector2d dir = (targetCc.GetPos() - m_creature.GetPos());
                dir.Normalize();
                //if (dir == Vector2.zero)
                //{
                //    dir = m_creature.GetDir();
                //}
                int selectSkillUid = m_dataBase.GetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX);

                CSkillInfo skillInfo = m_creature.GetSkillByIndex(selectSkillUid);



                CmdFspSendSkill cmd = new CmdFspSendSkill();
                cmd.m_casterUid  = (int)m_creature.GetUid();
                cmd.m_skillIndex = selectSkillUid;

                if (skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.Self)
                {
                }
                else if (skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.Dir ||
                         skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.SectorDir)
                {
                    cmd.m_dir = dir;
                }
                else if (skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.Pos)
                {
                    cmd.m_dir    = dir;
                    cmd.m_endPos = targetCc.GetPos();
                }
                cmd.m_bDown = bDown;

                if (m_creature.m_aiType == eAIType.Player)
                {
                    m_creature.SendFspCmd(cmd);
                }
                else
                {
                    m_creature.PushCommand(cmd);
                }

                // 进入公共CD
                m_dataBase.SetData <int>((int)eAIParam.INT_SKILL_INTERVAL, GetSkillCastCd(m_creature, m_dataBase));
                // 清空当前发送的技能
                m_dataBase.SetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX, -1);
                return(true);
            }
            return(false);
        }
Beispiel #6
0
        public override BtResult Execute()
        {
            GetSkillDis();
            if (m_skillDis == 0)
            {
                AIParam.SendSkill(m_creature, m_dataBase);
                return(BtResult.Ended);
            }

            // 1.实时获取当前选择的技能和目标计算 当前的移动位置
            // 2.如果到达,即可结束
            int       targetUid = m_dataBase.GetData <int>((int)eAIParam.INT_TARGET_UID);
            CCreature targetCC  = CCreatureMgr.Get(targetUid);

            if (targetCC != null)
            {
                FixedPoint dis2 = FPCollide.GetDis2(targetCC.GetPos(), m_creature.GetPos());
                if (dis2 < new FixedPoint(m_skillDis * m_skillDis))
                {
                    return(BtResult.Ended);
                }
                else
                {
                    // 一秒执行一次
                    m_curTime += FSPParam.clientFrameMsTime;
                    if (m_curTime >= 30 * FSPParam.clientFrameMsTime)
                    {
                        m_curTime = 0;

                        //Vector2 pPos = targetCC.GetPos();
                        //m_creature.GoTo(pPos);

                        Vector2d dir    = targetCC.GetPos() - m_creature.GetPos();
                        Vector2d target = m_creature.GetPos() + dir.normalized * new FixedPoint(m_skillDis);
                        Vector2d endPos = CMapMgr.m_map.GetRandomPos(target.x.value, target.y.value, 3, m_creature.m_aiType).ToVector2d();
                        //Vector2d pPos = targetCC.GetPos();

                        CmdFspAutoMove cmd = new CmdFspAutoMove();
                        cmd.m_pos = endPos;

                        if (m_creature.m_aiType == eAIType.Player)
                        {
                            m_creature.SendFspCmd(cmd);
                        }
                        else
                        {
                            m_creature.PushCommand(cmd);
                        }
                    }
                    return(BtResult.Running);
                }
            }

            return(BtResult.Ended);
        }
Beispiel #7
0
        public void OnHitTarget()
        {
            FixedPoint  m_minDis2 = new FixedPoint(999999);
            CCreature   target    = null;
            List <long> list      = CCreatureMgr.GetCreatureList();

            for (int i = 0; i < list.Count; i++)
            {
                CCreature creature = CCreatureMgr.Get(list[i]);
                if (m_listHited != null && m_listHited.Contains((int)list[i]))
                {
                    continue;
                }
                if (m_caster == creature || m_caster.bCamp(creature) || creature.IsDie() || creature == m_rec)
                {
                    continue;
                }
                FixedPoint abDis2 = FPCollide.GetDis2(m_rec.GetPos(), creature.GetPos());
                if (abDis2 < new FixedPoint(m_triggerData.Length * m_triggerData.Length))
                {
                    if (abDis2 < m_minDis2)
                    {
                        target    = creature;
                        m_minDis2 = abDis2;
                    }
                }
            }
            if (target != null)
            {
                if (m_listHited == null)
                {
                    m_listHited = new List <int>();
                }

                Debug.Log("添加单位:" + target.GetUid());
                m_listHited.Add((int)target.GetUid());
                OnHitAddBuff(m_caster, target, m_listHited);

                VTrigger vTri = GetVTrigger();
                if (vTri != null && m_rec != null && m_rec.GetVObject() != null)
                {
                    Vector3 sh = m_rec.GetVObject().GetHitHeight();
                    Vector3 th = target.GetVObject().GetHitHeight();
                    vTri.SetLineStartPos(GetPos().ToVector3() + sh);
                    vTri.SetLineTargetPos(target.GetPos().ToVector3() + th);
                }
            }
            else
            {
                Destory();
            }
        }
Beispiel #8
0
        // 矩形检测,获取最近的单位,进行激光链接
        public override void Trigger()
        {
            FixedPoint  minDis = new FixedPoint(999999);
            CCreature   minCC  = null;
            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   = m_caster.GetPos() + GetDir().normalized *new FixedPoint((m_triggerData.Length + m_triggerData.vBulletDeltaPos.z) * 0.5f);
                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))
                {
                    FixedPoint dis = Vector2d.Distance(creature.GetPos(), GetPos());
                    if (dis < minDis)
                    {
                        minDis = dis;
                        minCC  = creature;
                    }
                }
            }
            if (minCC != null)
            {
                OnHitAddBuff(m_caster, minCC);
                Vector2d targetPos = GetPos() + GetDir().normalized *minDis;

                if (m_vCreature != null)
                {
                    Vector3 tH = minCC.GetVObject().GetHitHeight();
                    GetVTrigger().SetLineTargetPos(targetPos.ToVector3() + tH);
                }
            }
            else
            {
                _CheckObstacle();
            }
        }
Beispiel #9
0
        /// <summary>
        /// 消息内容转指令对象
        /// </summary>
        private void HandleServerCmd(FspVKey cmd)
        {
            CmdFspEnum type = (CmdFspEnum)cmd.vkey;
            uint       uid  = cmd.playerId;

            if (uid == 0)
            {
                return;
            }
            CCreature   player   = CCreatureMgr.Get(uid);
            IFspCmdType logicCmd = null;

            switch (type)
            {
            case CmdFspEnum.eFspStopMove:
                //Debug.Log(uid + " 停止移动");
                logicCmd = new CmdFspStopMove();
                break;

            case CmdFspEnum.eFspMove:
                //Debug.Log(uid + " 客户端调用移动命令 " + cmd.args[0] + " " + cmd.args[1]);
                Vector2d v = new Vector2d(cmd.args[0] * 0.01f, cmd.args[1] * 0.01f);
                logicCmd = new CmdFspMove(ref v);
                break;

            case CmdFspEnum.eFspAutoMove:
                Vector2d v1 = new Vector2d(cmd.args[0] * 0.01f, cmd.args[1] * 0.01f);
                logicCmd = new CmdFspAutoMove(ref v1);
                break;

            case CmdFspEnum.eFspSendSkill:
                //Debug.Log(uid + " 客户端调用技能 " + cmd.args[0] + " " + cmd.args[1]);

                CmdFspSendSkill skill = new CmdFspSendSkill();
                skill.m_casterUid  = cmd.args[0];
                skill.m_skillIndex = cmd.args[1];
                skill.m_targetId   = cmd.args[2];
                Vector2d dir    = new Vector2d(cmd.args[3] * 0.01f, cmd.args[4] * 0.01f);
                Vector2d endPos = new Vector2d(cmd.args[5] * 0.01f, cmd.args[6] * 0.01f);
                skill.m_dir    = dir;
                skill.m_endPos = endPos;
                logicCmd       = skill;
                break;
            }
            player.PushCommand(logicCmd);
        }
Beispiel #10
0
        // 正式的游戏逻辑帧
        private void ExecuteFrame(int frameId, FspFrame frameMsg)
        {
            if (frameMsg != null && frameMsg.vkeys != null)
            {
                for (int i = 0; i < frameMsg.vkeys.Count; i++)
                {
                    FspVKey cmd = frameMsg.vkeys[i];
                    // 根据keyid做不同逻辑处理
                    HandleServerCmd(cmd);
                }
            }

            CFrameTimeMgr.Inst.FixedUpdate();
            CCreatureMgr.ExecuteFrame(frameId);
            CSkillMgr.ExecuteFrame(frameId);
            CBuffMgr.ExecuteFrame(frameId);
            CBuffTriggerMgr.ExecuteFrame(frameId);
        }
Beispiel #11
0
        public virtual void Destory()
        {
            // 还原动作
            if (m_curSkillCmd == null)
            {
                return;
            }

            CCreature player = CCreatureMgr.Get(m_curSkillCmd.m_casterUid);

            if (player != null && player.m_vCreature != null)
            {
                player.m_vCreature.PushCommand(CmdFspStopMove.Inst);
            }
            if (m_curCasterEffectHid != 0)
            {
                CEffectMgr.Destroy(m_curCasterEffectHid);
            }
        }
Beispiel #12
0
        public void Init()
        {
            CCreature player = CCreatureMgr.Get(m_curSkillCmd.m_casterUid);

            if (m_curSkillCmd.m_skillId == 0)
            {
                m_skillInfo = player.GetSkillByIndex(m_curSkillCmd.m_skillIndex).m_skillInfo;
            }
            else
            {
                // 组合技能
                SkillCsv skillCsv = CsvManager.Inst.GetCsv <SkillCsv>((int)eAllCSV.eAC_Skill);
                m_skillInfo = skillCsv.GetData(m_curSkillCmd.m_skillId);
            }

            int skillId = m_skillInfo.id;

            SkillStepCsv step = CsvManager.Inst.GetCsv <SkillStepCsv>((int)eAllCSV.eAC_SkillStep);

            m_casterData = step.GetCasterData(skillId);


            //Debug.Log("播放施法动作" + m_casterData.animaName);
            if (player.m_vCreature == null)
            {
                return;
            }

            if (m_casterData == null)
            {
                Debug.LogError("技能子表 施法配置为空:" + skillId);
                return;
            }

            m_casterObject = player.GetVObject();
            m_casterObject.StartRotate(m_curSkillCmd.m_dir.ToVector3());

            Start();
        }
Beispiel #13
0
        private void OnLoadSelect()
        {
            m_master = CCreatureMgr.GetMaster();
            m_master.UpdateUI_Skill();
            EntityBaseInfo info = new EntityBaseInfo();

            info.m_resID    = 3;
            info.m_ilayer   = (int)LusuoLayer.eEL_Dynamic;
            m_skillChoseHid = EntityManager.Inst.CreateEntity(eEntityType.eNone, info, (ent) =>
            {
                ent.SetDirection(Vector3.zero);
                //ent.SetColor(SKLL_BLUE);
                ent.SetRenderQueue(3001);
                GameObject skillChose = ent.GetObject();
                m_skillChose          = skillChose.transform;
                m_skillDistance       = m_skillChose.FindChild("distance");
                m_skillCenter         = m_skillChose.FindChild("center");
                m_skillSectorDir      = m_skillCenter.FindChild("sector_dir");
                m_skillDir            = m_skillCenter.FindChild("dir");
                m_skillPos            = m_skillCenter.FindChild("pos");

                CancelSkill();
            });
        }
Beispiel #14
0
        public static bool GetAtkTarget(CCreature m_creature, BtDatabase m_dataBase, int lookDis)
        {
            // 仇恨值高的优先作为目标
            int       hTargetUid = m_creature.m_ai.GetHightHatred();
            CCreature hTargetCC  = CCreatureMgr.Get(hTargetUid);

            if (hTargetUid != -1 &&
                hTargetCC != null &&
                !hTargetCC.IsDie())   // 有仇恨对象,并且没死
            {
                m_dataBase.SetData <int>((int)eAIParam.INT_TARGET_UID, hTargetUid);
            }

            // 如果有目标,判断是否距离足够远,远了就清空目标,继续找附近的
            int       targetUid = m_dataBase.GetData <int>((int)eAIParam.INT_TARGET_UID);
            CCreature targetCC  = CCreatureMgr.Get(targetUid);

            if (targetCC == null ||
                FPCollide.GetDis2(targetCC.GetPos(), m_creature.GetPos()) > new FixedPoint(20 * 20) ||
                targetCC.IsDie())  // 隐藏时,不作为目标
            {
                targetUid = 0;
            }
            else
            {
                return(true);
            }

            targetUid = m_creature.GetTarget(lookDis);
            // 如果没有目标,检测玩家附近的单位,锁定目标
            //FixedPoint m_minDis2 = new FixedPoint(999999);
            //List<long> list = CCreatureMgr.GetCreatureList();
            //for (int i = 0; i < list.Count; i++)
            //{
            //    CCreature cc = CCreatureMgr.Get(list[i]);
            //    FixedPoint abDis2 = FPCollide.GetDis2(m_creature.GetPos(), cc.GetPos());
            //    if (abDis2 > new FixedPoint(lookDis * lookDis))
            //        continue;

            //    if (cc.IsDie() || cc.GetUid() == m_creature.GetUid())
            //        continue;
            //    //if (m_creature.bCamp(cc))
            //    //    continue;


            //    if (abDis2 < new FixedPoint(lookDis * lookDis))    // 如果目标在视线范围内
            //    {
            //        if (abDis2 < m_minDis2)
            //        {
            //            targetUid = (int)cc.GetUid();
            //            m_minDis2 = abDis2;
            //        }
            //    }
            //}

            if (targetUid != 0)
            {
                m_dataBase.SetData <int>((int)eAIParam.INT_TARGET_UID, targetUid);
                return(true);
            }
            //m_creature.DestoryDownUpSkill();  // 无目标,结束机枪
            return(false);
        }
Beispiel #15
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();
                        }
                    }
                }
            }
        }
Beispiel #16
0
 public CCreature GetCaster()
 {
     return(CCreatureMgr.Get(m_curSkillCmd.m_casterUid));
 }
Beispiel #17
0
        /// <summary>
        /// 服务器收到所有人准备后,开始游戏
        /// </summary>
        public void Start(SC_BattleInfo battleInfo)
        {
            m_fspMgr = new FspManager();
            m_fspMgr.Init();

            Debug.Log("开始加载场景,开始汇报场景进度");

            LoginModule loginHero = (LoginModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelLogin);

            loginHero.SetVisible(false);

            SelectHeroModule selectHero = (SelectHeroModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelSelectHero);

            selectHero.SetVisible(false);

            MainModule mainModule = (MainModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelMain);

            mainModule.SetVisible(false);

            JoyStickModule js = (JoyStickModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelJoyStick);

            js.SetVisible(true);
            HeadModule head = (HeadModule)LayoutMgr.Inst.GetLogicModule(LogicModuleIndex.eLM_PanelHead);

            head.SetVisible(true);


            SetRandSeed(10);
            CMap map = CMapMgr.Create(1);

            map.Create();


            for (int i = 0; i < battleInfo.playerInfo.Count; i++)
            {
                PlayerInfo playerInfo = battleInfo.playerInfo[i];
                int        uid        = (int)playerInfo.uid;
                if (EGame.m_openid.Equals(uid.ToString()))
                {
                    EGame.m_uid = uid;
                }
                CCreature master = CCreatureMgr.Create(EThingType.Player, uid);
                master.Create(playerInfo.heroIndex, uid.ToString(), new Vector2d(60, 60 + i * 4), FPCollide.GetVector(60));

                master.m_ai     = new CCreatureAI(master, eAILevel.HARD);
                master.m_aiType = eAIType.Player;
                master.StartAi(false);
            }

            for (int i = 0; i < 1; i++)
            {
                CCreature test1 = CCreatureMgr.Create(EThingType.Player, 3000 + i);
                test1.Create(3, "测试" + i, new Vector2d(50 + i * 2, 60), FPCollide.GetVector(-220));
                test1.m_ai = new CCreatureAI(test1, eAILevel.EASY);
                test1.StartAi(true);
            }

            for (int i = 0; i < 1; i++)
            {
                CCreature test1 = CCreatureMgr.Create(EThingType.Player, 2000 + i);
                test1.Create(2, "测试" + i, new Vector2d(50 + i * 2, 60), FPCollide.GetVector(-220));
                test1.m_ai = new CCreatureAI(test1, eAILevel.EASY);
                test1.StartAi(true);
            }

            for (int i = 0; i < 1; i++)
            {
                CCreature test1 = CCreatureMgr.Create(EThingType.Player, 1000 + i);
                test1.Create(1, "测试" + i, new Vector2d(50 + i * 2, 60), FPCollide.GetVector(-220));
                test1.m_ai = new CCreatureAI(test1, eAILevel.EASY);
                test1.StartAi(true);
            }

            m_bRunning = true;
        }
Beispiel #18
0
        /// <summary>
        /// 摇杆的场景指示器也只能主角自己有,并且是操作完成才发送指令
        /// </summary>
        private void OnSkillEvent(int index, eJoyStickEvent jsEvent, Vector2 m_delta, bool bCancel)
        {
            m_curSkillIndex    = index;
            m_curSkillJoyStick = jsEvent;
            CCreature master = CCreatureMgr.GetMaster();

            CSkillInfo sInfo = m_master.GetSkillByIndex(index);

            //if (sInfo == null || !sInfo.IsCanUse())
            //{
            //    Debug.Log(index + " 不可用" + jsEvent);
            //    return;
            //}


            if (jsEvent == eJoyStickEvent.Drag)
            {
                m_curSkillDir = new Vector3(m_delta.x, 0, m_delta.y);
                m_curSkillDir.Normalize();
            }

            if (jsEvent == eJoyStickEvent.Down)
            {
                m_bSkillCancel = false;

                skillInfo = sInfo.m_skillInfo;


                m_ui.m_cancelBtn.SetActiveNew(true);
                m_ui.SetColor(index, SKLL_BLUE);


                m_skillChose.gameObject.SetActiveNew(true);
                m_skillCenter.gameObject.SetActiveNew(true);
                m_skillDistance.gameObject.SetActiveNew(true);
                m_skillSectorDir.gameObject.SetActiveNew(false);
                m_skillDir.gameObject.SetActiveNew(false);
                m_skillPos.gameObject.SetActiveNew(false);

                m_skillDistance.localScale = new Vector3(skillInfo.distance, 0.01f, skillInfo.distance) * 2;
            }

            // 自己
            if (skillInfo.selectTargetType == (int)eSelectTargetType.Self)
            {
                m_curSkillDir = master.GetDir().ToVector3();
            }
            // 扇形方向
            else if (skillInfo.selectTargetType == (int)eSelectTargetType.SectorDir)
            {
                if (jsEvent == eJoyStickEvent.Down)
                {
                    m_curSkillDir = master.GetDir().ToVector3();
                    m_skillSectorDir.gameObject.SetActiveNew(true);
                    m_skillSectorDir.localScale = new Vector3(skillInfo.distance, 0.01f, skillInfo.distance);
                }
                else if (jsEvent == eJoyStickEvent.Drag)
                {
                }
                m_skillCenter.rotation = Quaternion.LookRotation(m_curSkillDir);  // 只用控制中心点的方向
            }
            // 直线方向
            else if (skillInfo.selectTargetType == (int)eSelectTargetType.Dir)
            {
                if (jsEvent == eJoyStickEvent.Down)
                {
                    int tUid = master.GetTarget(skillInfo.distance);
                    if (tUid == 0)
                    {
                        m_curSkillDir = master.GetDir().ToVector3();
                    }
                    else
                    {
                        CCreature cc = CCreatureMgr.Get(tUid);
                        if (cc != null)
                        {
                            m_curSkillDir = (cc.GetPos() - master.GetPos()).ToVector3().normalized;
                        }
                    }
                    m_skillDir.gameObject.SetActiveNew(true);
                    m_skillDir.localScale = new Vector3(skillInfo.distance, 0.01f, skillInfo.distance);
                }
                else if (jsEvent == eJoyStickEvent.Drag)
                {
                }
                m_skillCenter.rotation = Quaternion.LookRotation(m_curSkillDir);  // 只用控制中心点的方向
            }
            // 位置
            else if (skillInfo.selectTargetType == (int)eSelectTargetType.Pos)
            {
                if (jsEvent == eJoyStickEvent.Down)
                {
                    int tUid = master.GetTarget(skillInfo.distance);
                    if (tUid == 0)
                    {
                        m_curSkilPos = m_master.GetPos().ToVector3();
                    }
                    else
                    {
                        CCreature cc = CCreatureMgr.Get(tUid);
                        if (cc != null)
                        {
                            m_curSkilPos = cc.GetPos().ToVector3();
                        }
                    }
                    m_skillPos.gameObject.SetActiveNew(true);
                    m_skillPos.position   = m_curSkilPos;
                    m_skillPos.localScale = new Vector3(skillInfo.length, 0.001f, skillInfo.length);
                }
                else if (jsEvent == eJoyStickEvent.Drag)
                {
                    Vector3 atkOffset = m_curSkillDir * m_delta.magnitude * skillInfo.distance;
                    m_curSkilPos        = m_master.m_vCreature.GetEnt().GetPos() + atkOffset;
                    m_skillPos.position = m_curSkilPos;
                }
            }

            if (jsEvent == eJoyStickEvent.Up)
            {
                // 发送技能
                if (!m_bSkillCancel)
                {
                    m_bSkillCancel = true;
                    //Debug.Log("发送技能:" + skillInfo.id  + "dir:" + m_curSkillDir + " pos:" + m_curSkilPos);
                    CmdFspSendSkill cmd = new CmdFspSendSkill();
                    cmd.m_casterUid  = (int)m_master.GetUid();
                    cmd.m_skillIndex = m_curSkillIndex;
                    cmd.m_dir        = (new Vector2(m_curSkillDir.x, m_curSkillDir.z)).ToVector2d();
                    cmd.m_endPos     = (new Vector2(m_curSkilPos.x, m_curSkilPos.z)).ToVector2d();
                    master.SendFspCmd(cmd);

                    OnSkillSpeak(index);
                }
                // 还原指示器
                CancelSkill();

                m_skillChose.gameObject.SetActiveNew(false);
            }
        }