Added basic monster spawners
This commit is contained in:
parent
761d6876cc
commit
c8649ed6f9
@ -1752,3 +1752,12 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 72794012913ccd840a73788b90573212, type: 3}
|
m_Script: {fileID: 11500000, guid: 72794012913ccd840a73788b90573212, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
spawners:
|
||||||
|
- {x: -10, y: 10, z: 0}
|
||||||
|
- {x: 10, y: 10, z: 0}
|
||||||
|
- {x: -17.75, y: 0, z: 0}
|
||||||
|
- {x: 17.75, y: 0, z: 0}
|
||||||
|
- {x: -10, y: -10, z: 0}
|
||||||
|
- {x: 10, y: -10, z: 0}
|
||||||
|
stats: {fileID: 11400000, guid: fe319ad8c9a37b84e8b45268c913d54c, type: 2}
|
||||||
|
monsterPrefab: {fileID: 2399377275812995980, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3}
|
||||||
|
|||||||
118
Assets/Prefabs/Gladiator.prefab
Normal file
118
Assets/Prefabs/Gladiator.prefab
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &197677485360569561
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 197677485360569565}
|
||||||
|
- component: {fileID: 197677485360569564}
|
||||||
|
- component: {fileID: 197677485360569563}
|
||||||
|
- component: {fileID: 197677485360569562}
|
||||||
|
- component: {fileID: 197677485360569566}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Gladiator
|
||||||
|
m_TagString: Gladiator
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &197677485360569565
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 197677485360569561}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 6.2, y: -2.69, z: -0.43858913}
|
||||||
|
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!33 &197677485360569564
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 197677485360569561}
|
||||||
|
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!23 &197677485360569563
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 197677485360569561}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||||
|
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: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!135 &197677485360569562
|
||||||
|
SphereCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 197677485360569561}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Radius: 0.5
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &197677485360569566
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 197677485360569561}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: c537e1bd61b8d5c42b1ec03f90e14855, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
health: 100
|
||||||
|
movementSpeed: 5
|
||||||
|
rotSpeed: 3
|
||||||
|
fov: 0
|
||||||
|
attackRange: 1.5
|
||||||
|
attackDmg: 10
|
||||||
|
attackCooldown: 1
|
||||||
|
target: {fileID: 0}
|
||||||
7
Assets/Prefabs/Gladiator.prefab.meta
Normal file
7
Assets/Prefabs/Gladiator.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b25a487d193f24049b6a791adf592b2e
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
118
Assets/Prefabs/Monster.prefab
Normal file
118
Assets/Prefabs/Monster.prefab
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &2399377275812995980
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 2399377275812995968}
|
||||||
|
- component: {fileID: 2399377275812995969}
|
||||||
|
- component: {fileID: 2399377275812995970}
|
||||||
|
- component: {fileID: 2399377275812995971}
|
||||||
|
- component: {fileID: 2399377275812995974}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Monster
|
||||||
|
m_TagString: Monster
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &2399377275812995968
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2399377275812995980}
|
||||||
|
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!33 &2399377275812995969
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2399377275812995980}
|
||||||
|
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!23 &2399377275812995970
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2399377275812995980}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||||
|
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: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!65 &2399377275812995971
|
||||||
|
BoxCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2399377275812995980}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &2399377275812995974
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2399377275812995980}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7e480b0ef5998894283e8091830941cb, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
health: 100
|
||||||
|
movementSpeed: 5
|
||||||
|
rotSpeed: 3
|
||||||
|
fov: 0
|
||||||
|
attackRange: 1.5
|
||||||
|
attackDmg: 10
|
||||||
|
attackCooldown: 1
|
||||||
|
target: {fileID: 0}
|
||||||
7
Assets/Prefabs/Monster.prefab.meta
Normal file
7
Assets/Prefabs/Monster.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5f633c05dee3f4b4784f5702b2365f02
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
15
Assets/Scripts/Arena Stats.asset
Normal file
15
Assets/Scripts/Arena Stats.asset
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8de175900b604adb984b49af64538a07, type: 3}
|
||||||
|
m_Name: Arena Stats
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
secondsBetweenSpawners: 3
|
||||||
8
Assets/Scripts/Arena Stats.asset.meta
Normal file
8
Assets/Scripts/Arena Stats.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fe319ad8c9a37b84e8b45268c913d54c
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,18 +1,43 @@
|
|||||||
|
#nullable enable
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class Arena : MonoBehaviour
|
public class Arena : MonoBehaviour {
|
||||||
{
|
//TODO probably add initial direction too
|
||||||
// Start is called before the first frame update
|
[SerializeField] Vector3[] spawners = null!;
|
||||||
void Start()
|
[SerializeField] ArenaStats stats = null!;
|
||||||
{
|
[SerializeField] GameObject monsterPrefab = null!;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
SafeZone safeZone = null!;
|
||||||
void Update()
|
|
||||||
{
|
void Awake() => safeZone = GetComponentInChildren<SafeZone>();
|
||||||
|
|
||||||
}
|
void Start() => StartCoroutine(SpawnEnemies());
|
||||||
}
|
|
||||||
|
void SpawnEnemy(int spawnerIndex) {
|
||||||
|
var monster = Instantiate(monsterPrefab, spawners[spawnerIndex], Quaternion.identity).GetComponent<Monster>();
|
||||||
|
//TODO Replace hardcoded target with entity discovery
|
||||||
|
monster.SetTarget(safeZone.transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator SpawnEnemies() {
|
||||||
|
yield return new WaitForSeconds(stats.secondsBetweenSpawners);
|
||||||
|
|
||||||
|
int currentSpawner = 0;
|
||||||
|
|
||||||
|
//TODO Stop when pause/end game
|
||||||
|
while (true) {
|
||||||
|
SpawnEnemy(currentSpawner);
|
||||||
|
currentSpawner = Random.Range(0, spawners.Length);
|
||||||
|
yield return new WaitForSeconds(stats.secondsBetweenSpawners);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
void OnDrawGizmosSelected() {
|
||||||
|
Gizmos.color = Color.blue;
|
||||||
|
foreach (Vector3 spawner in spawners)
|
||||||
|
Gizmos.DrawWireCube(spawner, Vector3.one);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
6
Assets/Scripts/ArenaStats.cs
Normal file
6
Assets/Scripts/ArenaStats.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[CreateAssetMenu]
|
||||||
|
public class ArenaStats : ScriptableObject {
|
||||||
|
[Min(0f)] public float secondsBetweenSpawners = 3f;
|
||||||
|
}
|
||||||
3
Assets/Scripts/ArenaStats.cs.meta
Normal file
3
Assets/Scripts/ArenaStats.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8de175900b604adb984b49af64538a07
|
||||||
|
timeCreated: 1648887966
|
||||||
@ -4,20 +4,16 @@ using UnityEngine.InputSystem;
|
|||||||
|
|
||||||
[RequireComponent(typeof(PlayerInput), typeof(Rigidbody2D))]
|
[RequireComponent(typeof(PlayerInput), typeof(Rigidbody2D))]
|
||||||
public class PlayerMovement : MonoBehaviour {
|
public class PlayerMovement : MonoBehaviour {
|
||||||
[SerializeField] PlayerStats playerStats;
|
[SerializeField] PlayerStats playerStats = null!;
|
||||||
Rigidbody2D rb;
|
Rigidbody2D rb = null!;
|
||||||
|
|
||||||
PlayerInput playerInput;
|
|
||||||
Vector2 moveDirection;
|
Vector2 moveDirection;
|
||||||
BaseState currentState = new ImmobileMovementState();
|
BaseState currentState = new ImmobileMovementState();
|
||||||
SafeZone? safeZone;
|
SafeZone? safeZone;
|
||||||
|
|
||||||
bool lastJumpButton;
|
bool lastJumpButton;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() => rb = GetComponent<Rigidbody2D>();
|
||||||
rb = GetComponent<Rigidbody2D>();
|
|
||||||
playerInput = GetComponent<PlayerInput>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FixedUpdate() {
|
void FixedUpdate() {
|
||||||
if (currentState.FixedUpdateState(this) is {} newState)
|
if (currentState.FixedUpdateState(this) is {} newState)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user