Orb effects
This commit is contained in:
parent
9ecec372ce
commit
41c558ce69
357 changed files with 27818 additions and 34 deletions
|
@ -38,10 +38,9 @@ public class GameManager : MonoBehaviour {
|
|||
OrbTypes selected;
|
||||
Array values = Enum.GetValues(typeof(OrbTypes));
|
||||
do {
|
||||
selected = (OrbTypes)values.GetValue(Random.Range(1, values.Length));
|
||||
selected = (OrbTypes)values.GetValue(Random.Range(0, values.Length));
|
||||
} while (selected == currentType || selected == _lastType);
|
||||
|
||||
Debug.Log(selected);
|
||||
ChangeEventCall(selected);
|
||||
return selected;
|
||||
}
|
||||
|
|
40
Assets/Scripts/Obstacles/TilemapActivation.cs
Normal file
40
Assets/Scripts/Obstacles/TilemapActivation.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Tilemaps;
|
||||
|
||||
public class TilemapActivation : MonoBehaviour {
|
||||
|
||||
Tilemap _tilemap;
|
||||
Collider2D _tilemapColliders;
|
||||
|
||||
[SerializeField] float disabledTransparency;
|
||||
[SerializeField] float transitionDuration;
|
||||
|
||||
void Awake() {
|
||||
_tilemap = GetComponent<Tilemap>();
|
||||
_tilemapColliders = GetComponent<Collider2D>();
|
||||
|
||||
_tilemapColliders.enabled = false;
|
||||
}
|
||||
|
||||
public void ChangeTilemapState(bool enabled) {
|
||||
_tilemapColliders.enabled = _enabled = enabled;
|
||||
}
|
||||
|
||||
bool _enabled;
|
||||
float _start;
|
||||
void Update() {
|
||||
float alpha = _enabled
|
||||
? Mathf.Lerp(disabledTransparency, 1, (Time.time - _start) / transitionDuration)
|
||||
: Mathf.Lerp(1, disabledTransparency, (Time.time - _start) / transitionDuration);
|
||||
|
||||
alpha = Mathf.Round(alpha * 5);
|
||||
alpha /= 5f;
|
||||
|
||||
Color color = _tilemap.color;
|
||||
color = new Color(color.r, color.g, color.b, alpha);
|
||||
_tilemap.color = color;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Obstacles/TilemapActivation.cs.meta
Normal file
11
Assets/Scripts/Obstacles/TilemapActivation.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3ebb6b9dbeda6f142b6a9515f6b253e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -49,9 +49,11 @@ public class PlayerController : MonoBehaviour {
|
|||
void Awake() {
|
||||
_rb2d = GetComponent<Rigidbody2D>();
|
||||
_anim = GetComponent<Animator>();
|
||||
|
||||
_defaultGravity = _rb2d.gravityScale;
|
||||
|
||||
_cameraTarget = new GameObject("Camera Target").transform;
|
||||
vCam.m_Follow = _cameraTarget;
|
||||
//_cameraTarget = new GameObject("Camera Target").transform;
|
||||
//vCam.m_Follow = _cameraTarget;
|
||||
|
||||
_currentSpeed = speed;
|
||||
}
|
||||
|
@ -68,8 +70,8 @@ public class PlayerController : MonoBehaviour {
|
|||
|
||||
_input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
|
||||
_facingDirection = _input.x switch {
|
||||
> 0f => 1,
|
||||
< 0f => -1,
|
||||
> 0f => _controlsDirection,
|
||||
< 0f => -_controlsDirection,
|
||||
_ => _facingDirection
|
||||
};
|
||||
|
||||
|
@ -92,7 +94,7 @@ public class PlayerController : MonoBehaviour {
|
|||
void FixedUpdate() {
|
||||
if (_dead) return;
|
||||
|
||||
_rb2d.velocity = new Vector2(Mathf.SmoothDamp(_rb2d.velocity.x, _input.x * _currentSpeed, ref _xVelocity, acceleration), _rb2d.velocity.y);
|
||||
_rb2d.velocity = new Vector2(Mathf.SmoothDamp(_rb2d.velocity.x, _input.x * _currentSpeed * _controlsDirection, ref _xVelocity, acceleration), _rb2d.velocity.y);
|
||||
_anim.SetFloat(Speed, Mathf.Abs(_rb2d.velocity.x));
|
||||
|
||||
if (_coyoteTime > 0f && _jumpBuffer > 0f) {
|
||||
|
@ -107,13 +109,6 @@ public class PlayerController : MonoBehaviour {
|
|||
}
|
||||
}
|
||||
|
||||
void LateUpdate() {
|
||||
if (_dead) return;
|
||||
|
||||
float yPos = _isGrounded && _rb2d.velocity.y <= 0f ? transform.position.y : _cameraTarget.position.y;
|
||||
_cameraTarget.position = new Vector3(transform.position.x, yPos);
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected() {
|
||||
Gizmos.color = Color.red;
|
||||
if (feetPos) Gizmos.DrawWireCube(feetPos.position, new Vector3(feetWidth, feetHeight));
|
||||
|
@ -127,4 +122,19 @@ public class PlayerController : MonoBehaviour {
|
|||
ScreenShake.Shake(20f, .5f);
|
||||
}
|
||||
}
|
||||
|
||||
#region OrbEffects
|
||||
int _controlsDirection = 1;
|
||||
public void InvertControls(bool inverted) {
|
||||
_controlsDirection = inverted ? -1 : 1;
|
||||
}
|
||||
|
||||
float _defaultGravity;
|
||||
public void ChangeGravity(float gravity) {
|
||||
_rb2d.gravityScale = gravity;
|
||||
}
|
||||
public void ResetGravity() {
|
||||
_rb2d.gravityScale = _defaultGravity;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class Thunder : MonoBehaviour{
|
|||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
orgLightColor = globalLight.color;
|
||||
orgIntensity = globalLight.intensity;
|
||||
_defaultIntensity = orgIntensity = globalLight.intensity;
|
||||
orgCamBGColor = camera.backgroundColor;
|
||||
|
||||
timer = intervalTime;
|
||||
|
@ -69,4 +69,12 @@ public class Thunder : MonoBehaviour{
|
|||
camera.backgroundColor = orgCamBGColor;
|
||||
globalLight.intensity = orgIntensity;
|
||||
}
|
||||
|
||||
float _defaultIntensity;
|
||||
public void DarkRoom(float intensity) {
|
||||
orgIntensity = intensity;
|
||||
}
|
||||
public void LightRoom() {
|
||||
orgIntensity = _defaultIntensity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,5 +26,6 @@ public class CanvasController : MonoBehaviour {
|
|||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
GameManager.instance.SelectRandomEffect();
|
||||
StartCoroutine(Countdown());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue