pas de moyen d'accéder et de gérer et d'accéder aux unités / props sur la map - ajout d'un LevelManager qui contient tous les objet de niveau (ILevelObject) - ajout d'un ResourceTile qui s'ajoute lui-même au level manager, et contient ses informations. ResourceTile pas terminée puisque le genre de resource est dépendant du ResourceManager, pas encore contenu dans main.
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Tilemaps;
|
|
|
|
|
|
[CreateAssetMenu(menuName = "Gather And Defend/Resource Tile")]
|
|
public class ResourceTile : TileBase
|
|
{
|
|
public class ResourceTileData : ILevelObject
|
|
{
|
|
private Vector3 _position;
|
|
private string _resourceType;
|
|
|
|
public Vector3 Position => _position;
|
|
public string ResourceType => _resourceType;
|
|
|
|
public ResourceTileData(Vector2 position, string resourceType)
|
|
{
|
|
this._position = position;
|
|
this._resourceType = resourceType;
|
|
}
|
|
}
|
|
[SerializeField]
|
|
private Sprite _sprite;
|
|
public override bool StartUp(Vector3Int position, ITilemap tilemap, GameObject go)
|
|
{
|
|
if (!Application.isPlaying) return base.StartUp(position, tilemap, go);
|
|
if (position == new Vector3Int(-5, -5))
|
|
{
|
|
Debug.Log("Yo");
|
|
}
|
|
LevelManager.Instance.Add(new ResourceTileData((Vector3)position, name));
|
|
return base.StartUp(position, tilemap, go);
|
|
}
|
|
public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData)
|
|
{
|
|
tileData.sprite = _sprite;
|
|
tileData.transform.SetTRS(Vector3.zero, Quaternion.identity, Vector3.one);
|
|
tileData.color = Color.white;
|
|
}
|
|
} |