Add Warior
This commit is contained in:
parent
436e8b10d0
commit
b1e00327d8
6
.vsconfig
Normal file
6
.vsconfig
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"components": [
|
||||
"Microsoft.VisualStudio.Workload.ManagedGame"
|
||||
]
|
||||
}
|
@ -61,6 +61,31 @@ MonoBehaviour:
|
||||
maxHP: 100
|
||||
inventoryCapacity: 4
|
||||
InvisibleMaterial: {fileID: 0}
|
||||
_warior:
|
||||
- spawnPos:
|
||||
x: 0
|
||||
z: 0
|
||||
wariorPrefa: {fileID: 5982292246613942016, guid: e508e7126551af140aae54649db1a0c1, type: 3}
|
||||
color: 0
|
||||
manaRegen: 100
|
||||
maxMana: 1000
|
||||
maxHP: 1000
|
||||
InvisibleMaterial: {fileID: 0}
|
||||
prefab: {fileID: 0}
|
||||
Type: 0
|
||||
_weapon:
|
||||
name:
|
||||
icon: {fileID: 0}
|
||||
objectToThrow: {fileID: 0}
|
||||
VFXGameObject: {fileID: 0}
|
||||
modifiedDamage: 0
|
||||
damage: 0
|
||||
speed: 0
|
||||
disnatce: 0
|
||||
reloadTime: 0
|
||||
shots: 0
|
||||
shotSound: {fileID: 0}
|
||||
hitSound: {fileID: 0}
|
||||
playerBarCanvas: {fileID: 482855193181693567, guid: dec5dd0d644d5c548a53563e65837162, type: 3}
|
||||
botBarCanvas: {fileID: 482855193181693567, guid: 1af9afdbdd132df4989c826eb6cb6562, type: 3}
|
||||
attackAimCanvas: {fileID: 2273039178377770117, guid: 09a0317cbdff9fa479a18c9e20743a8e, type: 3}
|
||||
|
@ -61,6 +61,31 @@ MonoBehaviour:
|
||||
maxHP: 100
|
||||
inventoryCapacity: 4
|
||||
InvisibleMaterial: {fileID: 0}
|
||||
_warior:
|
||||
- spawnPos:
|
||||
x: 0
|
||||
z: 0
|
||||
wariorPrefa: {fileID: 5982292246613942016, guid: e508e7126551af140aae54649db1a0c1, type: 3}
|
||||
color: 0
|
||||
manaRegen: 100
|
||||
maxMana: 1000
|
||||
maxHP: 100
|
||||
InvisibleMaterial: {fileID: 0}
|
||||
prefab: {fileID: 0}
|
||||
Type: 0
|
||||
_weapon:
|
||||
name:
|
||||
icon: {fileID: 0}
|
||||
objectToThrow: {fileID: 0}
|
||||
VFXGameObject: {fileID: 0}
|
||||
modifiedDamage: 0
|
||||
damage: 0
|
||||
speed: 0
|
||||
disnatce: 0
|
||||
reloadTime: 0
|
||||
shots: 0
|
||||
shotSound: {fileID: 0}
|
||||
hitSound: {fileID: 0}
|
||||
playerBarCanvas: {fileID: 482855193181693567, guid: dec5dd0d644d5c548a53563e65837162, type: 3}
|
||||
botBarCanvas: {fileID: 482855193181693567, guid: 1af9afdbdd132df4989c826eb6cb6562, type: 3}
|
||||
attackAimCanvas: {fileID: 2273039178377770117, guid: 09a0317cbdff9fa479a18c9e20743a8e, type: 3}
|
||||
|
@ -61,6 +61,31 @@ MonoBehaviour:
|
||||
maxHP: 100
|
||||
inventoryCapacity: 4
|
||||
InvisibleMaterial: {fileID: 0}
|
||||
_warior:
|
||||
- spawnPos:
|
||||
x: 0
|
||||
z: 0
|
||||
wariorPrefa: {fileID: 5982292246613942016, guid: e508e7126551af140aae54649db1a0c1, type: 3}
|
||||
color: 0
|
||||
manaRegen: 100
|
||||
maxMana: 1000
|
||||
maxHP: 100
|
||||
InvisibleMaterial: {fileID: 0}
|
||||
prefab: {fileID: 0}
|
||||
Type: 0
|
||||
_weapon:
|
||||
name:
|
||||
icon: {fileID: 0}
|
||||
objectToThrow: {fileID: 0}
|
||||
VFXGameObject: {fileID: 0}
|
||||
modifiedDamage: 0
|
||||
damage: 0
|
||||
speed: 0
|
||||
disnatce: 0
|
||||
reloadTime: 0
|
||||
shots: 0
|
||||
shotSound: {fileID: 0}
|
||||
hitSound: {fileID: 0}
|
||||
playerBarCanvas: {fileID: 482855193181693567, guid: dec5dd0d644d5c548a53563e65837162, type: 3}
|
||||
botBarCanvas: {fileID: 482855193181693567, guid: 1af9afdbdd132df4989c826eb6cb6562, type: 3}
|
||||
attackAimCanvas: {fileID: 2273039178377770117, guid: 09a0317cbdff9fa479a18c9e20743a8e, type: 3}
|
||||
|
39
Assets/Resources/Data/WariorsData.asset
Normal file
39
Assets/Resources/Data/WariorsData.asset
Normal file
@ -0,0 +1,39 @@
|
||||
%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: 8c901c6adaad405f8e9c000e0bf91391, type: 3}
|
||||
m_Name: WariorsData
|
||||
m_EditorClassIdentifier:
|
||||
_wariors:
|
||||
- spawnPos:
|
||||
x: 0
|
||||
z: 0
|
||||
wariorPrefa: {fileID: 5982292246613942016, guid: e508e7126551af140aae54649db1a0c1, type: 3}
|
||||
color: 0
|
||||
manaRegen: 2
|
||||
maxMana: 50
|
||||
maxHP: 20
|
||||
InvisibleMaterial: {fileID: 0}
|
||||
prefab: {fileID: 0}
|
||||
Type: 0
|
||||
_weapon:
|
||||
name:
|
||||
icon: {fileID: 0}
|
||||
objectToThrow: {fileID: 0}
|
||||
VFXGameObject: {fileID: 0}
|
||||
modifiedDamage: 0
|
||||
damage: 0
|
||||
speed: 0
|
||||
disnatce: 0
|
||||
reloadTime: 0
|
||||
shots: 0
|
||||
shotSound: {fileID: 0}
|
||||
hitSound: {fileID: 0}
|
8
Assets/Resources/Data/WariorsData.asset.meta
Normal file
8
Assets/Resources/Data/WariorsData.asset.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95ff3f9dfdc9589429836c544811a695
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -224,6 +224,99 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1 &894515827
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 894515829}
|
||||
- component: {fileID: 894515828}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &894515828
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 894515827}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 0
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &894515829
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 894515827}
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 111.5, y: 223, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &963194225
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -38,7 +38,7 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
|
||||
m_IndirectSpecularColor: {r: 0.37311918, g: 0.3807398, b: 0.35872716, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
@ -28630,7 +28630,7 @@ MonoBehaviour:
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Bits: 319
|
||||
--- !u!114 &464538514
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -7,83 +7,23 @@ using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Runtime.Controller;
|
||||
using Units;
|
||||
using Units.Wariors.AbstractsBase;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DefaultNamespace.AI
|
||||
{
|
||||
public class AIAgent : IFixedExecute, IDisposable
|
||||
public class AIAgent : AIBase
|
||||
{
|
||||
private Unit _unit;
|
||||
private Camera _camera;
|
||||
private BotState curentState;
|
||||
public Queue<HexDirection> currentPath;
|
||||
public Action<AIAgent> OnAgentInited;
|
||||
private Vector2 _attackDirection;
|
||||
|
||||
public Unit Unit => _unit;
|
||||
|
||||
public BotState CurentState => curentState;
|
||||
|
||||
public AIAgent(UnitInfo enemyInfo, Unit unit)
|
||||
public AIAgent(UnitBase unitBase) : base(unitBase)
|
||||
{
|
||||
currentPath = new Queue<HexDirection>();
|
||||
_unit = unit;
|
||||
_camera = Camera.main;
|
||||
_unit.OnDeath += AgentDeath;
|
||||
unit.OnPlayerSpawned += InitAgent;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void AgentDeath(Unit unit)
|
||||
{
|
||||
AIManager.Instance.RemoveAgent(this);
|
||||
currentPath.Clear();
|
||||
}
|
||||
|
||||
private void InitAgent(Unit unit)
|
||||
protected override void InitAgent(UnitBase aiBase)
|
||||
{
|
||||
AIManager.Instance.AddAgent(this);
|
||||
HexManager.agents.Add(unit.Instance, this);
|
||||
HexManager.agents.Add(aiBase.Instance, this);
|
||||
OnAgentInited?.Invoke(this);
|
||||
}
|
||||
|
||||
public void AttackTarget(Vector2 direction)
|
||||
{
|
||||
_attackDirection = direction;
|
||||
|
||||
}
|
||||
|
||||
public void FixedExecute()
|
||||
{
|
||||
if (curentState == BotState.Attack && !_unit.IsBusy)
|
||||
{
|
||||
_unit.Aim(_attackDirection);
|
||||
_unit.StartAttack();
|
||||
curentState = AIManager.Instance.GetNewBehaviour(this);
|
||||
}
|
||||
if (currentPath.Count > 0 && !_unit.IsBusy)
|
||||
{
|
||||
var dir = currentPath.Dequeue();
|
||||
if (!HexManager.UnitCurrentCell.TryGetValue(_unit.Color, out var value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
while (value.cell == null)
|
||||
{
|
||||
dir = dir.PlusSixtyDeg();
|
||||
}
|
||||
_unit.Move(dir);
|
||||
}
|
||||
if(currentPath.Count == 0 && !_unit.IsBusy)
|
||||
{
|
||||
curentState = AIManager.Instance.GetNewBehaviour(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
80
Assets/Scripts/AI/AIBase.cs
Normal file
80
Assets/Scripts/AI/AIBase.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AI;
|
||||
using Controller;
|
||||
using HexFiled;
|
||||
using Units;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DefaultNamespace.AI
|
||||
{
|
||||
public abstract class AIBase : IFixedExecute, IDisposable
|
||||
{
|
||||
protected UnitBase _unitBase;
|
||||
private Camera _camera;
|
||||
private BotState curentState;
|
||||
public Queue<HexDirection> currentPath;
|
||||
public Action<AIBase> OnAgentInited;
|
||||
private Vector2 _attackDirection;
|
||||
|
||||
public UnitBase UnitBase => _unitBase;
|
||||
|
||||
public BotState CurentState => curentState;
|
||||
|
||||
public AIBase(UnitBase unitBase)
|
||||
{
|
||||
currentPath = new Queue<HexDirection>();
|
||||
_camera = Camera.main;
|
||||
_unitBase = unitBase;
|
||||
_unitBase.OnDeath += AgentDeath;
|
||||
_unitBase.OnSpawned += InitAgent;
|
||||
}
|
||||
|
||||
|
||||
protected virtual void AgentDeath(UnitBase aiBase)
|
||||
{
|
||||
AIManager.Instance.RemoveAgent(this);
|
||||
currentPath.Clear();
|
||||
}
|
||||
|
||||
protected abstract void InitAgent(UnitBase aiBase);
|
||||
|
||||
public void AttackTarget(Vector2 direction)
|
||||
{
|
||||
_attackDirection = direction;
|
||||
|
||||
}
|
||||
|
||||
public virtual void FixedExecute()
|
||||
{
|
||||
if (curentState == BotState.Attack && !_unitBase.IsBusy)
|
||||
{
|
||||
_unitBase.Aim(_attackDirection);
|
||||
_unitBase.StartAttack();
|
||||
curentState = AIManager.Instance.GetNewBehaviour(this);
|
||||
}
|
||||
if (currentPath.Count > 0 && !_unitBase.IsBusy)
|
||||
{
|
||||
var dir = currentPath.Dequeue();
|
||||
if (!HexManager.UnitCurrentCell.TryGetValue(_unitBase.Color, out var value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
while (value.cell == null)
|
||||
{
|
||||
dir = dir.PlusSixtyDeg();
|
||||
}
|
||||
_unitBase.Move(dir);
|
||||
}
|
||||
if(currentPath.Count == 0 && !_unitBase.IsBusy)
|
||||
{
|
||||
curentState = AIManager.Instance.GetNewBehaviour(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/AI/AIBase.cs.meta
Normal file
11
Assets/Scripts/AI/AIBase.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf76c1d50ebf01d4688b29e6ee6e240b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -32,42 +32,43 @@ namespace AI
|
||||
{
|
||||
_data = data;
|
||||
Instance = this;
|
||||
HexManager.agents = new Dictionary<GameObject, AIAgent>();
|
||||
HexManager.agents = new Dictionary<GameObject, AIBase>();
|
||||
}
|
||||
|
||||
public void AddAgent(AIAgent agent)
|
||||
public void AddAgent(AIBase agent)
|
||||
{
|
||||
agent.OnAgentInited += InitAI;
|
||||
}
|
||||
|
||||
public void RemoveAgent(AIAgent agent)
|
||||
public void RemoveAgent(AIBase agent)
|
||||
{
|
||||
agent.OnAgentInited -= InitAI;
|
||||
}
|
||||
|
||||
private void InitAI(AIAgent agent)
|
||||
private void InitAI(AIBase agent)
|
||||
{
|
||||
SetBehaviour(BotState.Patrol, agent);
|
||||
}
|
||||
|
||||
private void StartPatrolBehaviour(AIAgent agent)
|
||||
private void StartPatrolBehaviour(AIBase agent)
|
||||
{
|
||||
HexManager.GetNearestDifferCell(agent.Unit.Color, agent.currentPath);
|
||||
HexManager.GetNearestDifferCell(agent.UnitBase.Color, agent.currentPath);
|
||||
while (agent.currentPath.Count == 0 && _triesToCalculatePath < _maxTriesToCalculatePath)
|
||||
{
|
||||
HexManager.GetNearestDifferCell(agent.Unit.Color, agent.currentPath);
|
||||
HexManager.GetNearestDifferCell(agent.UnitBase.Color, agent.currentPath);
|
||||
_triesToCalculatePath++;
|
||||
}
|
||||
|
||||
_triesToCalculatePath = 0;
|
||||
}
|
||||
|
||||
public static Unit GetNearestUnit(int cellDist, Unit agent)
|
||||
public static Unit GetNearestUnit(int cellDist, UnitBase agent)
|
||||
{
|
||||
List<(float dist, Unit unit)> res = new List<(float, Unit)>();
|
||||
List<(float dist, UnitBase unit)> res = new List<(float, UnitBase)>();
|
||||
try
|
||||
{
|
||||
res.AddRange(from color in (UnitColor[])Enum.GetValues(typeof(UnitColor))
|
||||
|
||||
res.AddRange(from color in (UnitColor[]) Enum.GetValues(typeof(UnitColor))
|
||||
where HexManager.UnitCurrentCell.ContainsKey(color) &&
|
||||
HexManager.UnitCurrentCell[color].unit.IsVisible &&
|
||||
HexManager.UnitCurrentCell[color] != (null, null) &&
|
||||
@ -78,7 +79,7 @@ namespace AI
|
||||
Vector3.Distance(HexManager.UnitCurrentCell[color].unit.Instance.transform.position,
|
||||
agent.Instance.transform.position), HexManager.UnitCurrentCell[color].unit));
|
||||
|
||||
return res.Count > 0 ? res.OrderBy(x => x.Item1).First().unit : null;
|
||||
return (Unit) (res.Count > 0 ? res.OrderBy(x => x.Item1).First().unit : null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -88,28 +89,28 @@ namespace AI
|
||||
}
|
||||
|
||||
|
||||
public BotState GetNewBehaviour(AIAgent agent)
|
||||
public BotState GetNewBehaviour(AIBase agent)
|
||||
{
|
||||
var attack = agent.Unit.Inventory.Where(x => x.Item is Bonus { BonusType: BonusType.Attack }).ToList();
|
||||
if (agent.CurentState is BotState.Attack && agent.Unit.AttackBonus == 0 && attack.Count > 0)
|
||||
var attack = agent.UnitBase.Inventory.Where(x => x.Item is Bonus { BonusType: BonusType.Attack }).ToList();
|
||||
if (agent.CurentState is BotState.Attack && agent.UnitBase.AttackBonus == 0 && attack.Count > 0)
|
||||
{
|
||||
SetBehaviour(BotState.AttackBonusUsage, agent);
|
||||
return BotState.AttackBonusUsage;
|
||||
}
|
||||
|
||||
|
||||
var enemy = GetNearestUnit(_data.DistanceToAgr, agent.Unit);
|
||||
if (enemy != null && agent.Unit.Hp > agent.Unit.Data.maxHP * _data.PercentToRetreet && enemy.IsAlive)
|
||||
var enemy = GetNearestUnit(_data.DistanceToAgr, agent.UnitBase);
|
||||
if (enemy != null && agent.UnitBase.Hp > agent.UnitBase.maxHP * _data.PercentToRetreet && enemy.IsAlive)
|
||||
{
|
||||
if (agent.Unit.Hp <= agent.Unit.Data.maxHP * _data.PercentToRetreet ||
|
||||
agent.Unit.UnitView.AvailableShots == 0)
|
||||
if (agent.UnitBase.Hp <= agent.UnitBase.maxHP * _data.PercentToRetreet ||
|
||||
agent.UnitBase.UnitView.AvailableShots == 0)
|
||||
{
|
||||
SetBehaviour(BotState.Retreet, agent);
|
||||
return BotState.Retreet;
|
||||
}
|
||||
|
||||
if (Vector3.Distance(agent.Unit.Instance.transform.position, enemy.Instance.transform.position) <=
|
||||
agent.Unit.Weapon.disnatce)
|
||||
if (Vector3.Distance(agent.UnitBase.Instance.transform.position, enemy.Instance.transform.position) <=
|
||||
agent.UnitBase.Weapon.disnatce)
|
||||
{
|
||||
SetBehaviour(BotState.Attack, agent);
|
||||
return BotState.Attack;
|
||||
@ -118,25 +119,27 @@ namespace AI
|
||||
SetBehaviour(BotState.Agressive, agent);
|
||||
return BotState.Agressive;
|
||||
}
|
||||
|
||||
var item = GetNearestItem(agent);
|
||||
if (item.hex != null)
|
||||
if (agent == (AIAgent)agent)
|
||||
{
|
||||
if ((item.dist <= _data.DistaceToCollectBonus ||
|
||||
agent.Unit.Mana <= agent.Unit.Data.maxMana * _data.ManaPercentToCollectBonus) &&
|
||||
(item.hex.Item.Item.Type == ItemType.DEFENCE
|
||||
? agent.Unit.InventoryDefence.Count
|
||||
: agent.Unit.Inventory.Count) < agent.Unit.InventoryCapacity / 2)
|
||||
var item = GetNearestItem((AIAgent)agent);
|
||||
if (item.hex != null)
|
||||
{
|
||||
SetBehaviour(BotState.CollectingBonus, agent);
|
||||
return BotState.CollectingBonus;
|
||||
if ((item.dist <= _data.DistaceToCollectBonus ||
|
||||
agent.UnitBase.Mana <= agent.UnitBase.maxMana * _data.ManaPercentToCollectBonus) &&
|
||||
(item.hex.Item.Item.Type == ItemType.DEFENCE
|
||||
? agent.UnitBase.InventoryDefence.Count
|
||||
: agent.UnitBase.Inventory.Count) < agent.UnitBase.InventoryCapacity / 2)
|
||||
{
|
||||
SetBehaviour(BotState.CollectingBonus, agent);
|
||||
return BotState.CollectingBonus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var protect = agent.Unit.InventoryDefence.Where(x => x.Item is Bonus { BonusType: BonusType.Defence })
|
||||
var protect = agent.UnitBase.InventoryDefence.Where(x => x.Item is Bonus { BonusType: BonusType.Defence })
|
||||
.ToList();
|
||||
if (protect.Count > 0 && agent.Unit.Hp <= agent.Unit.Data.maxHP * _data.PercentToUseProtectBonus &&
|
||||
agent.Unit.DefenceBonus == 0)
|
||||
if (protect.Count > 0 && agent.UnitBase.Hp <= agent.UnitBase.maxHP * _data.PercentToUseProtectBonus &&
|
||||
agent.UnitBase.DefenceBonus == 0)
|
||||
{
|
||||
SetBehaviour(BotState.ProtectBonusUsage, agent);
|
||||
return BotState.ProtectBonusUsage;
|
||||
@ -147,7 +150,7 @@ namespace AI
|
||||
return BotState.Patrol;
|
||||
}
|
||||
|
||||
private void SetBehaviour(BotState state, AIAgent agent)
|
||||
private void SetBehaviour(BotState state, AIBase agent)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
@ -161,13 +164,16 @@ namespace AI
|
||||
AttackEnemy(agent);
|
||||
break;
|
||||
case BotState.CollectingBonus:
|
||||
MoveToBonus(agent);
|
||||
if (agent != (AIAgent)agent) break;
|
||||
MoveToBonus((AIAgent)agent);
|
||||
break;
|
||||
case BotState.ProtectBonusUsage:
|
||||
UseBonus(agent, BonusType.Defence);
|
||||
if (agent != (AIAgent)agent) break;
|
||||
UseBonus((AIAgent)agent, BonusType.Defence);
|
||||
break;
|
||||
case BotState.AttackBonusUsage:
|
||||
UseBonus(agent, BonusType.Attack);
|
||||
if (agent != (AIAgent)agent) break;
|
||||
UseBonus((AIAgent)agent, BonusType.Attack);
|
||||
break;
|
||||
case BotState.Dead:
|
||||
break;
|
||||
@ -181,25 +187,25 @@ namespace AI
|
||||
|
||||
private void UseBonus(AIAgent agent, BonusType type)
|
||||
{
|
||||
var attack = agent.Unit.Inventory.Where(x => x.Item is Bonus bonus && bonus.BonusType == type).ToList();
|
||||
if (attack.Count == 0 || !agent.Unit.IsAlive)
|
||||
var attack = agent.UnitBase.Inventory.Where(x => x.Item is Bonus bonus && bonus.BonusType == type).ToList();
|
||||
if (attack.Count == 0 || !agent.UnitBase.IsAlive)
|
||||
{
|
||||
GetNewBehaviour(agent);
|
||||
return;
|
||||
}
|
||||
|
||||
((Bonus)attack.First().Item).Invoke(agent.Unit);
|
||||
((Bonus)attack.First().Item).Invoke((Unit)(agent.UnitBase));
|
||||
}
|
||||
|
||||
private void Retreet(AIAgent agent)
|
||||
private void Retreet(AIBase agent)
|
||||
{
|
||||
var enemy = GetNearestUnit(6, agent.Unit)?.Instance.transform;
|
||||
var enemy = GetNearestUnit(6, agent.UnitBase)?.Instance.transform;
|
||||
if (enemy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dir = -DirectionHelper.DirectionTo(agent.Unit.Instance.transform.position,
|
||||
var dir = -DirectionHelper.DirectionTo(agent.UnitBase.Instance.transform.position,
|
||||
enemy.position);
|
||||
agent.currentPath.Clear();
|
||||
agent.currentPath.Enqueue(DirectionHelper.VectorToDirection(new Vector2(dir.x, dir.z)));
|
||||
@ -209,9 +215,9 @@ namespace AI
|
||||
{
|
||||
var itemsToMove =
|
||||
(from entry in ItemFabric.Items
|
||||
where Vector3.Distance(agent.Unit.Instance.transform.position, entry.Value.transform.position) <
|
||||
where Vector3.Distance(agent.UnitBase.Instance.transform.position, entry.Value.transform.position) <
|
||||
10 * HexGrid.HexDistance
|
||||
orderby Vector3.Distance(agent.Unit.Instance.transform.position, entry.Value.transform.position)
|
||||
orderby Vector3.Distance(agent.UnitBase.Instance.transform.position, entry.Value.transform.position)
|
||||
select entry).ToList();
|
||||
|
||||
|
||||
@ -222,35 +228,35 @@ namespace AI
|
||||
|
||||
var itemToMove = itemsToMove.First();
|
||||
return (
|
||||
(int)(Vector3.Distance(itemToMove.Value.transform.position, agent.Unit.Instance.transform.position) /
|
||||
(int)(Vector3.Distance(itemToMove.Value.transform.position, agent.UnitBase.Instance.transform.position) /
|
||||
HexGrid.HexDistance), itemToMove.Value);
|
||||
}
|
||||
|
||||
private void MoveToBonus(AIAgent agent)
|
||||
{
|
||||
if (HexManager.UnitCurrentCell.TryGetValue(agent.Unit.Color, out var value))
|
||||
if (HexManager.UnitCurrentCell.TryGetValue(agent.UnitBase.Color, out var value))
|
||||
|
||||
Pathfinding.FindPath(value.cell, GetNearestItem(agent).hex,
|
||||
agent.currentPath);
|
||||
}
|
||||
|
||||
private void AttackEnemy(AIAgent agent)
|
||||
private void AttackEnemy(AIBase agent)
|
||||
{
|
||||
var enemy = GetNearestUnit(agent.Unit.Weapon.disnatce, agent.Unit);
|
||||
var dir = DirectionHelper.DirectionTo(agent.Unit.Instance.transform.position,
|
||||
var enemy = GetNearestUnit(agent.UnitBase.Weapon.disnatce, agent.UnitBase);
|
||||
var dir = DirectionHelper.DirectionTo(agent.UnitBase.Instance.transform.position,
|
||||
enemy.Instance.transform.position);
|
||||
agent.AttackTarget(new Vector2(dir.x, dir.z));
|
||||
}
|
||||
|
||||
private void MoveToEnemy(AIAgent agent)
|
||||
private void MoveToEnemy(AIBase agent)
|
||||
{
|
||||
var enemies = HexManager.UnitCurrentCell
|
||||
.Where(unit =>
|
||||
unit.Value.unit.Color != agent.Unit.Color &&
|
||||
unit.Value.unit.Color != agent.UnitBase.Color &&
|
||||
Vector3.Distance(unit.Value.unit.Instance.transform.position,
|
||||
agent.Unit.Instance.transform.position) <= 6 * HexGrid.HexDistance).ToList();
|
||||
agent.UnitBase.Instance.transform.position) <= 6 * HexGrid.HexDistance).ToList();
|
||||
|
||||
Pathfinding.FindPath(HexManager.UnitCurrentCell[agent.Unit.Color].cell,
|
||||
Pathfinding.FindPath(HexManager.UnitCurrentCell[agent.UnitBase.Color].cell,
|
||||
enemies[Random.Range(0, enemies.Count)].Value.cell, agent.currentPath);
|
||||
}
|
||||
}
|
||||
|
20
Assets/Scripts/AI/AIPatrol.cs
Normal file
20
Assets/Scripts/AI/AIPatrol.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using AI;
|
||||
using HexFiled;
|
||||
using Units;
|
||||
|
||||
namespace DefaultNamespace.AI
|
||||
{
|
||||
public class AIPatrol : AIBase
|
||||
{
|
||||
public AIPatrol(UnitBase unitBase) : base(unitBase)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitAgent(UnitBase aiBase)
|
||||
{
|
||||
AIManager.Instance.AddAgent(this);
|
||||
HexManager.agents.Add(aiBase.Instance, this);
|
||||
OnAgentInited?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/AI/AIPatrol.cs.meta
Normal file
11
Assets/Scripts/AI/AIPatrol.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bef0c79296c67c4478be65e6574b766b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -8,6 +8,7 @@ using GameUI;
|
||||
using HexFiled;
|
||||
using Items;
|
||||
using Units;
|
||||
using Units.Wariors;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
using Random = UnityEngine.Random;
|
||||
@ -35,12 +36,15 @@ namespace Controller
|
||||
|
||||
|
||||
var unitFactory = new UnitFactory(hexGrid, data, uiController, paintedController, controllers);
|
||||
var wariorFactory = new WariorFactory(hexGrid, controllers, data);
|
||||
|
||||
hexGrid.OnGridLoaded += () => unitFactory.SpawnList(data.UnitData.Units);
|
||||
|
||||
|
||||
hexGrid.OnHexPainted += paintedController.SetHexColors;
|
||||
|
||||
hexGrid.SpawnField();
|
||||
unitFactory.Player.OnShoot += wariorFactory.Spawn;
|
||||
unitFactory.Player.wariorInfo = data.UnitData.Warior[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace Data
|
||||
public class UnitData : ScriptableObject
|
||||
{
|
||||
[SerializeField] private List<UnitInfo> _units;
|
||||
[SerializeField] private List<WariorInfo> _warior;
|
||||
[SerializeField] private BarCanvas playerBarCanvas;
|
||||
[SerializeField] private BarCanvas botBarCanvas;
|
||||
[SerializeField] private GameObject attackAimCanvas;
|
||||
@ -22,6 +23,8 @@ namespace Data
|
||||
|
||||
public List<UnitInfo> Units => _units;
|
||||
|
||||
public List<WariorInfo> Warior => _warior;
|
||||
|
||||
public BarCanvas PlayerBarCanvas => playerBarCanvas;
|
||||
|
||||
public BarCanvas BotBarCanvas => botBarCanvas;
|
||||
@ -40,5 +43,16 @@ namespace Data
|
||||
public int maxHP;
|
||||
public int inventoryCapacity;
|
||||
public Material InvisibleMaterial;
|
||||
}
|
||||
public partial struct WariorInfo
|
||||
{
|
||||
public HexCoordinates spawnPos;
|
||||
public GameObject wariorPrefa;
|
||||
public UnitColor color;
|
||||
public int manaRegen;
|
||||
public int maxMana;
|
||||
public int maxHP;
|
||||
public Material InvisibleMaterial;
|
||||
internal int inventoryCapacity;
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ namespace Data
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct WariorInfo
|
||||
public partial struct WariorInfo
|
||||
{
|
||||
[SerializeField] private GameObject prefab;
|
||||
[SerializeField] private WariorType Type;
|
||||
|
@ -12,9 +12,9 @@ namespace HexFiled
|
||||
{
|
||||
public static class HexManager
|
||||
{
|
||||
public static Dictionary<UnitColor, (HexCell cell, Unit unit)> UnitCurrentCell;
|
||||
public static Dictionary<UnitColor, (HexCell cell, UnitBase unit)> UnitCurrentCell;
|
||||
public static Dictionary<UnitColor, List<HexCell>> CellByColor;
|
||||
public static Dictionary<GameObject, AIAgent> agents;
|
||||
public static Dictionary<GameObject, AIBase> agents;
|
||||
|
||||
public static void GetNearestDifferCell(UnitColor color, Queue<HexDirection> path)
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace HexFiled
|
||||
|
||||
public PaintedController()
|
||||
{
|
||||
HexManager.UnitCurrentCell = new Dictionary<UnitColor, (HexCell cell, Unit unit)>();
|
||||
HexManager.UnitCurrentCell = new Dictionary<UnitColor, (HexCell cell, UnitBase unit)>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using DefaultNamespace;
|
||||
using HexFiled;
|
||||
using Units;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@ -68,7 +69,8 @@ namespace Items
|
||||
var obj = Instantiate(buildingPrefab,
|
||||
cell.transform.position + buildingPrefab.transform.position, Quaternion.identity);
|
||||
obj.GetComponent<ISetUp>().SetUp(container.Unit);
|
||||
if (!container.Unit.IsPlayer)
|
||||
var unit = (Unit) container.Unit;
|
||||
if (!unit.IsPlayer)
|
||||
{
|
||||
obj.transform.GetChilds().Where(x => !x.TryGetComponent(typeof(ISetUp), out _))
|
||||
.Select(x => x.gameObject).ToList()
|
||||
|
@ -16,7 +16,7 @@ namespace Items
|
||||
|
||||
public ItemView Instance => _instance;
|
||||
|
||||
public Unit Unit { get; }
|
||||
public UnitBase Unit { get; }
|
||||
|
||||
public GameObject AimInstance { get; set; }
|
||||
|
||||
@ -24,9 +24,9 @@ namespace Items
|
||||
|
||||
public Vector2 Direction { get; set; }
|
||||
|
||||
public Unit Value { get; set; }
|
||||
public UnitBase Value { get; set; }
|
||||
|
||||
public ItemContainer(Item item, ItemView instance, Unit unit)
|
||||
public ItemContainer(Item item, ItemView instance, UnitBase unit)
|
||||
{
|
||||
Item = item;
|
||||
_instance = instance;
|
||||
|
@ -2,6 +2,7 @@ using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Units;
|
||||
using Units.Views;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Items.ItemViews
|
||||
@ -12,7 +13,7 @@ namespace Items.ItemViews
|
||||
[SerializeField] private float duration;
|
||||
[SerializeField]private UnitColor color;
|
||||
|
||||
public void SetUp(Unit unit)
|
||||
public void SetUp(UnitBase unit)
|
||||
{
|
||||
color = unit.Color;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using DefaultNamespace;
|
||||
using HexFiled;
|
||||
using Units;
|
||||
using Units.Views;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Items
|
||||
@ -11,10 +12,10 @@ namespace Items
|
||||
[SerializeField] private int damage;
|
||||
[SerializeField] private GameObject hit;
|
||||
[SerializeField] private float timeHit;
|
||||
private Unit _unit;
|
||||
private UnitBase _unit;
|
||||
|
||||
|
||||
public void SetUp(Unit unit)
|
||||
public void SetUp(UnitBase unit)
|
||||
{
|
||||
_unit = unit;
|
||||
gameObject.AddComponent<CapsuleCollider>().radius = HexGrid.HexDistance;
|
||||
|
@ -4,6 +4,6 @@ namespace Items
|
||||
{
|
||||
public interface ISetUp
|
||||
{
|
||||
public void SetUp(Unit unit);
|
||||
public void SetUp(UnitBase unit);
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ namespace Items.ItemViews
|
||||
Rotate();
|
||||
}
|
||||
|
||||
public void PickUp(Unit unit)
|
||||
public void PickUp(UnitBase unit)
|
||||
{
|
||||
if (_item is Bonus { BonusType: BonusType.Heal } bonus)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ namespace Items.ItemViews
|
||||
[SerializeField] private UnitColor _color;
|
||||
[SerializeField] private float speed;
|
||||
|
||||
public void SetUp(Unit unit)
|
||||
public void SetUp(UnitBase unit)
|
||||
{
|
||||
_unit = unit.Instance;
|
||||
_color = unit.Color;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using DefaultNamespace;
|
||||
using Units;
|
||||
using Units.Views;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
@ -13,9 +14,9 @@ namespace Items.ItemViews
|
||||
[SerializeField] private int time;
|
||||
[SerializeField] private GameObject catchVfx;
|
||||
[SerializeField] private GameObject destroed;
|
||||
private Unit _unit;
|
||||
private UnitBase _unit;
|
||||
|
||||
public void SetUp(Unit unit)
|
||||
public void SetUp(UnitBase unit)
|
||||
{
|
||||
_unit = unit;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Linq;
|
||||
using DefaultNamespace;
|
||||
using HexFiled;
|
||||
using Units;
|
||||
using Units.Views;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
@ -13,11 +14,11 @@ namespace Items.ItemViews
|
||||
[SerializeField] private GameObject Hit;
|
||||
[SerializeField] private GameObject vfx;
|
||||
[SerializeField] private int dmg;
|
||||
private Unit _unit;
|
||||
private UnitBase _unit;
|
||||
private GameObject _instance;
|
||||
|
||||
|
||||
public void SetUp(Unit unit)
|
||||
public void SetUp(UnitBase unit)
|
||||
{
|
||||
_unit = unit;
|
||||
_instance = Instantiate(vfx, transform);
|
||||
|
@ -7,6 +7,7 @@ using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Items;
|
||||
using Units;
|
||||
using Units.Views;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
@ -29,7 +30,7 @@ public class TowerView : MonoBehaviour, ISetUp
|
||||
|
||||
public UnitColor Color => _color;
|
||||
|
||||
public void SetUp(Unit unit)
|
||||
public void SetUp(UnitBase unit)
|
||||
{
|
||||
_color = unit.Color;
|
||||
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using DefaultNamespace;
|
||||
using HexFiled;
|
||||
using Units;
|
||||
using Units.Views;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@ -13,16 +14,16 @@ namespace Items
|
||||
[SerializeField] private GameObject aimCanvas;
|
||||
[SerializeField] private LayerMask _layerMask;
|
||||
[SerializeField] private float time;
|
||||
|
||||
|
||||
|
||||
|
||||
public override void Invoke(ItemContainer container)
|
||||
{
|
||||
if (!container.Unit.IsPlayer)
|
||||
var unit = (Unit) container.Unit;
|
||||
if (!unit.IsPlayer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (container.AimInstance == null)
|
||||
container.AimInstance = Object.Instantiate(aimCanvas, container.Unit.Instance.transform);
|
||||
@ -31,7 +32,8 @@ namespace Items
|
||||
|
||||
public void Aim(Vector2 direction, ItemContainer container)
|
||||
{
|
||||
if (container.Unit.IsPlayer)
|
||||
var unit = (Unit) container.Unit;
|
||||
if (unit.IsPlayer)
|
||||
{
|
||||
if (container.AimInstance == null)
|
||||
container.AimInstance = Object.Instantiate(aimCanvas, container.Unit.Instance.transform);
|
||||
@ -50,7 +52,6 @@ namespace Items
|
||||
container.Value = hit.collider.gameObject.GetComponent<UnitView>().Unit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Debug.DrawRay(ray.origin,
|
||||
ray.direction * hit.distance, UnityEngine.Color.red, 10f);
|
||||
@ -64,6 +65,7 @@ namespace Items
|
||||
container.DeAim();
|
||||
return;
|
||||
}
|
||||
|
||||
container.Unit.UseItem(this);
|
||||
container.Unit.isSwitched = true;
|
||||
container.DeAim();
|
||||
@ -84,7 +86,5 @@ namespace Items
|
||||
container.Value.IsBusy = false;
|
||||
}, time);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ using HexFiled;
|
||||
using Items;
|
||||
using Runtime.Controller;
|
||||
using Units;
|
||||
using Units.Views;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@ -40,7 +41,7 @@ namespace Chars
|
||||
_attackJoystick = joyView.AttackJoystick;
|
||||
_placeJoystick = joyView.PlaceJoystick;
|
||||
_placeJoystick.gameObject.SetActive(false);
|
||||
_unitView = unit.UnitView;
|
||||
_unitView = (UnitView) unit.UnitView;
|
||||
|
||||
_attackJoystick.OnTouchUp += DoAttack;
|
||||
_attackJoystick.OnDrug += AimCanvas;
|
||||
@ -163,7 +164,7 @@ namespace Chars
|
||||
switchingPlaces.Aim(placeDir.normalized, _itemToPlace);
|
||||
if (_itemToPlace.Value != null)
|
||||
{
|
||||
chosenUnit = _itemToPlace.Value;
|
||||
chosenUnit = (Unit) _itemToPlace.Value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2,13 +2,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AI;
|
||||
using Chars;
|
||||
using Data;
|
||||
using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Items;
|
||||
using Sirenix.Utilities;
|
||||
using Units.Views;
|
||||
using Units.Wariors;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
using Object = UnityEngine.Object;
|
||||
@ -16,124 +17,29 @@ using Object = UnityEngine.Object;
|
||||
|
||||
namespace Units
|
||||
{
|
||||
public class Unit
|
||||
public class Unit : UnitBase
|
||||
{
|
||||
private GameObject _instance;
|
||||
private List<ItemContainer> _inventory;
|
||||
private List<ItemContainer> _inventoryDefence;
|
||||
private AnimLength _animLength;
|
||||
private HexCell _cell;
|
||||
private HexGrid _hexGrid;
|
||||
public event Action<Unit> OnPlayerSpawned;
|
||||
private Animator _animator;
|
||||
private UnitInfo _data;
|
||||
private int _hp;
|
||||
private int _mana;
|
||||
private Weapon _weapon;
|
||||
private Vector2 _direction;
|
||||
|
||||
private bool _isCapturing;
|
||||
private bool _isInfiniteMana;
|
||||
|
||||
private int _defenceBonus;
|
||||
private Camera _camera;
|
||||
private UnitColor _easyCaptureColor;
|
||||
|
||||
public bool IsStaned;
|
||||
public bool isSwitched;
|
||||
public int AttackBonus => _weapon.modifiedDamage - _weapon.damage;
|
||||
|
||||
|
||||
public int DefenceBonus => _defenceBonus;
|
||||
|
||||
public bool IsBusy { get; set; }
|
||||
|
||||
public UnitView UnitView { get; private set; }
|
||||
|
||||
public bool IsAlive { get; private set; }
|
||||
|
||||
public bool IsHardToCapture { get; private set; }
|
||||
|
||||
|
||||
public UnitColor Color => _data.color;
|
||||
public int InventoryCapacity => _data.inventoryCapacity;
|
||||
public event Action<ItemContainer> OnItemPickUp;
|
||||
public event Action<Unit> OnDeath;
|
||||
public BarCanvas BarCanvas => UnitView.BarCanvas;
|
||||
public GameObject Instance => _instance;
|
||||
public UnitInfo Data => _data;
|
||||
public int Mana => _mana;
|
||||
public int Hp => _hp;
|
||||
public List<ItemContainer> Inventory => _inventory;
|
||||
public List<ItemContainer> InventoryDefence => _inventoryDefence;
|
||||
public Weapon Weapon => _weapon;
|
||||
public WariorInfo wariorInfo;
|
||||
public WariorFactory wariorFactory;
|
||||
public bool IsPlayer => _data.isPlayer;
|
||||
public Animator Animator => _animator;
|
||||
public event Action<ItemContainer> OnItemPickUp;
|
||||
public event Action<WariorInfo,UnitColor> OnShoot;
|
||||
|
||||
public bool IsVisible
|
||||
|
||||
public Unit(UnitInfo data, Weapon weapon, HexGrid hexGrid)
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
Initialize(weapon, hexGrid);
|
||||
_data = data;
|
||||
Color = _data.color;
|
||||
maxHP = _data.maxHP;
|
||||
maxMana = _data.maxMana;
|
||||
InventoryCapacity = _data.inventoryCapacity;
|
||||
|
||||
}
|
||||
|
||||
public Unit(UnitInfo unitData, Weapon weapon, HexGrid hexGrid)
|
||||
{
|
||||
_camera = Camera.main;
|
||||
_weapon = weapon;
|
||||
_data = unitData;
|
||||
IsAlive = false;
|
||||
_hexGrid = hexGrid;
|
||||
IsBusy = false;
|
||||
IsHardToCapture = false;
|
||||
_isCapturing = false;
|
||||
_easyCaptureColor = UnitColor.Grey;
|
||||
}
|
||||
|
||||
public void SetUpBonus(float duration, int value, BonusType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case BonusType.Attack:
|
||||
TimerHelper.Instance.StartTimer(() => _weapon.SetModifiedDamage(0), duration);
|
||||
_weapon.SetModifiedDamage(value);
|
||||
break;
|
||||
case BonusType.Defence:
|
||||
TimerHelper.Instance.StartTimer(() => _defenceBonus = 0, duration);
|
||||
_defenceBonus = value;
|
||||
break;
|
||||
case BonusType.Heal:
|
||||
break;
|
||||
case BonusType.Magnet:
|
||||
var col = UnitView.gameObject.GetComponent<CapsuleCollider>();
|
||||
var defRadius = col.radius;
|
||||
col.radius = value * HexGrid.HexDistance;
|
||||
TimerHelper.Instance.StartTimer(() => col.radius = defRadius, duration);
|
||||
break;
|
||||
case BonusType.Mana:
|
||||
_isInfiniteMana = true;
|
||||
TimerHelper.Instance.StartTimer(() => _isInfiniteMana = false, duration);
|
||||
break;
|
||||
case BonusType.Invisible:
|
||||
IsVisible = false;
|
||||
UnitView.SetInvisible(IsVisible);
|
||||
TimerHelper.Instance.StartTimer(() =>
|
||||
{
|
||||
IsVisible = true;
|
||||
UnitView.SetInvisible(IsVisible);
|
||||
}, duration);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTimeScale(float scale)
|
||||
{
|
||||
_animator.speed = scale;
|
||||
|
||||
}
|
||||
|
||||
public void Retreet(HexDirection dir)
|
||||
public override void Retreet(HexDirection dir)
|
||||
{
|
||||
if (!_isCapturing) return;
|
||||
var openList = _cell.GetListNeighbours().Where(x => x != null && x.Color == _data.color).ToList();
|
||||
@ -148,7 +54,7 @@ namespace Units
|
||||
Move(dir);
|
||||
}
|
||||
|
||||
public void Move(HexDirection direction)
|
||||
public override void Move(HexDirection direction)
|
||||
{
|
||||
if (_cell.GetNeighbor(direction) == null || _cell.GetNeighbor(direction).BuildingInstance != null ||
|
||||
IsBusy || IsHardToCapture ||
|
||||
@ -176,7 +82,7 @@ namespace Units
|
||||
}
|
||||
}
|
||||
|
||||
private void DoTransit(HexDirection direction)
|
||||
protected override void DoTransit(HexDirection direction)
|
||||
{
|
||||
IsBusy = true;
|
||||
_isCapturing = _data.color != _cell.GetNeighbor(direction).Color;
|
||||
@ -189,7 +95,7 @@ namespace Units
|
||||
_instance.transform.DOMove(_cell.transform.position, _animLength.Move);
|
||||
}
|
||||
|
||||
public void SetCell(HexCell cell, bool isInstanceTrans = false, bool isPaintingHex = false)
|
||||
public override void SetCell(HexCell cell, bool isInstanceTrans = false, bool isPaintingHex = false)
|
||||
{
|
||||
_cell = cell;
|
||||
HexManager.UnitCurrentCell[Color] = (cell, this);
|
||||
@ -208,21 +114,9 @@ namespace Units
|
||||
{
|
||||
cell.PaintHex(Color, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void SetEasyColor(UnitColor color, float time)
|
||||
{
|
||||
_easyCaptureColor = color;
|
||||
if (time > 0f)
|
||||
{
|
||||
TimerHelper.Instance.StartTimer(() => _easyCaptureColor = UnitColor.Grey, time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CaptureHex()
|
||||
protected override void CaptureHex()
|
||||
{
|
||||
if (!_isInfiniteMana)
|
||||
{
|
||||
@ -237,7 +131,7 @@ namespace Units
|
||||
}
|
||||
|
||||
UnitView.RegenMana();
|
||||
|
||||
|
||||
|
||||
UpdateBarCanvas();
|
||||
IsBusy = false;
|
||||
@ -245,32 +139,7 @@ namespace Units
|
||||
_cell.PaintHex(_data.color);
|
||||
}
|
||||
|
||||
private void SetAnimLength()
|
||||
{
|
||||
AnimationClip[] clips = _animator.runtimeAnimatorController.animationClips;
|
||||
foreach (var clip in clips)
|
||||
{
|
||||
switch (clip.name)
|
||||
{
|
||||
case "MoveJump":
|
||||
_animLength.Move = clip.length;
|
||||
break;
|
||||
case "Attack":
|
||||
_animLength.Attack = clip.length;
|
||||
break;
|
||||
case "Dead":
|
||||
_animLength.Death = clip.length;
|
||||
break;
|
||||
case "SuperAttack":
|
||||
_animLength.SuperJump = clip.length;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Spawn(HexCoordinates hexCoordinates, HexCell spawnCell = null)
|
||||
public override void Spawn(HexCoordinates hexCoordinates, HexCell spawnCell = null)
|
||||
{
|
||||
if (!IsAlive)
|
||||
{
|
||||
@ -302,17 +171,17 @@ namespace Units
|
||||
_weapon.SetModifiedDamage(0);
|
||||
|
||||
IsBusy = false;
|
||||
OnPlayerSpawned?.Invoke(this);
|
||||
OnOnPlayerSpawned(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void RegenMana()
|
||||
protected override void RegenMana()
|
||||
{
|
||||
_mana += _data.manaRegen;
|
||||
UpdateBarCanvas();
|
||||
}
|
||||
|
||||
public bool CanPickUpItem(Item item)
|
||||
public override bool CanPickUpItem(Item item)
|
||||
{
|
||||
switch (item.Type)
|
||||
{
|
||||
@ -337,7 +206,7 @@ namespace Units
|
||||
return false;
|
||||
}
|
||||
|
||||
public void PickUpItem(ItemContainer item)
|
||||
public override void PickUpItem(ItemContainer item)
|
||||
{
|
||||
switch (item.Item.Type)
|
||||
{
|
||||
@ -360,65 +229,20 @@ namespace Units
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
OnItemPickUp?.Invoke(item);
|
||||
}
|
||||
|
||||
public void UseItem(Item item)
|
||||
{
|
||||
if (item.Type == ItemType.ATTACK)
|
||||
{
|
||||
var i = _inventory.First(i => i.Item == item);
|
||||
_inventory.Remove(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
var i = _inventoryDefence.First(i => i.Item == item);
|
||||
_inventoryDefence.Remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveEnd()
|
||||
{
|
||||
IsBusy = false;
|
||||
_animator.SetBool("isMoving", IsBusy);
|
||||
|
||||
if (!_isCapturing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsHardToCapture)
|
||||
{
|
||||
UnitView.HardCaptureHex(_cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
CaptureHex();
|
||||
}
|
||||
}
|
||||
|
||||
private void AttackEnd()
|
||||
{
|
||||
IsBusy = false;
|
||||
UpdateBarCanvas();
|
||||
}
|
||||
|
||||
private void Attacking()
|
||||
protected override void Attacking()
|
||||
{
|
||||
Aim(_direction);
|
||||
|
||||
_weapon.Fire(_instance.transform, _direction, this);
|
||||
if(IsPlayer)
|
||||
OnShoot.Invoke(wariorInfo,_data.color);
|
||||
}
|
||||
|
||||
private void SetUpActions()
|
||||
{
|
||||
UnitView.OnStep += MoveEnd;
|
||||
UnitView.OnAttackEnd += AttackEnd;
|
||||
UnitView.OnAttack += Attacking;
|
||||
UnitView.OnHit += Damage;
|
||||
}
|
||||
|
||||
private void UpdateBarCanvas()
|
||||
protected override void UpdateBarCanvas()
|
||||
{
|
||||
if (_hp > _data.maxHP)
|
||||
_hp = _data.maxHP;
|
||||
@ -433,7 +257,7 @@ namespace Units
|
||||
BarCanvas.HealthBar.DOFillAmount(hp / maxHp, 0.5f).SetEase(Ease.InQuad);
|
||||
}
|
||||
|
||||
public void Death()
|
||||
public override void Death()
|
||||
{
|
||||
UnitView.OnStep -= MoveEnd;
|
||||
UnitView.OnAttackEnd -= AttackEnd;
|
||||
@ -448,20 +272,18 @@ namespace Units
|
||||
_instance.transform.position);
|
||||
TimerHelper.Instance.StartTimer(() =>
|
||||
{
|
||||
|
||||
HexManager.PaintHexList(hexToPaint.Where(x => x.Color == Color).ToList(), UnitColor.Grey);
|
||||
|
||||
Object.Destroy(_instance);
|
||||
OnDeath?.Invoke(this);
|
||||
OnOnDeath(this);
|
||||
}, _animLength.Death);
|
||||
|
||||
|
||||
MusicController.Instance.AddAudioSource(vfx);
|
||||
MusicController.Instance.PlayAudioClip(MusicController.Instance.MusicData.SfxMusic.Death, vfx);
|
||||
MusicController.Instance.RemoveAudioSource(_instance);
|
||||
}
|
||||
|
||||
|
||||
public void StartAttack()
|
||||
public override void StartAttack()
|
||||
{
|
||||
if (IsBusy || !UnitView.Shoot()) return;
|
||||
|
||||
@ -484,22 +306,7 @@ namespace Units
|
||||
_animator.SetTrigger("Attack");
|
||||
}
|
||||
|
||||
public void RotateUnit(Vector2 direction)
|
||||
{
|
||||
UnitView.transform.DOLookAt(new Vector3(direction.x, 0, direction.y) + UnitView.transform.position,
|
||||
0.1f).onUpdate += () => BarCanvas.transform.LookAt(
|
||||
BarCanvas.transform.position + _camera.transform.rotation * Vector3.back,
|
||||
_camera.transform.rotation * Vector3.up);
|
||||
}
|
||||
|
||||
public void Aim(Vector2 direction)
|
||||
{
|
||||
UnitView.AimCanvas.transform.LookAt(
|
||||
new Vector3(direction.x, 0, direction.y) + UnitView.transform.position);
|
||||
_direction = direction;
|
||||
}
|
||||
|
||||
public HexCell PlaceItemAim(HexDirection direction)
|
||||
public override HexCell PlaceItemAim(HexDirection direction)
|
||||
{
|
||||
if (_cell.GetNeighbor(direction).Color != Color)
|
||||
{
|
||||
@ -512,7 +319,7 @@ namespace Units
|
||||
return cell;
|
||||
}
|
||||
|
||||
private void Damage(int dmg)
|
||||
protected override void Damage(int dmg)
|
||||
{
|
||||
if (_defenceBonus == 0 && _hp - dmg <= 0f)
|
||||
{
|
||||
|
272
Assets/Scripts/Units/UnitBase.cs
Normal file
272
Assets/Scripts/Units/UnitBase.cs
Normal file
@ -0,0 +1,272 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Chars;
|
||||
using Data;
|
||||
using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Items;
|
||||
using Units.Views;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
namespace Units
|
||||
{
|
||||
public abstract class UnitBase
|
||||
{
|
||||
public event Action<UnitBase> OnSpawned;
|
||||
public event Action<UnitBase> OnDeath;
|
||||
protected GameObject _instance;
|
||||
protected List<ItemContainer> _inventory;
|
||||
protected List<ItemContainer> _inventoryDefence;
|
||||
protected AnimLength _animLength;
|
||||
protected HexCell _cell;
|
||||
protected HexGrid _hexGrid;
|
||||
protected Animator _animator;
|
||||
protected int _hp;
|
||||
protected int _mana;
|
||||
public int maxMana { protected set; get; }
|
||||
public int maxHP { protected set; get; }
|
||||
public int InventoryCapacity { protected set; get; }
|
||||
|
||||
|
||||
protected Weapon _weapon;
|
||||
protected Vector2 _direction;
|
||||
|
||||
protected bool _isCapturing;
|
||||
protected bool _isInfiniteMana;
|
||||
|
||||
protected int _defenceBonus;
|
||||
private Camera _camera;
|
||||
protected UnitColor _easyCaptureColor;
|
||||
public UnitColor Color { get; protected set; }
|
||||
|
||||
public bool IsStaned;
|
||||
public bool isSwitched;
|
||||
public int AttackBonus => _weapon.modifiedDamage - _weapon.damage;
|
||||
|
||||
|
||||
public int DefenceBonus => _defenceBonus;
|
||||
|
||||
public bool IsBusy { get; set; }
|
||||
|
||||
public bool IsAlive { get; protected set; }
|
||||
|
||||
public bool IsHardToCapture { get; protected set; }
|
||||
|
||||
|
||||
|
||||
public BarCanvas BarCanvas => UnitView.BarCanvas;
|
||||
public GameObject Instance => _instance;
|
||||
public int Mana => _mana;
|
||||
public ViewBase UnitView { get; protected set; }
|
||||
|
||||
public int Hp => _hp;
|
||||
public List<ItemContainer> Inventory => _inventory;
|
||||
public List<ItemContainer> InventoryDefence => _inventoryDefence;
|
||||
public Weapon Weapon => _weapon;
|
||||
public Animator Animator => _animator;
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
|
||||
public virtual void Initialize(Weapon weapon, HexGrid hexGrid)
|
||||
{
|
||||
_camera = Camera.main;
|
||||
_weapon = weapon;
|
||||
IsAlive = false;
|
||||
_hexGrid = hexGrid;
|
||||
IsBusy = false;
|
||||
IsHardToCapture = false;
|
||||
_isCapturing = false;
|
||||
_easyCaptureColor = UnitColor.Grey;
|
||||
}
|
||||
|
||||
public virtual void SetUpBonus(float duration, int value, BonusType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case BonusType.Attack:
|
||||
TimerHelper.Instance.StartTimer(() => _weapon.SetModifiedDamage(0), duration);
|
||||
_weapon.SetModifiedDamage(value);
|
||||
break;
|
||||
case BonusType.Defence:
|
||||
TimerHelper.Instance.StartTimer(() => _defenceBonus = 0, duration);
|
||||
_defenceBonus = value;
|
||||
break;
|
||||
case BonusType.Heal:
|
||||
break;
|
||||
case BonusType.Magnet:
|
||||
var col = UnitView.gameObject.GetComponent<CapsuleCollider>();
|
||||
var defRadius = col.radius;
|
||||
col.radius = value * HexGrid.HexDistance;
|
||||
TimerHelper.Instance.StartTimer(() => col.radius = defRadius, duration);
|
||||
break;
|
||||
case BonusType.Mana:
|
||||
_isInfiniteMana = true;
|
||||
TimerHelper.Instance.StartTimer(() => _isInfiniteMana = false, duration);
|
||||
break;
|
||||
case BonusType.Invisible:
|
||||
IsVisible = false;
|
||||
UnitView.SetInvisible(IsVisible);
|
||||
TimerHelper.Instance.StartTimer(() =>
|
||||
{
|
||||
IsVisible = true;
|
||||
UnitView.SetInvisible(IsVisible);
|
||||
}, duration);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTimeScale(float scale)
|
||||
{
|
||||
_animator.speed = scale;
|
||||
|
||||
}
|
||||
|
||||
public abstract void Retreet(HexDirection dir);
|
||||
|
||||
public abstract void Move(HexDirection direction);
|
||||
|
||||
protected abstract void DoTransit(HexDirection direction);
|
||||
|
||||
public abstract void SetCell(HexCell cell, bool isInstanceTrans = false, bool isPaintingHex = false);
|
||||
|
||||
public void SetEasyColor(UnitColor color, float time)
|
||||
{
|
||||
_easyCaptureColor = color;
|
||||
if (time > 0f)
|
||||
{
|
||||
TimerHelper.Instance.StartTimer(() => _easyCaptureColor = UnitColor.Grey, time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected abstract void CaptureHex();
|
||||
|
||||
protected void SetAnimLength()
|
||||
{
|
||||
AnimationClip[] clips = _animator.runtimeAnimatorController.animationClips;
|
||||
foreach (var clip in clips)
|
||||
{
|
||||
switch (clip.name)
|
||||
{
|
||||
case "MoveJump":
|
||||
_animLength.Move = clip.length;
|
||||
break;
|
||||
case "Attack":
|
||||
_animLength.Attack = clip.length;
|
||||
break;
|
||||
case "Dead":
|
||||
_animLength.Death = clip.length;
|
||||
break;
|
||||
case "SuperAttack":
|
||||
_animLength.SuperJump = clip.length;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Spawn(HexCoordinates hexCoordinates, HexCell spawnCell = null);
|
||||
|
||||
protected abstract void RegenMana();
|
||||
|
||||
public abstract bool CanPickUpItem(Item item);
|
||||
|
||||
public abstract void PickUpItem(ItemContainer item);
|
||||
|
||||
public void UseItem(Item item)
|
||||
{
|
||||
if (item.Type == ItemType.ATTACK)
|
||||
{
|
||||
var i = _inventory.First(i => i.Item == item);
|
||||
_inventory.Remove(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
var i = _inventoryDefence.First(i => i.Item == item);
|
||||
_inventoryDefence.Remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
protected void MoveEnd()
|
||||
{
|
||||
IsBusy = false;
|
||||
_animator.SetBool("isMoving", IsBusy);
|
||||
|
||||
if (!_isCapturing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsHardToCapture)
|
||||
{
|
||||
UnitView.HardCaptureHex(_cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
CaptureHex();
|
||||
}
|
||||
}
|
||||
|
||||
protected void AttackEnd()
|
||||
{
|
||||
IsBusy = false;
|
||||
UpdateBarCanvas();
|
||||
}
|
||||
|
||||
protected abstract void Attacking();
|
||||
|
||||
protected void SetUpActions()
|
||||
{
|
||||
UnitView.OnStep += MoveEnd;
|
||||
UnitView.OnAttackEnd += AttackEnd;
|
||||
UnitView.OnAttack += Attacking;
|
||||
UnitView.OnHit += Damage;
|
||||
}
|
||||
|
||||
protected abstract void UpdateBarCanvas();
|
||||
|
||||
public abstract void Death();
|
||||
|
||||
|
||||
public abstract void StartAttack();
|
||||
|
||||
public void RotateUnit(Vector2 direction)
|
||||
{
|
||||
UnitView.transform.DOLookAt(new Vector3(direction.x, 0, direction.y) + UnitView.transform.position,
|
||||
0.1f).onUpdate += () => BarCanvas.transform.LookAt(
|
||||
BarCanvas.transform.position + _camera.transform.rotation * Vector3.back,
|
||||
_camera.transform.rotation * Vector3.up);
|
||||
}
|
||||
|
||||
public void Aim(Vector2 direction)
|
||||
{
|
||||
UnitView.AimCanvas.transform.LookAt(
|
||||
new Vector3(direction.x, 0, direction.y) + UnitView.transform.position);
|
||||
_direction = direction;
|
||||
}
|
||||
|
||||
public abstract HexCell PlaceItemAim(HexDirection direction);
|
||||
|
||||
protected abstract void Damage(int dmg);
|
||||
|
||||
protected virtual void OnOnPlayerSpawned(UnitBase obj)
|
||||
{
|
||||
OnSpawned?.Invoke(obj);
|
||||
}
|
||||
|
||||
protected virtual void OnOnDeath(UnitBase obj)
|
||||
{
|
||||
OnDeath?.Invoke(obj);
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/Units/UnitBase.cs.meta
Normal file
3
Assets/Scripts/Units/UnitBase.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89de54cb85e441cc96c7f3b8a4dfc10a
|
||||
timeCreated: 1646881504
|
@ -20,6 +20,7 @@ namespace Chars
|
||||
private readonly Data.Data _data;
|
||||
private readonly Controllers _controllers;
|
||||
private readonly UIController _uiController;
|
||||
public Unit Player { get; private set; }
|
||||
|
||||
public UnitFactory(HexGrid grid, Data.Data data, UIController uiController, PaintedController paintedController,
|
||||
Controllers controllers)
|
||||
@ -59,7 +60,7 @@ namespace Chars
|
||||
new CameraControl(Camera.main, _data.CameraData);
|
||||
_controllers.Add(cameraControl);
|
||||
|
||||
player.OnPlayerSpawned += p =>
|
||||
player.OnSpawned += p =>
|
||||
{
|
||||
playerControl = new PlayerControl(player, _uiController.PlayerControlView,
|
||||
_uiController.PlayerInventoryView);
|
||||
@ -67,10 +68,10 @@ namespace Chars
|
||||
};
|
||||
|
||||
|
||||
player.OnPlayerSpawned += unit => _uiController.CheatMenu.SetPlayerNData(unit, _data);
|
||||
player.OnSpawned += unit => _uiController.CheatMenu.SetPlayerNData((Unit)unit, _data);
|
||||
player.OnDeath += unit1 => _controllers.Remove(playerControl);
|
||||
player.OnDeath += u => playerControl.Dispose();
|
||||
player.OnPlayerSpawned += unit => cameraControl.InitCameraControl(unit.Instance);
|
||||
player.OnSpawned += unit => cameraControl.InitCameraControl(unit.Instance);
|
||||
player.OnDeath += unit => _uiController.CheatMenu.OnPlayerDeath();
|
||||
|
||||
player.OnDeath += p => _uiController.AdsMob.ShowCanvas(unitInfo, this);
|
||||
@ -78,6 +79,7 @@ namespace Chars
|
||||
player.Spawn(spawnPos.coordinates, spawnPos);
|
||||
spawnPos.isSpawnPos = false;
|
||||
player.UnitView.SetBar(_data.UnitData.PlayerBarCanvas, _data.UnitData.AttackAimCanvas);
|
||||
Player = player;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -86,8 +88,8 @@ namespace Chars
|
||||
|
||||
if (unitInfo.isAI)
|
||||
{
|
||||
AIAgent agent = new AIAgent(unitInfo, enemy);
|
||||
enemy.OnPlayerSpawned += x => _controllers.Add(agent);
|
||||
AIAgent agent = new AIAgent(enemy);
|
||||
enemy.OnSpawned += x => _controllers.Add(agent);
|
||||
enemy.OnDeath += x => { _controllers.Remove(agent); };
|
||||
}
|
||||
|
||||
|
@ -1,257 +1,49 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Items;
|
||||
using Items.ItemViews;
|
||||
using Sirenix.Utilities;
|
||||
using Units;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
|
||||
public class UnitView : MonoBehaviour
|
||||
namespace Units.Views
|
||||
{
|
||||
public event Action OnStep;
|
||||
public event Action OnAttackEnd;
|
||||
public event Action OnAttack;
|
||||
public Action<int> OnHit;
|
||||
private BarCanvas _barCanvas;
|
||||
private GameObject _aimCanvas;
|
||||
|
||||
|
||||
private Stack<ShotUIView> _shootUIStack;
|
||||
private Stack<ShotUIView> _toReloadStack;
|
||||
private Weapon _weapon;
|
||||
private int _manaRegen;
|
||||
private Action _startRegen;
|
||||
private Coroutine _previosRegen;
|
||||
private Coroutine _previosReload;
|
||||
private Dictionary<string, Action> animActionDic;
|
||||
private int _mana;
|
||||
private event Action CaptureHex;
|
||||
private AudioSource _audioSource;
|
||||
private Unit _unit;
|
||||
private float _hardCaptureTime;
|
||||
private Action onSupperJump;
|
||||
private Coroutine _previousRegenCoroutine;
|
||||
private List<Material> _materials;
|
||||
|
||||
public BarCanvas BarCanvas => _barCanvas;
|
||||
public GameObject AimCanvas => _aimCanvas;
|
||||
public UnitColor Color => _unit.Color;
|
||||
public int AvailableShots => _shootUIStack.Count;
|
||||
|
||||
public Unit Unit => _unit;
|
||||
|
||||
public Dictionary<string, Action> AnimActionDic => animActionDic;
|
||||
|
||||
public void SetBar(BarCanvas barCanvas, GameObject aimCanvas)
|
||||
public class UnitView : ViewBase
|
||||
{
|
||||
_barCanvas = Instantiate(barCanvas, _unit.Instance.transform);
|
||||
_aimCanvas = Instantiate(aimCanvas, _unit.Instance.transform);
|
||||
_shootUIStack = _barCanvas.SpawnShotUI(_weapon.shots);
|
||||
_aimCanvas.SetActive(false);
|
||||
_barCanvas.transform.LookAt(
|
||||
BarCanvas.transform.position + Camera.main.transform.rotation * Vector3.back,
|
||||
Camera.main.transform.rotation * Vector3.up);
|
||||
}
|
||||
public UnitColor Color => _unit.Color;
|
||||
|
||||
public void SetUp(Weapon weapon, Action regenMana, int manaRegen, Action captureHex,
|
||||
Unit unit, float hardCaptureTime)
|
||||
{
|
||||
animActionDic = new Dictionary<string, Action> { { "SuperJump", onSupperJump } };
|
||||
_materials = new List<Material>();
|
||||
_weapon = weapon;
|
||||
_toReloadStack = new Stack<ShotUIView>();
|
||||
_startRegen = regenMana;
|
||||
_manaRegen = manaRegen;
|
||||
CaptureHex = captureHex;
|
||||
_unit = unit;
|
||||
_hardCaptureTime = hardCaptureTime;
|
||||
}
|
||||
|
||||
public void SetInvisible(bool isVisible)
|
||||
{
|
||||
var i = 0;
|
||||
transform.GetChilds().ForEach(x =>
|
||||
protected override void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (x.gameObject.TryGetComponent(typeof(SkinnedMeshRenderer), out var mesh))
|
||||
var weaponView = other.GetComponent<WeaponView>();
|
||||
if (weaponView != null && weaponView.Unit.Color != _unit.Color)
|
||||
{
|
||||
if (!isVisible)
|
||||
{
|
||||
_materials.Add(((SkinnedMeshRenderer)mesh).material);
|
||||
((SkinnedMeshRenderer)mesh).material = _unit.Data.InvisibleMaterial;
|
||||
}
|
||||
else
|
||||
{
|
||||
((SkinnedMeshRenderer)mesh).material = _materials[i++];
|
||||
}
|
||||
OnHit?.Invoke(weaponView.Weapon.modifiedDamage);
|
||||
|
||||
var vfx = VFXController.Instance.PlayEffect(weaponView.Weapon.VFXGameObject,
|
||||
transform.position + new Vector3(0, 2, 0),
|
||||
weaponView.Weapon.VFXGameObject.transform.rotation);
|
||||
MusicController.Instance.AddAudioSource(vfx);
|
||||
MusicController.Instance.PlayAudioClip(weaponView.Weapon.hitSound, vfx);
|
||||
|
||||
other.transform.DOKill();
|
||||
Destroy(other.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected override IEnumerator Regen()
|
||||
{
|
||||
if (_mana >= ((Unit)_unit).Data.maxMana)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (x.gameObject.TryGetComponent(typeof(MeshRenderer), out var mesh1))
|
||||
while (_mana < ((Unit)_unit).Data.maxMana)
|
||||
{
|
||||
if(!isVisible)
|
||||
{
|
||||
_materials.Add(((MeshRenderer)mesh1).material);
|
||||
((MeshRenderer)mesh1).material = _unit.Data.InvisibleMaterial;
|
||||
}
|
||||
else
|
||||
{
|
||||
((MeshRenderer)mesh1).material = _materials[i++];
|
||||
}
|
||||
yield return new WaitForSeconds(1f);
|
||||
_mana += _manaRegen;
|
||||
_startRegen.Invoke();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void HardCaptureHex(HexCell cell)
|
||||
{
|
||||
_unit.BarCanvas.CaptureBar.DOFillAmount(0f, 0);
|
||||
_barCanvas.CaptureBack.SetActive(true);
|
||||
|
||||
_unit.BarCanvas.CaptureBar.DOFillAmount(1f, _hardCaptureTime).SetEase(Ease.Linear).OnComplete(
|
||||
() =>
|
||||
{
|
||||
CaptureHex?.Invoke();
|
||||
_barCanvas.CaptureBack.SetActive(false);
|
||||
MusicController.Instance.PlayRandomClip(MusicController.Instance.MusicData.SfxMusic.Captures,
|
||||
cell.gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void StopHardCapture()
|
||||
{
|
||||
_barCanvas.CaptureBar.DOKill();
|
||||
|
||||
_barCanvas.CaptureBar.DOFillAmount(0f, 0f).SetEase(Ease.Linear);
|
||||
_unit.BarCanvas.CaptureBack.SetActive(false);
|
||||
}
|
||||
|
||||
public bool Shoot()
|
||||
{
|
||||
if (_shootUIStack.Count == 0) return false;
|
||||
var shot = _shootUIStack.Pop();
|
||||
shot.Switch();
|
||||
_toReloadStack.Push(shot);
|
||||
if (_previosReload != null)
|
||||
{
|
||||
StopCoroutine(_previosReload);
|
||||
}
|
||||
|
||||
_previosReload = StartCoroutine(Reload());
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RegenMana()
|
||||
{
|
||||
_mana = _unit.Mana;
|
||||
if (_previosRegen != null)
|
||||
{
|
||||
StopCoroutine(_previosRegen);
|
||||
}
|
||||
|
||||
_previosRegen = StartCoroutine(Regen());
|
||||
}
|
||||
|
||||
private void Step()
|
||||
{
|
||||
OnStep?.Invoke();
|
||||
}
|
||||
|
||||
private void Land()
|
||||
{
|
||||
MusicController.Instance.PlayRandomClip(
|
||||
MusicController.Instance.MusicData.SfxMusic.Step, gameObject);
|
||||
}
|
||||
|
||||
private void AttackEnd() // Методы выполняемые из аниматора
|
||||
{
|
||||
OnAttackEnd?.Invoke();
|
||||
}
|
||||
|
||||
private void Attack()
|
||||
{
|
||||
OnAttack?.Invoke();
|
||||
}
|
||||
|
||||
private void SuperAttack()
|
||||
{
|
||||
for (var i = 0; i < animActionDic.Count; i++)
|
||||
{
|
||||
var item = animActionDic.ElementAt(i);
|
||||
item.Value?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
WeaponView weaponView = other.GetComponent<WeaponView>();
|
||||
if (weaponView != null && weaponView.Unit.Color != _unit.Color)
|
||||
{
|
||||
OnHit?.Invoke(weaponView.Weapon.modifiedDamage);
|
||||
|
||||
var vfx = VFXController.Instance.PlayEffect(weaponView.Weapon.VFXGameObject,
|
||||
transform.position + new Vector3(0, 2, 0),
|
||||
weaponView.Weapon.VFXGameObject.transform.rotation);
|
||||
MusicController.Instance.AddAudioSource(vfx);
|
||||
MusicController.Instance.PlayAudioClip(weaponView.Weapon.hitSound, vfx);
|
||||
|
||||
other.transform.DOKill();
|
||||
Destroy(other.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
ItemView itemView = other.GetComponent<ItemView>();
|
||||
|
||||
if (itemView == null || itemView.pickedUp || !_unit.CanPickUpItem(itemView.Item)) return;
|
||||
itemView.pickedUp = true;
|
||||
itemView.PickUp(Unit);
|
||||
|
||||
ItemFabric.Items.Remove(itemView.gameObject);
|
||||
}
|
||||
|
||||
private IEnumerator Reload()
|
||||
{
|
||||
if (_toReloadStack.Count == 0) yield break;
|
||||
yield return new WaitForSeconds(_weapon.reloadTime);
|
||||
if (_toReloadStack.Count == 0) yield break;
|
||||
var shot = _toReloadStack.Pop();
|
||||
|
||||
shot.Switch();
|
||||
_shootUIStack.Push(shot);
|
||||
|
||||
foreach (var item in _toReloadStack)
|
||||
{
|
||||
if (Time.deltaTime < _weapon.reloadTime)
|
||||
{
|
||||
StopCoroutine(_previosReload);
|
||||
_previosReload = null;
|
||||
}
|
||||
|
||||
_previosReload = StartCoroutine(Reload());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator Regen()
|
||||
{
|
||||
if (_mana >= _unit.Data.maxMana)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
while (_mana < _unit.Data.maxMana)
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
_mana += _manaRegen;
|
||||
_startRegen.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
233
Assets/Scripts/Units/Views/ViewBase.cs
Normal file
233
Assets/Scripts/Units/Views/ViewBase.cs
Normal file
@ -0,0 +1,233 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Items;
|
||||
using Items.ItemViews;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
namespace Units.Views
|
||||
{
|
||||
public abstract class ViewBase : MonoBehaviour
|
||||
{
|
||||
public event Action OnStep;
|
||||
public event Action OnAttackEnd;
|
||||
public event Action OnAttack;
|
||||
public Action<int> OnHit;
|
||||
private BarCanvas _barCanvas;
|
||||
private GameObject _aimCanvas;
|
||||
|
||||
|
||||
private Stack<ShotUIView> _shootUIStack;
|
||||
private Stack<ShotUIView> _toReloadStack;
|
||||
private Weapon _weapon;
|
||||
protected int _manaRegen;
|
||||
protected Action _startRegen;
|
||||
private Coroutine _previosRegen;
|
||||
private Coroutine _previosReload;
|
||||
private Dictionary<string, Action> animActionDic;
|
||||
protected int _mana;
|
||||
private event Action CaptureHex;
|
||||
private AudioSource _audioSource;
|
||||
protected UnitBase _unit;
|
||||
private float _hardCaptureTime;
|
||||
private Action onSupperJump;
|
||||
private Coroutine _previousRegenCoroutine;
|
||||
private List<Material> _materials;
|
||||
|
||||
public BarCanvas BarCanvas => _barCanvas;
|
||||
public GameObject AimCanvas => _aimCanvas;
|
||||
public int AvailableShots => _shootUIStack.Count;
|
||||
|
||||
public UnitBase Unit => _unit;
|
||||
|
||||
public Dictionary<string, Action> AnimActionDic => animActionDic;
|
||||
|
||||
public void SetBar(BarCanvas barCanvas, GameObject aimCanvas)
|
||||
{
|
||||
_barCanvas = Instantiate(barCanvas, _unit.Instance.transform);
|
||||
_aimCanvas = Instantiate(aimCanvas, _unit.Instance.transform);
|
||||
_shootUIStack = _barCanvas.SpawnShotUI(_weapon.shots);
|
||||
_aimCanvas.SetActive(false);
|
||||
_barCanvas.transform.LookAt(
|
||||
BarCanvas.transform.position + Camera.main.transform.rotation * Vector3.back,
|
||||
Camera.main.transform.rotation * Vector3.up);
|
||||
}
|
||||
|
||||
public void SetUp(Weapon weapon, Action regenMana, int manaRegen, Action captureHex,
|
||||
UnitBase unit, float hardCaptureTime)
|
||||
{
|
||||
animActionDic = new Dictionary<string, Action> { { "SuperJump", onSupperJump } };
|
||||
_materials = new List<Material>();
|
||||
_weapon = weapon;
|
||||
_toReloadStack = new Stack<ShotUIView>();
|
||||
_startRegen = regenMana;
|
||||
_manaRegen = manaRegen;
|
||||
CaptureHex = captureHex;
|
||||
_unit = unit;
|
||||
_hardCaptureTime = hardCaptureTime;
|
||||
}
|
||||
|
||||
public void SetInvisible(bool isVisible)
|
||||
{
|
||||
var i = 0;
|
||||
transform.GetChilds().ForEach(x =>
|
||||
{
|
||||
if (x.gameObject.TryGetComponent(typeof(SkinnedMeshRenderer), out var mesh))
|
||||
{
|
||||
if (!isVisible)
|
||||
{
|
||||
var materialColor = ((SkinnedMeshRenderer)mesh).material.color;
|
||||
materialColor.a=0;
|
||||
((SkinnedMeshRenderer) mesh).material.color = materialColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
var materialColor = ((SkinnedMeshRenderer)mesh).material.color;
|
||||
materialColor.a=100;
|
||||
((SkinnedMeshRenderer) mesh).material.color = materialColor;
|
||||
}
|
||||
}
|
||||
|
||||
if (x.gameObject.TryGetComponent(typeof(MeshRenderer), out var mesh1))
|
||||
{
|
||||
if (!isVisible)
|
||||
{
|
||||
var materialColor = ((SkinnedMeshRenderer)mesh1).material.color;
|
||||
materialColor.a=0;
|
||||
((SkinnedMeshRenderer) mesh1).material.color = materialColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
var materialColor = ((SkinnedMeshRenderer)mesh1).material.color;
|
||||
materialColor.a=100;
|
||||
((SkinnedMeshRenderer) mesh1).material.color = materialColor;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public virtual void HardCaptureHex(HexCell cell)
|
||||
{
|
||||
_unit.BarCanvas.CaptureBar.DOFillAmount(0f, 0);
|
||||
_barCanvas.CaptureBack.SetActive(true);
|
||||
|
||||
_unit.BarCanvas.CaptureBar.DOFillAmount(1f, _hardCaptureTime).SetEase(Ease.Linear).OnComplete(
|
||||
() =>
|
||||
{
|
||||
CaptureHex?.Invoke();
|
||||
_barCanvas.CaptureBack.SetActive(false);
|
||||
MusicController.Instance.PlayRandomClip(MusicController.Instance.MusicData.SfxMusic.Captures,
|
||||
cell.gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public virtual void StopHardCapture()
|
||||
{
|
||||
_barCanvas.CaptureBar.DOKill();
|
||||
|
||||
_barCanvas.CaptureBar.DOFillAmount(0f, 0f).SetEase(Ease.Linear);
|
||||
_unit.BarCanvas.CaptureBack.SetActive(false);
|
||||
}
|
||||
|
||||
public bool Shoot()
|
||||
{
|
||||
if (_shootUIStack.Count == 0) return false;
|
||||
var shot = _shootUIStack.Pop();
|
||||
shot.Switch();
|
||||
_toReloadStack.Push(shot);
|
||||
if (_previosReload != null)
|
||||
{
|
||||
StopCoroutine(_previosReload);
|
||||
}
|
||||
|
||||
_previosReload = StartCoroutine(Reload());
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RegenMana()
|
||||
{
|
||||
_mana = _unit.Mana;
|
||||
if (_previosRegen != null)
|
||||
{
|
||||
StopCoroutine(_previosRegen);
|
||||
}
|
||||
|
||||
_previosRegen = StartCoroutine(Regen());
|
||||
}
|
||||
|
||||
private void Step()
|
||||
{
|
||||
OnStep?.Invoke();
|
||||
}
|
||||
|
||||
private void Land()
|
||||
{
|
||||
MusicController.Instance.PlayRandomClip(
|
||||
MusicController.Instance.MusicData.SfxMusic.Step, gameObject);
|
||||
}
|
||||
|
||||
private void AttackEnd() // Методы выполняемые из аниматора
|
||||
{
|
||||
OnAttackEnd?.Invoke();
|
||||
}
|
||||
|
||||
private void Attack()
|
||||
{
|
||||
OnAttack?.Invoke();
|
||||
}
|
||||
|
||||
private void SuperAttack()
|
||||
{
|
||||
for (var i = 0; i < animActionDic.Count; i++)
|
||||
{
|
||||
var item = animActionDic.ElementAt(i);
|
||||
item.Value?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void OnTriggerEnter(Collider other);
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
ItemView itemView = other.GetComponent<ItemView>();
|
||||
|
||||
if (itemView == null || itemView.pickedUp || !_unit.CanPickUpItem(itemView.Item)) return;
|
||||
itemView.pickedUp = true;
|
||||
itemView.PickUp(Unit);
|
||||
|
||||
ItemFabric.Items.Remove(itemView.gameObject);
|
||||
}
|
||||
|
||||
private IEnumerator Reload()
|
||||
{
|
||||
if (_toReloadStack.Count == 0) yield break;
|
||||
yield return new WaitForSeconds(_weapon.reloadTime);
|
||||
if (_toReloadStack.Count == 0) yield break;
|
||||
var shot = _toReloadStack.Pop();
|
||||
|
||||
shot.Switch();
|
||||
_shootUIStack.Push(shot);
|
||||
|
||||
foreach (var item in _toReloadStack)
|
||||
{
|
||||
if (Time.deltaTime < _weapon.reloadTime)
|
||||
{
|
||||
StopCoroutine(_previosReload);
|
||||
_previosReload = null;
|
||||
}
|
||||
|
||||
_previosReload = StartCoroutine(Reload());
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract IEnumerator Regen();
|
||||
}
|
||||
}
|
3
Assets/Scripts/Units/Views/ViewBase.cs.meta
Normal file
3
Assets/Scripts/Units/Views/ViewBase.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28f02a660e62481bbfa8accf1e2dc147
|
||||
timeCreated: 1646888245
|
46
Assets/Scripts/Units/Views/WariorView.cs
Normal file
46
Assets/Scripts/Units/Views/WariorView.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using HexFiled;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
namespace Units.Views
|
||||
{
|
||||
public class WariorView : ViewBase
|
||||
{
|
||||
protected override void OnTriggerEnter(Collider other)
|
||||
{
|
||||
var weaponView = other.GetComponent<WeaponView>();
|
||||
if (weaponView != null && weaponView.Unit.Color != _unit.Color)
|
||||
{
|
||||
OnHit?.Invoke(weaponView.Weapon.modifiedDamage);
|
||||
|
||||
var vfx = VFXController.Instance.PlayEffect(weaponView.Weapon.VFXGameObject,
|
||||
transform.position + new Vector3(0, 2, 0),
|
||||
weaponView.Weapon.VFXGameObject.transform.rotation);
|
||||
MusicController.Instance.AddAudioSource(vfx);
|
||||
MusicController.Instance.PlayAudioClip(weaponView.Weapon.hitSound, vfx);
|
||||
|
||||
other.transform.DOKill();
|
||||
Destroy(other.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected override IEnumerator Regen()
|
||||
{
|
||||
if (_mana >= ((Unit)_unit).Data.maxMana)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
while (_mana < ((Unit)_unit).Data.maxMana)
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
_mana += _manaRegen;
|
||||
_startRegen.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/Units/Views/WariorView.cs.meta
Normal file
3
Assets/Scripts/Units/Views/WariorView.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26ffa1df18054a30acc8001ffea3bb38
|
||||
timeCreated: 1646996501
|
3
Assets/Scripts/Units/Wariors/AbstractsBase.meta
Normal file
3
Assets/Scripts/Units/Wariors/AbstractsBase.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2bfc492e23546f386a5f3a86558a241
|
||||
timeCreated: 1646882631
|
201
Assets/Scripts/Units/Wariors/AbstractsBase/Patrol.cs
Normal file
201
Assets/Scripts/Units/Wariors/AbstractsBase/Patrol.cs
Normal file
@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AI;
|
||||
using Data;
|
||||
using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Items;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
namespace Units.Wariors.AbstractsBase
|
||||
{
|
||||
public abstract class Patrol : UnitBase
|
||||
{
|
||||
protected WariorInfo _data;
|
||||
public WariorInfo Data => _data;
|
||||
|
||||
|
||||
public Patrol(WariorInfo data, Weapon weapon, HexGrid hexGrid, UnitColor spawnerColor)
|
||||
{
|
||||
Initialize(weapon, hexGrid);
|
||||
_data = data;
|
||||
_data.color = spawnerColor;
|
||||
Color = _data.color;
|
||||
maxHP = _data.maxHP;
|
||||
maxMana = _data.maxMana;
|
||||
}
|
||||
|
||||
public override void Retreet(HexDirection dir)
|
||||
{
|
||||
if (!_isCapturing) return;
|
||||
var openList = _cell.GetListNeighbours().Where(x => x != null && x.Color == _data.color).ToList();
|
||||
if (!openList.Contains(_cell.GetNeighbor(dir)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsBusy = false;
|
||||
IsHardToCapture = false;
|
||||
UnitView.StopHardCapture();
|
||||
Move(dir);
|
||||
}
|
||||
|
||||
public override void Move(HexDirection direction)
|
||||
{
|
||||
if (_cell.GetNeighbor(direction) == null || _cell.GetNeighbor(direction).BuildingInstance != null ||
|
||||
IsBusy || IsHardToCapture ||
|
||||
(_cell.GetNeighbor(direction).Color != Color
|
||||
&& HexManager.UnitCurrentCell.TryGetValue(_cell.GetNeighbor(direction).Color, out var value)
|
||||
&& value.cell.Equals(_cell.GetNeighbor(direction)))) return;
|
||||
|
||||
|
||||
if (_cell.GetNeighbor(direction).Color == _data.color ||
|
||||
(_cell.GetNeighbor(direction).Color == _easyCaptureColor && _easyCaptureColor != UnitColor.Grey))
|
||||
{
|
||||
DoTransit(direction);
|
||||
}
|
||||
else if (_cell.GetNeighbor(direction).Color != UnitColor.Grey)
|
||||
{
|
||||
if (_mana - _hexGrid.HexHardCaptureCost <= 0) return;
|
||||
IsHardToCapture = true;
|
||||
DoTransit(direction);
|
||||
}
|
||||
|
||||
else if (_mana - _hexGrid.HexCaptureCost >= 0)
|
||||
{
|
||||
if (_mana - _hexGrid.HexHardCaptureCost <= 0) return;
|
||||
DoTransit(direction);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetCell(HexCell cell, bool isInstanceTrans = false, bool isPaintingHex = false)
|
||||
{
|
||||
_cell = cell;
|
||||
HexManager.UnitCurrentCell[Color] = (cell, this);
|
||||
if (!isInstanceTrans)
|
||||
{
|
||||
IsBusy = true;
|
||||
_instance.transform.DOMove(_cell.transform.position, _animLength.SuperJump)
|
||||
.OnComplete(() => IsBusy = false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_instance.transform.DOMove(_cell.transform.position, 0.5f).SetEase(Ease.Linear);
|
||||
}
|
||||
|
||||
if (isPaintingHex)
|
||||
{
|
||||
cell.PaintHex(Color, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CaptureHex()
|
||||
{
|
||||
if (!_isInfiniteMana)
|
||||
{
|
||||
if (IsHardToCapture)
|
||||
{
|
||||
_mana -= _hexGrid.HexHardCaptureCost;
|
||||
}
|
||||
else
|
||||
{
|
||||
_mana -= _hexGrid.HexCaptureCost;
|
||||
}
|
||||
}
|
||||
|
||||
UnitView.RegenMana();
|
||||
|
||||
|
||||
UpdateBarCanvas();
|
||||
IsBusy = false;
|
||||
IsHardToCapture = false;
|
||||
_cell.PaintHex(_data.color);
|
||||
}
|
||||
|
||||
|
||||
protected override void RegenMana()
|
||||
{
|
||||
_mana += _data.manaRegen;
|
||||
UpdateBarCanvas();
|
||||
}
|
||||
|
||||
public override bool CanPickUpItem(Item item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void PickUpItem(ItemContainer item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
protected override void UpdateBarCanvas()
|
||||
{
|
||||
if (_hp > _data.maxHP)
|
||||
_hp = _data.maxHP;
|
||||
if (_mana > _data.maxMana)
|
||||
_mana = _data.maxMana;
|
||||
|
||||
float hp = _hp;
|
||||
float mana = _mana;
|
||||
float maxHp = _data.maxHP;
|
||||
float maxMana = _data.maxMana;
|
||||
BarCanvas.ManaBar.DOFillAmount(mana / maxMana, 0.5f).SetEase(Ease.InQuad);
|
||||
BarCanvas.HealthBar.DOFillAmount(hp / maxHp, 0.5f).SetEase(Ease.InQuad);
|
||||
}
|
||||
|
||||
public override void StartAttack()
|
||||
{
|
||||
if (IsBusy || !UnitView.Shoot()) return;
|
||||
|
||||
IsBusy = true;
|
||||
if (_direction.Equals(Vector2.zero))
|
||||
{
|
||||
var enemy = AIManager.GetNearestUnit(_weapon.disnatce, this);
|
||||
if (enemy == null)
|
||||
_direction =
|
||||
new Vector2(UnitView.transform.forward.x, UnitView.transform.forward.z);
|
||||
else
|
||||
{
|
||||
var dir = DirectionHelper.DirectionTo(_instance.transform.position,
|
||||
enemy.Instance.transform.position);
|
||||
_direction = new Vector2(dir.x, dir.z);
|
||||
}
|
||||
}
|
||||
|
||||
RotateUnit(_direction);
|
||||
_animator.SetTrigger("Attack");
|
||||
}
|
||||
|
||||
public override HexCell PlaceItemAim(HexDirection direction)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void Damage(int dmg)
|
||||
{
|
||||
if (_defenceBonus == 0 && _hp - dmg <= 0f)
|
||||
{
|
||||
Death();
|
||||
}
|
||||
|
||||
if (_hp - dmg > _data.maxHP)
|
||||
{
|
||||
_hp = _data.maxHP;
|
||||
}
|
||||
|
||||
if (_defenceBonus > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_hp -= dmg;
|
||||
|
||||
UpdateBarCanvas();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00daeb53caf94ed5a8361a5d5680282a
|
||||
timeCreated: 1646882593
|
96
Assets/Scripts/Units/Wariors/Holem.cs
Normal file
96
Assets/Scripts/Units/Wariors/Holem.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using System.Collections.Generic;
|
||||
using Data;
|
||||
using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Items;
|
||||
using Units.Views;
|
||||
using Units.Wariors.AbstractsBase;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
namespace Units.Wariors
|
||||
{
|
||||
public class Holem : Patrol
|
||||
{
|
||||
public Holem(WariorInfo data, Weapon weapon, HexGrid hexGrid, UnitColor spawnerColor) : base(data, weapon,
|
||||
hexGrid, spawnerColor)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DoTransit(HexDirection direction)
|
||||
{
|
||||
IsBusy = true;
|
||||
_isCapturing = _data.color != _cell.GetNeighbor(direction).Color;
|
||||
_cell = _cell.GetNeighbor(direction);
|
||||
HexManager.UnitCurrentCell[_data.color] = (_cell, this);
|
||||
RotateUnit(new Vector2((_cell.transform.position - _instance.transform.position).normalized.x,
|
||||
(_cell.transform.position - _instance.transform.position).normalized.z));
|
||||
_animator.SetTrigger("Move");
|
||||
_animator.SetBool("isMoving", IsBusy);
|
||||
_instance.transform.DOMove(_cell.transform.position, _animLength.Move);
|
||||
}
|
||||
|
||||
public override void Spawn(HexCoordinates hexCoordinates, HexCell spawnCell = null)
|
||||
{
|
||||
if (!IsAlive)
|
||||
{
|
||||
_cell = spawnCell != null ? spawnCell : _hexGrid.GetCellFromCoord(hexCoordinates);
|
||||
IsVisible = true;
|
||||
_cell.PaintHex(_data.color, true);
|
||||
_cell.GetListNeighbours().ForEach(x => { x?.PaintHex(Color, true); });
|
||||
_inventory = new List<ItemContainer>();
|
||||
_inventoryDefence = new List<ItemContainer>();
|
||||
|
||||
_instance = Object.Instantiate(_data.wariorPrefa, _cell.transform.parent);
|
||||
|
||||
_instance.transform.localPosition = _cell.transform.localPosition;
|
||||
|
||||
IsAlive = true;
|
||||
_animator = _instance.GetComponent<Animator>();
|
||||
UnitView = _instance.AddComponent<UnitView>();
|
||||
|
||||
|
||||
UnitView.SetUp(_weapon, RegenMana, _data.manaRegen, CaptureHex,
|
||||
this, _hexGrid.HardCaptureTime);
|
||||
SetAnimLength();
|
||||
MusicController.Instance.AddAudioSource(_instance);
|
||||
_mana = _data.maxMana;
|
||||
_hp = _data.maxHP;
|
||||
SetUpActions();
|
||||
_weapon.SetModifiedDamage(0);
|
||||
|
||||
IsBusy = false;
|
||||
OnOnPlayerSpawned(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Death()
|
||||
{
|
||||
UnitView.OnStep -= MoveEnd;
|
||||
UnitView.OnAttackEnd -= AttackEnd;
|
||||
UnitView.OnAttack -= Attacking;
|
||||
UnitView.OnHit -= Damage;
|
||||
IsAlive = false;
|
||||
IsBusy = true;
|
||||
_animator.SetTrigger("Death");
|
||||
var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[Color].VFXDeathPrefab,
|
||||
_instance.transform.position);
|
||||
TimerHelper.Instance.StartTimer(() =>
|
||||
{
|
||||
Object.Destroy(_instance);
|
||||
OnOnDeath(this);
|
||||
}, _animLength.Death);
|
||||
MusicController.Instance.AddAudioSource(vfx);
|
||||
MusicController.Instance.PlayAudioClip(MusicController.Instance.MusicData.SfxMusic.Death, vfx);
|
||||
MusicController.Instance.RemoveAudioSource(_instance);
|
||||
}
|
||||
|
||||
protected override void Attacking()
|
||||
{
|
||||
Aim(_direction);
|
||||
|
||||
_weapon.Fire(_instance.transform, _direction, this);
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/Units/Wariors/Holem.cs.meta
Normal file
3
Assets/Scripts/Units/Wariors/Holem.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5832a21568e9400a9384d67e2eb12026
|
||||
timeCreated: 1646884967
|
@ -1,16 +0,0 @@
|
||||
using HexFiled;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Units.Wariors
|
||||
{
|
||||
public class Warior
|
||||
{
|
||||
private GameObject _instance;
|
||||
|
||||
|
||||
public GameObject Spawn(HexCell cell)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
44
Assets/Scripts/Units/Wariors/WariorFactory.cs
Normal file
44
Assets/Scripts/Units/Wariors/WariorFactory.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Controller;
|
||||
using Data;
|
||||
using DefaultNamespace.AI;
|
||||
using GameUI;
|
||||
using HexFiled;
|
||||
using System.Linq;
|
||||
using Units.Wariors.AbstractsBase;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
namespace Units.Wariors
|
||||
{
|
||||
public class WariorFactory
|
||||
{
|
||||
private readonly HexGrid _hexGrid;
|
||||
private readonly Controllers _controllers;
|
||||
private readonly Data.Data _data;
|
||||
|
||||
public WariorFactory(HexGrid grid, Controllers controllers, Data.Data data)
|
||||
{
|
||||
_hexGrid = grid;
|
||||
_data = data;
|
||||
_controllers = controllers;
|
||||
}
|
||||
|
||||
|
||||
public void Spawn(WariorInfo wariorInfo , UnitColor unitColor)
|
||||
{
|
||||
var spawnPos= HexManager.CellByColor[unitColor].Where(x => x != null).ToList()[
|
||||
Random.Range(0, HexManager.CellByColor[unitColor].Count - 1)];
|
||||
|
||||
var patrol = new Holem(wariorInfo,_data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid,unitColor);
|
||||
|
||||
AIAgent agent = new AIAgent(patrol);
|
||||
patrol.OnSpawned += x => _controllers.Add(agent);
|
||||
patrol.OnDeath += x => { _controllers.Remove(agent); };
|
||||
|
||||
patrol.Spawn(spawnPos.coordinates, spawnPos);
|
||||
spawnPos.isSpawnPos = false;
|
||||
|
||||
patrol.UnitView.SetBar(_data.UnitData.BotBarCanvas, _data.UnitData.AttackAimCanvas);
|
||||
}
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ namespace Weapons
|
||||
modifiedDamage = damage + bonus;
|
||||
}
|
||||
|
||||
public GameObject Fire(Transform start, Vector2 direction, Unit unit, bool isMoving = true)
|
||||
public GameObject Fire(Transform start, Vector2 direction, UnitBase unit, bool isMoving = true)
|
||||
{
|
||||
var ball = Object.Instantiate(objectToThrow,
|
||||
start.forward + start.transform.position + new Vector3(0, 1),
|
||||
|
@ -6,9 +6,9 @@ namespace Weapons
|
||||
public class WeaponView : MonoBehaviour
|
||||
{
|
||||
public Weapon Weapon { get; private set; }
|
||||
public Unit Unit { get; private set; }
|
||||
public UnitBase Unit { get; private set; }
|
||||
|
||||
public void SetWeapon(Weapon weapon, Unit unit)
|
||||
public void SetWeapon(Weapon weapon, UnitBase unit)
|
||||
{
|
||||
Weapon = weapon;
|
||||
Unit = unit;
|
||||
|
@ -2,21 +2,21 @@
|
||||
"dependencies": {
|
||||
"com.unity.2d.sprite": "1.0.0",
|
||||
"com.unity.2d.tilemap": "1.0.0",
|
||||
"com.unity.ads": "3.7.1",
|
||||
"com.unity.analytics": "3.5.3",
|
||||
"com.unity.collab-proxy": "1.7.1",
|
||||
"com.unity.ads": "3.7.5",
|
||||
"com.unity.analytics": "3.6.11",
|
||||
"com.unity.collab-proxy": "1.13.5",
|
||||
"com.unity.device-simulator": "3.0.3-preview",
|
||||
"com.unity.ide.rider": "2.0.7",
|
||||
"com.unity.ide.visualstudio": "2.0.11",
|
||||
"com.unity.ide.vscode": "1.2.4",
|
||||
"com.unity.mobile.android-logcat": "1.2.3",
|
||||
"com.unity.postprocessing": "3.1.1",
|
||||
"com.unity.purchasing": "3.2.2",
|
||||
"com.unity.test-framework": "1.1.27",
|
||||
"com.unity.purchasing": "4.0.3",
|
||||
"com.unity.test-framework": "1.1.29",
|
||||
"com.unity.textmeshpro": "3.0.6",
|
||||
"com.unity.timeline": "1.4.8",
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.xr.legacyinputhelpers": "2.1.7",
|
||||
"com.unity.xr.legacyinputhelpers": "2.1.8",
|
||||
"com.unity.modules.ai": "1.0.0",
|
||||
"com.unity.modules.androidjni": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0",
|
||||
|
@ -13,7 +13,7 @@
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.ads": {
|
||||
"version": "3.7.1",
|
||||
"version": "3.7.5",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@ -22,7 +22,7 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.analytics": {
|
||||
"version": "3.5.3",
|
||||
"version": "3.6.11",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@ -31,11 +31,12 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.collab-proxy": {
|
||||
"version": "1.7.1",
|
||||
"version": "1.13.5",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.nuget.newtonsoft-json": "2.0.0"
|
||||
"com.unity.nuget.newtonsoft-json": "2.0.0",
|
||||
"com.unity.services.core": "1.0.1"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
@ -102,7 +103,7 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.purchasing": {
|
||||
"version": "3.2.2",
|
||||
"version": "4.0.3",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@ -110,12 +111,22 @@
|
||||
"com.unity.modules.unityanalytics": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.androidjni": "1.0.0"
|
||||
"com.unity.modules.androidjni": "1.0.0",
|
||||
"com.unity.services.core": "1.0.1"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.services.core": {
|
||||
"version": "1.0.1",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.test-framework": {
|
||||
"version": "1.1.27",
|
||||
"version": "1.1.29",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
@ -156,7 +167,7 @@
|
||||
}
|
||||
},
|
||||
"com.unity.xr.legacyinputhelpers": {
|
||||
"version": "2.1.7",
|
||||
"version": "2.1.8",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
|
6
ProjectSettings/DeviceSimulatorSettings.asset
Normal file
6
ProjectSettings/DeviceSimulatorSettings.asset
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"SystemInfoSimulation": true,
|
||||
"ApplicationSimulation": true,
|
||||
"SystemInfoDefaultAssembly": true,
|
||||
"SystemInfoAssemblies": []
|
||||
}
|
@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 2020.3.16f1
|
||||
m_EditorVersionWithRevision: 2020.3.16f1 (049d6eca3c44)
|
||||
m_EditorVersion: 2020.3.22f1
|
||||
m_EditorVersionWithRevision: 2020.3.22f1 (e1a7f79fd887)
|
||||
|
167
ProjectSettings/SceneTemplateSettings.json
Normal file
167
ProjectSettings/SceneTemplateSettings.json
Normal file
@ -0,0 +1,167 @@
|
||||
{
|
||||
"templatePinStates": [],
|
||||
"dependencyTypeInfos": [
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.AnimationClip",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEditor.Animations.AnimatorController",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.AnimatorOverrideController",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEditor.Audio.AudioMixerController",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.ComputeShader",
|
||||
"ignore": true,
|
||||
"defaultInstantiationMode": 1,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.Cubemap",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.GameObject",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEditor.LightingDataAsset",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": false
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.LightingSettings",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.Material",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEditor.MonoScript",
|
||||
"ignore": true,
|
||||
"defaultInstantiationMode": 1,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.PhysicMaterial",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.PhysicsMaterial2D",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.Rendering.PostProcessing.PostProcessResources",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.Rendering.VolumeProfile",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEditor.SceneAsset",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": false
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.Shader",
|
||||
"ignore": true,
|
||||
"defaultInstantiationMode": 1,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.ShaderVariantCollection",
|
||||
"ignore": true,
|
||||
"defaultInstantiationMode": 1,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.Texture",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.Texture2D",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
},
|
||||
{
|
||||
"userAdded": false,
|
||||
"type": "UnityEngine.Timeline.TimelineAsset",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 0,
|
||||
"supportsModification": true
|
||||
}
|
||||
],
|
||||
"defaultDependencyTypeInfo": {
|
||||
"userAdded": false,
|
||||
"type": "<default_scene_template_dependencies>",
|
||||
"ignore": false,
|
||||
"defaultInstantiationMode": 1,
|
||||
"supportsModification": true
|
||||
},
|
||||
"newSceneOverride": 0
|
||||
}
|
15
ProjectSettings/TimelineSettings.asset
Normal file
15
ProjectSettings/TimelineSettings.asset
Normal file
@ -0,0 +1,15 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &1
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 61
|
||||
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: a287be6c49135cd4f9b2b8666c39d999, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
assetDefaultFramerate: 60
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user