Hero spawner WIP
This commit is contained in:
parent
50acf25ecc
commit
425450a137
16 changed files with 252 additions and 10 deletions
0
Assets/Scenes/Prefabs.meta → Assets/Prefabs.meta
generated
0
Assets/Scenes/Prefabs.meta → Assets/Prefabs.meta
generated
126
Assets/Prefabs/Hero.prefab
generated
Normal file
126
Assets/Prefabs/Hero.prefab
generated
Normal file
|
@ -0,0 +1,126 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &3021765642569073806
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3021765642569073804}
|
||||
- component: {fileID: 3021765642569073807}
|
||||
- component: {fileID: 5083176976606134597}
|
||||
- component: {fileID: 8641468276557857728}
|
||||
m_Layer: 0
|
||||
m_Name: Hero
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &3021765642569073804
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3021765642569073806}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
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}
|
||||
--- !u!212 &3021765642569073807
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3021765642569073806}
|
||||
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_RayTraceProcedural: 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: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 7482667652216324306, guid: 48e93eef0688c4a259cb0eddcd8661f7, type: 3}
|
||||
m_Color: {r: 0.8113208, g: 0.27171594, b: 0.674586, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
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: 3
|
||||
timeToMove: 3
|
||||
--- !u!61 &8641468276557857728
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3021765642569073806}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
oldSize: {x: 1, y: 1}
|
||||
newSize: {x: 1, y: 1}
|
||||
adaptiveTilingThreshold: 0.5
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_EdgeRadius: 0
|
7
Assets/Prefabs/Hero.prefab.meta
generated
Normal file
7
Assets/Prefabs/Hero.prefab.meta
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 56983197fa2e04a4c8d44100f0ef42b4
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
Assets/Scenes/Gameplay.unity
generated
15
Assets/Scenes/Gameplay.unity
generated
|
@ -132,6 +132,7 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 422242825}
|
||||
- component: {fileID: 422242826}
|
||||
m_Layer: 0
|
||||
m_Name: Gameplay
|
||||
m_TagString: Untagged
|
||||
|
@ -155,6 +156,20 @@ Transform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &422242826
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 422242824}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4394cbc18a6894dd4bebd223ac6022b1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
hero: {fileID: 3021765642569073806, guid: 56983197fa2e04a4c8d44100f0ef42b4, type: 3}
|
||||
timeRemaining: 3
|
||||
--- !u!1 &519420028
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
0
Assets/Scenes/Scripts.meta → Assets/Scripts.meta
generated
0
Assets/Scenes/Scripts.meta → Assets/Scripts.meta
generated
|
@ -5,15 +5,14 @@ using UnityEngine;
|
|||
public class Fireball : MonoBehaviour
|
||||
{
|
||||
public float speed = 1.0f;
|
||||
public Vector2 destination;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Debug.Log("Fireball destination:");
|
||||
Debug.Log(destination);
|
||||
}
|
||||
public Vector3 destination;
|
||||
|
||||
void Update()
|
||||
{
|
||||
Move();
|
||||
}
|
||||
|
||||
void Move()
|
||||
{
|
||||
float step = speed * Time.deltaTime;
|
||||
transform.position = Vector3.MoveTowards(transform.position, destination, step);
|
|
@ -17,9 +17,6 @@ public class FireballSpawner : MonoBehaviour
|
|||
|
||||
GameObject spawnedFireball = Instantiate(fireball, dragonHead.transform.position, Quaternion.identity);
|
||||
spawnedFireball.GetComponent<Fireball>().destination = mouseClickFromCamera;
|
||||
/* Debug.Log(mouseClickFromCamera); */
|
||||
/* Debug.Log(dragonHead.transform.position); */
|
||||
/* gameObject.transform.position = pz; */
|
||||
}
|
||||
}
|
||||
}
|
39
Assets/Scripts/Hero.cs
Normal file
39
Assets/Scripts/Hero.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Hero : MonoBehaviour
|
||||
{
|
||||
public float speed = 3.0f;
|
||||
public float timeToMove = 3;
|
||||
private float originalTimeToMove;
|
||||
private float[] xPositions = new float[]{0.0f, 1.0f, 2.0f, 3.0f, 4.0f};
|
||||
private int numberOfPositions = 5;
|
||||
private int currentPosition = 0;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Debug.Log("Prepare to Die, Dragon!");
|
||||
originalTimeToMove = timeToMove;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (timeToMove > 0)
|
||||
{
|
||||
timeToMove -= Time.deltaTime;
|
||||
} else
|
||||
{
|
||||
timeToMove = originalTimeToMove;
|
||||
if (currentPosition + 1 < numberOfPositions) currentPosition += 1;
|
||||
}
|
||||
MoveTowardsDragon();
|
||||
}
|
||||
|
||||
void MoveTowardsDragon()
|
||||
{
|
||||
float step = speed * Time.deltaTime;
|
||||
Vector2 targetPosition = new Vector2(xPositions[currentPosition], transform.position.y);
|
||||
transform.position = Vector2.MoveTowards(transform.position, targetPosition, step);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Hero.cs.meta
generated
Normal file
11
Assets/Scripts/Hero.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 847b2a28cac2e4ee49ab279670c7ac93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
36
Assets/Scripts/HeroSpawner.cs
Normal file
36
Assets/Scripts/HeroSpawner.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HeroSpawner : MonoBehaviour
|
||||
{
|
||||
public GameObject hero;
|
||||
public float timeRemaining = 3;
|
||||
private float originalTimeRemaining;
|
||||
private float[] yPositions = new float[]{4.0f, 2.0f, 0.0f, -2.0f, -4.0f};
|
||||
|
||||
void Start()
|
||||
{
|
||||
originalTimeRemaining = timeRemaining;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (timeRemaining > 0)
|
||||
{
|
||||
timeRemaining -= Time.deltaTime;
|
||||
} else
|
||||
{
|
||||
SpawnHero();
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnHero()
|
||||
{
|
||||
float heroStartingX = -3.0f;
|
||||
float heroStartingY = 0.0f;
|
||||
Vector2 heroStartingPosition = new Vector2(heroStartingX, heroStartingY);
|
||||
timeRemaining = originalTimeRemaining;
|
||||
GameObject spawnedHero = Instantiate(hero, heroStartingPosition, Quaternion.identity);
|
||||
}
|
||||
}
|
11
Assets/Scripts/HeroSpawner.cs.meta
generated
Normal file
11
Assets/Scripts/HeroSpawner.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4394cbc18a6894dd4bebd223ac6022b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1
tags.lock
Normal file
1
tags.lock
Normal file
|
@ -0,0 +1 @@
|
|||
81535
|
Loading…
Add table
Reference in a new issue