public static bool ToBool(this LevelManager.ActionResult actionResult) { switch (actionResult) { case LevelManager.ActionResult.SUCCESS: return(true); default: return(false); } }
private void Update() { if (playerEntity != LevelManager.player) { playerEntity = LevelManager.player; } if (playerEntity != null) { if (Input.anyKeyDown) { LevelManager.ActionResult actionResult = LevelManager.ActionResult.FAILED; if (Input.GetKeyDown(walkForward)) { actionResult = levelMgr.PlayerTakeAction(new ActionMove(playerEntity, playerEntity.pos + (IntVec)playerEntity.forward)); if (actionResult.ToBool()) { walkSFX.PlayRandomSoundAtPosition((Vector3)playerEntity.pos, 1, 1); } } if (Input.GetKeyDown(walkBack)) { actionResult = levelMgr.PlayerTakeAction(new ActionMove(playerEntity, playerEntity.pos - (IntVec)playerEntity.forward)); if (actionResult.ToBool()) { walkSFX.PlayRandomSoundAtPosition((Vector3)playerEntity.pos, 1, 0.7f); } } if (Input.GetKeyDown(turnLeft)) { actionResult = levelMgr.PlayerTakeAction(new ActionTurn(playerEntity, playerEntity.forward.Turn(-1))); if (actionResult.ToBool()) { turnSFX.PlayRandomSoundAtPosition(transform.position); } } if (Input.GetKeyDown(turnRight)) { actionResult = levelMgr.PlayerTakeAction(new ActionTurn(playerEntity, playerEntity.forward.Turn(1))); if (actionResult.ToBool()) { turnSFX.PlayRandomSoundAtPosition(transform.position); } } BeatDisplay.instance.AddInputMarker(actionResult); } } }
public void AddInputMarker(LevelManager.ActionResult markerType, float time) { float metronomeValue = Mathf.PingPong((float)BeatManager.GetBeatTime(time), 1f); RectTransform marker = Instantiate(InputMarkerPrefabs[(int)markerType], InputsDisplay).GetComponent <RectTransform>(); Vector2 anchoredPos = marker.anchoredPosition; Vector2 anchorMin = marker.anchorMin; Vector2 anchorMax = marker.anchorMax; anchoredPos.x = 0f; anchorMin.x = anchorMax.x = metronomeValue; marker.anchorMin = anchorMin; marker.anchorMax = anchorMax; marker.anchoredPosition = anchoredPos; marker.gameObject.AddComponent <Autodestroy>().destroyTimer = 1 / (BeatManager.bpm / 60f); marker.GetComponent <EffectGUIColourOverLifetime>().Initiate(); }
public void AddInputMarker(LevelManager.ActionResult markerType) { AddInputMarker(markerType, (float)BeatManager.musicTime); }