Example #1
0
        public void CreateNpc()
        {
            Utils.Assert(curChapConfig == null, "Chapter Configdata is null.");

            if (reader.loadSceneConfig(curChapConfig.scene_config))
            {
                NPCInSceneData[] npcInScene = reader.GetSceneEditorElementData <NPCInSceneData>();
                if (npcInScene != null && npcInScene.Length > 0)
                {
                    int       len      = npcInScene.Length;
                    CrtHero[] toClient = new CrtHero[len];

                    for (int i = 0; i < len; i++)
                    {
                        NPCInSceneData sceneD = npcInScene [i];
                        ServerNPC      npc    = virNpcLoader.Load(sceneD.npcID, sceneD.camp, WarPoint);
                        if (npc == null)
                        {
                            ConsoleEx.DebugWarning("Create npc fail!!!!!!!!!   id::  " + sceneD.npcID);
                            continue;
                        }

                        npc.transform.localPosition    = new Vector3(sceneD.pos [0], sceneD.pos [1], sceneD.pos [2]);
                        npc.transform.localScale       = new Vector3(sceneD.scale [0], sceneD.scale [1], sceneD.scale [2]);
                        npc.transform.localEulerAngles = new Vector3(sceneD.rotation [0], sceneD.rotation [1], sceneD.rotation [2]);

                        npc.spawnPos = npc.transform.position;
                        npc.spawnRot = npc.transform.rotation;

                        npc.dataInScene     = sceneD;
                        npc.data.btData.way = sceneD.way;

                        //初始化buff
                        InitBuff(npc);
                        //初始化AI
                        InitAi(npc);

                        toClient[i] = new CrtHero()
                        {
                            npcID    = sceneD.npcID,
                            uniqueId = npc.UniqueID,
                            pos      = VectorWrap.ToVector(npc.transform.position),
                            rotation = VectorWrap.ToVector(npc.transform.eulerAngles),
                            camp     = (int)npc.Camp,
                        };
                    }
                    //send creating npc message to client
                    IpcCreateNpcMsg msg = new IpcCreateNpcMsg()
                    {
                        npclist = toClient,
                    };
                    WarSMgr.realServer.proxyCli.CtorNpc(msg);
                }
            }
            else
            {
                ConsoleEx.DebugWarning(curChapConfig.scene_config + " scene config is not find.");
            }
        }
Example #2
0
 //发送创建npc消息
 void SendCreateNpcMsg(ServerNPC newNpc)
 {
     crtMsg.npclist[0].npcID    = newNpc.data.configData.ID;
     crtMsg.npclist[0].uniqueId = newNpc.UniqueID;
     crtMsg.npclist[0].camp     = (int)newNpc.Camp;
     crtMsg.npclist[0].pos      = VectorWrap.ToVector(newNpc.transform.position);
     crtMsg.npclist[0].rotation = VectorWrap.ToVector(newNpc.transform.eulerAngles);
     WarServerManager.Instance.realServer.proxyCli.CtorNpc(crtMsg);
 }
Example #3
0
        public void SendNpcMoveMsg(bool forceMove = false)
        {
            if (data != null && data.configData.moveable == Moveable.Movable)
            {
                if (moveMsg == null)
                {
                    moveMsg = new IpcNpcMoveMsg();
                }

                moveMsg.uniqueId  = UniqueID;
                moveMsg.pos       = VectorWrap.ToVector(mTrans.position);
                moveMsg.rotation  = QuaternionWrap.ToLpcQuaternion(mTrans.rotation);
                moveMsg.forceMove = forceMove;
                WarServerManager.Instance.realServer.proxyCli.NPCMove(moveMsg);
            }
        }
Example #4
0
        void SendCrtBulletMsg(ServerNPC npc)
        {
            IpcCreateNpcMsg msg = new IpcCreateNpcMsg();

            msg.npclist             = new CrtHero[1];
            msg.npclist[0]          = new CrtHero();
            msg.npclist[0].npcID    = npc.data.configData.ID;
            msg.npclist[0].uniqueId = npc.UniqueID;
            msg.npclist[0].camp     = (int)npc.Camp;
            msg.npclist[0].pos      = VectorWrap.ToVector(npc.transform.position);
            msg.npclist[0].rotation = VectorWrap.ToVector(npc.transform.eulerAngles);
            WarServerManager mgr = WarServerManager.Instance;

            if (mgr != null)
            {
                mgr.realServer.proxyCli.CtorNpc(msg);
            }
        }
Example #5
0
        void CreateOneSideHero(WarCamp wc, out List <ServerLifeNpc> NpcContainer, List <CrtHero> heroList)
        {
            NpcContainer = new List <ServerLifeNpc>();

            List <RoomCharactor> OneSide = Charactors.get(wc);

            int count = OneSide.Count;

            for (int j = 0; j < count; ++j)
            {
                WrapperTeam    wrapperTeam = (WrapperTeam)OneSide[j].team;
                List <NPCData> dataTeam    = wrapperTeam.dataTeam;
                int            cnt         = dataTeam.Count;
                #if SINGLE_HERO
                cnt = 1;
                #endif

                if (dataTeam != null && cnt > 0)
                {
                    //一方出生点
                    CAMP camp = WarCamp2Camp.toCamp(wc);

                    List <ServerNPC> npcList = WarSMgr.npcMgr.GetNPCListByNum(NpcMgr <ServerNPC> .BORN_POINT, camp);

                    for (int i = 0; i < cnt; i++)
                    {
                        ServerNPC npc = virNpcLoader.Load(dataTeam[i].configData.ID, camp, WarPoint);

                        //设置出生点
                        npc.transform.position = npcList[i].transform.position;

                        npc.spawnPos = npc.transform.position;
                        npc.spawnRot = npc.transform.rotation;

                        ServerLifeNpc hero = npc as ServerLifeNpc;
                        NpcContainer.Add(hero);

                        wrapperTeam.AddNpcMember(hero, i);

                        BehaviorTree tree = hero.gameObject.AddComponent <BehaviorTree>();
                        tree.ExternalBehavior    = AiLoader.load(AILoader.PATHFIND_ATK);
                        tree.StartWhenEnabled    = true;
                        tree.RestartWhenComplete = true;

                        hero.SwitchAutoBattle(true);
                        hero.SwitchAutoBattle(false);

                        CrtHero crt = new CrtHero();
                        crt.camp     = (int)npc.Camp;
                        crt.npcID    = npc.data.configData.ID;
                        crt.uniqueId = npc.UniqueID;
                        crt.pos      = VectorWrap.ToVector(npc.transform.position);
                        crt.rotation = VectorWrap.ToVector(npc.transform.eulerAngles);
                        crt.ClientID = OneSide[j].UID;
                        crt.index    = i;

                        heroList.Add(crt);
                    }
                }
            }
        }