From 838d8b5be766cc6d3137b4aa1abd5d5b6d75f727 Mon Sep 17 00:00:00 2001 From: Ava Gaiety Wroten Date: Sun, 11 Jul 2021 12:27:39 -0500 Subject: [PATCH] heroes come from door, then spread out --- Assets/Prefabs/Hero.prefab | 30 +++++++++++++++--------------- Assets/Scenes/Gameplay.unity | 8 ++++---- Assets/Scripts/Hero.cs | 6 +++--- Assets/Scripts/HeroSpawner.cs | 5 +++-- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Assets/Prefabs/Hero.prefab b/Assets/Prefabs/Hero.prefab index c9581ed..7ac15ae 100644 --- a/Assets/Prefabs/Hero.prefab +++ b/Assets/Prefabs/Hero.prefab @@ -10,8 +10,8 @@ GameObject: m_Component: - component: {fileID: 3021765642569073804} - component: {fileID: 3021765642569073807} - - component: {fileID: 5083176976606134597} - component: {fileID: 8641468276557857728} + - component: {fileID: 3082253598467112898} m_Layer: 0 m_Name: Hero m_TagString: Untagged @@ -84,20 +84,6 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!114 &5083176976606134597 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3021765642569073806} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 847b2a28cac2e4ee49ab279670c7ac93, type: 3} - m_Name: - m_EditorClassIdentifier: - speed: 6 - timeToMove: 2 --- !u!61 &8641468276557857728 BoxCollider2D: m_ObjectHideFlags: 0 @@ -124,3 +110,17 @@ BoxCollider2D: serializedVersion: 2 m_Size: {x: 1, y: 1} m_EdgeRadius: 0 +--- !u!114 &3082253598467112898 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3021765642569073806} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 847b2a28cac2e4ee49ab279670c7ac93, type: 3} + m_Name: + m_EditorClassIdentifier: + speed: 6 + timeToMove: 2 diff --git a/Assets/Scenes/Gameplay.unity b/Assets/Scenes/Gameplay.unity index 879de2a..f0d255d 100644 --- a/Assets/Scenes/Gameplay.unity +++ b/Assets/Scenes/Gameplay.unity @@ -170,8 +170,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: hero: {fileID: 3021765642569073806, guid: 56983197fa2e04a4c8d44100f0ef42b4, type: 3} - timeRemaining: 3 - numberOfHeros: 2 + timeRemaining: 10 + numberOfHeros: 5 --- !u!82 &422242827 AudioSource: m_ObjectHideFlags: 0 @@ -556,8 +556,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1903661299} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.12011865, y: 0.20069107, z: 1} - m_LocalScale: {x: 18.594135, y: 10.121618, z: 1} + m_LocalPosition: {x: 0.1735, y: 0.2007, z: 1} + m_LocalScale: {x: 18.70012, y: 10.121618, z: 1} m_Children: [] m_Father: {fileID: 422242825} m_RootOrder: 1 diff --git a/Assets/Scripts/Hero.cs b/Assets/Scripts/Hero.cs index 786ec70..0680101 100644 --- a/Assets/Scripts/Hero.cs +++ b/Assets/Scripts/Hero.cs @@ -4,8 +4,9 @@ using UnityEngine; public class Hero : MonoBehaviour { - public float speed = 3.0f; + public float speed = 6.0f; public float timeToMove = 3; + public float yLane = 0.0f; private float originalTimeToMove; private float[] xPositions = new float[]{0.0f, 1.0f, 2.0f, 3.0f, 4.0f}; private int numberOfPositions = 5; @@ -13,7 +14,6 @@ public class Hero : MonoBehaviour void Start() { - Debug.Log("Prepare to Die, Dragon!"); originalTimeToMove = timeToMove; } @@ -33,7 +33,7 @@ public class Hero : MonoBehaviour void MoveTowardsDragon() { float step = speed * Time.deltaTime; - Vector2 targetPosition = new Vector2(xPositions[currentPosition], transform.position.y); + Vector2 targetPosition = new Vector2(xPositions[currentPosition], yLane); transform.position = Vector2.MoveTowards(transform.position, targetPosition, step); } } diff --git a/Assets/Scripts/HeroSpawner.cs b/Assets/Scripts/HeroSpawner.cs index 3348411..b31c097 100644 --- a/Assets/Scripts/HeroSpawner.cs +++ b/Assets/Scripts/HeroSpawner.cs @@ -38,12 +38,13 @@ public class HeroSpawner : MonoBehaviour } } - void SpawnHero(float heroStartingY) + void SpawnHero(float heroYLane) { float heroStartingX = -3.0f; - /* float heroStartingY = yPositions[Random.Range(0, numberOfYPositions - 1)]; */ + float heroStartingY = 0.0f; Vector2 heroStartingPosition = new Vector2(heroStartingX, heroStartingY); timeRemaining = originalTimeRemaining; GameObject spawnedHero = Instantiate(hero, heroStartingPosition, Quaternion.identity); + spawnedHero.GetComponent().yLane = heroYLane; } }