Character health, tiling randomization

This commit is contained in:
Norbi Peti 2020-11-07 14:47:31 +01:00
parent 247e630c46
commit 2bf74cb2ca
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 174 additions and 8 deletions

View file

@ -131,8 +131,10 @@ GameObject:
m_Component:
- component: {fileID: 416234159}
- component: {fileID: 416234158}
- component: {fileID: 416234160}
- component: {fileID: 416234161}
m_Layer: 0
m_Name: cloudLayer1
m_Name: FrontClouds
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -176,7 +178,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1324642093
m_SortingLayer: -3
m_SortingOrder: 0
m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 8039604243b9466ab89d4474e2290aed, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
@ -196,12 +198,44 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 416234157}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5.46, y: 3.54, z: 0}
m_LocalPosition: {x: -5.46, y: 3.54, z: 22.6}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &416234160
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 416234157}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 21a0aa7215a1d9ab4bdb030081c773b6, type: 3}
m_Name:
m_EditorClassIdentifier:
offsetX: 2
hasARightBuddy: 0
hasALeftBuddy: 0
randomSprites:
- {fileID: 21300000, guid: 8039604243b9466ab89d4474e2290aed, type: 3}
- {fileID: 21300000, guid: f9450af438098a98295c466474f947d0, type: 3}
reverseScale: 0
--- !u!114 &416234161
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 416234157}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bd5c70ae65614c79a9c0670d4eb84eff, type: 3}
m_Name:
m_EditorClassIdentifier:
smoothing: 1
--- !u!1 &996257474
GameObject:
m_ObjectHideFlags: 0
@ -300,6 +334,7 @@ MonoBehaviour:
offsetX: 2
hasARightBuddy: 0
hasALeftBuddy: 0
randomSprites: []
reverseScale: 0
--- !u!114 &996257478
MonoBehaviour:
@ -344,6 +379,121 @@ Transform:
m_Father: {fileID: 2053847422}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1070284622
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1070284625}
- component: {fileID: 1070284624}
- component: {fileID: 1070284623}
- component: {fileID: 1070284626}
m_Layer: 0
m_Name: BackClouds
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1070284623
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1070284622}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 21a0aa7215a1d9ab4bdb030081c773b6, type: 3}
m_Name:
m_EditorClassIdentifier:
offsetX: 2
hasARightBuddy: 0
hasALeftBuddy: 0
randomSprites:
- {fileID: 21300000, guid: 124ce2ecbeb511c43af5cfd20998717f, type: 3}
- {fileID: 21300000, guid: ad63d3046da9cdd8aa290fde476a7d44, type: 3}
reverseScale: 0
--- !u!212 &1070284624
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1070284622}
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: 1324642093
m_SortingLayer: -3
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 124ce2ecbeb511c43af5cfd20998717f, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 10.24, y: 4}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &1070284625
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1070284622}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5.46, y: 4.44, z: 26.48}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1070284626
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1070284622}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bd5c70ae65614c79a9c0670d4eb84eff, type: 3}
m_Name:
m_EditorClassIdentifier:
smoothing: 1
--- !u!1 &1351818047
GameObject:
m_ObjectHideFlags: 0
@ -500,7 +650,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1324642093
m_SortingLayer: -3
m_SortingOrder: 1
m_SortingOrder: 2
m_Sprite: {fileID: 21300000, guid: 945baed7357a5d9c69e6f65181575af1, type: 3}
m_Color: {r: 0.5707547, g: 1, b: 0.63111734, a: 1}
m_FlipX: 0
@ -541,6 +691,7 @@ MonoBehaviour:
offsetX: 2
hasARightBuddy: 0
hasALeftBuddy: 0
randomSprites: []
reverseScale: 0
--- !u!114 &1372634520
MonoBehaviour:
@ -682,6 +833,7 @@ MonoBehaviour:
offsetX: 2
hasARightBuddy: 0
hasALeftBuddy: 0
randomSprites: []
reverseScale: 0
--- !u!114 &1508769558
MonoBehaviour:

View file

@ -3,11 +3,14 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Random = System.Random;
public class OwnCharacterController : MonoBehaviour
{
private Rigidbody2D _rb;
private Vector3 _spawnPos;
private float _health = 100f;
private Random _random = new Random();
// Start is called before the first frame update
void Start()
@ -41,12 +44,15 @@ public class OwnCharacterController : MonoBehaviour
public void Hit()
{
_health -= (float) _random.NextDouble() % 20f + 20f;
if (_health <= 0f)
Respawn();
}
private void Respawn()
{
transform.position = _spawnPos;
_health = 100f;
}
private bool IsOnGround()

View file

@ -1,8 +1,8 @@
using UnityEngine;
using Random = System.Random;
public class Tiling : MonoBehaviour
{
private const int LEFT = -1;
private const int RIGHT = 1;
@ -12,15 +12,20 @@ public class Tiling : MonoBehaviour
public bool hasARightBuddy;
public bool hasALeftBuddy;
public Sprite[] randomSprites;
public bool reverseScale; // used if the object is not tilable
private float spriteWidth; // the width of our element
private Camera cam;
private Transform myTransform;
private Random _random;
void Awake () {
cam = Camera.main;
myTransform = transform;
if (randomSprites.Length > 0)
_random = new Random();
}
// Start is called before the first frame update
@ -66,6 +71,9 @@ public class Tiling : MonoBehaviour
// instantating our new body and storing him in a variable
Transform newBuddy = Instantiate (myTransform, newPosition, myTransform.rotation);
if (randomSprites.Length > 0) //Randomizált háttér
newBuddy.GetComponent<SpriteRenderer>().sprite = randomSprites[_random.Next(randomSprites.Length)];
// if not tilable let's reverse the x size og our object to get rid of ugly seams
if (reverseScale)
{