Commit 738b438a authored by Abdulrahman Mohammed's avatar Abdulrahman Mohammed

Generate Random Levels

parent bb3fa8f0
...@@ -225,7 +225,7 @@ GameObject: ...@@ -225,7 +225,7 @@ GameObject:
- component: {fileID: 2998999329351238821} - component: {fileID: 2998999329351238821}
- component: {fileID: 2681292289843926559} - component: {fileID: 2681292289843926559}
m_Layer: 0 m_Layer: 0
m_Name: Start m_Name: Empty
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
...@@ -241,7 +241,7 @@ Transform: ...@@ -241,7 +241,7 @@ Transform:
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.23, y: 0, z: -30} m_LocalPosition: {x: 2.23, y: 0, z: -30}
m_LocalScale: {x: 1.15, y: 1, z: 1} m_LocalScale: {x: 1.15, y: 1, z: 1.5}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 4251326578671272785} - {fileID: 4251326578671272785}
...@@ -312,7 +312,7 @@ MonoBehaviour: ...@@ -312,7 +312,7 @@ MonoBehaviour:
m_PreserveMeshAssetOnDestroy: 0 m_PreserveMeshAssetOnDestroy: 0
assetGuid: assetGuid:
m_Mesh: {fileID: 0} m_Mesh: {fileID: 0}
m_VersionIndex: 2184 m_VersionIndex: 2190
m_IsSelectable: 1 m_IsSelectable: 1
m_SelectedFaces: m_SelectedFaces:
m_SelectedEdges: [] m_SelectedEdges: []
...@@ -4384,7 +4384,7 @@ MonoBehaviour: ...@@ -4384,7 +4384,7 @@ MonoBehaviour:
m_PreserveMeshAssetOnDestroy: 0 m_PreserveMeshAssetOnDestroy: 0
assetGuid: assetGuid:
m_Mesh: {fileID: 0} m_Mesh: {fileID: 0}
m_VersionIndex: 2001 m_VersionIndex: 2007
m_IsSelectable: 1 m_IsSelectable: 1
m_SelectedFaces: m_SelectedFaces:
m_SelectedEdges: [] m_SelectedEdges: []
......
...@@ -122,7 +122,7 @@ RectTransform: ...@@ -122,7 +122,7 @@ RectTransform:
m_Father: {fileID: 9143448237922178203} m_Father: {fileID: 9143448237922178203}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
...@@ -416,7 +416,6 @@ Transform: ...@@ -416,7 +416,6 @@ Transform:
m_Children: m_Children:
- {fileID: 1014630243346878185} - {fileID: 1014630243346878185}
- {fileID: 8705232317391820588} - {fileID: 8705232317391820588}
- {fileID: 8724371554304158580}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2673343522929614604 --- !u!1 &2673343522929614604
...@@ -434,7 +433,7 @@ GameObject: ...@@ -434,7 +433,7 @@ GameObject:
- component: {fileID: 3386078076239196088} - component: {fileID: 3386078076239196088}
- component: {fileID: 3860284701908414044} - component: {fileID: 3860284701908414044}
m_Layer: 0 m_Layer: 0
m_Name: Cube m_Name: Wall
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
...@@ -449,11 +448,11 @@ Transform: ...@@ -449,11 +448,11 @@ Transform:
m_GameObject: {fileID: 2673343522929614604} m_GameObject: {fileID: 2673343522929614604}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4, y: 0, z: 129} m_LocalPosition: {x: -5.4173913, y: 0, z: 19.992012}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 0.8695652, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 8292781845706186428} m_Father: {fileID: 8705232317391820588}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2295769132377960148 --- !u!114 &2295769132377960148
MonoBehaviour: MonoBehaviour:
...@@ -910,8 +909,8 @@ BoxCollider: ...@@ -910,8 +909,8 @@ BoxCollider:
m_ProvidesContacts: 0 m_ProvidesContacts: 0
m_Enabled: 1 m_Enabled: 1
serializedVersion: 3 serializedVersion: 3
m_Size: {x: 0.20713311, y: 0.062318023, z: 0.1398578} m_Size: {x: 0.22093646, y: 0.062318023, z: 0.15918258}
m_Center: {x: 0, y: 0.013320199, z: 0.06801179} m_Center: {x: 0, y: 0.013320202, z: 0.05834952}
--- !u!114 &3632654124685458951 --- !u!114 &3632654124685458951
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -928,7 +927,6 @@ MonoBehaviour: ...@@ -928,7 +927,6 @@ MonoBehaviour:
health: 80 health: 80
healthSlider: {fileID: 7855868623801550860} healthSlider: {fileID: 7855868623801550860}
hitClip: {fileID: 8300000, guid: a991034414d277544af7084dd6dc7a2b, type: 3} hitClip: {fileID: 8300000, guid: a991034414d277544af7084dd6dc7a2b, type: 3}
shakeStrength: 0.0075
--- !u!54 &8673915052375520288 --- !u!54 &8673915052375520288
Rigidbody: Rigidbody:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -965,7 +963,8 @@ AudioSource: ...@@ -965,7 +963,8 @@ AudioSource:
m_GameObject: {fileID: 4099675634854172904} m_GameObject: {fileID: 4099675634854172904}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 4 serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0} OutputAudioMixerGroup: {fileID: 24300002, guid: 5a4ab7a92d37e3649b9839994fbe2bc2,
type: 2}
m_audioClip: {fileID: 8300000, guid: 6e631738d40a5da4198bbf9cf0b59bb6, type: 3} m_audioClip: {fileID: 8300000, guid: 6e631738d40a5da4198bbf9cf0b59bb6, type: 3}
m_PlayOnAwake: 1 m_PlayOnAwake: 1
m_Volume: 1 m_Volume: 1
...@@ -5214,8 +5213,8 @@ Transform: ...@@ -5214,8 +5213,8 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5639176411216372903} m_GameObject: {fileID: 5639176411216372903}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: -2.23, y: 0, z: -109.00799}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
...@@ -5253,13 +5252,14 @@ Transform: ...@@ -5253,13 +5252,14 @@ Transform:
m_GameObject: {fileID: 5978578856613855189} m_GameObject: {fileID: 5978578856613855189}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.23, y: 0, z: 109.00799} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.15, y: 1, z: 1} m_LocalScale: {x: 1.15, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 834189057126252906} - {fileID: 834189057126252906}
- {fileID: 6674855103497809671} - {fileID: 6674855103497809671}
- {fileID: 6667120662435470534} - {fileID: 6667120662435470534}
- {fileID: 8724371554304158580}
m_Father: {fileID: 8292781845706186428} m_Father: {fileID: 8292781845706186428}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1073588711995899552 --- !u!114 &1073588711995899552
...@@ -5441,45 +5441,7 @@ MonoBehaviour: ...@@ -5441,45 +5441,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 981ddc12ab1298541a79492bf95afd3f, type: 3} m_Script: {fileID: 11500000, guid: 981ddc12ab1298541a79492bf95afd3f, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
wakeUpEnemy: virus: {fileID: 4099675634854172904}
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 4099675634854172904}
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
m_MethodName: SetActive
m_Mode: 6
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 1
m_CallState: 2
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: PlayerMovement, Assembly-CSharp
m_MethodName: SetSpeed
m_Mode: 3
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 1
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: CameraMovement, Assembly-CSharp
m_MethodName: SetSpeed
m_Mode: 4
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 1
m_FloatArgument: 0.25
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!1 &7655358461642858228 --- !u!1 &7655358461642858228
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -152,7 +152,6 @@ MonoBehaviour: ...@@ -152,7 +152,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0bd912bb11f767e45b3d040f71b0aaa7, type: 3} m_Script: {fileID: 11500000, guid: 0bd912bb11f767e45b3d040f71b0aaa7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
<index>k__BackingField: 0
--- !u!1 &932225745288769094 --- !u!1 &932225745288769094
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -483,7 +482,6 @@ MonoBehaviour: ...@@ -483,7 +482,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0bd912bb11f767e45b3d040f71b0aaa7, type: 3} m_Script: {fileID: 11500000, guid: 0bd912bb11f767e45b3d040f71b0aaa7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
<index>k__BackingField: 2
--- !u!1 &1762389888842252517 --- !u!1 &1762389888842252517
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -738,6 +736,7 @@ MonoBehaviour: ...@@ -738,6 +736,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
fadeDuration: 0.75 fadeDuration: 0.75
fadeOnStart: 0
--- !u!1 &2662198505241990919 --- !u!1 &2662198505241990919
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -909,6 +908,7 @@ MonoBehaviour: ...@@ -909,6 +908,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
fadeDuration: 0.75 fadeDuration: 0.75
fadeOnStart: 0
--- !u!1 &2719780919841259492 --- !u!1 &2719780919841259492
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1220,6 +1220,7 @@ MonoBehaviour: ...@@ -1220,6 +1220,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
fadeDuration: 0.75 fadeDuration: 0.75
fadeOnStart: 0
--- !u!1 &4538400059142529437 --- !u!1 &4538400059142529437
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1252,7 +1253,7 @@ Transform: ...@@ -1252,7 +1253,7 @@ Transform:
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.23, y: 0, z: -10} m_LocalPosition: {x: 2.23, y: 0, z: -10}
m_LocalScale: {x: 1.15, y: 1, z: 1.4876} m_LocalScale: {x: 1.15, y: 1, z: 1.5}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8259959051626121911} - {fileID: 8259959051626121911}
...@@ -1715,7 +1716,6 @@ MonoBehaviour: ...@@ -1715,7 +1716,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0bd912bb11f767e45b3d040f71b0aaa7, type: 3} m_Script: {fileID: 11500000, guid: 0bd912bb11f767e45b3d040f71b0aaa7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
<index>k__BackingField: 1
--- !u!1 &6681320055666666270 --- !u!1 &6681320055666666270
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -107,7 +107,7 @@ BoxCollider: ...@@ -107,7 +107,7 @@ BoxCollider:
m_ProvidesContacts: 0 m_ProvidesContacts: 0
m_Enabled: 1 m_Enabled: 1
serializedVersion: 3 serializedVersion: 3
m_Size: {x: 0.02573255, y: 0.26380414, z: 0.03183084} m_Size: {x: 0.026069043, y: 0.2672538, z: 0.026132142}
m_Center: {x: 0, y: 0, z: 0} m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &6261498682272946386 --- !u!114 &6261498682272946386
MonoBehaviour: MonoBehaviour:
...@@ -134,15 +134,19 @@ MonoBehaviour: ...@@ -134,15 +134,19 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 46c085c8075e92e47964f4d92e29d15d, type: 3} m_Script: {fileID: 11500000, guid: 46c085c8075e92e47964f4d92e29d15d, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
isObstacle: 1
idleObstacle: 0
rotate: 1 rotate: 1
reverse: 0 reverse: 0
rotateDuration: 5 rotateDuration: 5
upAndDown: 1 upAndDown: 1
EnableRandomUpAndDown: 0
upAndDownAmount: 3 upAndDownAmount: 3
upAndDownDuration: 1 upAndDownDuration: 1
moveLeftAndRight: 0 moveLeftAndRight: 0
moveLeftAndRightAmount: 0 moveLeftAndRightAmount: 3
moveLeftAndRightDuration: 0 moveLeftAndRightDuration: 2
moveLocalLeftAndRightAndRandom: 0
--- !u!54 &2016084165090486392 --- !u!54 &2016084165090486392
Rigidbody: Rigidbody:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -805,7 +805,7 @@ MonoBehaviour: ...@@ -805,7 +805,7 @@ MonoBehaviour:
m_fontSizeMax: 72 m_fontSizeMax: 72
m_fontStyle: 0 m_fontStyle: 0
m_HorizontalAlignment: 2 m_HorizontalAlignment: 2
m_VerticalAlignment: 1024 m_VerticalAlignment: 512
m_textAlignment: 65535 m_textAlignment: 65535
m_characterSpacing: 0 m_characterSpacing: 0
m_wordSpacing: 0 m_wordSpacing: 0
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ContainerManager : MonoBehaviour
{
public static ContainerManager Instance { get; private set; }
[field: SerializeField] public GameObject Player { get; private set; }
[field: SerializeField] public GameObject Camera { get; private set; }
private void Awake()
{
if (Instance == null)
Instance = this;
else
Destroy(gameObject);
}
}
fileFormatVersion: 2 fileFormatVersion: 2
guid: 9703e8899d7c635469f1820520e3180f guid: 3a664e0e26c55554d8711b1041ff2200
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class CameraMovement : MonoBehaviour public class CameraMovement : MonoBehaviour
...@@ -10,6 +8,10 @@ public class CameraMovement : MonoBehaviour ...@@ -10,6 +8,10 @@ public class CameraMovement : MonoBehaviour
void Start() void Start()
{ {
// defult value
transform.position = new Vector3(-2.30999994f, 2.25f, 11.92f);
transform.rotation = Quaternion.Euler(20,0,0);
_offset = transform.position - player.position; _offset = transform.position - player.position;
} }
void LateUpdate() void LateUpdate()
......
...@@ -3,12 +3,22 @@ using UnityEngine.Events; ...@@ -3,12 +3,22 @@ using UnityEngine.Events;
public class EnemyArea : MonoBehaviour public class EnemyArea : MonoBehaviour
{ {
[SerializeField] UnityEvent wakeUpEnemy; [SerializeField] GameObject virus;
PlayerMovement playerMovement;
CameraMovement cameraMovement;
private void Start()
{
playerMovement= ContainerManager.Instance.Player.GetComponent<PlayerMovement>();
cameraMovement= ContainerManager.Instance.Camera.GetComponent<CameraMovement>();
}
void OnTriggerEnter(Collider other) void OnTriggerEnter(Collider other)
{ {
if (other.CompareTag("Player")) if (other.CompareTag("Player"))
{ {
wakeUpEnemy?.Invoke(); virus.SetActive(true);
playerMovement.SetSpeed(1);
cameraMovement.SetSpeed(.25f);
} }
} }
} }
using DG.Tweening; using DG.Tweening;
using System; using System;
using System.Collections; using System.Collections;
using Unity.Mathematics;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
...@@ -16,7 +17,6 @@ public class EnemyScript : MonoBehaviour ...@@ -16,7 +17,6 @@ public class EnemyScript : MonoBehaviour
int hitsNumber; int hitsNumber;
AudioSource _audioSource; AudioSource _audioSource;
SkinnedMeshRenderer _meshRenderer; SkinnedMeshRenderer _meshRenderer;
[SerializeField] float shakeStrength;
private void Start() private void Start()
{ {
_audioSource = GetComponent<AudioSource>(); _audioSource = GetComponent<AudioSource>();
...@@ -38,7 +38,7 @@ public class EnemyScript : MonoBehaviour ...@@ -38,7 +38,7 @@ public class EnemyScript : MonoBehaviour
} }
if (other.CompareTag("Player")) if (other.CompareTag("Player"))
{ {
transform.parent.DOShakeScale(6, shakeStrength); transform.parent.DOShakeScale(6, 0.0075f);
_meshRenderer.material.DOColor(Color.red, fadeColorDuration).SetEase(Ease.Linear).SetLoops(24, LoopType.Yoyo).OnComplete(() => _meshRenderer.material.DOColor(Color.red, fadeColorDuration).SetEase(Ease.Linear).SetLoops(24, LoopType.Yoyo).OnComplete(() =>
{ {
_meshRenderer.material.color = Color.white; _meshRenderer.material.color = Color.white;
...@@ -53,6 +53,7 @@ public class EnemyScript : MonoBehaviour ...@@ -53,6 +53,7 @@ public class EnemyScript : MonoBehaviour
health--; health--;
hitsNumber++; hitsNumber++;
healthSlider.value = health; healthSlider.value = health;
_audioSource.pitch = UnityEngine.Random.Range(0.6f, 1.6f);
_audioSource.PlayOneShot(hitClip); _audioSource.PlayOneShot(hitClip);
if (health <= 0) if (health <= 0)
{ {
......
...@@ -3,31 +3,25 @@ using UnityEngine; ...@@ -3,31 +3,25 @@ using UnityEngine;
public class PlayerMovement : MonoBehaviour public class PlayerMovement : MonoBehaviour
{ {
[SerializeField] float distanceBetweenLanes;
[SerializeField] float moveForwardSpeed; [SerializeField] float moveForwardSpeed;
[SerializeField] float swapeSpeed; [SerializeField] float swapeSpeed;
[SerializeField] float maxLeft;
int _currentLane; [SerializeField] float maxRight;
float targetX; float targetX;
void Start()
{
_currentLane = 0;
}
void Update() void Update()
{ {
transform.position += Vector3.forward * moveForwardSpeed * Time.deltaTime; transform.position += Vector3.forward * moveForwardSpeed * Time.deltaTime;
// -1 = left + 0 = center + 1 = right
if (Input.GetKey(KeyCode.A)) if (Input.GetKey(KeyCode.A))
MovePlayer(-1); MovePlayer(0);
else if (Input.GetKey(KeyCode.D)) else if (Input.GetKey(KeyCode.D))
MovePlayer(1); MovePlayer(1);
} }
public void MovePlayer(float moveX) // public to call from kinect public void MovePlayer(float moveX) // public to call from kinect
{ {
float targetX = Mathf.MoveTowards(transform.position.x, moveX * distanceBetweenLanes, Time.deltaTime * swapeSpeed); float lerp = Mathf.Lerp(maxLeft,maxRight, moveX);
float targetX = Mathf.MoveTowards(transform.position.x, lerp , Time.deltaTime * swapeSpeed);
transform.position = new Vector3(targetX, transform.position.y, transform.position.z); transform.position = new Vector3(targetX, transform.position.y, transform.position.z);
} }
public void SetSpeed(int speed) public void SetSpeed(int speed)
......
...@@ -4,6 +4,8 @@ using UnityEngine; ...@@ -4,6 +4,8 @@ using UnityEngine;
using DG.Tweening; using DG.Tweening;
public class RotateBlood : MonoBehaviour public class RotateBlood : MonoBehaviour
{ {
[SerializeField] bool isObstacle;
[SerializeField] bool idleObstacle;
[SerializeField] bool rotate; [SerializeField] bool rotate;
[SerializeField] bool reverse; [SerializeField] bool reverse;
[SerializeField] float rotateDuration; [SerializeField] float rotateDuration;
...@@ -15,8 +17,35 @@ public class RotateBlood : MonoBehaviour ...@@ -15,8 +17,35 @@ public class RotateBlood : MonoBehaviour
[SerializeField] float moveLeftAndRightAmount; [SerializeField] float moveLeftAndRightAmount;
[SerializeField] float moveLeftAndRightDuration; [SerializeField] float moveLeftAndRightDuration;
[SerializeField] bool moveLocalLeftAndRightAndRandom; [SerializeField] bool moveLocalLeftAndRightAndRandom;
//[Header("Obstacle Setting")]
void Start() void Start()
{ {
if (isObstacle)
{
float randomPos = Random.value;
if(randomPos < .5f)
{
float xPos = -.5f;
moveLeftAndRightAmount *= -1;
transform.position = new Vector3(xPos, 1, transform.position.z);
}
else
{
float xPos = -4f;
moveLeftAndRightAmount *= 1;
transform.position = new Vector3(xPos, 1, transform.position.z);
}
idleObstacle = Random.value > .5f ? true : false;
if (idleObstacle)
{
moveLeftAndRight = false;
transform.position = new Vector3(Random.Range(-.5f, -4f), 1, transform.position.z);
}
else
moveLeftAndRight = true;
}
if (rotate) if (rotate)
{ {
int angle = reverse ? -360 : 360; int angle = reverse ? -360 : 360;
......
...@@ -4,7 +4,7 @@ using UnityEngine; ...@@ -4,7 +4,7 @@ using UnityEngine;
public class Answer : MonoBehaviour public class Answer : MonoBehaviour
{ {
[field: SerializeField] public int index { get; private set; } public int index { get; private set; }
public event Action<int> OnPlayerHit; public event Action<int> OnPlayerHit;
void OnTriggerEnter(Collider other) void OnTriggerEnter(Collider other)
...@@ -23,4 +23,5 @@ public class Answer : MonoBehaviour ...@@ -23,4 +23,5 @@ public class Answer : MonoBehaviour
{ {
DOTween.Kill(transform.parent); DOTween.Kill(transform.parent);
} }
public void SetIndex(int index) => this.index = index;
} }
...@@ -5,7 +5,7 @@ using UnityEngine; ...@@ -5,7 +5,7 @@ using UnityEngine;
public class QuestionArea : MonoBehaviour public class QuestionArea : MonoBehaviour
{ {
public Question question; public Question Question { get; private set; }
public static event Action<bool> OnQuestionIsAnswer; public static event Action<bool> OnQuestionIsAnswer;
public static event Action<string> OnPlayerTriggerTheQuestion; public static event Action<string> OnPlayerTriggerTheQuestion;
...@@ -14,7 +14,7 @@ public class QuestionArea : MonoBehaviour ...@@ -14,7 +14,7 @@ public class QuestionArea : MonoBehaviour
[SerializeField] List<Answer> answers = new List<Answer>(); [SerializeField] List<Answer> answers = new List<Answer>();
void Start() void Start()
{ {
if (question == null) if (Question == null)
GetComponent<Collider>().enabled = false; GetComponent<Collider>().enabled = false;
DisplayText(null); DisplayText(null);
...@@ -29,14 +29,14 @@ public class QuestionArea : MonoBehaviour ...@@ -29,14 +29,14 @@ public class QuestionArea : MonoBehaviour
{ {
RotateAnswer(0); RotateAnswer(0);
DisplayText(question.answers); DisplayText(Question.answers);
} }
} }
void DisplayText(string[] allText) void DisplayText(string[] allText)
{ {
if (allText != null) if (allText != null)
{ {
OnPlayerTriggerTheQuestion?.Invoke(question.questionText); OnPlayerTriggerTheQuestion?.Invoke(Question.questionText);
for (int i = 0; i < answersText.Length; i++) for (int i = 0; i < answersText.Length; i++)
{ {
...@@ -59,6 +59,8 @@ public class QuestionArea : MonoBehaviour ...@@ -59,6 +59,8 @@ public class QuestionArea : MonoBehaviour
foreach (Answer child in GetComponentsInChildren<Answer>()) foreach (Answer child in GetComponentsInChildren<Answer>())
{ {
answers.Add(child); answers.Add(child);
child.SetIndex(answers.IndexOf(child));
if (status) if (status)
child.OnPlayerHit += playerHitAnswer; child.OnPlayerHit += playerHitAnswer;
else else
...@@ -67,10 +69,10 @@ public class QuestionArea : MonoBehaviour ...@@ -67,10 +69,10 @@ public class QuestionArea : MonoBehaviour
} }
private void playerHitAnswer(int answerIndex) private void playerHitAnswer(int answerIndex)
{ {
if(question == null) if(Question == null)
return; return;
if (answerIndex == question.correctAnswerIndex) if (answerIndex == Question.correctAnswerIndex)
{ {
OnQuestionIsAnswer?.Invoke(true); OnQuestionIsAnswer?.Invoke(true);
foreach (Answer child in answers) foreach (Answer child in answers)
...@@ -94,4 +96,5 @@ public class QuestionArea : MonoBehaviour ...@@ -94,4 +96,5 @@ public class QuestionArea : MonoBehaviour
child.rotateParent(deg); child.rotateParent(deg);
} }
} }
public void SetQuestions(Question question) => Question = question;
} }
\ No newline at end of file
using UnityEngine;
public class QuestionManager : MonoBehaviour
{
[SerializeField] QuestionArea[] questionAreas;
[SerializeField] Question[] Question;
void Start()
{
if (questionAreas.Length == Question.Length)
{
for (int i = 0; i < questionAreas.Length; i++)
{
questionAreas[i].question = Question[i];
}
}
else
{
Debug.LogError("QuestionAreas and Questions arrays must have the same length");
}
}
}
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class SpawnQuestion : MonoBehaviour
{
[SerializeField] bool randomQuestionEveryRound;
[SerializeField] float areaLength; // defult: 30
[Header("Question Settings")]
[SerializeField] Transform QuestionParent;
[SerializeField] GameObject questionAreaPrefab;
[SerializeField] GameObject emptyAreaPrefab;
[SerializeField] GameObject enemyAreaPrefab;
[SerializeField] Question[] questionScriptableObjects;
[Header("Obstacle Settings")]
[SerializeField] Transform obstacleParent;
[SerializeField] GameObject obstaclePrefab;
[SerializeField] int NumberOfObstaclePerArea;
float currentLenght;
private void Start()
{
SpawnQuestionAreas();
}
//[ContextMenu("Spawn")]
void SpawnQuestionAreas()
{
DestroyChild();
currentLenght = 0;
if (randomQuestionEveryRound)
{
//questionScriptableObjects = questionScriptableObjects.OrderBy(x => Random.value).ToArray();
ShuffleArray(questionScriptableObjects);
}
for (int i = 0; i < questionScriptableObjects.Length; i++)
{
if (questionScriptableObjects[i] == null)
Instantiate(emptyAreaPrefab, new Vector3(0, 0, currentLenght), Quaternion.identity, QuestionParent);
else
{
GameObject questionArea = Instantiate(questionAreaPrefab, new Vector3(0, 0, currentLenght), Quaternion.identity, QuestionParent);
questionArea.GetComponent<QuestionArea>().SetQuestions(questionScriptableObjects[i]);
}
if (i > 0 && i < questionScriptableObjects.Length - 1)
for (int j = 0; j < NumberOfObstaclePerArea; j++)
Instantiate(obstaclePrefab, new Vector3(0, 1, Random.Range(currentLenght, currentLenght + areaLength)), Quaternion.identity, obstacleParent);
currentLenght += areaLength;
}
Instantiate(enemyAreaPrefab, new Vector3(0, 0, currentLenght), Quaternion.identity, QuestionParent);
}
void ShuffleArray(Question[] array)
{
for (int i = array.Length - 1; i > 0; i--)
{
int randomIndex = Random.Range(1, i + 1);
Question temp = array[i];
array[i] = array[randomIndex];
array[randomIndex] = temp;
}
}
private void DestroyChild()
{
foreach (Transform Question in QuestionParent)
{
DestroyImmediate(Question.gameObject);
}
foreach (Transform obstacle in obstacleParent)
{
DestroyImmediate(obstacle.gameObject);
}
}
}
fileFormatVersion: 2
guid: 90d407e88a00e3747a2a730f56ab8436
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -5,8 +5,6 @@ public class SpwanManager : MonoBehaviour ...@@ -5,8 +5,6 @@ public class SpwanManager : MonoBehaviour
{ {
public static SpwanManager Instance; public static SpwanManager Instance;
[SerializeField] Transform questionsParent;
[Header("NPC Spawn Settings")] [Header("NPC Spawn Settings")]
[SerializeField] int maxNPCsInGame; [SerializeField] int maxNPCsInGame;
[SerializeField] int maxIncreasePerSpawn; [SerializeField] int maxIncreasePerSpawn;
...@@ -82,14 +80,6 @@ public class SpwanManager : MonoBehaviour ...@@ -82,14 +80,6 @@ public class SpwanManager : MonoBehaviour
} }
ChangeCurrentNPCsInGame(); ChangeCurrentNPCsInGame();
RePositionNPCs(); RePositionNPCs();
//int howManyAvailableInNPCsParent = maxNPCsInGame - NPCsSpawnParent.childCount;
//int spawnCount = Mathf.Min(increaseAmount, howManyAvailableInNPCsParent);
//for (int i = 0; i < spawnCount; i++)
//{
// Instantiate(NPCsPrefab, NPCsSpawnParent.position, Quaternion.identity, NPCsSpawnParent);
//}
} }
void DecreaseNPCs(int decreaseAmount) void DecreaseNPCs(int decreaseAmount)
...@@ -109,21 +99,9 @@ public class SpwanManager : MonoBehaviour ...@@ -109,21 +99,9 @@ public class SpwanManager : MonoBehaviour
ChangeCurrentNPCsInGame(); ChangeCurrentNPCsInGame();
RePositionNPCs(); RePositionNPCs();
//int removeCount = Mathf.Min(decreaseAmount, NPCsSpawnParent.childCount);
//for (int i = 0; i < removeCount; i++)
//{
// Transform npcToRemove = NPCsSpawnParent.GetChild(NPCsSpawnParent.childCount - 1);
// npcToRemove.SetParent(null);
// Destroy(npcToRemove.gameObject);
//}
} }
public void ChangeCurrentNPCsInGame() public void ChangeCurrentNPCsInGame()
{ {
//_currentNPCsInGame += newAmount;
//_currentNPCsInGame = Mathf.Clamp(_currentNPCsInGame, 0, maxNPCsInGame);
_currentNPCsInGame = 0; _currentNPCsInGame = 0;
foreach (Transform child in NPCsSpawnParent) foreach (Transform child in NPCsSpawnParent)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment