public GameObject ChooseShip(KBEngine.Entity entity) { if (entity == null || entity.className != "Avatar") { return(null); } KBEngine.Avatar avatar = (KBEngine.Avatar)entity; Debug.Log(name + ",world::ChooseShip,avatar.level:" + avatar.level); if (avatar.level == 1) { return(ship1Perfab); } else if (avatar.level == 2) { return(ship2Perfab); } else if (avatar.level == 3) { return(ship3Perfab); } return(null); }
public void createPlayer() { if (player != null) { return; } if (KBEngineApp.app.entity_type != "Avatar") { return; } KBEngine.Avatar avatar = (KBEngine.Avatar)KBEngineApp.app.player(); if (avatar == null) { Debug.Log("wait create(palyer)!"); return; } float y = avatar.position.y; if (avatar.isOnGround) { y = 1.3f; } player = Instantiate(avatarPerfab, new Vector3(avatar.position.x, y, avatar.position.z), Quaternion.Euler(new Vector3(avatar.direction.y, avatar.direction.z, avatar.direction.x))) as UnityEngine.GameObject; player.GetComponent <GameEntity>().entityDisable(); avatar.renderObj = player; ((UnityEngine.GameObject)avatar.renderObj).GetComponent <GameEntity>().isPlayer = true; }
public void dialog_setContent(Int32 talkerId, List <object> dialogIds, List <object> dialogsTitles, string title, string body, string sayname) { KBEngine.Entity entity = KBEngineApp.app.player(); KBEngine.Avatar avatar = null; if (entity != null && entity.className == "Avatar") { avatar = (KBEngine.Avatar)entity; } List <string> titles = new List <string>(); List <UnityAction> actions = new List <UnityAction>(); for (int i = 0; i < dialogsTitles.Count; i++) { titles.Add((string)dialogsTitles[i]); UInt32 dialogId = (UInt32)dialogIds[i]; actions.Add(() => avatar.dialog(talkerId, dialogId)); } if (titles.Count > 0) { MenuBox.Show ( titles, actions, sayname + ": " + body ); } }
public void onMineDestroy(KBEngine.Entity entity, Int32 CollisionID, UInt16 explodeTime) { if (gameObject == null || entity.renderObj == null || entity.className != "Mine") { return; } UnityEngine.GameObject.Destroy((UnityEngine.GameObject)entity.renderObj); entity.renderObj = null; KBEngine.Avatar collisioner = (KBEngine.Avatar)KBEngineApp.app.findEntity(CollisionID); if (collisioner == null) { Debug.Log("collisioner not in your world!"); return; } string perfabName = ""; if (collisioner.level == 1) { perfabName = "character/daoju/effect/prefab/spacecraft_zhadan02baozha"; } else if (collisioner.level == 2) { perfabName = "character/daoju/effect/prefab/spacecraft_zhadan02baozha"; } else if (collisioner.level == 3) { perfabName = "character/daoju/effect/prefab/spacecraft_zhadan02baozha"; } addEffect(collisioner.position, collisioner.direction, perfabName, explodeTime); Debug.Log("World::onMineDestroy: " + entity.id + ",className:" + entity.className); }
private void OnGUI() { GUI.Label(new Rect(80, 90, 320, 20), "MousePos=" + _mousePos.ToString()); GUI.Label(new Rect(80, 110, 320, 20), "LookPos=" + _lookPos.ToString()); strSpaceId = GUI.TextField(new Rect(80, 130, 45, 24), strSpaceId); if (GUI.Button(new Rect(130, 130, 60, 24), "传送")) { byte spaceId; if (byte.TryParse(strSpaceId, out spaceId)) { KBEngine.Avatar avatar = (KBEngine.Avatar)KBEngineApp.app.player(); if (avatar != null) { avatar.teleport(spaceId); } } } UnityEngine.GameObject obj = UnityEngine.GameObject.Find("player(Clone)"); if (obj != null) { GUI.Label(new Rect(240, 20, 400, 100), "id=" + KBEngineApp.app.entity_id + ", position=" + obj.transform.position.ToString()); Camera.main.fieldOfView = GUI.VerticalSlider(new Rect(Screen.width - 140, 20, 100, 400), Camera.main.fieldOfView, 90.0f, 10.0f); } }
public void SetBagItemPos(UnityEngine.GameObject surface, UnityEngine.GameObject old) { Debug.LogWarning("setBagItemPos"); Monitor.Enter(KBEngineApp.app.entities); KBEngine.Avatar player = (KBEngine.Avatar)KBEngineApp.app.player(); UInt64 serialnum = itemsDic[old]; FrameBagIndex new_fbi = frameBagDic[surface]; player.setBagItemPos(serialnum, new_fbi.FrameIndex, new_fbi.BagIndex); Monitor.Exit(KBEngineApp.app.entities); Byte frame = 0; UInt16 bagindex = 0; foreach (var v in KnapSackInfo.inst.allKanpItems) { foreach (var mv in v.Value) { if (mv.Value.serialnum == serialnum) { frame = v.Key; bagindex = mv.Key; } } } KnapsakItem ksi = KnapSackInfo.inst.allKanpItems[frame][bagindex]; KnapSackInfo.inst.allKanpItems[frame].Remove(bagindex); ksi.bagFrameIndex = new_fbi.FrameIndex; ksi.bagItemIndex = new_fbi.BagIndex; KnapSackInfo.inst.allKanpItems[new_fbi.FrameIndex].Add(new_fbi.BagIndex, ksi); }
void PickUpItem() { Monitor.Enter(KBEngineApp.app.entities); KBEngine.Avatar player = (KBEngine.Avatar)KBEngineApp.app.player(); player.pickUpRequest(seo.kbentity.id); Monitor.Exit(KBEngineApp.app.entities); }
private void CreateSceneCallBackAction() { IsSceneLoadComplete = true; SingletonGather.UiManager.TryGetOrCreatePanel("SceneLoadPanel").SetActive(false); KBEngine.Avatar avatar = (KBEngine.Avatar)KBEngineApp.app.player(); if (avatar == null) { Debug.LogError("onMainAvatarEnterSpace:avatar == null!"); return; } var gamePanel = SingletonGather.UiManager.TryGetOrCreatePanel("GamePanel").GetComponent <GamePanel>(); if (gamePanel != null) { gamePanel.OnMainAvatarActive(avatar); } var playerDialogPanel = SingletonGather.UiManager.TryGetOrCreatePanel("PlayerDialogPanel").GetComponent <PlayerDialogPanel>();//聊天窗口 if (playerDialogPanel != null) { playerDialogPanel.OnMainAvatarActive(avatar); } if (PlayerInputController.instance) { PlayerInputController.instance.gameObject.SetActive(true); } SingletonGather.UiManager.Canvas.ToString(); PlayerTarget.Instance.ToString(); ObjectSelectManager.Instance.ToString(); ClientApp.Instance.DelayExecuteRepeating(DetectRenderObj, 0, 4); }
void CreatePlayer() { Debug.Log("SyncManager::CreatePlayer.count:" + GameData.Instance.RoomPlayers.Count); for (int i = 0; i < GameData.Instance.RoomPlayers.Count; i++) { KBEngine.Avatar player = GameData.Instance.RoomPlayers[i]; if (player.component1.isWathcher > 0) { continue; } //TSVector bronPosition = new TSVector(-3 + (i - 1) * 4, 1, 16); GameObject perfab = SyncedInstantiate(playerPerfab, player.position.ToTSVector(), new TSQuaternion(0, 0, 0, 1)); Debug.Log("SyncManager::CreatePlayer.player.renderObj:" + (perfab == null? "Null": perfab.name) + ",position:" + perfab.transform.position); PlayerContorl playerScript = perfab.AddComponent <PlayerContorl>(); playerScript.owner = player; // GameEntity gameEntity = perfab.AddComponent<GameEntity>(); // gameEntity.entity = player; // gameEntity.name = player.className + "_" + player.id; // // gameEntity.isPlayer = true; // gameEntity.isAvatar = true; player.renderObj = perfab; } }
void CreatePlayer() { Debug.Log("SyncManager::CreatePlayer.count:" + GameData.Instance.RoomPlayers.Count); for (int i = 0; i < GameData.Instance.RoomPlayers.Count; i++) { KBEngine.Avatar player = GameData.Instance.RoomPlayers[i]; TSVector position = new TSVector(player.position.x, player.position.y, player.position.z); TSVector direciton = new TSVector(0, 180, 0); //Debug.Log("SyncManager::CreatePlayer.player.position:"+ player.position + ",direciton:"+ player.direction); GameObject perfab = SyncedInstantiate(playerPerfab, position, TSQuaternion.Euler(direciton)); Debug.Log("SyncManager::CreatePlayer.player.renderObj:" + (perfab == null ? "Null" : perfab.name) + ",position:" + perfab.transform.position + ",direction:" + perfab.transform.eulerAngles); perfab.name = player.className + "_" + player.id; PlayerBehaviour playerScript = perfab.AddComponent <PlayerBehaviour>(); playerScript.owner = player; player.renderObj = perfab; playerBehaviours.Add(player.id, playerScript); if (player.isPlayer()) { cameraTransform.GetComponent <CamerFllown>().AttachTarget(perfab.transform); cameraTransform.transform.parent = perfab.transform; } } }
public void onLoginSuccessfully(UInt64 rndUUID, Int32 eid, KBEngine.Avatar accountEntity) { Debug.Log("accountText.text:" + accountText.text); ShowTips(new Vector2(10.2f, 228), "Welcome " + accountText.text); ActivePanel(PanelType.Room); }
void OnGUI() { if (ui_state == 1) { onSelAvatarUI(); } else if (ui_state == 2) { createPlayer(); if (showReliveGUI) { if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2, 200, 30), "Relive(复活)")) { if (KBEngineApp.app.entity_type == "Avatar") { KBEngine.Avatar avatar = (KBEngine.Avatar)KBEngineApp.app.player(); if (avatar != null) { avatar.relive(1); } } } } } else { onLoginUI(); } GUI.contentColor = labelColor; GUI.Label(new Rect((Screen.width / 2) - 100, 40, 400, 100), labelMsg); }
public void InitShipAttri(KBEngine.Avatar avatar) { if (gameObject == null || player == null || avatar == null) { return; } ShipBase shipScript = player.GetComponent <ShipBase>(); if (shipScript == null) { Debug.LogError("shipScript not found!!"); return; } shipScript._attri.Id = avatar.id; GameEntity gameScript = player.GetComponent <GameEntity>(); if (gameScript == null) { Debug.LogError("gameScript not found!!"); return; } gameScript.isPlayer = true; gameScript.entityEnable(); player.name = avatar.className + "_" + avatar.id; avatar.renderObj = player; }
private void InstanceUnLoadObj(KBEngine.Entity entity) { if (entity.className == "Avatar") { KBEngine.Avatar avatar = (KBEngine.Avatar)entity; GameObject obj = (GameObject)Resources.Load("Prefabs/AvatarPlayer"); obj = Instantiate(obj, avatar.position, Quaternion.identity) as UnityEngine.GameObject; SpaceData.Instance.SpacePlayers.Add(((KBEngine.Avatar)entity).componentFrameSync); SpaceData.Instance.SpacePlayers = SpaceData.Instance.SpacePlayers.OrderBy(s => s.seatNo).ToList(); if (avatar.teamID == CommonConfigs.RED_TEAM_ID) { //变换头发 } obj.transform.forward = avatar.direction; if (entity.isPlayer()) { AvatarPlayer = obj; AvatarPlayer.name = PlayerCommonName.AvatarPlayerName; AddCameraFllow(); AddController(); // Debug.Log("entity_entity_entity:::" + entity.id + ",CurWeapon:::" + GameManager.Instance.CurWeapon); } FrameSyncManager.InitPlayerBehaviour(obj, avatar); entity.renderObj = obj; AddBattleRelateData(entity, obj); Debug.Log("name::" + avatar.name + " ,entity.id::" + entity.id + " ,position::" + avatar.position + ",direction::" + avatar.direction); return; } }
public void createPlayer() { //if (player != null) // return; if (sEntityManager.GetInstance().isSelfCreated()) { return; } if (KBEngineApp.app.entity_type != "Avatar") { return; } KBEngine.Avatar avatar = (KBEngine.Avatar)KBEngineApp.app.player(); if (avatar == null) { Debug.Log("wait create(palyer)!"); return; } //float y = avatar.position.y; //if(avatar.isOnGround) // y = 1.3f; Debug.Log("server pos:" + avatar.position); Vector3 startpos = new Vector3(0.0f, 0.0f, 0.0f); sEntityManager.GetInstance().createSelf(avatar.id, avatar.position); //player = Instantiate(avatarPerfab, new Vector3(avatar.position.x, y, avatar.position.z), // Quaternion.Euler(new Vector3(avatar.direction.y, avatar.direction.z, avatar.direction.x))) as UnityEngine.GameObject; //player.GetComponent<GameEntity>().entityDisable(); //avatar.renderObj = player; //((UnityEngine.GameObject)avatar.renderObj).GetComponent<GameEntity>().isPlayer = true; }
public void giveUp() { KBEngine.Avatar avatar = KBEngineApp.app.player() as KBEngine.Avatar; if (avatar != null) { avatar.cellCall("reqGiveUp"); } }
public void useItem() { KBEngine.Avatar p = (KBEngine.Avatar)KBEngineApp.app.player(); if (p != null) { p.useItemRequest(item.itemIndex); deactivateTooltip(); } }
public void dropItem() { KBEngine.Avatar p = (KBEngine.Avatar)KBEngineApp.app.player(); if (p != null) { p.dropRequest(item.itemUUID); deactivateTooltip(); } }
public void onAvatarEnterWorld(UInt64 rndUUID, Int32 eid, KBEngine.Avatar avatar) { if (!avatar.isPlayer()) { return; } Debug.Log("loading scene..."); }
public void AvatarReady(KBEngine.Avatar avatar) { Debug.Log("AvatarReady.id:" + avatar.id); GameData.Instance.localPlayer = avatar; RecvGetAchieve(); //发送查询 KBEngine.Event.fireIn("reqSpaceList", new object[] { }); }
public void AccountEnterWorld(int eid, KBEngine.Avatar account) { TankManager tm = new TankManager(); tm.SetAvatar(account); g_tankDict.Add(account.id, tm); g_tankList.Add(tm); g_tankList.Sort((x, y) => x.m_roomNo.CompareTo(y.m_roomNo)); }
public void onAvatarControlled(KBEngine.Avatar avatar, bool isControlled_) { Debug.LogErrorFormat("Avatar id {0} iscontroller {1}", avatar.id, isControlled_); // if (isControlled_) // { // GameObject tGO = avatar.renderObj as GameObject; // tGO.AddComponent<AutoMove>(); // tGO.GetComponent<Collider>().enabled = false; // } }
public void onAvatarEnterWorld(UInt64 rndUUID, Int32 eid, KBEngine.Avatar avatar) { if (!avatar.isPlayer()) { return; } //UI.inst.info("loading scene...(加载场景中...)"); Debug.Log("loading scene...(加载场景中...)"); }
public void onAvatarEnterWorld(UInt64 rndUUID, Int32 eid, KBEngine.Avatar avatar) { Debug.Log("onAvatarEnterWorld"); if (!avatar.isPlayer()) { return; } sNetworkOutOfWorld.inst.info("loading scene...(加载场景中...)"); Debug.Log("loading scene..."); }
public void onBagItemDoubleClick(UnityEngine.GameObject go) { Debug.Log("double click"); //FrameBagIndex fbi = frameBagDic[go.transform.parent.gameObject]; //KnapsakItem ki = KnapSackInfo.inst.allKanpItems[fbi.FrameIndex][fbi.BagIndex]; //ki.OnUse(); UInt64 serialnum = go.GetComponent <knapsackDragDropItem>().serialnum; KBEngine.Avatar player = (KBEngine.Avatar)KBEngineApp.app.player(); player.baseCall("ItemUse", new object[] { serialnum }); }
public void SetAvatar(KBEngine.Avatar tAccount) { m_avatar = tAccount; m_eid = tAccount.id; m_roomNo = tAccount.roomNo; m_avatarName = tAccount.name; isPlayer = tAccount.isPlayer; m_curPropType = EPropType.ept_None; Debug.LogErrorFormat("onEnterWorld,{0} is Player: {1} ", m_avatarName, isPlayer); }
//点击使用 public void OnPointerDown(PointerEventData data) { UnityEngine.GameObject itemobject = inventory.getItemGameObject(itemId); if (itemobject != null) { KBEngine.Avatar p = (KBEngine.Avatar)KBEngineApp.app.player(); if (p != null) { p.useItemRequest(itemobject.GetComponent <ItemOnObject>().item.itemIndex); } } }
public void ReplaceBagItemPos(UnityEngine.GameObject newItem, UnityEngine.GameObject oldItem) { Debug.LogWarning("setBagItemPos"); Monitor.Enter(KBEngineApp.app.entities); KBEngine.Avatar player = (KBEngine.Avatar)KBEngineApp.app.player(); UInt64 old_serialnum = itemsDic[oldItem]; UInt64 new_serialnum = itemsDic[newItem]; player.rePlaceBagItemPos(new_serialnum, old_serialnum); Monitor.Exit(KBEngineApp.app.entities); Byte new_frame = 0; UInt16 new_bagindex = 0; foreach (var v in KnapSackInfo.inst.allKanpItems) { foreach (var mv in v.Value) { if (mv.Value.serialnum == new_serialnum) { new_frame = v.Key; new_bagindex = mv.Key; } } } KnapsakItem new_ksi = KnapSackInfo.inst.allKanpItems[new_frame][new_bagindex]; KnapSackInfo.inst.allKanpItems[new_frame].Remove(new_bagindex); Byte old_frame = 0; UInt16 old_bagindex = 0; foreach (var v in KnapSackInfo.inst.allKanpItems) { foreach (var mv in v.Value) { if (mv.Value.serialnum == old_serialnum) { old_frame = v.Key; old_bagindex = mv.Key; } } } KnapsakItem old_ksi = KnapSackInfo.inst.allKanpItems[old_frame][old_bagindex]; KnapSackInfo.inst.allKanpItems[old_frame].Remove(old_bagindex); old_ksi.bagFrameIndex = new_frame; old_ksi.bagItemIndex = new_bagindex; new_ksi.bagFrameIndex = old_frame; new_ksi.bagItemIndex = old_bagindex; KnapSackInfo.inst.allKanpItems[old_frame].Add(old_bagindex, new_ksi); KnapSackInfo.inst.allKanpItems[new_frame].Add(new_bagindex, old_ksi); }
public void endRound() { if (state == 0) { return; } KBEngine.Avatar avatar = KBEngineApp.app.player() as KBEngine.Avatar; if (avatar != null) { avatar.cellCall("reqEndRound"); } }
public void onAvatarEnterWorld(UInt64 rndUUID, Int32 eid, KBEngine.Avatar avatar) { if (!avatar.isPlayer()) { return; } UI.inst.info("loading scene...(加载场景中...)"); Debug.Log("loading scene..."); // TriggerEvent((int)EVENT_ID.EVENT_CREAT_PLAYER); }