Unit work completed

This commit is contained in:
Uamgl 2022-03-29 19:13:27 +02:00
parent 0cef3f4972
commit 858dd43fed
27 changed files with 567 additions and 328 deletions

41
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,41 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"WARNING01": "*********************************************************************************",
"WARNING02": "The C# extension was unable to automatically decode projects in the current",
"WARNING03": "workspace to create a runnable launch.json file. A template launch.json file has",
"WARNING04": "been created as a placeholder.",
"WARNING05": "",
"WARNING06": "If OmniSharp is currently unable to load your project, you can attempt to resolve",
"WARNING07": "this by restoring any missing project dependencies (example: run 'dotnet restore')",
"WARNING08": "and by fixing any reported errors from building the projects in your workspace.",
"WARNING09": "If this allows OmniSharp to now load your project then --",
"WARNING10": " * Delete this file",
"WARNING11": " * Open the Visual Studio Code command palette (View->Command Palette)",
"WARNING12": " * run the command: '.NET: Generate Assets for Build and Debug'.",
"WARNING13": "",
"WARNING14": "If your project requires a more complex launch configuration, you may wish to delete",
"WARNING15": "this configuration and pick a different template using the 'Add Configuration...'",
"WARNING16": "button at the bottom of this file.",
"WARNING17": "*********************************************************************************",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

View File

@ -1,14 +1,6 @@
using System;
using System.Collections.Generic;
using AI;
using Controller;
using Data;
using DG.Tweening;
using HexFiled;
using Runtime.Controller;
using Units;
using Units.Wariors.AbstractsBase;
using UnityEngine;
namespace DefaultNamespace.AI
{
@ -19,6 +11,33 @@ namespace DefaultNamespace.AI
}
public override void FixedExecute()
{
if (curentState == BotState.Attack && !_unitBase.IsBusy)
{
_unitBase.Aim(_attackDirection);
_unitBase.StartAttack();
curentState = Unit.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 = Unit.Instance.GetNewBehaviour(this);
}
}
protected override void InitAgent(UnitBase aiBase)
{
AIManager.Instance.AddAgent(this);

View File

@ -45,32 +45,7 @@ namespace DefaultNamespace.AI
}
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 abstract void FixedExecute();
public void Dispose()

View File

@ -0,0 +1,33 @@
using AI;
using HexFiled;
using Units;
namespace DefaultNamespace.AI
{
public class AIInvader : AIWarior
{
public AIInvader(UnitBase unitBase) : base(unitBase)
{
}
public override void FixedExecute()
{
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 = Warior.Instance.GetNewBehaviour(this);
}
}
}
}

View File

@ -7,19 +7,18 @@ using DefaultNamespace.AI;
using HexFiled;
using Items;
using Units;
using Units.Wariors.AbstractsBase;
using UnityEngine;
using Random = UnityEngine.Random;
namespace AI
{
public class AIManager
public abstract class AIManager
{
private int _triesToCalculatePath = 0;
private int _maxTriesToCalculatePath = 5;
private AIData _data;
protected int _triesToCalculatePath = 0;
protected int _maxTriesToCalculatePath = 5;
protected AIData _data;
private static AIManager _instance;
protected static AIManager _instance;
public static AIManager Instance
@ -45,13 +44,10 @@ namespace AI
{
agent.OnAgentInited -= InitAI;
}
protected abstract void SetBehaviour(BotState state, AIBase agent, int dist);
protected abstract void InitAI(AIBase agent);
private void InitAI(AIBase agent)
{
SetBehaviour(BotState.Patrol, agent,500);
}
private void StartPatrolBehaviour(AIBase agent)
protected void StartPatrolBehaviour(AIBase agent)
{
HexManager.GetNearestDifferCell(agent.UnitBase.Color, agent.currentPath);
while (agent.currentPath.Count == 0 && _triesToCalculatePath < _maxTriesToCalculatePath)
@ -90,111 +86,9 @@ namespace AI
}
public BotState GetNewBehaviour(AIBase agent)
{
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,500);
return BotState.AttackBonusUsage;
}
public abstract BotState GetNewBehaviour(AIBase agent);
var enemy = GetNearestUnit(_data.DistanceToAgr, agent.UnitBase);
if (enemy != null && agent.UnitBase.Hp > agent.UnitBase.maxHP * _data.PercentToRetreet && enemy.IsAlive)
{
if (agent.UnitBase.Hp <= agent.UnitBase.maxHP * _data.PercentToRetreet ||
agent.UnitBase.BaseView.AvailableShots == 0)
{
SetBehaviour(BotState.Retreet, agent,500);
return BotState.Retreet;
}
if (Vector3.Distance(agent.UnitBase.Instance.transform.position, enemy.Instance.transform.position) <=
agent.UnitBase.Weapon.disnatce)
{
SetBehaviour(BotState.Attack, agent,500);
return BotState.Attack;
}
SetBehaviour(BotState.Agressive, agent,500);
return BotState.Agressive;
}
var item = GetNearestItem(agent);
if (item.hex != null)
{
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,500);
return BotState.CollectingBonus;
}
}
var protect = agent.UnitBase.InventoryDefence.Where(x => x.Item is Bonus { BonusType: BonusType.Defence })
.ToList();
if (protect.Count > 0 && agent.UnitBase.Hp <= agent.UnitBase.maxHP * _data.PercentToUseProtectBonus &&
agent.UnitBase.DefenceBonus == 0)
{
SetBehaviour(BotState.ProtectBonusUsage, agent,500);
return BotState.ProtectBonusUsage;
}
SetBehaviour(BotState.Patrol, agent,500);
return BotState.Patrol;
}
private void SetBehaviour(BotState state, AIBase agent, int dist)
{
switch (state)
{
case BotState.Patrol:
StartPatrolBehaviour(agent);
break;
case BotState.Agressive:
MoveToEnemy(agent, dist);
break;
case BotState.Attack:
AttackEnemy(agent);
break;
case BotState.CollectingBonus:
StartPatrolBehaviour(agent);
break;
case BotState.ProtectBonusUsage:
StartPatrolBehaviour(agent);
break;
case BotState.AttackBonusUsage:
StartPatrolBehaviour(agent);
break;
case BotState.Dead:
break;
case BotState.Retreet:
Retreet(agent);
break;
default:
throw new ArgumentOutOfRangeException(nameof(state), state, null);
}
}
private void UseBonus(AIBase agent, BonusType type)
{
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((Unit)(agent.UnitBase));
}
private void Retreet(AIBase agent)
protected void Retreet(AIBase agent)
{
var enemy = GetNearestUnit(6, agent.UnitBase)?.Instance.transform;
@ -209,7 +103,7 @@ namespace AI
agent.currentPath.Enqueue(DirectionHelper.VectorToDirection(new Vector2(dir.x, dir.z)));
}
private (int dist, HexCell hex) GetNearestItem(AIBase agent)
protected (int dist, HexCell hex) GetNearestItem(AIBase agent)
{
var itemsToMove =
(from entry in ItemFabric.Items
@ -230,7 +124,7 @@ namespace AI
HexGrid.HexDistance), itemToMove.Value);
}
private void MoveToBonus(AIBase agent)
protected void MoveToBonus(AIBase agent)
{
if (HexManager.UnitCurrentCell.TryGetValue(agent.UnitBase.Color, out var value))
@ -238,7 +132,7 @@ namespace AI
agent.currentPath);
}
private void AttackEnemy(AIBase agent)
protected void AttackEnemy(AIBase agent)
{
var enemy = GetNearestUnit(agent.UnitBase.Weapon.disnatce, agent.UnitBase);
var dir = DirectionHelper.DirectionTo(agent.UnitBase.Instance.transform.position,
@ -246,7 +140,7 @@ namespace AI
agent.AttackTarget(new Vector2(dir.x, dir.z));
}
private void MoveToEnemy(AIBase agent, int dist)
protected void MoveToEnemy(AIBase agent, int dist)
{
var enemies = HexManager.UnitCurrentCell.Where(unit =>
unit.Value.unit.Color != agent.UnitBase.Color &&
@ -257,12 +151,24 @@ namespace AI
Pathfinding.FindPath(HexManager.UnitCurrentCell[agent.UnitBase.Color].cell,
enemies[Random.Range(0, enemies.Count)].Value.cell, agent.currentPath);
}
private void CatchHex(AIBase agent)
protected void CatchHex(AIBase agent)
{
Pathfinding.FindPath(HexManager.UnitCurrentCell[agent.UnitBase.Color].cell, HexManager.CellByColor[UnitColor.Grey].Where(x => x != null).ToList()[
Random.Range(0, HexManager.CellByColor[UnitColor.Grey].Count - 1)]
, agent.currentPath);
}
protected void UseBonus(AIAgent agent, BonusType type)
{
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((Units.Unit.Unit)agent.UnitBase);
}
}

View File

@ -1,20 +0,0 @@
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);
}
}
}

View File

@ -0,0 +1,46 @@
using AI;
using HexFiled;
using Units;
namespace DefaultNamespace.AI
{
public class AIWarior : AIBase
{
public AIWarior(UnitBase unitBase) : base(unitBase)
{
}
public override void FixedExecute(){
if (curentState == BotState.Attack && !_unitBase.IsBusy)
{
_unitBase.Aim(_attackDirection);
_unitBase.StartAttack();
curentState = Unit.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 = Warior.Instance.GetNewBehaviour(this);
}
}
protected override void InitAgent(UnitBase aiBase)
{
AIManager.Instance.AddAgent(this);
HexManager.agents.Add(aiBase.Instance, this);
OnAgentInited?.Invoke(this);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d8232766eef26164e9f591cac9961576
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

114
Assets/Scripts/AI/Unit.cs Normal file
View File

@ -0,0 +1,114 @@
using System;
using System.Linq;
using Data;
using DefaultNamespace.AI;
using Items;
using UnityEngine;
namespace AI
{
public sealed class Unit : AIManager
{
public Unit(AIData data) : base(data)
{
}
protected override void SetBehaviour(BotState state, AIBase agent, int dist)
{
switch (state)
{
case BotState.Patrol:
StartPatrolBehaviour(agent);
break;
case BotState.Agressive:
MoveToEnemy(agent, dist);
break;
case BotState.Attack:
AttackEnemy(agent);
break;
case BotState.CollectingBonus:
StartPatrolBehaviour(agent);
break;
case BotState.ProtectBonusUsage:
StartPatrolBehaviour(agent);
break;
case BotState.AttackBonusUsage:
StartPatrolBehaviour(agent);
break;
case BotState.Dead:
break;
case BotState.Retreet:
Retreet(agent);
break;
default:
throw new ArgumentOutOfRangeException(nameof(state), state, null);
}
}
protected override void InitAI(AIBase agent)
{
SetBehaviour(BotState.Patrol, agent, 500);
}
public override BotState GetNewBehaviour(AIBase agent)
{
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, 500);
return BotState.AttackBonusUsage;
}
var enemy = GetNearestUnit(_data.DistanceToAgr, agent.UnitBase);
if (enemy != null && agent.UnitBase.Hp > agent.UnitBase.maxHP * _data.PercentToRetreet && enemy.IsAlive)
{
if (agent.UnitBase.Hp <= agent.UnitBase.maxHP * _data.PercentToRetreet ||
agent.UnitBase.BaseView.AvailableShots == 0)
{
SetBehaviour(BotState.Retreet, agent, 500);
return BotState.Retreet;
}
if (Vector3.Distance(agent.UnitBase.Instance.transform.position, enemy.Instance.transform.position) <=
agent.UnitBase.Weapon.disnatce)
{
SetBehaviour(BotState.Attack, agent, 500);
return BotState.Attack;
}
SetBehaviour(BotState.Agressive, agent, 500);
return BotState.Agressive;
}
var item = GetNearestItem(agent);
if (item.hex != null)
{
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, 500);
return BotState.CollectingBonus;
}
}
var protect = agent.UnitBase.InventoryDefence.Where(x => x.Item is Bonus { BonusType: BonusType.Defence })
.ToList();
if (protect.Count > 0 && agent.UnitBase.Hp <= agent.UnitBase.maxHP * _data.PercentToUseProtectBonus &&
agent.UnitBase.DefenceBonus == 0)
{
SetBehaviour(BotState.ProtectBonusUsage, agent, 500);
return BotState.ProtectBonusUsage;
}
SetBehaviour(BotState.Patrol, agent, 500);
return BotState.Patrol;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c95536c68c42e6c46b3075074a074ef9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,92 @@
using System;
using System.Linq;
using Data;
using DefaultNamespace.AI;
using UnityEngine;
namespace AI
{
public class Invader : Warior
{
public Invader(AIData data) : base(data)
{
}
public override BotState GetNewBehaviour(AIBase agent)
{
var enemy = GetNearestUnit(_data.DistanceToAgr, agent.UnitBase);
if (enemy != null && agent.UnitBase.Hp > agent.UnitBase.maxHP * _data.PercentToRetreet && enemy.IsAlive)
{
if (agent.UnitBase.Hp <= agent.UnitBase.maxHP * _data.PercentToRetreet ||
agent.UnitBase.BaseView.AvailableShots == 0)
{
SetBehaviour(BotState.Retreet, agent, 500);
return BotState.Retreet;
}
}
SetBehaviour(BotState.Patrol, agent, 500);
return BotState.Patrol;
}
}
public class Warior : AIManager
{
public Warior(AIData data) : base(data)
{
}
public override BotState GetNewBehaviour(AIBase agent)
{
var enemy = GetNearestUnit(_data.DistanceToAgr, agent.UnitBase);
if (enemy != null && agent.UnitBase.Hp > agent.UnitBase.maxHP * _data.PercentToRetreet && enemy.IsAlive)
{
if (agent.UnitBase.Hp <= agent.UnitBase.maxHP * _data.PercentToRetreet ||
agent.UnitBase.BaseView.AvailableShots == 0)
{
SetBehaviour(BotState.Retreet, agent, 500);
return BotState.Retreet;
}
if (Vector3.Distance(agent.UnitBase.Instance.transform.position, enemy.Instance.transform.position) <=
agent.UnitBase.Weapon.disnatce)
{
SetBehaviour(BotState.Attack, agent, 500);
return BotState.Attack;
}
SetBehaviour(BotState.Agressive, agent, 500);
return BotState.Agressive;
}
SetBehaviour(BotState.Patrol, agent, 500);
return BotState.Patrol;
}
protected override void SetBehaviour(BotState state, AIBase agent, int dist)
{
switch (state)
{
case BotState.Patrol:
StartPatrolBehaviour(agent);
break;
case BotState.Agressive:
MoveToEnemy(agent, dist);
break;
case BotState.Attack:
AttackEnemy(agent);
break;
case BotState.Dead:
break;
case BotState.Retreet:
Retreet(agent);
break;
default:
throw new ArgumentOutOfRangeException(nameof(state), state, null);
}
}
protected override void InitAI(AIBase agent)
{
SetBehaviour(BotState.Patrol, agent, 500);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b8e820aaee60c1d45983930a2c54a69e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -15,7 +15,7 @@ public class CheatMenu : MonoBehaviour
[SerializeField] private GameObject grid;
[SerializeField] private Button buttonPrefab;
[SerializeField] private GameObject gridPrefab;
private Unit _player;
private Units.Unit.Unit _player;
private Data.Data _data;
private GameObject _itemsPrefab;
private List<GameObject> _buttons;
@ -23,7 +23,7 @@ public class CheatMenu : MonoBehaviour
public void SetPlayerNData(Data.Data data)
{
_buttons = new List<GameObject>();
_player = (Unit)(HexManager.UnitCurrentCell.FirstOrDefault(unit => ((Unit)unit.Value.unit).IsPlayer).Value.unit);
_player = (Units.Unit.Unit)(HexManager.UnitCurrentCell.FirstOrDefault(unit => ((Units.Unit.Unit)unit.Value.unit).IsPlayer).Value.unit);
_itemsPrefab = new GameObject("CheatedItems");
showButton.onClick.AddListener(() => scrollRect.SetActive(!scrollRect.activeSelf));

View File

@ -1,17 +1,12 @@
using System.Collections.Generic;
using AI;
using CamControl;
using AI;
using Chars;
using DefaultNamespace;
using DefaultNamespace.AI;
using GameUI;
using HexFiled;
using Items;
using Units;
using Units.Wariors;
using UnityEngine;
using Weapons;
using Random = UnityEngine.Random;
namespace Controller
{
@ -19,7 +14,8 @@ namespace Controller
{
public GameInit(Controllers controllers, Data.Data data)
{
new AIManager(data.AIData);
new Unit(data.AIData);
new Warior(data.AIData);
var hexGrid = new HexGrid(data.FieldData);
new MusicController();
new VFXController();

View File

@ -5,6 +5,7 @@ using Items;
using Units;
using UnityEngine;
using UnityEngine.UI;
using Unit = Units.Unit.Unit;
namespace GameUI
{

View File

@ -1,4 +1,5 @@
using DefaultNamespace;
using System;
using DefaultNamespace;
using HexFiled;
using Units;
using UnityEngine;
@ -31,7 +32,7 @@ namespace Items
public GameObject UsisngVFX => usisngVFX;
public void Invoke(Unit unit)
public void Invoke(Units.Unit.Unit unit)
{
unit.SetUpBonus(duration, value, bonusType);
var vfx = VFXController.Instance.PlayEffect(usisngVFX, unit.Instance.transform);

View File

@ -69,7 +69,7 @@ namespace Items
var obj = Instantiate(buildingPrefab,
cell.transform.position + buildingPrefab.transform.position, Quaternion.identity);
obj.GetComponent<ISetUp>().SetUp(container.Unit);
var unit = (Unit) container.Unit;
var unit = (Units.Unit.Unit) container.Unit;
if (!unit.IsPlayer)
{
obj.transform.GetChilds().Where(x => !x.TryGetComponent(typeof(ISetUp), out _))

View File

@ -5,6 +5,7 @@ using Units;
using Units.Views;
using UnityEngine;
using Object = UnityEngine.Object;
using Unit = Units.Unit.Unit;
namespace Items
{

View File

@ -11,7 +11,7 @@ using Runtime.Controller;
using Units;
using Units.Views;
using UnityEngine;
using Object = UnityEngine.Object;
using Unit = Units.Unit.Unit;
namespace Chars
{

View File

@ -15,7 +15,7 @@ using Weapons;
using Object = UnityEngine.Object;
namespace Units
namespace Units.Unit
{
public class Unit : UnitBase
{

View File

@ -22,7 +22,7 @@ namespace Chars
private readonly Data.Data _data;
private readonly Controllers _controllers;
private readonly UIController _uiController;
public Unit Player { get; private set; }
public Units.Unit.Unit Player { get; private set; }
public UnitFactory(HexGrid grid, Data.Data data, UIController uiController, PaintedController paintedController,
Controllers controllers)
@ -56,7 +56,7 @@ namespace Chars
if (unitInfo.isPlayer)
{
var player = new Unit(unitInfo, _chosenWeapon, _hexGrid, _data);
var player = new Units.Unit.Unit(unitInfo, _chosenWeapon, _hexGrid, _data);
PlayerControl playerControl = null;
CameraControl cameraControl =
@ -86,7 +86,7 @@ namespace Chars
}
else
{
var enemy = new Unit(unitInfo,
var enemy = new Units.Unit.Unit(unitInfo,
_data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid, _data);
@ -94,7 +94,7 @@ namespace Chars
if (unitInfo.isAI)
{
AIPatrol agent = new AIPatrol(enemy);
AIWarior agent = new AIWarior(enemy);
enemy.OnSpawned += x => _controllers.Add(agent);
enemy.OnDeath += x => { _controllers.Remove(agent); };
}

View File

@ -2,7 +2,6 @@ using System.Collections;
using DefaultNamespace;
using DG.Tweening;
using HexFiled;
using Units;
using UnityEngine;
using Weapons;
@ -33,12 +32,12 @@ namespace Units.Views
protected override IEnumerator Regen()
{
if (_mana >= ((Unit)_unit).UnitData.maxMana)
if (_mana >= (( Units.Unit.Unit)_unit).UnitData.maxMana)
{
yield break;
}
while (_mana < ((Unit)_unit).UnitData.maxMana)
while (_mana < ((Units.Unit.Unit)_unit).UnitData.maxMana)
{
yield return new WaitForSeconds(1f);
_mana += _manaRegen;

View File

@ -75,7 +75,6 @@ namespace Units.Views
public void SetInvisible(bool isVisible)
{
var i = 0;
transform.GetChilds().ForEach(x =>
{
if (x.gameObject.TryGetComponent(typeof(SkinnedMeshRenderer), out var mesh))
@ -152,7 +151,7 @@ namespace Units.Views
return true;
}
public void RegenMana()
public virtual void RegenMana()
{
_mana = _unit.Mana;
if (_previosRegen != null)

View File

@ -2,6 +2,7 @@
using DefaultNamespace;
using DG.Tweening;
using HexFiled;
using Units.Wariors.AbstractsBase;
using UnityEngine;
using Weapons;
@ -29,12 +30,12 @@ namespace Units.Views
protected override IEnumerator Regen()
{
if (_mana >= ((Unit)_unit).UnitData.maxMana)
if (_mana >= ((Warior)_unit).Data.maxMana)
{
yield break;
}
while (_mana < ((Unit)_unit).UnitData.maxMana)
while (_mana < ((Warior)_unit).Data.maxMana)
{
yield return new WaitForSeconds(1f);
_mana += _manaRegen;

View File

@ -1,6 +1,7 @@
using Data;
using DG.Tweening;
using HexFiled;
using UnityEngine;
using Weapons;
namespace Units.Wariors.AbstractsBase
@ -12,6 +13,7 @@ namespace Units.Wariors.AbstractsBase
}
public override void Move(HexDirection direction)
{
if (_cell.GetNeighbor(direction) == null) return;
base.Move(direction);
if (_cell.GetNeighbor(direction).Color == Color ||
(_cell.GetNeighbor(direction).Color == _easyCaptureColor && _easyCaptureColor != UnitColor.Grey))

View File

@ -33,7 +33,7 @@ namespace Units.Wariors
var patrol = new TestInvader(wariorInfo,_data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid,unitColor);
AIAgent agent = new AIAgent (patrol);
AIInvader agent = new AIInvader (patrol);
patrol.OnSpawned += x => _controllers.Add(agent);
patrol.OnDeath += x => { _controllers.Remove(agent); };