diff --git a/Assets/Prefab/GameWin.prefab b/Assets/Prefab/GameWin.prefab new file mode 100644 index 0000000000000000000000000000000000000000..ab55e8946f78dc9ce5c1a71d660b16cc13ca433a --- /dev/null +++ b/Assets/Prefab/GameWin.prefab @@ -0,0 +1,32 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &4334850820553036048 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2388334960364419616} + m_Layer: 0 + m_Name: GameWin + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2388334960364419616 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4334850820553036048} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 4.5898275, y: 3.887589, z: 0.94433594} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Prefab/GameWin.prefab.meta b/Assets/Prefab/GameWin.prefab.meta new file mode 100644 index 0000000000000000000000000000000000000000..d3c5c32464a6079ae9a2b49b443a08dc373cb29b --- /dev/null +++ b/Assets/Prefab/GameWin.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 80a61f8911aa37046a2d5e13d579c221 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameEnd.meta b/Assets/Scripts/GameEnd.meta new file mode 100644 index 0000000000000000000000000000000000000000..c8eeb410ce05a432ddf5c3cdb6921197f6520fbc --- /dev/null +++ b/Assets/Scripts/GameEnd.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cf62eacc43e8a40469118b61f12a5364 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameEnd/MoveRandomly.cs b/Assets/Scripts/GameEnd/MoveRandomly.cs new file mode 100644 index 0000000000000000000000000000000000000000..9db50ad0882f21a98bb1ee0435c331a9b8d73f29 --- /dev/null +++ b/Assets/Scripts/GameEnd/MoveRandomly.cs @@ -0,0 +1,29 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class MoveRandomly : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + StartCoroutine("moveAround"); + } + + private IEnumerator moveAround() { + while (true) + { + float moveTime = Random.value * 2; + float timeSpent = 0; + Vector3 direction = new Vector3(Random.value*2-1,Random.value*2-1, 0); + + while (timeSpent < moveTime) + { + transform.position = transform.position + direction*0.01f; + yield return null; + timeSpent += Time.deltaTime; + + } + } + } +} diff --git a/Assets/Scripts/GameEnd/MoveRandomly.cs.meta b/Assets/Scripts/GameEnd/MoveRandomly.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..bd2dc1b097a707426f83a4b0db133d5cd34a8451 --- /dev/null +++ b/Assets/Scripts/GameEnd/MoveRandomly.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d3063605b31636c4e9998676be17db5d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameEnd/WinGame.cs b/Assets/Scripts/GameEnd/WinGame.cs new file mode 100644 index 0000000000000000000000000000000000000000..519f1dab23788a6954388cf655b47e5e0c57741c --- /dev/null +++ b/Assets/Scripts/GameEnd/WinGame.cs @@ -0,0 +1,60 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class WinGame : MonoBehaviour +{ + [SerializeField] + private GameObject housePrefab = null; + [SerializeField] + private GameObject workerPrefab = null; + + private List<GameObject> houses = new List<GameObject>(); + + void Start() + { + StartCoroutine("MoveCamera"); + StartCoroutine("EndGame"); + } + private IEnumerator MoveCamera() + { + while (Camera.main.orthographicSize < 9f) { + Camera.main.orthographicSize += 0.01f; + yield return null; + } + } + + private IEnumerator EndGame() + { + float spawnRate = 5f; + int count = 0; + while (count < 9) + { + GameObject go = Instantiate<GameObject>(housePrefab); + houses.Add(go); + go.transform.position = new Vector3(Random.Range(1f, 14f), Random.Range(1f, 14f),-5); + spawnRate -= 0.5f; + yield return new WaitForSeconds(spawnRate); + count++; + } + for (int i = 0; i < 3; i++) { + GameObject go = Instantiate<GameObject>(housePrefab); + houses.Add(go); + go.transform.position = new Vector3(Random.Range(1f, 14f), Random.Range(1f, 14f), -5); + yield return new WaitForSeconds(spawnRate); + } + count = 0; + while (count < 150) + { + GameObject go = Instantiate<GameObject>(workerPrefab); + int index = Random.Range(0, houses.Count); + go.transform.position = houses[index].transform.position; + go.AddComponent<MoveRandomly>(); + Destroy(go.GetComponent<Collector>()); + Destroy(go.GetComponent<Rigidbody2D>()); + yield return new WaitForSeconds(0.1f); + count++; + } + } + +} diff --git a/Assets/Scripts/GameEnd/WinGame.cs.meta b/Assets/Scripts/GameEnd/WinGame.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a6fa2a8111d55b06cef7ef6d9d7d9b0fa36d9e3d --- /dev/null +++ b/Assets/Scripts/GameEnd/WinGame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d3674a5cdecf6e14abe5d88e6f0f7618 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/Ground.xcf b/Assets/Sprites/Ground.xcf index ff8d57744e11c2991942ea87d2013b2a9293f804..202a670723728f5954a0a05ee868edc8b82fbadb 100644 Binary files a/Assets/Sprites/Ground.xcf and b/Assets/Sprites/Ground.xcf differ