This commit is contained in:
Sewmina Dilshan 2023-01-23 13:49:56 +05:30
parent 263feed880
commit a9e65bfc72
19 changed files with 7248 additions and 31 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,9 @@ public class CameraFollower : MonoBehaviour
public float Ysmoothness =1f;
public static Transform Target;
public Vector2 offset;
public Vector3 shakeIntensity;
public GameObject shakeFX_good;
public GameObject shakeFX_bad;
void FixedUpdate()
{
UpdateFrame();
@ -23,12 +26,19 @@ public class CameraFollower : MonoBehaviour
void updateFrame(){
if(PlayerController.boosting){
//Add boost here
}
float newX = Mathf.Lerp(transform.position.x, Target.position.x + offset.x, Xsmoothness);
float newY = Mathf.Lerp(transform.position.y, Target.position.y + offset.y, Ysmoothness);
transform.position = new Vector3(newX, newY, transform.position.z);
if(PlayerController.boosting){
//Add boost here
shakeFX_good.SetActive(PlayerController.instance.isUp);
shakeFX_bad.SetActive(!PlayerController.instance.isUp);
transform.position += new Vector3(Random.Range(-shakeIntensity.x, shakeIntensity.x), Random.Range(-shakeIntensity.y,shakeIntensity.y), Random.Range(-shakeIntensity.z,shakeIntensity.z));
}else{
shakeFX_good.SetActive(false);
shakeFX_bad.SetActive(false);
}
}
}

View File

@ -1,16 +1,72 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public static GameManager instance;
void Awake(){
instance = this;
}
public Text txt_money;
public float moneyMultiplier = 5;
public Vector3 txtMoneyOffset = Vector2.one;
public GameObject gameOverPanel;
public GameObject startPanel;
public GameObject finishPanel;
public Text finishedScoreTxt;
public Transform CheckeredFlag;
public void StartGame(){
startPanel.SetActive(false);
}
void Update(){
txt_money.text = "$"+(PlayerController.t.position.y*moneyMultiplier).ToString("n4");
txt_money.rectTransform.position = Camera.main.WorldToScreenPoint(PlayerController.t.position + txtMoneyOffset);
if(PlayerController.boosting){
txt_money.rectTransform.localScale = Vector3.Lerp(txt_money.rectTransform.localScale, Vector3.one * 1.5f, 0.05f);
}else{
txt_money.rectTransform.localScale = Vector3.Lerp(txt_money.rectTransform.localScale, Vector3.one , 0.1f);
}
if(PlayerController.t.position.y > 120){
Color curColor = Camera.main.backgroundColor;
Camera.main.backgroundColor = Color.Lerp(curColor, Color.black, 0.001f);
}
if(CheckeredFlag.position.x - PlayerController.t.position.x > 20){
CheckeredFlag.position = new Vector2(CheckeredFlag.position.x,PlayerController.t.position.y);
}else if(CheckeredFlag.position.x - PlayerController.t.position.x < 4){
FinishGame();
}
}
public void gameOver(){
gameOverPanel.SetActive(true);
PlayerController.instance.GameOver();
}
public static void GameOver(){
instance.gameOver();
}
public void FinishGame(){
finishPanel.SetActive(true);
finishedScoreTxt.text = txt_money.text;
PlayerController.instance.GameOver();
}
public void Restart(){
SceneManager.LoadScene("Game");
}
}

View File

@ -9,6 +9,8 @@ public class OptionsSpawner : MonoBehaviour
{
instance = this;
}
public int goodSpawnRate=2;
public int badSpawnRate=5;
public Transform optionGood;
public Transform optionBad;
public Vector2 SpawnDistanceMin;
@ -19,6 +21,16 @@ public class OptionsSpawner : MonoBehaviour
void Update()
{
if (!PlayerController.Started) { return; }
if(PlayerController.t.position.y < 100){
goodSpawnRate = 2;
badSpawnRate = 1;
}else if(PlayerController.t.position.y < 500){
goodSpawnRate = 2;
badSpawnRate = 2;
}else{
goodSpawnRate = 1;
badSpawnRate = 3;
}
if (t < SpawnTimer)
{
t += Time.deltaTime;
@ -27,13 +39,29 @@ public class OptionsSpawner : MonoBehaviour
{
t = 0;
float newGoodRate = 1.05f + GetRandomRateDiff();
SpawnGood(newGoodRate);
for (int i = 0; i < 2; i++)
List<Vector3> positions= new List<Vector3>();
for (int i = 0; i < goodSpawnRate; i++)
{
float newGoodRate = 1.05f + GetRandomRateDiff();
Vector3 position = PlayerController.t.position + new Vector3(PlayerController.t.right.x * Random.Range(SpawnDistanceMin.x, SpawnDistanceMax.x), PlayerController.t.right.y * Random.Range(SpawnDistanceMin.y, SpawnDistanceMax.y));
// foreach(Vector3 pos in positions){
// if(Vector3.Distance(pos, position) < 3){
// position += new Vector3(10,0,0);
// }
// }
SpawnGood(newGoodRate);
}
for (int i = 0; i < badSpawnRate; i++)
{
Vector3 position = PlayerController.t.position + new Vector3(PlayerController.t.right.x * Random.Range(SpawnDistanceMin.x, SpawnDistanceMax.x), PlayerController.t.right.y * Random.Range(SpawnDistanceMin.y, SpawnDistanceMax.y));
// foreach(Vector3 pos in positions){
// if(Vector3.Distance(pos, position) < 3){
// position += new Vector3(10,0,0);
// }
// }
float newBadRate = 0.95f - GetRandomRateDiff();
SpawnBad(newBadRate);
SpawnBad(newBadRate,position);
}
}
}

View File

@ -29,6 +29,11 @@ public class PlayerController : MonoBehaviour
CameraFollower.Target = transform;
}
public void GameOver(){
Started=false;
spriteRenderer.sprite = downwardSprite;
}
public static bool Started;
// Update is called once per frame
void Update(){
@ -44,7 +49,9 @@ public class PlayerController : MonoBehaviour
eulerAngles = transform.eulerAngles;
currentTrail.transform.position = transform.position;
if(transform.position.y < 0){
GameManager.GameOver();
}
if(boosting){return;}
Collider2D overlap = Physics2D.OverlapCircle(transform.position, senseRadius);
if(overlap!=null){
@ -62,16 +69,19 @@ public class PlayerController : MonoBehaviour
boosting=true;
float newY = transform.position.y * perc;
spriteRenderer.sprite = (perc > 1) ? upwardSprite : downwardSprite;
// float boostingSpeed = transform.position.y * (1f/boostSpeed);
float boostingSpeed = boostSpeed;
if(transform.position.y < 250){boostingSpeed = boostSpeed/2f;}
if(perc > 1){
while(transform.position.y < newY){
transform.position += new Vector3(0,boostSpeed,0);
transform.position += new Vector3(0,boostingSpeed,0);
if(!isUp){SwitchSide();}
yield return new WaitForFixedUpdate();
}
}else{
while(transform.position.y > newY){
transform.position -= new Vector3(0,boostSpeed,0);
transform.position -= new Vector3(0,boostingSpeed,0);
if(isUp){SwitchSide();}
yield return new WaitForFixedUpdate();
}
@ -82,7 +92,11 @@ public class PlayerController : MonoBehaviour
void SwitchSide(){
if(!Started){
GameManager.instance.StartGame();
}
Started=true;
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, isUp ? -turnAngle : turnAngle);
GameObject newTrail = Instantiate(trailPrefab, transform.position, Quaternion.identity);
@ -90,7 +104,7 @@ public class PlayerController : MonoBehaviour
newTrail.GetComponent<TrailRenderer>().startColor = newTrail.GetComponent<TrailRenderer>().endColor = (isUp) ? Color.green:Color.red;
// GetComponent<SpriteRenderer>().sprite = (isUp) ? upwardSprite : downwardSprite;
GetComponent<SpriteRenderer>().sprite = (isUp) ? upwardSprite : downwardSprite;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 KiB

View File

@ -0,0 +1,96 @@
fileFormatVersion: 2
guid: ff8ffab9b81bc8a418ee60bb9e21323e
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f00e3281c0dda734d928e5ad6e5b8914
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: d39a55c59a9aab74d8e35bb9d964bdab
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Bungee
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

86
Assets/Sprites/soike2.mat Normal file
View File

@ -0,0 +1,86 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: soike2
m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
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: 2800000, guid: 17f45e06be26f4c02a566b31517e7833, type: 3}
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_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: 1, g: 1, b: 1, 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: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 959d57fcfaf544de283e90f822b7195b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5798a795da5814e6a86443b807ea1950
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

86
Assets/Sprites/spike.mat Normal file
View File

@ -0,0 +1,86 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: spike
m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
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: 2800000, guid: da16118c18c1841c3be57e405b44a708, type: 3}
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_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: 1, g: 1, b: 1, 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: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f998408b37ea949f582315259899f0f7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Sprites/yuiop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -0,0 +1,96 @@
fileFormatVersion: 2
guid: 17f45e06be26f4c02a566b31517e7833
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,7 +3,8 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
tags:
- Ground
layers:
- Default
- TransparentFX