Made player mods affect the player
This commit is contained in:
91
Assets/Materials/DarkGreenMat.mat
Normal file
91
Assets/Materials/DarkGreenMat.mat
Normal file
@@ -0,0 +1,91 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: DarkGreenMat
|
||||
m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AlphaTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- PixelSnap: 0
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _EnableExternalAlpha: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0, g: 0.5019608, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _Flip: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
8
Assets/Materials/DarkGreenMat.mat.meta
Normal file
8
Assets/Materials/DarkGreenMat.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22eb1f2017d2a15459d4c10b27104270
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -163,6 +163,8 @@ MonoBehaviour:
|
||||
m_SpinSpeed: 0
|
||||
m_Renderer: {fileID: 104400500}
|
||||
m_ScoreText: {fileID: 1501855168}
|
||||
m_DefaultMaterial: {fileID: 2100000, guid: 2b4111cfdf7255c48b4c3dbcf9e202a6, type: 2}
|
||||
m_FreeHitMaterial: {fileID: 2100000, guid: 22eb1f2017d2a15459d4c10b27104270, type: 2}
|
||||
--- !u!4 &104400498
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnemyController : OrbitalPositionBehaviour
|
||||
{
|
||||
private static readonly List<EnemyController> s_Instances = new();
|
||||
|
||||
public static void KillAllEnemies()
|
||||
{
|
||||
foreach (EnemyController controller in s_Instances)
|
||||
{
|
||||
Destroy(controller.gameObject);
|
||||
PlayerController.s_PlayerScore++;
|
||||
}
|
||||
|
||||
s_Instances.Clear();
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
s_Instances.Add(this);
|
||||
|
||||
transform.position = new Vector3(0, 0, -200f);
|
||||
|
||||
m_OrbitalPosition.m_DistanceAlongRadius = Random.Range(0f, Mathf.PI * 2f);
|
||||
@@ -13,9 +29,10 @@ public class EnemyController : OrbitalPositionBehaviour
|
||||
|
||||
public override void OnReachCentre()
|
||||
{
|
||||
if (GlobalOrbitalPositionManager.IsSimulationRunning)
|
||||
if (GlobalOrbitalPositionManager.s_IsSimulationRunning)
|
||||
PlayerController.s_PlayerScore++;
|
||||
|
||||
|
||||
s_Instances.Remove(this);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +35,14 @@ public class Ring : MonoBehaviour
|
||||
|
||||
public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
{
|
||||
private static GlobalOrbitalPositionManager s_Instance = null;
|
||||
private static GlobalOrbitalPositionManager s_Instance;
|
||||
public static GlobalOrbitalPositionManager Instance => s_Instance;
|
||||
|
||||
private readonly List<OrbitalPosition> m_ObjectInstances = new();
|
||||
private readonly List<Ring> m_Rings = new();
|
||||
private readonly Dictionary<int, float> m_Distances = new();
|
||||
|
||||
public static bool IsSimulationRunning = true;
|
||||
public static bool s_IsSimulationRunning = true;
|
||||
|
||||
private OrbitalPosition m_PlayerOrbitalPosition;
|
||||
public static void SetPlayer(OrbitalPosition player) => s_Instance.m_PlayerOrbitalPosition = player;
|
||||
@@ -60,6 +62,15 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
private bool m_CurrentRingAllowsSpawning;
|
||||
|
||||
private Vector3[] m_PrecalculatedPositions;
|
||||
|
||||
public IEnumerator StartPlayerSpeedupModifier()
|
||||
{
|
||||
m_LocalDeltaTimeScale *= 2f;
|
||||
|
||||
yield return new WaitForSeconds(10f);
|
||||
|
||||
m_LocalDeltaTimeScale /= 2f;
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] private static void OnApplicationStart()
|
||||
{
|
||||
@@ -84,7 +95,7 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
|
||||
private static IEnumerator RestartSimulationInternal()
|
||||
{
|
||||
IsSimulationRunning = false;
|
||||
s_IsSimulationRunning = false;
|
||||
|
||||
s_Instance.m_LocalDeltaTimeScale = 7f;
|
||||
AllowPlayerInput = false;
|
||||
@@ -106,7 +117,7 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
AllowPlayerInput = true;
|
||||
s_Instance.m_LocalDeltaTimeScale = 1f;
|
||||
|
||||
IsSimulationRunning = true;
|
||||
s_IsSimulationRunning = true;
|
||||
}
|
||||
|
||||
public static void RestartSimulation() => s_Instance.StartCoroutine(RestartSimulationInternal());
|
||||
@@ -160,7 +171,7 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
Color c = Color.Lerp(Color.black, Color.white, Mathf.Clamp01(lerp));
|
||||
if (ring.transform.localScale.x < 0.5f)
|
||||
{
|
||||
if (IsSimulationRunning)
|
||||
if (s_IsSimulationRunning)
|
||||
PlayerController.s_PlayerScore++;
|
||||
|
||||
toRemove.Add(ring);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -14,9 +15,15 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
private Vector3 m_SuicidePoint;
|
||||
private bool m_KillingItself;
|
||||
private float m_DeathLerp;
|
||||
|
||||
private bool m_HasFreeHitActive;
|
||||
private bool m_HasInvicibility;
|
||||
|
||||
public MeshRenderer m_Renderer;
|
||||
public Text m_ScoreText;
|
||||
[Header("References")]
|
||||
[SerializeField] private MeshRenderer m_Renderer;
|
||||
[SerializeField] private Text m_ScoreText;
|
||||
[SerializeField] private Material m_DefaultMaterial;
|
||||
[SerializeField] private Material m_FreeHitMaterial;
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
@@ -37,6 +44,11 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
m_ScoreText.color = Color.yellow;
|
||||
else
|
||||
m_ScoreText.color = Color.white;
|
||||
|
||||
if (m_HasFreeHitActive)
|
||||
m_Renderer.material = m_FreeHitMaterial;
|
||||
else
|
||||
m_Renderer.material = m_DefaultMaterial;
|
||||
|
||||
if (GlobalInput.IsScreenClicked && GlobalOrbitalPositionManager.AllowPlayerInput)
|
||||
{
|
||||
@@ -50,6 +62,43 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
m_DeathLerp += Time.deltaTime;
|
||||
}
|
||||
|
||||
private IEnumerator OnGrowPlayerModifier()
|
||||
{
|
||||
transform.localScale *= 1.5f;
|
||||
m_OrbitalPosition.m_ObjectRadius *= 1.5f;
|
||||
|
||||
yield return new WaitForSecondsRealtime(5f);
|
||||
|
||||
transform.localScale /= 1.5f;
|
||||
m_OrbitalPosition.m_ObjectRadius /= 1.5f;
|
||||
}
|
||||
|
||||
private IEnumerator OnShrinkPlayerModifier()
|
||||
{
|
||||
transform.localScale *= 0.6f;
|
||||
m_OrbitalPosition.m_ObjectRadius *= 0.6f;
|
||||
|
||||
yield return new WaitForSecondsRealtime(5f);
|
||||
|
||||
transform.localScale /= 0.6f;
|
||||
m_OrbitalPosition.m_ObjectRadius /= 0.6f;
|
||||
}
|
||||
|
||||
private IEnumerator OnSpeedUpModifier()
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
private IEnumerator TriggerInvicibility()
|
||||
{
|
||||
m_HasFreeHitActive = false;
|
||||
m_HasInvicibility = true;
|
||||
|
||||
yield return new WaitForSecondsRealtime(1f);
|
||||
|
||||
m_HasInvicibility = false;
|
||||
}
|
||||
|
||||
public override void OnCollision(OrbitalPositionBehaviour other)
|
||||
{
|
||||
if (!m_OrbitalPosition.m_IsAttachedToRings)
|
||||
@@ -57,6 +106,17 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
|
||||
if (other.CompareTag("Enemy"))
|
||||
{
|
||||
if (m_HasInvicibility)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_HasFreeHitActive)
|
||||
{
|
||||
StartCoroutine(TriggerInvicibility());
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalOrbitalPositionManager.RestartSimulation();
|
||||
m_SuicidePoint = transform.position;
|
||||
m_KillingItself = true;
|
||||
@@ -65,7 +125,38 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
|
||||
else if (other.CompareTag("PlayerMod"))
|
||||
{
|
||||
other.OnCollision(this);
|
||||
Debug.Log($"Collision with player mod [{((PlayerModifier)other).HeldModifier}]");
|
||||
switch (((PlayerModifier)other).HeldModifier)
|
||||
{
|
||||
case PlayerModifier.Modifier.GainPoints:
|
||||
s_PlayerScore += 100;
|
||||
break;
|
||||
|
||||
case PlayerModifier.Modifier.FreeHit:
|
||||
m_HasFreeHitActive = true;
|
||||
break;
|
||||
|
||||
case PlayerModifier.Modifier.GrowPlayer:
|
||||
StartCoroutine(OnGrowPlayerModifier());
|
||||
break;
|
||||
|
||||
case PlayerModifier.Modifier.ShrinkPlayer:
|
||||
StartCoroutine(OnShrinkPlayerModifier());
|
||||
break;
|
||||
|
||||
case PlayerModifier.Modifier.SpeedUp:
|
||||
StartCoroutine(GlobalOrbitalPositionManager.Instance.StartPlayerSpeedupModifier());
|
||||
break;
|
||||
|
||||
case PlayerModifier.Modifier.ClearAllEnemies:
|
||||
EnemyController.KillAllEnemies();
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.Log($"Collision with unknown modifier occured [{((PlayerModifier)other).HeldModifier}]");
|
||||
break;
|
||||
}
|
||||
|
||||
Debug.Log("Collided with player mod");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,32 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class PlayerModifier : OrbitalPositionBehaviour
|
||||
{
|
||||
public enum Modifier
|
||||
{
|
||||
GainPoints,
|
||||
FreeHit,
|
||||
GrowPlayer,
|
||||
ShrinkPlayer,
|
||||
ClearAllEnemies,
|
||||
SpeedUp
|
||||
}
|
||||
|
||||
private static readonly System.Random s_RandomGenerator = new();
|
||||
|
||||
private static Modifier GetRandomModifier()
|
||||
{
|
||||
return Modifier.SpeedUp;
|
||||
|
||||
Array possibilities = Enum.GetValues(typeof(Modifier));
|
||||
return (Modifier)possibilities.GetValue(s_RandomGenerator.Next(possibilities.Length));
|
||||
}
|
||||
|
||||
private Modifier m_Modifier;
|
||||
public Modifier HeldModifier => m_Modifier;
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
transform.position = new Vector3(0, 0, -100f);
|
||||
@@ -9,6 +34,8 @@ public class PlayerModifier : OrbitalPositionBehaviour
|
||||
m_OrbitalPosition.m_DistanceAlongRadius = Random.Range(0f, Mathf.PI * 2f);
|
||||
m_OrbitalPosition.m_ObjectRadius = 0.3f;
|
||||
m_OrbitalPosition.m_SpinSpeed = 1.6f;
|
||||
|
||||
m_Modifier = GetRandomModifier();
|
||||
}
|
||||
|
||||
public override void OnReachCentre() => Destroy(gameObject);
|
||||
|
||||
Reference in New Issue
Block a user