private KeyInputSnapshot MakeInputSnapshot() { KeyInputSnapshot input = new KeyInputSnapshot(false, false, false, false, false); if (Input.GetKey(KeyCode.W)) { input.upKey = true; } if (Input.GetKey(KeyCode.A)) { input.leftKey = true; } if (Input.GetKey(KeyCode.S)) { input.downKey = true; } if (Input.GetKey(KeyCode.D)) { input.rightKey = true; } if (Input.GetMouseButton(0)) { input.mouseLeftDown = true; } return(input); }
private void FixedUpdate() { KeyInputSnapshot snapshot = MakeInputSnapshot(); Vector3 direction = Input.mousePosition - gameCam.WorldToScreenPoint(Storage.GameObjects["CurrentPlayerCharacter"].transform.position); float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; Packet inputPacket = new Packet(Packet.HEADER.GAME_INPUT, Config.MAX_SESSION_BUFFER_SIZE); inputPacket.Push(snapshot); inputPacket.Push(angle); MyNetUnityClient.Instance.Send(inputPacket); }
public override void OnReceive(Packet packet) { switch (packet.Head) { case Packet.HEADER.REPLY_GAME_INIT_COMPLETE: { Console.WriteLine(this.nickname + "가 게임 클라이언트 초기화를 완료했습니다."); isGamePrepared = true; break; } case Packet.HEADER.GAME_INPUT: { this.input.CharacterRotation = packet.Pop_Float(); KeyInputSnapshot input = new KeyInputSnapshot(); input.Deserialize(packet.Pop_Bytes(KeyInputSnapshot.MemberSize)); this.input.KeyInput += input; break; } } }
public void Clear() { this.keyInput = new KeyInputSnapshot(); this.characterRotation = 0.0f; }
public UserInput(KeyInputSnapshot key, float rotation) { keyInput = key.Clone() as KeyInputSnapshot; characterRotation = rotation; }