// Update is called once per frame void Update() { if (GameCore.Instance.gameState == GameState.PLAY) { movementSpeedAux = movementSpeed * AuxLib.Map(GameCore.Instance.playerController.rBody.velocity.x, GameCore.Instance.playerController.minSpeed, GameCore.Instance.playerController.maxSpeed, 0, 1); animatedOffset += new Vector2(movementSpeedAux, 0) * Time.deltaTime; this.GetComponent <MeshRenderer>().material.SetTextureOffset("_MainTex", animatedOffset); } }
void CreateParallaxLayers() { for (int i = 0; i < parallaxLayers.Count; i++) { GameObject go = new GameObject(); go.transform.parent = this.transform; if (parallaxLayers[i].order == ParallaxLayerOrder.BACK) { go.name = "Parallax_BackLayer " + i; go.transform.localPosition = new Vector3(0, 0, AuxLib.Map(i, 0, parallaxLayers.Count, parallaxLayerMin, parallaxLayerMax)); } else { go.name = "Parallax_FrontLayer " + i; go.transform.localPosition = new Vector3(0, 0, AuxLib.Map(i, 0, parallaxLayers.Count, -parallaxLayerMin, -parallaxLayerMax)); } GameObject goDay = GameObject.CreatePrimitive(PrimitiveType.Quad); goDay.name = "DayLayer"; goDay.transform.parent = go.transform; goDay.transform.localPosition = Vector3.zero; Destroy(goDay.GetComponent <MeshCollider>()); goDay.GetComponent <MeshRenderer>().material = Resources.Load("Materials/MAT_ParallaxLayer") as Material; goDay.GetComponent <MeshRenderer>().material.mainTexture = parallaxLayers[i].day; if (parallaxLayers[i].order == ParallaxLayerOrder.FRONT) { goDay.GetComponent <MeshRenderer>().sortingLayerName = "FrontParallax"; Debug.Log("Sorting layer: " + goDay.GetComponent <MeshRenderer>().sortingLayerName); } goDay.layer = GameCore.DAY_LAYER; goDay.AddComponent <ParallaxLayerBehaviour>().movementSpeed = parallaxLayers[i].speed; GameObject goNight = GameObject.CreatePrimitive(PrimitiveType.Quad); goNight.name = "NightLayer"; goNight.transform.parent = go.transform; goNight.transform.localPosition = Vector3.zero; Destroy(goNight.GetComponent <MeshCollider>()); goNight.GetComponent <MeshRenderer>().material = Resources.Load("Materials/MAT_ParallaxLayer") as Material; goNight.GetComponent <MeshRenderer>().material.mainTexture = parallaxLayers[i].night; if (parallaxLayers[i].order == ParallaxLayerOrder.FRONT) { goNight.GetComponent <MeshRenderer>().sortingLayerName = "FrontParallax"; } goNight.layer = GameCore.NIGHT_LAYER; goNight.AddComponent <ParallaxLayerBehaviour>().movementSpeed = parallaxLayers[i].speed; } }
void UpdateCameraSize() { camSize = Mathf.Lerp(camSize, AuxLib.Map(playerController.rBody.velocity.x, playerController.minSpeed, playerController.maxSpeed, minCamSize, maxCamSize), Time.deltaTime * 4f); }
void Update() { switch (GameCore.Instance.gameState) { case GameState.AWAKE: { if (!GameCore.Instance.barrier) { barrierBarBorders.gameObject.SetActive(false); } if (GameCore.Instance.currentStage == WorldConstructor.Stage.Z_BOSS) { StartGame(); } } break; case GameState.PAUSE: break; case GameState.PLAY: { hudDisplay.SetBool("Playing", true); if (GameCore.Instance.staminaBoost) { staminaBarValue.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, AuxLib.Map(GameCore.Instance.playerController.GetCurrentPower(), 0, GameCore.Instance.playerController.maxPower, 0, 512 * 2)); staminaBarBorders.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 512); } else { staminaBarValue.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, AuxLib.Map(GameCore.Instance.playerController.GetCurrentPower(), 0, GameCore.Instance.playerController.maxPower, 0, 256 * 2)); } if (GameCore.Instance.barrier) { barrierBarValue.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, AuxLib.Map(GameCore.Instance.playerController.GetCurrentBarrier(), 0, GameCore.Instance.playerController.maxBarrier, 0, barrierBarLength * 2)); barrierBarBorders.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, barrierBarLength); if (GameCore.Instance.playerController.barrier <= 0) { GameCore.Instance.barrier = false; GameCore.Instance.playerController.transform.GetChild(0).GetChild(0).gameObject.SetActive(false); GameCore.Instance.playerController.transform.GetChild(1).GetChild(0).gameObject.SetActive(false); } } } break; case GameState.GAMEOVER: { endMenuAnimator.SetBool("Show", true); finalScore.GetComponent <Text>().text = "SCORE: " + GameCore.Instance.finalScore; } break; default: break; } score.GetComponent <Text>().text = "SCORE: " + GameCore.Instance.finalScore; }
public void DecreaseBarrierValue(float percentOnTotal) { barrier -= AuxLib.Map(Mathf.Clamp(percentOnTotal, 0, 100), 0, 100, 0, maxBarrier); }
public void DecreaseStamina(float percentOnTotal) { power -= AuxLib.Map(Mathf.Clamp(percentOnTotal, 0, 100), 0, 100, 0, maxPower); }
public void RecoverStamina(float percentOnTotal) { power += AuxLib.Map(Mathf.Clamp(percentOnTotal, 0, 100), 0, 100, 0, maxPower); }