// 레벨 시작 시에 호출. public override void start() { // 각 플레이어가 케이크를 획득한 수.. this.cake_counts = new int[NetConfig.PLAYER_MAX]; for (int i = 0; i < this.cake_counts.Length; i++) { if (GameRoot.get().isConnected(i)) { this.cake_counts[i] = -1; } else { this.cake_counts[i] = 0; } } chrBehaviorLocal local_player = PartyControl.get().getLocalPlayer(); this.cake_counts[local_player.getGlobalIndex()] = local_player.getCakeCount(); QueryCakeCount query_cake = new QueryCakeCount(local_player.getAcountID(), local_player.getCakeCount()); query_cake.timeout = 20.0f; QueryManager.get().registerQuery(query_cake); // Network 클래스의 컴포넌트 획득. GameObject obj = GameObject.Find("Network"); if (obj != null) { this.m_network = obj.GetComponent <Network>(); if (this.m_network != null) { this.m_network.RegisterReceiveNotification(PacketId.PrizeResult, OnReceivePrizeResultPacket); } } // 케이크 데이터 송신. sendPrizeData(); this.step.set_next(STEP.WAIT_FRIEND); }
// ---------------------------------------------------------------- // // 케이트 데이터 송수신. private void sendPrizeData() { PrizeData data = new PrizeData(); chrBehaviorLocal local_player = PartyControl.get().getLocalPlayer(); Debug.Log("[CLIENT] sendPrizeData"); // 획득한 케이크 수를 설정. data.characterId = local_player.getAcountID(); data.cakeNum = local_player.getCakeCount(); if (this.m_network != null) { PrizePacket packet = new PrizePacket(data); int serverNode = this.m_network.GetServerNode(); this.m_network.SendReliable <PrizeData>(serverNode, packet); Debug.Log("[CLIENT] send cake num[" + data.characterId + "]:" + data.cakeNum); } }
public int RandomSeedForDebugMax = 1000; //< UseRandomSeedForDebug가 유효한 때 사용하는 랜덤 레인지. public override void initializeMap(GameRoot game_root) { MapCreator mapCreator = MapCreator.getInstance(); Vector3 playerStartPosition; int seed = 0; if (UseRandomSeedForDebug) { TimeSpan ts = new TimeSpan(DateTime.Now.Ticks); double seconds = ts.TotalSeconds; seed = (int)((long)seconds - (long)(seconds / 1000.0) * 1000); //seed = Random.Range(RandomSeedForDebugMin, RandomSeedForDebugMax); } else { seed = GlobalParam.get().seed; } // 맵 자동 생성. Debug.Log("Use random seed:" + seed); mapCreator.generateLevel(seed); GameRoot.get().createLocalPlayer(); GameRoot.get().createNetPlayers(); chrBehaviorLocal local_player = PartyControl.get().getLocalPlayer(); // 아이템을 만든다. mapCreator.generateItems(local_player.getAcountID()); mapCreator.createFloorDoor(); // 플레이어의 위치 설정. playerStartPosition = mapCreator.getPlayerStartPosition(); local_player.transform.position = playerStartPosition + PartyControl.get().getPositionOffset(local_player.control.global_index); for (int i = 0; i < PartyControl.get().getFriendCount(); i++) { chrBehaviorPlayer friend = PartyControl.get().getFriend(i); friend.control.cmdSetPositionAnon(playerStartPosition + PartyControl.get().getPositionOffset(friend.control.global_index)); } PartyControl.get().setCurrentRoom(mapCreator.getRoomFromPosition(playerStartPosition)); // 스테이터스 윈도우. Navi.get().createStatusWindows(); // // #if false string local_player_id = PartyControl.get().getLocalPlayer().getAcountID(); ItemManager.get().createItem("candy00", local_player_id); ItemManager.get().setPositionToItem("candy00", playerStartPosition + new Vector3(0.0f, 0.0f, 4.0f)); ItemManager.get().createItem("ice00", local_player_id); ItemManager.get().setPositionToItem("ice00", playerStartPosition + new Vector3(7.0f, 0.0f, 0.0f)); ItemManager.get().createItem("key00", local_player_id); ItemManager.get().setPositionToItem("key00", playerStartPosition + new Vector3(10.0f, 0.0f, 0.0f)); ItemManager.get().createItem("key01", local_player_id); ItemManager.get().setPositionToItem("key01", playerStartPosition + new Vector3(10.0f, 0.0f, 0.0f)); ItemManager.get().createItem("key02", local_player_id); ItemManager.get().setPositionToItem("key02", playerStartPosition + new Vector3(10.0f, 0.0f, 0.0f)); ItemManager.get().createItem("key03", local_player_id); ItemManager.get().setPositionToItem("key03", playerStartPosition + new Vector3(10.0f, 0.0f, 0.0f)); #endif }
public void OnReceivePrizeResultPacket(int node, PacketId id, byte[] data) { PrizeResultPacket packet = new PrizeResultPacket(data); PrizeResultData result = packet.GetPacket(); Debug.Log("[CLIENT] ReceivePrizeResultPacket"); for (int i = 0; i < result.cakeDataNum; ++i) { this.cake_counts[i] = result.cakeNum[i]; Debug.Log("[CLIENT] Cake num[" + i + "]:" + result.cakeNum[i]); } chrBehaviorLocal local_player = PartyControl.get().getLocalPlayer(); QueryCakeCount query = QueryManager.get().findQuery <QueryCakeCount>(x => x.account_id == local_player.getAcountID()); if (query != null) { Debug.Log("[CLIENT]QueryCakeCount done"); query.set_done(true); query.set_success(true); } }