Debut Wave Editor
LevelConfig cnotient la liste des ennemies à spawn à un rythme constant ainsi que la durée du jeux EnemyType contient l'ennemi ainsi que la quantité à SpawnerTile Modifications de Level et TilemapData afin d'accéder aux paramètres des Spawners du jeu
This commit is contained in:
parent
e08f59d8a3
commit
15b5976cb0
8
Assets/LevelConfig.meta
Normal file
8
Assets/LevelConfig.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b3ad07c069cd06e4ebbd5f190b9aa25b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Scripts/LevelConfig.meta
Normal file
8
Assets/Scripts/LevelConfig.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a386aeb53fe226d41bbee33ac6fafa4e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
16
Assets/Scripts/LevelConfig/LevelConfig.cs
Normal file
16
Assets/Scripts/LevelConfig/LevelConfig.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[CreateAssetMenu(menuName = "Gather And Defend/Levels/LevelConfig")]
|
||||||
|
public class LevelConfig : ScriptableObject
|
||||||
|
{
|
||||||
|
//IEnumerable for 1. list of type 2. timer. with title of row nbr INSPIRED FROM DATA
|
||||||
|
[SerializeField]
|
||||||
|
private List<EnemyType> _constantSpawn = new List<EnemyType>();
|
||||||
|
[SerializeField]
|
||||||
|
private int _gameDuration = 0;
|
||||||
|
public List<EnemyType> ConstantSpawn { get { return _constantSpawn; } }
|
||||||
|
public int GameDuration { get { return _gameDuration; } }
|
||||||
|
|
||||||
|
}
|
||||||
11
Assets/Scripts/LevelConfig/LevelConfig.cs.meta
Normal file
11
Assets/Scripts/LevelConfig/LevelConfig.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eb0795e326609f0499365f5b65c2b5cd
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -11,6 +11,8 @@ namespace GatherAndDefend.LevelEditor
|
|||||||
public Rect Bounds => _bounds;
|
public Rect Bounds => _bounds;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private List<TilemapData> _data = new List<TilemapData>();
|
private List<TilemapData> _data = new List<TilemapData>();
|
||||||
|
[SerializeField]
|
||||||
|
private LevelConfig _levelConfig;
|
||||||
public void SaveFromTilemap(Tilemap tilemap)
|
public void SaveFromTilemap(Tilemap tilemap)
|
||||||
{
|
{
|
||||||
var data = new TilemapData();
|
var data = new TilemapData();
|
||||||
@ -21,8 +23,8 @@ namespace GatherAndDefend.LevelEditor
|
|||||||
{
|
{
|
||||||
var data = _data.Find(x => x.Key == tilemap.name);
|
var data = _data.Find(x => x.Key == tilemap.name);
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
|
|
||||||
data.LoadToTilemap(tilemap);
|
data.LoadToTilemap(tilemap, _levelConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator<TilemapData> GetEnumerator()
|
public IEnumerator<TilemapData> GetEnumerator()
|
||||||
|
|||||||
@ -33,7 +33,7 @@ namespace GatherAndDefend.LevelEditor
|
|||||||
|
|
||||||
public string Key => _key;
|
public string Key => _key;
|
||||||
|
|
||||||
public void LoadToTilemap(Tilemap reference)
|
public void LoadToTilemap(Tilemap reference, LevelConfig _levelConfig = null)
|
||||||
{
|
{
|
||||||
reference.transform.localPosition = _position;
|
reference.transform.localPosition = _position;
|
||||||
reference.transform.localScale = _scale;
|
reference.transform.localScale = _scale;
|
||||||
@ -48,10 +48,22 @@ namespace GatherAndDefend.LevelEditor
|
|||||||
collision.isTrigger = _isTrigger;
|
collision.isTrigger = _isTrigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Log(_levelConfig != null);
|
||||||
|
if ( _levelConfig != null && _key.Equals("Spawners"))
|
||||||
|
{
|
||||||
|
foreach (TileData spawner in _tiles)
|
||||||
|
{
|
||||||
|
//string id = spawner.Tile.GetInstanceID().ToString();
|
||||||
|
//SpawnerTile spawnerGO = GameObject.Find(id).GetComponent<SpawnerTile>();
|
||||||
|
//spawnerGO.Prefab = _levelConfig.ConstantSpawn[0].GetEnemyObject();
|
||||||
|
Debug.Log("____GODLIKE____");
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach (TileData data in _tiles)
|
foreach (TileData data in _tiles)
|
||||||
{
|
{
|
||||||
reference.SetTile(data.Position, data.Tile);
|
reference.SetTile(data.Position, data.Tile);
|
||||||
|
Debug.Log(_key.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
31
Assets/Scripts/Opponent/EnemyType.cs
Normal file
31
Assets/Scripts/Opponent/EnemyType.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class EnemyType
|
||||||
|
{
|
||||||
|
[SerializeField]
|
||||||
|
private Opponent _enemy;
|
||||||
|
[SerializeField]
|
||||||
|
private int _count;
|
||||||
|
|
||||||
|
public int GetEnemyToughness()
|
||||||
|
{
|
||||||
|
float toughness = Mathf.Round((_enemy.Hp / 10) + _enemy.AttackDamage / 2);
|
||||||
|
return (int)toughness;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameObject GetEnemyObject()
|
||||||
|
{
|
||||||
|
return _enemy.gameObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetEnemyCount()
|
||||||
|
{
|
||||||
|
return _count;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
11
Assets/Scripts/Opponent/EnemyType.cs.meta
Normal file
11
Assets/Scripts/Opponent/EnemyType.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a747157705819b94499ad98134da8f88
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -9,7 +9,7 @@ public class ClickBehavior : MonoBehaviour
|
|||||||
if (Input.GetMouseButton(0))
|
if (Input.GetMouseButton(0))
|
||||||
{
|
{
|
||||||
Vector2 clickPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
Vector2 clickPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||||
RaycastHit2D hit = Physics2D.Raycast(clickPoint, transform.up);
|
RaycastHit2D hit = Physics2D.Raycast(clickPoint, transform.up, 0.0f);
|
||||||
if (hit.collider != null)
|
if (hit.collider != null)
|
||||||
{
|
{
|
||||||
if (hit.collider.CompareTag("Resource"))
|
if (hit.collider.CompareTag("Resource"))
|
||||||
|
|||||||
@ -61,4 +61,8 @@ public class SpawnerTile : LevelTile
|
|||||||
_lifetime = dict[nameof(_lifetime)].ToFloat();
|
_lifetime = dict[nameof(_lifetime)].ToFloat();
|
||||||
_spawnOnStart = dict[nameof(_spawnOnStart)].ToBool();
|
_spawnOnStart = dict[nameof(_spawnOnStart)].ToBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameObject Prefab { set {
|
||||||
|
Debug.Log("Changed");
|
||||||
|
_prefab = value; } }
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user