added item editor in item settings
This commit is contained in:
parent
919d7c8726
commit
eb2fd931ff
@ -1,62 +0,0 @@
|
|||||||
%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: 09939b8f9dce4b858d34f89d66c453e6, type: 3}
|
|
||||||
m_Name: Defaults
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
serializationData:
|
|
||||||
SerializedFormat: 2
|
|
||||||
SerializedBytes:
|
|
||||||
ReferencedUnityObjects:
|
|
||||||
- {fileID: 1175122412763585952, guid: ca39954219550f949aeeecf95f25f3d1, type: 3}
|
|
||||||
SerializedBytesString:
|
|
||||||
Prefab: {fileID: 0}
|
|
||||||
PrefabModificationsReferencedUnityObjects: []
|
|
||||||
PrefabModifications: []
|
|
||||||
SerializationNodes:
|
|
||||||
- Name: buildings
|
|
||||||
Entry: 7
|
|
||||||
Data: 0|System.Collections.Generic.Dictionary`2[[Data.BuildingKeys, Assembly-CSharp],[UnityEngine.GameObject,
|
|
||||||
UnityEngine.CoreModule]], mscorlib
|
|
||||||
- Name: comparer
|
|
||||||
Entry: 7
|
|
||||||
Data: 1|System.Collections.Generic.EnumEqualityComparer`1[[Data.BuildingKeys,
|
|
||||||
Assembly-CSharp]], mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 12
|
|
||||||
Data: 0
|
|
||||||
- Name:
|
|
||||||
Entry: 13
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 12
|
|
||||||
Data: 1
|
|
||||||
- Name:
|
|
||||||
Entry: 7
|
|
||||||
Data:
|
|
||||||
- Name: $k
|
|
||||||
Entry: 3
|
|
||||||
Data: 2
|
|
||||||
- Name: $v
|
|
||||||
Entry: 10
|
|
||||||
Data: 0
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 13
|
|
||||||
Data:
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: dd5ca1c9dc36b944a96cd347a3fe6b0d
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -19,7 +19,7 @@ MonoBehaviour:
|
|||||||
icon: {fileID: 0}
|
icon: {fileID: 0}
|
||||||
objectToThrow: {fileID: 662838864788327244, guid: 4ae54c1263fd76148b1888c9e05f1d48, type: 3}
|
objectToThrow: {fileID: 662838864788327244, guid: 4ae54c1263fd76148b1888c9e05f1d48, type: 3}
|
||||||
VFXGameObject: {fileID: 8032726150168125150, guid: 65c8920b6d1553a4d885992e8f7dff6a, type: 3}
|
VFXGameObject: {fileID: 8032726150168125150, guid: 65c8920b6d1553a4d885992e8f7dff6a, type: 3}
|
||||||
modifiedDamage: 0
|
modifiedDamage: 100
|
||||||
damage: 100
|
damage: 100
|
||||||
speed: 1
|
speed: 1
|
||||||
disnatce: 10
|
disnatce: 10
|
||||||
@ -28,3 +28,4 @@ MonoBehaviour:
|
|||||||
shotSound: {fileID: 0}
|
shotSound: {fileID: 0}
|
||||||
hitSound: {fileID: 0}
|
hitSound: {fileID: 0}
|
||||||
_aimGameObject: {fileID: 2273039178377770117, guid: 09a0317cbdff9fa479a18c9e20743a8e, type: 3}
|
_aimGameObject: {fileID: 2273039178377770117, guid: 09a0317cbdff9fa479a18c9e20743a8e, type: 3}
|
||||||
|
lifeTime: 3
|
||||||
|
@ -25,7 +25,7 @@ MonoBehaviour:
|
|||||||
maxHP: 100
|
maxHP: 100
|
||||||
inventoryCapacity: 4
|
inventoryCapacity: 4
|
||||||
- isPlayer: 0
|
- isPlayer: 0
|
||||||
isAI: 1
|
isAI: 0
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: 3
|
x: 3
|
||||||
z: 4
|
z: 4
|
||||||
@ -36,7 +36,7 @@ MonoBehaviour:
|
|||||||
maxHP: 100
|
maxHP: 100
|
||||||
inventoryCapacity: 4
|
inventoryCapacity: 4
|
||||||
- isPlayer: 0
|
- isPlayer: 0
|
||||||
isAI: 1
|
isAI: 0
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: -1
|
x: -1
|
||||||
z: 42
|
z: 42
|
||||||
@ -47,7 +47,7 @@ MonoBehaviour:
|
|||||||
maxHP: 100
|
maxHP: 100
|
||||||
inventoryCapacity: 4
|
inventoryCapacity: 4
|
||||||
- isPlayer: 0
|
- isPlayer: 0
|
||||||
isAI: 1
|
isAI: 0
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: -17
|
x: -17
|
||||||
z: 40
|
z: 40
|
||||||
|
@ -64,7 +64,7 @@ public class AdsMob : MonoBehaviour
|
|||||||
var randomCell = Random.Range(0, cells.Count);
|
var randomCell = Random.Range(0, cells.Count);
|
||||||
Vector3 respawnPosition = cells[randomCell].transform.position;
|
Vector3 respawnPosition = cells[randomCell].transform.position;
|
||||||
|
|
||||||
player = FindObjectOfType<ExtraLife>().gameObject;
|
|
||||||
|
|
||||||
player.transform.position = respawnPosition;
|
player.transform.position = respawnPosition;
|
||||||
if (player.transform.position == respawnPosition)
|
if (player.transform.position == respawnPosition)
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Sirenix.OdinInspector;
|
|
||||||
using Sirenix.Serialization;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Data
|
|
||||||
{
|
|
||||||
[CreateAssetMenu(fileName = "Defaults", menuName = "Data/Defaults", order = 0)]
|
|
||||||
public class DefaultLists : SerializedScriptableObject
|
|
||||||
{
|
|
||||||
[OdinSerialize] private Dictionary<BuildingKeys, GameObject> buildings;
|
|
||||||
|
|
||||||
public Dictionary<BuildingKeys, GameObject> Buildings => buildings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum BuildingKeys
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
Tree,
|
|
||||||
Bomb
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 09939b8f9dce4b858d34f89d66c453e6
|
|
||||||
timeCreated: 1644417891
|
|
@ -1,8 +1,12 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using Data;
|
using Data;
|
||||||
|
using Items;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using Sirenix.OdinInspector.Editor;
|
using Sirenix.OdinInspector.Editor;
|
||||||
|
using Sirenix.Serialization;
|
||||||
using Sirenix.Utilities;
|
using Sirenix.Utilities;
|
||||||
using Sirenix.Utilities.Editor;
|
using Sirenix.Utilities.Editor;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
@ -61,9 +65,11 @@ namespace Editor
|
|||||||
protected override OdinMenuTree BuildMenuTree()
|
protected override OdinMenuTree BuildMenuTree()
|
||||||
{
|
{
|
||||||
_createNewLevel = new CreateNewLevel();
|
_createNewLevel = new CreateNewLevel();
|
||||||
var tree = new OdinMenuTree();
|
var tree = new OdinMenuTree
|
||||||
tree.Add("New Level", _createNewLevel);
|
{
|
||||||
tree.Add("Default Lists",new Defaults());
|
{ "New Level", _createNewLevel },
|
||||||
|
{ "Items", new ItemList() }
|
||||||
|
};
|
||||||
var pathes = Resources.LoadAll<Data.Data>("Data/");
|
var pathes = Resources.LoadAll<Data.Data>("Data/");
|
||||||
pathes.ForEach(x =>
|
pathes.ForEach(x =>
|
||||||
{
|
{
|
||||||
@ -74,39 +80,74 @@ namespace Editor
|
|||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Defaults
|
|
||||||
|
|
||||||
|
private class ItemList
|
||||||
{
|
{
|
||||||
public Defaults()
|
public ItemList()
|
||||||
{
|
{
|
||||||
def = Resources.Load<DefaultLists>("Data/Defaults");
|
items = Resources.LoadAll<Item>("Data/Items").ToList();
|
||||||
if (def == null)
|
}
|
||||||
{
|
[OdinSerialize] public NewItem Type;
|
||||||
def = CreateInstance<DefaultLists>();
|
|
||||||
AssetDatabase.CreateAsset(def, "Assets/Resources/Data/Defaults.asset");
|
[InlineEditor(Expanded = true), ListDrawerSettings(HideAddButton = true, CustomRemoveElementFunction = "RemoveItem")] public List<Item> items;
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
|
private void RemoveItem(Item item)
|
||||||
|
{
|
||||||
|
var path = AssetDatabase.GetAssetPath(item);
|
||||||
|
var metaPath = path.Replace(".asset", ".asset.meta");
|
||||||
|
File.Delete(path);
|
||||||
|
File.Delete(metaPath);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
[InlineEditor(ObjectFieldMode = InlineEditorObjectFieldModes.Boxed, Expanded = true, DrawHeader = false)]
|
internal enum ItemType
|
||||||
public DefaultLists def;
|
{
|
||||||
|
Bonus,
|
||||||
|
Building,
|
||||||
|
CaptureAbility,
|
||||||
|
SpecialWeapon
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
|
internal class NewItem
|
||||||
|
{
|
||||||
|
public ItemType Type;
|
||||||
|
public string ItemName;
|
||||||
|
|
||||||
|
[Button("Add Item")]
|
||||||
|
private void AddItem()
|
||||||
|
{
|
||||||
|
Item item = Type switch
|
||||||
|
{
|
||||||
|
ItemType.Bonus => CreateInstance<Bonus>(),
|
||||||
|
ItemType.Building => CreateInstance<Building>(),
|
||||||
|
ItemType.CaptureAbility => CreateInstance<CaptureAbility>(),
|
||||||
|
ItemType.SpecialWeapon => CreateInstance<SpecialWeapon>(),
|
||||||
|
_ => throw new ArgumentOutOfRangeException(nameof(Type), Type, null)
|
||||||
|
};
|
||||||
|
AssetDatabase.CreateAsset(item,$"Assets/Resources/Data/Items/{ItemName}.asset");
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class CreateNewLevel
|
private class CreateNewLevel
|
||||||
{
|
{
|
||||||
public CreateNewLevel()
|
public CreateNewLevel()
|
||||||
{
|
{
|
||||||
data = ScriptableObject.CreateInstance<Data.Data>();
|
data = ScriptableObject.CreateInstance<Data.Data>();
|
||||||
datas = new List<ScriptableObject>();
|
datas = new List<ScriptableObject>
|
||||||
datas.Add(ScriptableObject.CreateInstance<AIData>());
|
{
|
||||||
datas.Add(ScriptableObject.CreateInstance<CameraData>());
|
ScriptableObject.CreateInstance<AIData>(),
|
||||||
datas.Add(ScriptableObject.CreateInstance<FieldData>());
|
ScriptableObject.CreateInstance<CameraData>(),
|
||||||
datas.Add(ScriptableObject.CreateInstance<ItemsData>());
|
ScriptableObject.CreateInstance<FieldData>(),
|
||||||
datas.Add(ScriptableObject.CreateInstance<MusicData>());
|
ScriptableObject.CreateInstance<ItemsData>(),
|
||||||
datas.Add(ScriptableObject.CreateInstance<UIData>());
|
ScriptableObject.CreateInstance<MusicData>(),
|
||||||
datas.Add(ScriptableObject.CreateInstance<UnitData>());
|
ScriptableObject.CreateInstance<UIData>(),
|
||||||
datas.Add(ScriptableObject.CreateInstance<WeaponsData>());
|
ScriptableObject.CreateInstance<UnitData>(),
|
||||||
|
ScriptableObject.CreateInstance<WeaponsData>()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,9 +22,7 @@ namespace HexFiled
|
|||||||
[SerializeField] private Item _item;
|
[SerializeField] private Item _item;
|
||||||
[SerializeField, AssetsOnly] public GameObject Building;
|
[SerializeField, AssetsOnly] public GameObject Building;
|
||||||
|
|
||||||
|
|
||||||
private Dictionary<BuildingKeys, GameObject> buildings =>
|
|
||||||
Resources.Load<DefaultLists>(Path.ChangeExtension("Data/Defaults.asset", null)).Buildings;
|
|
||||||
|
|
||||||
private UnitColor _color;
|
private UnitColor _color;
|
||||||
private MeshRenderer _renderer;
|
private MeshRenderer _renderer;
|
||||||
@ -51,7 +49,7 @@ namespace HexFiled
|
|||||||
{
|
{
|
||||||
if (BuildingInstance != null)
|
if (BuildingInstance != null)
|
||||||
{
|
{
|
||||||
DestroyImmediate(Building);
|
DestroyImmediate(BuildingInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Building != null)
|
if (Building != null)
|
||||||
@ -60,6 +58,7 @@ namespace HexFiled
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,9 @@ namespace HexFiled
|
|||||||
foreach (var neighbour in neighbours)
|
foreach (var neighbour in neighbours)
|
||||||
{
|
{
|
||||||
if (hexByColorDict.TryGetValue(neighbour.Color, out var value) &&
|
if (hexByColorDict.TryGetValue(neighbour.Color, out var value) &&
|
||||||
value.Count >= 2 && value.Count < 6)
|
hexByColorDict.TryGetValue(cell.Color, out var hexCells) &&
|
||||||
|
hexCells.Count >= 2 &&
|
||||||
|
value.Count < 6)
|
||||||
{
|
{
|
||||||
foreach (var hex in value)
|
foreach (var hex in value)
|
||||||
{
|
{
|
||||||
@ -48,7 +50,7 @@ namespace HexFiled
|
|||||||
if (neighbour.Color != UnitColor.Grey
|
if (neighbour.Color != UnitColor.Grey
|
||||||
&& HexManager.UnitCurrentCell.TryGetValue(neighbour.Color, out var unit)
|
&& HexManager.UnitCurrentCell.TryGetValue(neighbour.Color, out var unit)
|
||||||
&& hexByColorDict.TryGetValue(neighbour.Color, out var cells)
|
&& hexByColorDict.TryGetValue(neighbour.Color, out var cells)
|
||||||
&& cells.Count >= 2 && cells.Count < 5)
|
&& cells.Count >= 2 && cells.Count < 6)
|
||||||
{
|
{
|
||||||
var path = await HasPath(neighbour, unit.cell);
|
var path = await HasPath(neighbour, unit.cell);
|
||||||
if (!path.hasPath)
|
if (!path.hasPath)
|
||||||
@ -128,7 +130,7 @@ namespace HexFiled
|
|||||||
|
|
||||||
private async Task<(bool hasPath, List<HexCell> field)> HasPath(HexCell start, HexCell end)
|
private async Task<(bool hasPath, List<HexCell> field)> HasPath(HexCell start, HexCell end)
|
||||||
{
|
{
|
||||||
if (start.Color == _cell.Color || end.Color == _cell.Color)
|
if (start.Color == _cell.Color)
|
||||||
{
|
{
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
return (true, null);
|
return (true, null);
|
||||||
|
@ -26,7 +26,8 @@ namespace Items
|
|||||||
cell.transform.position + buildingPrefab.transform.position, Quaternion.identity);
|
cell.transform.position + buildingPrefab.transform.position, Quaternion.identity);
|
||||||
obj.GetComponent<ISetUp>().SetUp(Unit);
|
obj.GetComponent<ISetUp>().SetUp(Unit);
|
||||||
|
|
||||||
cell.Building = obj;
|
cell.Building = buildingPrefab;
|
||||||
|
cell.BuildingInstance = obj;
|
||||||
OnItemUsed.Invoke();
|
OnItemUsed.Invoke();
|
||||||
OnItemUsed = _action;
|
OnItemUsed = _action;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,8 @@ namespace Items
|
|||||||
|
|
||||||
public void Fire()
|
public void Fire()
|
||||||
{
|
{
|
||||||
|
OnItemUsed?.Invoke();
|
||||||
|
Unit.UseItem(this);
|
||||||
var cell = HexManager.UnitCurrentCell[Unit.Color].cell.GetNeighbor(_direction);
|
var cell = HexManager.UnitCurrentCell[Unit.Color].cell.GetNeighbor(_direction);
|
||||||
Unit.RotateUnit(new Vector2((cell.transform.position - Unit.Instance.transform.position).normalized.x,
|
Unit.RotateUnit(new Vector2((cell.transform.position - Unit.Instance.transform.position).normalized.x,
|
||||||
(cell.transform.position - Unit.Instance.transform.position).normalized.z));
|
(cell.transform.position - Unit.Instance.transform.position).normalized.z));
|
||||||
@ -54,7 +56,7 @@ namespace Items
|
|||||||
{
|
{
|
||||||
_weapon.DestroyBall();
|
_weapon.DestroyBall();
|
||||||
}, lifeTime);
|
}, lifeTime);
|
||||||
OnItemUsed?.Invoke();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 4690d5b96a9971f4fa845f4b25440eba
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,72 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using HexFiled;
|
|
||||||
|
|
||||||
public class ExtraLife : MonoBehaviour
|
|
||||||
{
|
|
||||||
[SerializeField] private GameObject canvasgroupe;
|
|
||||||
[SerializeField] private AdsMob canvasPref;
|
|
||||||
public static int lifeCount = 1;
|
|
||||||
public int health = 1;
|
|
||||||
|
|
||||||
private void Start() {
|
|
||||||
|
|
||||||
canvasPref = FindObjectOfType<AdsMob>();
|
|
||||||
canvasPref.gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Update() {
|
|
||||||
if(health <= 0)
|
|
||||||
{
|
|
||||||
lifeCount -= 1;
|
|
||||||
canvasPref.gameObject.SetActive(true);
|
|
||||||
Time.timeScale = 0f;
|
|
||||||
//canvasPref.ShowAd();
|
|
||||||
//Instantiate(canvasPref);//.GetComponent<add>().ShowAd();
|
|
||||||
if(lifeCount < 0)
|
|
||||||
{
|
|
||||||
lifeCount = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(lifeCount > 0)
|
|
||||||
{
|
|
||||||
canvasPref.gameObject.SetActive(false);
|
|
||||||
//Respawn();
|
|
||||||
Time.timeScale = 1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void Respawn()
|
|
||||||
// {
|
|
||||||
// List<HexCell> cells = new List<HexCell>(FindObjectsOfType<HexCell>());
|
|
||||||
// // for (int i = 0; i < cells.Count; i++)
|
|
||||||
// // {
|
|
||||||
|
|
||||||
// // }
|
|
||||||
// foreach (var cell in cells)
|
|
||||||
// {
|
|
||||||
// if(cell.Color == UnitColor.GREY)
|
|
||||||
// {
|
|
||||||
// var randomCell = Random.Range(0, cells.Count);
|
|
||||||
// Vector3 respawnPosition = cells[randomCell].transform.position;
|
|
||||||
// GameObject player = FindObjectOfType<ExtraLife>().gameObject;
|
|
||||||
// player.transform.position = respawnPosition;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void AddLIfe(int count)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// lifeCount = count;
|
|
||||||
// if(count < 1)
|
|
||||||
// {
|
|
||||||
// //add reward = new add();
|
|
||||||
// count++;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2d2f89853800f934f8dce9a6635a97bd
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,65 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class Gamelogic : MonoBehaviour
|
|
||||||
{
|
|
||||||
Mana manaSystem;
|
|
||||||
|
|
||||||
private void Start() {
|
|
||||||
manaSystem = new Mana();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Update() {
|
|
||||||
Debug.Log("HP: " + manaSystem.Current_MP);
|
|
||||||
|
|
||||||
manaSystem.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class Mana
|
|
||||||
{
|
|
||||||
public float Max_MP = 100;
|
|
||||||
public float Current_MP = 1;
|
|
||||||
List<ManaRegen> regenList;
|
|
||||||
public Mana()
|
|
||||||
{
|
|
||||||
regenList = new List<ManaRegen>();
|
|
||||||
}
|
|
||||||
public Mana(float max, float current)
|
|
||||||
{
|
|
||||||
Max_MP = max;
|
|
||||||
Current_MP = current;
|
|
||||||
regenList = new List<ManaRegen>();
|
|
||||||
}
|
|
||||||
public void Update() {
|
|
||||||
foreach (var regen in regenList.ToArray())
|
|
||||||
{
|
|
||||||
if(Current_MP < Max_MP && regen.fDuraton > 0)
|
|
||||||
{
|
|
||||||
Current_MP += regen.fManaPerSecond * Time.deltaTime;
|
|
||||||
}
|
|
||||||
regen.fDuraton -= 1f *Time.deltaTime;
|
|
||||||
|
|
||||||
if(regen.fDuraton < 0)
|
|
||||||
{
|
|
||||||
regenList.RemoveAt(regenList.IndexOf(regen));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ManaRegen
|
|
||||||
{
|
|
||||||
public float fDuraton;
|
|
||||||
public float fManaPerSecond;
|
|
||||||
|
|
||||||
public ManaRegen()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public ManaRegen(float duration, float manaPerSecond)
|
|
||||||
{
|
|
||||||
fDuraton = duration;
|
|
||||||
fManaPerSecond = manaPerSecond;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 4d34080a61fa47645b032357092bcc99
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,60 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class ManaBar : MonoBehaviour
|
|
||||||
{
|
|
||||||
public Slider manaBar;
|
|
||||||
|
|
||||||
private int maxMana = 100;
|
|
||||||
private int currentMana;
|
|
||||||
private WaitForSeconds regenTick = new WaitForSeconds(0.5f);
|
|
||||||
private Coroutine regen;
|
|
||||||
|
|
||||||
|
|
||||||
public static ManaBar instance;
|
|
||||||
|
|
||||||
private void Awake() {
|
|
||||||
instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Start() {
|
|
||||||
currentMana = maxMana;
|
|
||||||
manaBar.maxValue = maxMana;
|
|
||||||
manaBar.value = maxMana;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UseMana(int amount)
|
|
||||||
{
|
|
||||||
if(currentMana - amount >= 0 )
|
|
||||||
{
|
|
||||||
currentMana -= amount;
|
|
||||||
manaBar.value = currentMana;
|
|
||||||
|
|
||||||
if(regen != null)
|
|
||||||
StopCoroutine(regen);
|
|
||||||
|
|
||||||
regen = StartCoroutine(RegenMana());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("Not enough mana");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerator RegenMana()
|
|
||||||
{
|
|
||||||
yield return new WaitForSeconds(0.1f);
|
|
||||||
|
|
||||||
while(currentMana < maxMana)
|
|
||||||
{
|
|
||||||
currentMana += maxMana / 10;
|
|
||||||
manaBar.value = currentMana;
|
|
||||||
yield return regenTick;
|
|
||||||
}
|
|
||||||
|
|
||||||
regen = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 38891abd62cc9634584e630986c02534
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,13 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class Player : MonoBehaviour
|
|
||||||
{
|
|
||||||
private void Update() {
|
|
||||||
if(Input.GetKeyDown(KeyCode.Space))
|
|
||||||
{
|
|
||||||
ManaBar.instance.UseMana(15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8effecfd846c8cf43ab76c0185e0f2a0
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -117,10 +117,10 @@ namespace Units
|
|||||||
|
|
||||||
public void Move(HexDirection direction)
|
public void Move(HexDirection direction)
|
||||||
{
|
{
|
||||||
if (_cell.GetNeighbor(direction) == null || _isBusy || _isHardToCapture ||
|
if ( _cell.GetNeighbor(direction) == null || _cell.GetNeighbor(direction).BuildingInstance !=null || _isBusy || _isHardToCapture ||
|
||||||
(_cell.GetNeighbor(direction).Color != Color
|
(_cell.GetNeighbor(direction).Color != Color
|
||||||
&& HexManager.UnitCurrentCell.TryGetValue(_cell.GetNeighbor(direction).Color, out var value)
|
&& HexManager.UnitCurrentCell.TryGetValue(_cell.GetNeighbor(direction).Color, out var value)
|
||||||
&& value.cell.coordinates.Equals(_cell.GetNeighbor(direction).coordinates))) return;
|
&& value.cell.Equals(_cell.GetNeighbor(direction)))) return;
|
||||||
|
|
||||||
|
|
||||||
if (_cell.GetNeighbor(direction).Color == _data.color)
|
if (_cell.GetNeighbor(direction).Color == _data.color)
|
||||||
@ -383,13 +383,15 @@ namespace Units
|
|||||||
_unitView.OnHit -= Damage;
|
_unitView.OnHit -= Damage;
|
||||||
_isAlive = false;
|
_isAlive = false;
|
||||||
_isBusy = true;
|
_isBusy = true;
|
||||||
HexManager.PaintHexList(HexManager.CellByColor[Color], UnitColor.Grey);
|
|
||||||
HexManager.UnitCurrentCell.Remove(Color);
|
HexManager.UnitCurrentCell.Remove(Color);
|
||||||
|
var hexToPaint = HexManager.CellByColor[Color];
|
||||||
_animator.SetTrigger("Death");
|
_animator.SetTrigger("Death");
|
||||||
var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[Color].VFXDeathPrefab,
|
var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[Color].VFXDeathPrefab,
|
||||||
_instance.transform.position);
|
_instance.transform.position);
|
||||||
TimerHelper.Instance.StartTimer(() =>
|
TimerHelper.Instance.StartTimer(() =>
|
||||||
{
|
{
|
||||||
|
HexManager.PaintHexList(hexToPaint, UnitColor.Grey);
|
||||||
|
|
||||||
Object.Destroy(_instance);
|
Object.Destroy(_instance);
|
||||||
OnDeath?.Invoke(this);
|
OnDeath?.Invoke(this);
|
||||||
}, _animLength.Death);
|
}, _animLength.Death);
|
||||||
|
@ -33,7 +33,6 @@ public class UnitView : MonoBehaviour
|
|||||||
private Dictionary<string, Action> animActionDic;
|
private Dictionary<string, Action> animActionDic;
|
||||||
private int _mana;
|
private int _mana;
|
||||||
private event Action CaptureHex;
|
private event Action CaptureHex;
|
||||||
private Sequence _sequence;
|
|
||||||
private AudioSource _audioSource;
|
private AudioSource _audioSource;
|
||||||
private Unit _unit;
|
private Unit _unit;
|
||||||
private float _hardCaptureTime;
|
private float _hardCaptureTime;
|
||||||
@ -78,8 +77,8 @@ public class UnitView : MonoBehaviour
|
|||||||
{
|
{
|
||||||
_unit.BarCanvas.CaptureBar.DOFillAmount(0f, 0);
|
_unit.BarCanvas.CaptureBar.DOFillAmount(0f, 0);
|
||||||
_barCanvas.CaptureBack.SetActive(true);
|
_barCanvas.CaptureBack.SetActive(true);
|
||||||
_sequence = DOTween.Sequence();
|
|
||||||
_sequence.Append(_unit.BarCanvas.CaptureBar.DOFillAmount(1f, _hardCaptureTime).SetEase(Ease.Linear).OnComplete(
|
_unit.BarCanvas.CaptureBar.DOFillAmount(1f, _hardCaptureTime).SetEase(Ease.Linear).OnComplete(
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
CaptureHex?.Invoke();
|
CaptureHex?.Invoke();
|
||||||
@ -87,14 +86,14 @@ public class UnitView : MonoBehaviour
|
|||||||
MusicController.Instance.PlayRandomClip(MusicController.Instance.MusicData.SfxMusic.Captures,
|
MusicController.Instance.PlayRandomClip(MusicController.Instance.MusicData.SfxMusic.Captures,
|
||||||
cell.gameObject);
|
cell.gameObject);
|
||||||
|
|
||||||
}));
|
});
|
||||||
_sequence.Play();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void StopHardCapture()
|
public void StopHardCapture()
|
||||||
{
|
{
|
||||||
_sequence.Kill();
|
_barCanvas.CaptureBar.DOKill();
|
||||||
|
|
||||||
_barCanvas.CaptureBar.DOFillAmount(0f, 0f).SetEase(Ease.Linear);
|
_barCanvas.CaptureBar.DOFillAmount(0f, 0f).SetEase(Ease.Linear);
|
||||||
_unit.BarCanvas.CaptureBack.SetActive(false);
|
_unit.BarCanvas.CaptureBack.SetActive(false);
|
||||||
|
@ -46,15 +46,14 @@ namespace Weapons
|
|||||||
.SetEase(Ease.Linear)
|
.SetEase(Ease.Linear)
|
||||||
.OnComplete(() =>
|
.OnComplete(() =>
|
||||||
{
|
{
|
||||||
var vfx = VFXController.Instance.PlayEffect(tmpThis.VFXGameObject, localBall.transform.position, localBall.transform.rotation);
|
tmpThis.DestroyBall();
|
||||||
MusicController.Instance.AddAudioSource(vfx);
|
|
||||||
MusicController.Instance.PlayAudioClip(tmpThis.hitSound, vfx);
|
|
||||||
Object.Destroy(localBall);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DestroyBall()
|
public void DestroyBall()
|
||||||
{
|
{
|
||||||
|
if(ball == null)
|
||||||
|
return;
|
||||||
var vfx = VFXController.Instance.PlayEffect(VFXGameObject, ball.transform.position, ball.transform.rotation);
|
var vfx = VFXController.Instance.PlayEffect(VFXGameObject, ball.transform.position, ball.transform.rotation);
|
||||||
MusicController.Instance.AddAudioSource(vfx);
|
MusicController.Instance.AddAudioSource(vfx);
|
||||||
MusicController.Instance.PlayAudioClip(hitSound, vfx);
|
MusicController.Instance.PlayAudioClip(hitSound, vfx);
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user