This commit is contained in:
Sewmina Dilshan 2023-02-11 04:24:38 +05:30
parent a99474937b
commit f89528452e
10 changed files with 281 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -0,0 +1,96 @@
fileFormatVersion: 2
guid: 5ec98fb93327a1e4c973fd0acbd2ca9d
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:

8
Assets/Prefabs.meta Normal file
View File

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

View File

@ -23,7 +23,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1224988596171271543}
m_LocalRotation: {x: -0, y: -0, z: 0.020411367, w: 0.9997917}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 76.5, y: -5.14, z: 0}
m_LocalScale: {x: 0.65999997, y: 0.65999997, z: 0.66}
m_Children:
@ -137,14 +137,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3991448815925555394}
m_LocalRotation: {x: -0, y: -0, z: 0.04139302, w: 0.999143}
m_LocalPosition: {x: 0.66, y: 3.24, z: 0}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.99, y: 2.87, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 6865234905463367357}
m_Father: {fileID: 6006256522780223737}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 4.745}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &6397209502795689116
SpriteRenderer:
m_ObjectHideFlags: 0

115
Assets/Prefabs/Tree.prefab Normal file
View File

@ -0,0 +1,115 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3829158581930744394
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3829158581930744395}
- component: {fileID: 3829158581930744388}
m_Layer: 0
m_Name: mt_tree
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3829158581930744395
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3829158581930744394}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 2.202, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3829158582021451569}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &3829158581930744388
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3829158581930744394}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 5ec98fb93327a1e4c973fd0acbd2ca9d, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 3.16, y: 5.15}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &3829158582021451568
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3829158582021451569}
m_Layer: 0
m_Name: Tree
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3829158582021451569
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3829158582021451568}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 3.976, y: -0.667, z: 0}
m_LocalScale: {x: 0.56586, y: 0.56586, z: 0.56586}
m_Children:
- {fileID: 3829158581930744395}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

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

View File

@ -776,7 +776,7 @@ Transform:
m_GameObject: {fileID: 607602978}
m_LocalRotation: {x: -0, y: -0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 3.8875, z: 1}
m_LocalScale: {x: 1, y: 6, z: 1}
m_Children:
- {fileID: 54922998}
m_Father: {fileID: 370510547}
@ -1971,7 +1971,7 @@ SpriteShapeRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_SortingOrder: 2
m_Color: {r: 0.5686275, g: 0.8588236, b: 0.40784317, a: 1}
m_MaskInteraction: 0
m_ShapeTexture: {fileID: 2800000, guid: b281b91a70a624a0da1c43adc1c30c7b, type: 3}
@ -2881,7 +2881,8 @@ MonoBehaviour:
minDiff: {x: 5, y: -5}
maxDiff: {x: 10, y: 4}
flagPrefab: {fileID: 1224988596171271543, guid: 9f7458832f8d5e14fa0dd5dac44793ff, type: 3}
GoalDistance: 10
treePrefab: {fileID: 3829158582021451568, guid: 659b2fa9bee28844eb7b9fb1bb06d8bd, type: 3}
GoalDistance: 3
--- !u!114 &2119506458
MonoBehaviour:
m_ObjectHideFlags: 0
@ -2898,11 +2899,15 @@ MonoBehaviour:
cam: {fileID: 1449942455}
camTargetPos: {x: 0, y: 0, z: 0}
cameraSmoothness: 0.1
inputSensitivity: 0.1
inputSensitivity: 400
BallFriction: 0.01
StopVelocity: 0.2
StopTime: 0.1
curVelocity: 0
forceMultiplier: 5000
ballProjection: {fileID: 370510547}
ballProjectionScaleMin: 1
ballProjectionScaleMax: 5
--- !u!1 &2120181086
GameObject:
m_ObjectHideFlags: 0

View File

@ -15,11 +15,16 @@ public class GameManager : MonoBehaviour
public float StopTime = 0.1f;
public float curVelocity;
public float forceMultiplier;
public Transform ballProjection;
public float ballProjectionScaleMin, ballProjectionScaleMax;
void Start()
{
camTargetPos = ball.transform.position;
}
float stopCooldown = 0;
void FixedUpdate(){
curVelocity = ball.velocity.magnitude;
ball.velocity = Vector2.Lerp(ball.velocity, new Vector2(0, ball.velocity.y), BallFriction);
@ -47,6 +52,7 @@ public class GameManager : MonoBehaviour
bool dragging = false;
Vector2 startPos;
public void OnMouseDown(BaseEventData e){
if(ball.simulated){return;}
PointerEventData ped = (PointerEventData) e as PointerEventData;
startPos = ped.position;
@ -54,18 +60,35 @@ public class GameManager : MonoBehaviour
}
public void OnMouseUp(BaseEventData e){
PointerEventData ped = (PointerEventData) e as PointerEventData;
if(dragging){
Vector2 v = (ped.position-startPos)/inputSensitivity;
Vector2 v = ((ped.position-startPos)/inputSensitivity);
if(v.magnitude > 1){v = v.normalized;}
stopCooldown=0;
ball.simulated=true;
ball.AddForce(-v);
ball.AddForce(-v * forceMultiplier);
}
dragging = false;
ballProjection.position = Vector3.zero;
}
public void OnMouseDrag(BaseEventData e){
if(ball.simulated){return;}
ballProjection.position = ball.position;
PointerEventData ped = (PointerEventData) e as PointerEventData;
Vector2 v = ((ped.position-startPos)/inputSensitivity);
Debug.Log(v.magnitude);
if(v.magnitude > 1){v = v.normalized;}
Vector3 direction = (ped.position - startPos).normalized;
float rot_z = Mathf.Atan2(direction.y,direction.x) * Mathf.Rad2Deg;
ballProjection.rotation = Quaternion.Euler(0,0,rot_z+180);
float scaleDiff = ballProjectionScaleMax - ballProjectionScaleMin;
ballProjection.GetChild(0).localScale = new Vector3(ballProjection.GetChild(0).localScale.x,ballProjectionScaleMin + (scaleDiff*v.magnitude));
}
}

View File

@ -15,6 +15,7 @@ public class LevelGenerator : MonoBehaviour
public GameObject flagPrefab;
public GameObject treePrefab;
public int GoalDistance= 10;
@ -43,6 +44,18 @@ public class LevelGenerator : MonoBehaviour
// spriteShapeController.spline.InsertPointAt(i, points[i]);
InsertNewPoint(points[i]);
if(Random.Range(0f,1f) > 0.5f){
Vector2 newTreePosition = points[i];
Vector3 diff = points[i]-points[i-1];
Vector2 newTreePosition2 = points[i-1] + (diff/2f);
Debug.Log($"{points[i-1]} + {points[i]} - {points[i-1]} / 0.5f | diff = {diff}");
GameObject newTree = Instantiate(treePrefab, newTreePosition2, Quaternion.identity);
newTree.transform.localScale = Vector3.one * Random.Range(0.75f, 1.1f);
}
if(i % GoalDistance == 0){
InsertNewPoint(points[i] + new Vector3(0, -1f));
InsertNewPoint(points[i] + new Vector3(1f, -1f));
@ -62,7 +75,10 @@ public class LevelGenerator : MonoBehaviour
void InsertNewPoint(Vector3 point){
spriteShapeController.spline.InsertPointAt(spriteShapeController.spline.GetPointCount(), point);
int index= spriteShapeController.spline.GetPointCount();
spriteShapeController.spline.InsertPointAt(index, point);
spriteShapeController.spline.SetLeftTangent(index, Vector3.zero);
spriteShapeController.spline.SetTangentMode(index, ShapeTangentMode.Broken);
}