Platform level, character respawn and enemy despawn fixes

This commit is contained in:
Norbi Peti 2020-11-07 23:02:47 +01:00
parent 54ee7d5467
commit ee3be5496c
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
5 changed files with 103 additions and 10 deletions

View file

@ -144,6 +144,6 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
target: {fileID: 0} target: {fileID: 0}
speed: 6.5 speed: 8
flyForce: 30 flyForce: 30
finalHealth: 3 finalHealth: 3

View file

@ -169,6 +169,7 @@ MonoBehaviour:
platformRight: {fileID: 413955008} platformRight: {fileID: 413955008}
player: {fileID: 2053847422} player: {fileID: 2053847422}
maxSize: 5 maxSize: 5
maxLevel: 5
--- !u!1 &407879043 --- !u!1 &407879043
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -758,11 +759,11 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1043406433} m_GameObject: {fileID: 1043406433}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.128, y: 0.015, z: 0} m_LocalPosition: {x: 2.0156207, y: 0.17081104, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 17.081528, y: 17.081528, z: 17.081528}
m_Children: [] m_Children: []
m_Father: {fileID: 2053847422} m_Father: {fileID: 1811013770}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1070284622 --- !u!1 &1070284622
@ -1264,6 +1265,88 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1811013769
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1811013770}
- component: {fileID: 1811013771}
m_Layer: 0
m_Name: Gun
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1811013770
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1811013769}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.10400009, y: 0.103000164, z: 0}
m_LocalScale: {x: 0.058542777, y: 0.058542777, z: 0.058542777}
m_Children:
- {fileID: 1043406434}
m_Father: {fileID: 2053847422}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1811013771
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1811013769}
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_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: 345772978339323005, guid: e85a5dfbe00d05491b7f1688ea28a74e, 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.700976, y: 2.1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &2053847420 --- !u!1 &2053847420
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1325,7 +1408,7 @@ SpriteRenderer:
m_SortingLayerID: -507104343 m_SortingLayerID: -507104343
m_SortingLayer: -1 m_SortingLayer: -1
m_SortingOrder: 0 m_SortingOrder: 0
m_Sprite: {fileID: -4500823926942025012, guid: 22df4be82d91637658b965dd24a4a591, m_Sprite: {fileID: 6185353665997233981, guid: 22df4be82d91637658b965dd24a4a591,
type: 3} type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0 m_FlipX: 0
@ -1348,7 +1431,7 @@ Transform:
m_LocalPosition: {x: -7.23, y: 2.57, z: 0} m_LocalPosition: {x: -7.23, y: 2.57, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 1043406434} - {fileID: 1811013770}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 5 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1390,7 +1473,7 @@ BoxCollider2D:
m_SpriteTilingProperty: m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5} pivot: {x: 0.5, y: 0.5}
oldSize: {x: 0.21, y: 0.49} oldSize: {x: 0.38, y: 0.47}
newSize: {x: 0.21, y: 0.49} newSize: {x: 0.21, y: 0.49}
adaptiveTilingThreshold: 0.5 adaptiveTilingThreshold: 0.5
drawMode: 0 drawMode: 0

View file

@ -39,7 +39,7 @@ public class EnemyController : MonoBehaviour
return; return;
} }
if (diff.y > 5) if (diff.y > 5 || diff.x > 20)
Remove(); Remove();
diff.Normalize(); diff.Normalize();

View file

@ -66,6 +66,7 @@ public class OwnCharacterController : MonoBehaviour
{ {
transform.position = _spawnPos; transform.position = _spawnPos;
_health = 100f; _health = 100f;
_rb.velocity = Vector2.zero;
} }
public bool IsOnGround(string groundName = "") public bool IsOnGround(string groundName = "")

View file

@ -10,6 +10,7 @@ public class PlatformSpawner : MonoBehaviour
public Transform platformRight; public Transform platformRight;
public Transform player; public Transform player;
public int maxSize = 5; public int maxSize = 5;
public int maxLevel = 5;
private Vector3 _spawnDiff; private Vector3 _spawnDiff;
private int _level = 0; private int _level = 0;
@ -42,11 +43,19 @@ public class PlatformSpawner : MonoBehaviour
_lastPlatformPos = pos; _lastPlatformPos = pos;
if (_level == 0) if (_level == 0)
_lastLevel0Pos = pos.x; _lastLevel0Pos = pos.x;
if (_random.Next(2) == 1) int rand = _random.Next(10);
if (rand == 1 && _level < maxLevel)
{ {
_level++; _level++;
_lastPlatformPos.y++; _lastPlatformPos.y++;
_playerController.SetCheckpoint(_lastPlatformPos); _playerController.SetCheckpoint(_lastPlatformPos);
} }
else if (rand == 2 && _level > 1)
{
_level--;
_lastPlatformPos.y++;
_playerController.SetCheckpoint(_lastPlatformPos);
_lastPlatformPos.y -= 2;
}
} }
} }