private static void Listen(FileManager manager) { var logger = GetLogger(); var playManager = new PlayManager(); if (!playManager.CheckCompatibility()) { Console.Error.WriteLine("Unsupported Device"); return; } var line = Console.ReadLine(); while (line != null) { logger.Log(line); var command = CommandParser.Parse(line); if (command.Type == CommandType.Exit) { break; } switch (command.Type) { case CommandType.Play: var file = manager.Load(command.Args[1]); if (file != null) { playManager.Play(file, command.Args[0]); } break; case CommandType.IsPlaying: if (playManager.IsPlaying(command.Args[0])) { logger.Log("yes"); Console.WriteLine("yes"); } else { logger.Log("no"); Console.WriteLine("no"); } break; case CommandType.Release: manager.Release(command.Args[0]); break; } line = Console.ReadLine(); Thread.Sleep(10); } logger.Dispose(); }
void FixedUpdate() { foreach (KeyValuePair <Vector3, GameObject> exit in exits) { if (exit.Value.gameObject.GetComponent <BoxCollider2D>().IsTouching(player)) { playManager.Play(exit.Key * -1); break; } } }
private static void StartDebugMode(FileManager fileManager, bool aggressive) { fileManager.Debug(); var playManager = new PlayManager(); playManager.Debug(); if (aggressive) { var filePaths = fileManager.GetFilePaths(); var i = 0; foreach (var path in filePaths) { Console.Error.WriteLine("Playing {0}", path); var file = fileManager.Load(path); if (file != null) { i++; playManager.Play(file, i.ToString()); } while (playManager.IsPlaying(i.ToString())) { Thread.Sleep(10); } } } else { var example = fileManager.GetExampleFile(); if (example != "") { var file = fileManager.Load(example); Console.Error.WriteLine("Start Playing {0}", file.Path); playManager.Play(file, "1"); Console.Error.WriteLine("Done Playing"); } } Thread.Sleep(1000); }
public void Move(bool interact, bool extendInteract, bool interactSecondary, bool teleport) { if (collisionDanger && !isCarried) { playManager.Play(Vector3.left); } if (collisionDown && m_Rigidbody.velocity.y <= 0.1f && !isCarried) { m_Rigidbody.velocity = new Vector2(0, m_Rigidbody.velocity.y); m_Rigidbody.velocity -= new Vector2(0, throwPeakSmooth * Time.fixedDeltaTime); if (m_Rigidbody.velocity.y < -fallSpeed) { m_Rigidbody.velocity = new Vector2(m_Rigidbody.velocity.x, -fallSpeed); } } else if (isThrown && m_Rigidbody.position.y - throwStartHeight < throwHeight && canExtendThrow) { m_Rigidbody.velocity = new Vector2(m_Rigidbody.velocity.x, riseSpeed); } else if (!isCarried) { isThrown = false; m_Rigidbody.velocity -= new Vector2(0, throwPeakSmooth * Time.fixedDeltaTime); if (m_Rigidbody.velocity.y < -fallSpeed) { m_Rigidbody.velocity = new Vector2(m_Rigidbody.velocity.x, -fallSpeed); } } if (teleport && canTeleport && !isCarried && teleportRechargeTimer < 0) { if (!collisionTeleport) { velocityBuffer = m_Rigidbody.velocity; playerVelocityBuffer = playerRigidbody.velocity; teleportTimer = teleportDuration; teleportBuffer = true; canTeleport = false; player.SetTeleporting(true); } else { //SHOW PLAYER THAT THEY CAN'T TELEPORT HERE } } if (teleportTimer >= 0 && teleportTimer != teleportDuration) { playerRigidbody.position = m_Rigidbody.position + Vector2.up * 0.3f; m_Rigidbody.velocity = Vector2.zero; } if (teleportBuffer && teleportTimer < 0) { player.SetTeleporting(false); playerRigidbody.velocity = playerVelocityBuffer; playerRigidbody.velocity *= new Vector2(1, 0); m_Rigidbody.velocity = velocityBuffer; teleportBuffer = false; teleportRechargeTimer = teleportRechargeDuration; Carry(true); } if (!teleport) { canTeleport = true; } if (collisionUp && canExtendThrow && !isCarried && m_Rigidbody.velocity.y > 0) { canExtendThrow = false; m_Rigidbody.velocity = new Vector2(m_Rigidbody.velocity.x, 0f); } if (interact && canCarry && teleportTimer < 0 && ((Mathf.Abs(playerRigidbody.position.x - m_Rigidbody.position.x) <= 1f && Mathf.Abs(playerRigidbody.position.y - m_Rigidbody.position.y) <= 1.5f) || isCarried)) { Carry(); } if (interactSecondary && isCarried) { Drop(); } if (!extendInteract && !interact && !interactSecondary) { canCarry = true; } if (isCarried) { m_Rigidbody.velocity = Vector2.zero; bool canMoveX = true; bool canMoveY = true; if (playerRigidbody.position.x + carryWidth > m_Rigidbody.position.x && collisionRight) { canMoveX = false; if (playerRigidbody.position.x - m_Rigidbody.position.x > dropRadius) { Drop(); } } else if (playerRigidbody.position.x - carryWidth < m_Rigidbody.position.x && collisionLeft) { canMoveX = false; if (playerRigidbody.position.x - m_Rigidbody.position.x < -dropRadius) { Drop(); } } if (playerRigidbody.position.y + collisionCarryPlayer - 0.6f > m_Rigidbody.position.y && collisionUp) { canMoveY = false; if (playerRigidbody.position.y - m_Rigidbody.position.y > dropRadius) { Drop(); } } else if (playerRigidbody.position.y + collisionCarryPlayer - 0.6f < m_Rigidbody.position.y && collisionDown) { canMoveY = false; if (playerRigidbody.position.y - m_Rigidbody.position.y < -dropRadius) { Drop(); } } Vector2 destination; int direction = player.GetFacingRight() ? -1 : 1; float jumping = 1.0f - ((collisionCarryPlayer - 0.6f) / 1.2f); float height = Mathf.Min(collisionCarryPlayer, collisionCarry); destination = new Vector2( canMoveX ? playerRigidbody.position.x + (carryWidth * direction * jumping): m_Rigidbody.position.x, canMoveY ? playerRigidbody.position.y + height - 0.6f: m_Rigidbody.position.y); m_Rigidbody.position = Vector2.SmoothDamp(m_Rigidbody.position, destination, ref m_Velocity, pickupSmooth * Time.fixedDeltaTime); } }
public void PropagiatePlay(PlayManager playManager, InvokerData invoker, string url) { playManager.Play(invoker, url, audioType).UnwrapThrow(); }
public string PropagiatePlay(PlayManager playManager, InvokerData invoker, string parameter) { return(playManager.Play(invoker, parameter, audioType)); }
public void Move(float move, float speed, bool jump, bool extendJump) { Vector3 targetVelocity = new Vector2(move * speed, m_Rigidbody.velocity.y); m_Rigidbody.velocity = Vector3.SmoothDamp(m_Rigidbody.velocity, targetVelocity, ref m_Velocity, movementSmoothing * Time.fixedDeltaTime); if (collisionDanger) { playManager.Play(Vector3.left); } if (move > 0) { facingRight = true; transform.localScale = new Vector3(1, 1, 1); } else if (move < 0) { facingRight = false; transform.localScale = new Vector3(-1, 1, 1); } if (transitionJumpBuffer != transitionJump && transitionJump) { Debug.Log("Transition Jump!"); jumpStartHeight = m_Rigidbody.position.y; } if (transitionJump) { canExtendJump = true; canJump = false; stillHoldingJump = true; } if (collisionDownTimer > 0f && jump && canJump) { jumpStartHeight = m_Rigidbody.position.y; canExtendJump = true; canJump = false; stillHoldingJump = true; } if (!jump) { stillHoldingJump = false; } if (collisionDown && !stillHoldingJump) { canJump = true; } if (collisionUpLeft && !collisionUpMiddle && !collisionDown && m_Rigidbody.velocity.y > 0) { m_Rigidbody.position += Vector2.right * 0.1f; } else if (collisionUpRight && !collisionUpMiddle && !collisionDown && m_Rigidbody.velocity.y > 0) { m_Rigidbody.position += Vector2.left * 0.1f; } else if (collisionUpEnter && !transitionJump && (m_Rigidbody.velocity.y > 0 || !collisionDown)) { canExtendJump = false; canJump = false; m_Rigidbody.velocity = new Vector2(m_Rigidbody.velocity.x, 0); } detectDistance = Mathf.Abs(m_Rigidbody.velocity.x) / speed; if (collisionLeftStep > 0.1f && collisionLeftStep < 0.6f && m_Rigidbody.velocity.x < 0 && collisionDown) { m_Rigidbody.position += Vector2.up * ((0.6f - collisionLeftStep) + 0.1f); } else if (collisionRightStep > 0.1f && collisionRightStep < 0.6f && m_Rigidbody.velocity.x > 0 && collisionDown) { m_Rigidbody.position += Vector2.up * ((0.6f - collisionRightStep) + 0.1f); } if ((extendJump || transitionJump) && canExtendJump && m_Rigidbody.position.y - jumpStartHeight < jumpHeight) { m_Rigidbody.velocity = new Vector2(m_Rigidbody.velocity.x, jumpUpSpeed); } else { //Debug.Log("Stopped jump: " + extendJump + " " + transitionJump + " " + canExtendJump + " " + (m_Rigidbody.position.y - jumpStartHeight < jumpHeight)); canExtendJump = false; transitionJump = false; m_Rigidbody.velocity -= new Vector2(0, jumpPeakSmooth * Time.fixedDeltaTime); if (m_Rigidbody.velocity.y < -jumpDownSpeed) { m_Rigidbody.velocity = new Vector2(m_Rigidbody.velocity.x, -jumpDownSpeed); } } if (teleporting) { m_Sprite.enabled = false; m_Rigidbody.velocity = Vector2.zero; } else { m_Sprite.enabled = true; } transitionJumpBuffer = transitionJump; /* ANIMATIONS */ if (collisionDownEnter) { GameObject dustRight = Instantiate(dustAnim); dustRight.transform.position = transform.position + new Vector3(0.92f, -0.274f, 0f); GameObject dustLeft = Instantiate(dustAnim); dustLeft.transform.position += transform.position + new Vector3(-0.92f, -0.274f, 0f); dustLeft.transform.localScale = new Vector3(-1f, 1f, 1f); } }