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."); } }
//发送创建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); }
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); } }
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); } }
private void NpcMove(WarMsgParam param) { IpcNpcMoveMsg msg = param.param as IpcNpcMoveMsg; if (msg.forceMove) { tran.position = VectorWrap.ToVector3(msg.pos); tran.rotation = QuaternionWrap.ToQuaternion(msg.rotation); nextPos = tran.position; nextRotate = tran.rotation; } else { IsStartMove = true; movable = true; nextPos = VectorWrap.ToVector3(msg.pos); nextRotate = QuaternionWrap.ToQuaternion(msg.rotation); } }
// has expanding node //void addJumpList() { mJumpList.add( mCodeAreaPos ); } /// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public virtual void Commit() { // some context-related processing at final, and commits it if (mContextType == ContextType.CLASS) { // clean up super class proxy if (mSuperClassGetter != null) { mSuperClassGetter.Commit(); } } if (mContextType != ContextType.PROPERTY && mContextType != ContextType.SUPER_CLASS_GETTER) { int lexpos = GetLexPos(); //putCode( VM_SRV, lexpos ); //putCode( 0 ); if ((mCodeAreaPos + 2) >= mCodeArea.Length) { ExpandCodeArea(); } if (CompileState.mEnableDebugCode) { PutSrcPos(lexpos); } mCodeArea[mCodeAreaPos] = (short)(VM_SRV); mCodeAreaPos++; mCodeArea[mCodeAreaPos] = (short)(0); mCodeAreaPos++; //putCode( VM_RET, -1 ); mCodeArea[mCodeAreaPos] = (short)(VM_RET); mCodeAreaPos++; } RegisterFunction(); if (mContextType != ContextType.PROPERTY && mContextType != ContextType.SUPER_CLASS_GETTER) { FixCode(); } mDataArray = new Variant[mDataArea.Count]; mDataArray = Sharpen.Collections.ToArray(mDataArea, mDataArray); mDataArea.Clear(); mDataArea = null; if (mContextType == ContextType.SUPER_CLASS_GETTER) { mMaxVariableCount = 2; } else { // always 2 mMaxVariableCount = mNamespace.GetMaxCount(); } mSuperClassExpr = null; ClearNodesToDelete(); mCode = new short[mCodeAreaPos]; System.Array.Copy(mCodeArea, 0, mCode, 0, mCodeAreaPos); // set object type info for debugging // we do thus nasty thing because the std::vector does not free its storage // even we call 'clear' method... //mNodeToDeleteVector = null; mNodeToDeleteVector = new VectorWrap<ExprNode>(); 直前でクリアされているはず mCurrentNodeVector.Clear(); // mCurrentNodeVector = null; mCurrentNodeVector = new VectorWrap<ExprNode>(); mFuncArgStack = null; mFuncArgStack = new Stack<InterCodeGenerator.FuncArg>(); mArrayArgStack = null; mArrayArgStack = new Stack<InterCodeGenerator.ArrayArg>(); mNestVector = null; mNestVector = new VectorWrap<InterCodeGenerator.NestData>(); mJumpList = null; mJumpList = new IntVector(); mFixList = null; mFixList = new AList<InterCodeGenerator.FixData>(); mNonLocalFunctionDeclVector = null; mNonLocalFunctionDeclVector = new VectorWrap<InterCodeGenerator.NonLocalFunctionDecl >(); }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> public InterCodeGenerator(InterCodeGenerator parent, string name, Compiler block, int type) { //super(getContextHashSize(type)); //super.mCallFinalize = false; mNodeToDeleteVector = new VectorWrap<ExprNode>(); mCurrentNodeVector = new VectorWrap<ExprNode>(); mJumpList = new IntVector(); mNestVector = new VectorWrap<InterCodeGenerator.NestData>(); mArrayArgStack = new Stack<InterCodeGenerator.ArrayArg>(); mFuncArgStack = new Stack<InterCodeGenerator.FuncArg>(); mNamespace = new LocalNamespace(); mFixList = new AList<InterCodeGenerator.FixData>(); mNonLocalFunctionDeclVector = new VectorWrap<InterCodeGenerator.NonLocalFunctionDecl >(); mSuperClassGetterPointer = new IntVector(); mParent = parent; mPropGetter = mPropSetter = mSuperClassGetter = null; mCodeArea = new short[INC_ARRAY_COUNT]; mDataArea = new AList<Variant>(); mInterCodeDataArea = new AList<Variant>(); mFrameBase = 1; //mSuperClassExpr = null; //mMaxFrameCount = 0; //mMaxVariableCount = 0; //mFuncDeclArgCount = 0; //mFuncDeclUnnamedArgArrayBase = 0; mFuncDeclCollapseBase = -1; //mFunctionRegisterCodePoint = 0; mPrevSourcePos = -1; //mSourcePosArraySorted = false; //mSourcePosArray = null; if (name != null && name.Length > 0) { mName = name; } //else { // mName = null; //} //mAsGlobalContextMode = false; mContextType = type; switch (mContextType) { case ContextType.TOP_LEVEL: { // decide variable reservation count with context type mVariableReserveCount = 2; break; } case ContextType.FUNCTION: { mVariableReserveCount = 2; break; } case ContextType.EXPR_FUNCTION: { mVariableReserveCount = 2; break; } case ContextType.PROPERTY: { mVariableReserveCount = 0; break; } case ContextType.PROPERTY_SETTER: { mVariableReserveCount = 2; break; } case ContextType.PROPERTY_GETTER: { mVariableReserveCount = 2; break; } case ContextType.CLASS: { mVariableReserveCount = 2; break; } case ContextType.SUPER_CLASS_GETTER: { mVariableReserveCount = 2; break; } } mBlock = block; mBlock.Add(this); if (mContextType == ContextType.CLASS) { // add class information to the class instance information if (mMaxFrameCount < 1) { mMaxFrameCount = 1; } int dp = PutData(new Variant(mName)); int lexPos = GetLexPos(); // const %1, name // addci %-1, %1 // cl %1 if ((mCodeAreaPos + 7) >= mCodeArea.Length) { ExpandCodeArea(); } if (CompileState.mEnableDebugCode) { PutSrcPos(lexPos); } mCodeArea[mCodeAreaPos] = (short)VM_CONST; mCodeAreaPos++; mCodeArea[mCodeAreaPos] = (short)1; mCodeAreaPos++; mCodeArea[mCodeAreaPos] = (short)dp; mCodeAreaPos++; mCodeArea[mCodeAreaPos] = (short)VM_ADDCI; mCodeAreaPos++; mCodeArea[mCodeAreaPos] = (short)-1; mCodeAreaPos++; mCodeArea[mCodeAreaPos] = (short)1; mCodeAreaPos++; mCodeArea[mCodeAreaPos] = (short)VM_CL; mCodeAreaPos++; mCodeArea[mCodeAreaPos] = (short)1; mCodeAreaPos++; // update FunctionRegisterCodePoint mFunctionRegisterCodePoint = mCodeAreaPos; } }
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); } } } }
public LocalNamespace() { //mMaxCount = 0; //mCurrentCount = 0; mLevels = new VectorWrap<LocalSymbolList>(); }