heroes come from door, then spread out
This commit is contained in:
parent
0c9b53280b
commit
838d8b5be7
4 changed files with 25 additions and 24 deletions
30
Assets/Prefabs/Hero.prefab
generated
30
Assets/Prefabs/Hero.prefab
generated
|
@ -10,8 +10,8 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 3021765642569073804}
|
- component: {fileID: 3021765642569073804}
|
||||||
- component: {fileID: 3021765642569073807}
|
- component: {fileID: 3021765642569073807}
|
||||||
- component: {fileID: 5083176976606134597}
|
|
||||||
- component: {fileID: 8641468276557857728}
|
- component: {fileID: 8641468276557857728}
|
||||||
|
- component: {fileID: 3082253598467112898}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Hero
|
m_Name: Hero
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -84,20 +84,6 @@ SpriteRenderer:
|
||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 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
|
--- !u!61 &8641468276557857728
|
||||||
BoxCollider2D:
|
BoxCollider2D:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -124,3 +110,17 @@ BoxCollider2D:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 1, y: 1}
|
m_Size: {x: 1, y: 1}
|
||||||
m_EdgeRadius: 0
|
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
|
||||||
|
|
8
Assets/Scenes/Gameplay.unity
generated
8
Assets/Scenes/Gameplay.unity
generated
|
@ -170,8 +170,8 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
hero: {fileID: 3021765642569073806, guid: 56983197fa2e04a4c8d44100f0ef42b4, type: 3}
|
hero: {fileID: 3021765642569073806, guid: 56983197fa2e04a4c8d44100f0ef42b4, type: 3}
|
||||||
timeRemaining: 3
|
timeRemaining: 10
|
||||||
numberOfHeros: 2
|
numberOfHeros: 5
|
||||||
--- !u!82 &422242827
|
--- !u!82 &422242827
|
||||||
AudioSource:
|
AudioSource:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -556,8 +556,8 @@ Transform:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1903661299}
|
m_GameObject: {fileID: 1903661299}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0.12011865, y: 0.20069107, z: 1}
|
m_LocalPosition: {x: 0.1735, y: 0.2007, z: 1}
|
||||||
m_LocalScale: {x: 18.594135, y: 10.121618, z: 1}
|
m_LocalScale: {x: 18.70012, y: 10.121618, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 422242825}
|
m_Father: {fileID: 422242825}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
|
|
|
@ -4,8 +4,9 @@ using UnityEngine;
|
||||||
|
|
||||||
public class Hero : MonoBehaviour
|
public class Hero : MonoBehaviour
|
||||||
{
|
{
|
||||||
public float speed = 3.0f;
|
public float speed = 6.0f;
|
||||||
public float timeToMove = 3;
|
public float timeToMove = 3;
|
||||||
|
public float yLane = 0.0f;
|
||||||
private float originalTimeToMove;
|
private float originalTimeToMove;
|
||||||
private float[] xPositions = new float[]{0.0f, 1.0f, 2.0f, 3.0f, 4.0f};
|
private float[] xPositions = new float[]{0.0f, 1.0f, 2.0f, 3.0f, 4.0f};
|
||||||
private int numberOfPositions = 5;
|
private int numberOfPositions = 5;
|
||||||
|
@ -13,7 +14,6 @@ public class Hero : MonoBehaviour
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
Debug.Log("Prepare to Die, Dragon!");
|
|
||||||
originalTimeToMove = timeToMove;
|
originalTimeToMove = timeToMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class Hero : MonoBehaviour
|
||||||
void MoveTowardsDragon()
|
void MoveTowardsDragon()
|
||||||
{
|
{
|
||||||
float step = speed * Time.deltaTime;
|
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);
|
transform.position = Vector2.MoveTowards(transform.position, targetPosition, step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,13 @@ public class HeroSpawner : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnHero(float heroStartingY)
|
void SpawnHero(float heroYLane)
|
||||||
{
|
{
|
||||||
float heroStartingX = -3.0f;
|
float heroStartingX = -3.0f;
|
||||||
/* float heroStartingY = yPositions[Random.Range(0, numberOfYPositions - 1)]; */
|
float heroStartingY = 0.0f;
|
||||||
Vector2 heroStartingPosition = new Vector2(heroStartingX, heroStartingY);
|
Vector2 heroStartingPosition = new Vector2(heroStartingX, heroStartingY);
|
||||||
timeRemaining = originalTimeRemaining;
|
timeRemaining = originalTimeRemaining;
|
||||||
GameObject spawnedHero = Instantiate(hero, heroStartingPosition, Quaternion.identity);
|
GameObject spawnedHero = Instantiate(hero, heroStartingPosition, Quaternion.identity);
|
||||||
|
spawnedHero.GetComponent<Hero>().yLane = heroYLane;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue