public void onEnterWorld(KBEngine.Entity entity) { if (enterSpace == false) { pendingEnterEntityIDs.Add(entity.id); return; } Asset newasset = Scene.findAsset(entity.getDefinedPropterty("modelID") + ".unity3d", true, ""); newasset.createAtScene = loader.inst.currentSceneName; SceneEntityObject obj = new SceneEntityObject(); obj.kbentity = entity; if (entity.isPlayer()) { obj.createPlayer(); } else { obj.create(); } entity.renderObj = obj; Scene scene = null; if (!loader.inst.scenes.TryGetValue(loader.inst.currentSceneName, out scene)) { Common.ERROR_MSG("KBEEventProc::onEnterWorld: not found scene(" + loader.inst.currentSceneName + ")!"); return; } newasset.loadLevel = Asset.LOAD_LEVEL.LEVEL_IDLE; obj.asset = newasset; obj.idkey = "_entity_" + entity.id; Vector3 pos = obj.position; Common.calcPositionY(pos, out pos.y, false); if (entity.getDefinedPropterty("modelID") == "20002001") { pos.y += 15.0f; } obj.position = pos; obj.position = entity.position; obj.eulerAngles = new Vector3(entity.direction.y, entity.direction.z, entity.direction.x); obj.destDirection = obj.eulerAngles; object name = entity.getDefinedPropterty("name"); if (name != null) { obj.setName((string)name); } object hp = entity.getDefinedPropterty("HP"); if (hp != null) { obj.updateHPBar((Int32)hp, (Int32)entity.getDefinedPropterty("HP_Max")); } object state = entity.getDefinedPropterty("state"); if (state != null) { set_state(entity, state); } object modelScale = entity.getDefinedPropterty("modelScale"); if (modelScale != null) { set_modelScale(entity, modelScale); } object speed = entity.getDefinedPropterty("moveSpeed"); if (speed != null) { set_moveSpeed(entity, speed); } if (entity.className == "Avatar") { newasset.unloadLevel = Asset.UNLOAD_LEVEL.LEVEL_FORBID; } newasset.refs.Add(obj.idkey); scene.addSceneObject(obj.idkey, obj); if (newasset.isLoaded || newasset.bundle != null) { obj.Instantiate(); newasset.refs.Remove(obj.idkey); } else { loader.inst.loadPool.addLoad(newasset); loader.inst.loadPool.start(); } }
public void onEnterWorld(KBEngine.Entity entity) { if(enterSpace == false) { pendingEnterEntityIDs.Add(entity.id); return; } Asset newasset = Scene.findAsset(entity.getDefinedPropterty("modelID") + ".unity3d", true, ""); newasset.createAtScene = loader.inst.currentSceneName; SceneEntityObject obj = new SceneEntityObject(); obj.kbentity = entity; if(entity.isPlayer()) obj.createPlayer(); else obj.create(); entity.renderObj = obj; Scene scene = null; if(!loader.inst.scenes.TryGetValue(loader.inst.currentSceneName, out scene)) { Common.ERROR_MSG("KBEEventProc::onEnterWorld: not found scene(" + loader.inst.currentSceneName + ")!"); return; } newasset.loadLevel = Asset.LOAD_LEVEL.LEVEL_IDLE; obj.asset = newasset; obj.idkey = "_entity_" + entity.id; Vector3 pos = obj.position; Common.calcPositionY(pos, out pos.y, false); if(entity.getDefinedPropterty("modelID") == "20002001") pos.y += 15.0f; obj.position = pos; obj.position = entity.position; obj.eulerAngles = new Vector3(entity.direction.y, entity.direction.z, entity.direction.x); obj.destDirection = obj.eulerAngles; object name = entity.getDefinedPropterty("name"); if(name != null) obj.setName((string)name); object hp = entity.getDefinedPropterty("HP"); if(hp != null) obj.updateHPBar((Int32)hp, (Int32)entity.getDefinedPropterty("HP_Max")); object state = entity.getDefinedPropterty("state"); if(state != null) set_state(entity, state); object modelScale = entity.getDefinedPropterty("modelScale"); if(modelScale != null) set_modelScale(entity, modelScale); object speed = entity.getDefinedPropterty("moveSpeed"); if(speed != null) { set_moveSpeed(entity, speed); } if(entity.className == "Avatar") newasset.unloadLevel = Asset.UNLOAD_LEVEL.LEVEL_FORBID; newasset.refs.Add(obj.idkey); scene.addSceneObject(obj.idkey, obj); if(newasset.isLoaded || newasset.bundle != null) { obj.Instantiate(); newasset.refs.Remove(obj.idkey); } else { loader.inst.loadPool.addLoad(newasset); loader.inst.loadPool.start(); } }
public void onEnterWorld(KBEngine.Entity entity) { if (enterSpace == false) { pendingEnterEntityIDs.Add(entity.id); return; } int modelID = 0; string name = ""; int hp = -1, hpmax = -1; object state = null; object modelScale = null; object moveSpeed = null; // 底层使用了插件生成技术, 此处临时这么获得。 if (entity.className == "Avatar") { modelID = (int)((KBEngine.Avatar)entity).modelID; modelScale = ((KBEngine.Avatar)entity).modelScale; name = ((KBEngine.Avatar)entity).name; hp = (int)((KBEngine.Avatar)entity).HP; hpmax = (int)((KBEngine.Avatar)entity).HP_Max; state = ((KBEngine.Avatar)entity).state; moveSpeed = ((KBEngine.Avatar)entity).moveSpeed; } else if (entity.className == "Monster") { modelID = (int)((KBEngine.Monster)entity).modelID; modelScale = ((KBEngine.Monster)entity).modelScale; name = ((KBEngine.Monster)entity).name; hp = (int)((KBEngine.Monster)entity).HP; hpmax = (int)((KBEngine.Monster)entity).HP_Max; state = ((KBEngine.Monster)entity).state; moveSpeed = ((KBEngine.Monster)entity).moveSpeed; } else if (entity.className == "NPC") { modelID = (int)((KBEngine.NPC)entity).modelID; modelScale = ((KBEngine.NPC)entity).modelScale; name = ((KBEngine.NPC)entity).name; moveSpeed = ((KBEngine.NPC)entity).moveSpeed; } else if (entity.className == "Gate") { modelID = (int)((KBEngine.Gate)entity).modelID; modelScale = ((KBEngine.Gate)entity).modelScale; name = ((KBEngine.Gate)entity).name; } Asset newasset = Scene.findAsset(modelID + ".unity3d", true, ""); newasset.createAtScene = loader.inst.currentSceneName; SceneEntityObject obj = new SceneEntityObject(); obj.kbentity = entity; if (entity.isPlayer()) { obj.createPlayer(); } else { obj.create(); } entity.renderObj = obj; Scene scene = null; if (!loader.inst.scenes.TryGetValue(loader.inst.currentSceneName, out scene)) { Common.ERROR_MSG("KBEEventProc::onEnterWorld: not found scene(" + loader.inst.currentSceneName + ")!"); return; } newasset.loadLevel = Asset.LOAD_LEVEL.LEVEL_IDLE; obj.asset = newasset; obj.idkey = "_entity_" + entity.id; obj.position = entity.position; obj.eulerAngles = new Vector3(entity.direction.y, entity.direction.z, entity.direction.x); obj.destDirection = obj.eulerAngles; if (name != "") { obj.setName((string)name); } if (hp != -1) { obj.updateHPBar((Int32)hp, (Int32)hpmax); } if (state != null) { set_state(entity, state); } if (modelScale != null) { set_modelScale(entity, modelScale); } if (moveSpeed != null) { set_moveSpeed(entity, moveSpeed); } if (entity.className == "Avatar") { newasset.unloadLevel = Asset.UNLOAD_LEVEL.LEVEL_FORBID; } newasset.refs.Add(obj.idkey); scene.addSceneObject(obj.idkey, obj); if (newasset.isLoaded || newasset.bundle != null) { obj.Instantiate(); newasset.refs.Remove(obj.idkey); } else { loader.inst.loadPool.addLoad(newasset); loader.inst.loadPool.start(); } }