added capture ability. fixes
This commit is contained in:
parent
e8fdc6c5b5
commit
dbcc62d965
@ -19,7 +19,7 @@ MonoBehaviour:
|
|||||||
_spawnChance: 0.766
|
_spawnChance: 0.766
|
||||||
- item: {fileID: 11400000, guid: ef628c3158b0ea34bb919ca105507009, type: 2}
|
- item: {fileID: 11400000, guid: ef628c3158b0ea34bb919ca105507009, type: 2}
|
||||||
_spawnChance: 0.918
|
_spawnChance: 0.918
|
||||||
- item: {fileID: 0}
|
- item: {fileID: 11400000, guid: ef628c3158b0ea34bb919ca105507009, type: 2}
|
||||||
_spawnChance: 0
|
_spawnChance: 0.918
|
||||||
fromTimeSpawn: 2.93
|
fromTimeSpawn: 2.93
|
||||||
toTimeSpawn: 10
|
toTimeSpawn: 10
|
||||||
|
17
Assets/Resources/Data/Items/CaptureTAbility.asset
Normal file
17
Assets/Resources/Data/Items/CaptureTAbility.asset
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
%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: 461496314fe84e509ae72dd06538b62c, type: 3}
|
||||||
|
m_Name: CaptureTAbility
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
iconPrefab: {fileID: 0}
|
||||||
|
icon: {fileID: 0}
|
||||||
|
AimCanvas: {fileID: 0}
|
8
Assets/Resources/Data/Items/CaptureTAbility.asset.meta
Normal file
8
Assets/Resources/Data/Items/CaptureTAbility.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 133e523fdd159754e8bf8927faec5b0f
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -13,7 +13,7 @@ MonoBehaviour:
|
|||||||
m_Name: UnitsData
|
m_Name: UnitsData
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_units:
|
_units:
|
||||||
- isPlayer: 1
|
- isPlayer: 0
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: 19
|
x: 19
|
||||||
z: 4
|
z: 4
|
||||||
@ -23,7 +23,7 @@ MonoBehaviour:
|
|||||||
maxMana: 1000
|
maxMana: 1000
|
||||||
maxHP: 100
|
maxHP: 100
|
||||||
inventoryCapacity: 4
|
inventoryCapacity: 4
|
||||||
- isPlayer: 0
|
- isPlayer: 1
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: 3
|
x: 3
|
||||||
z: 4
|
z: 4
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Timers;
|
|
||||||
using AI;
|
using AI;
|
||||||
using CamControl;
|
using CamControl;
|
||||||
using Chars;
|
using Chars;
|
||||||
using DefaultNamespace;
|
using DefaultNamespace;
|
||||||
using DefaultNamespace.AI;
|
using DefaultNamespace.AI;
|
||||||
using DG.Tweening;
|
|
||||||
using GameUI;
|
using GameUI;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
using Items;
|
using Items;
|
||||||
using Units;
|
using Units;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Weapons;
|
using Weapons;
|
||||||
using Object = UnityEngine.Object;
|
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
namespace Controller
|
namespace Controller
|
||||||
@ -28,6 +24,7 @@ namespace Controller
|
|||||||
new VFXController();
|
new VFXController();
|
||||||
MusicController.Instance.SetMusicData(data.MusicData);
|
MusicController.Instance.SetMusicData(data.MusicData);
|
||||||
controllers.Add(hexGrid);
|
controllers.Add(hexGrid);
|
||||||
|
var paintedController = new PaintedController();
|
||||||
|
|
||||||
data.WeaponsData.WeaponsList.ForEach(x => x.SetModifiedDamage(0));
|
data.WeaponsData.WeaponsList.ForEach(x => x.SetModifiedDamage(0));
|
||||||
|
|
||||||
@ -61,6 +58,7 @@ namespace Controller
|
|||||||
units.Add(player);
|
units.Add(player);
|
||||||
|
|
||||||
player.OnDeath += uiController.AdsMob.ShowCanvas;
|
player.OnDeath += uiController.AdsMob.ShowCanvas;
|
||||||
|
player.OnDeath += paintedController.PaintOnDeath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -70,26 +68,21 @@ namespace Controller
|
|||||||
controllers.Add(enemyController);
|
controllers.Add(enemyController);
|
||||||
units.Add(enemy);
|
units.Add(enemy);
|
||||||
AIAgent agent = new AIAgent(unit, enemy);
|
AIAgent agent = new AIAgent(unit, enemy);
|
||||||
//controllers.Add(agent);
|
controllers.Add(agent);
|
||||||
enemy.OnDeath += x => { controllers.Remove(agent); };
|
enemy.OnDeath += x => { controllers.Remove(agent); };
|
||||||
|
enemy.OnDeath += paintedController.PaintOnDeath;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var unitFactory = new UnitFactory(units, hexGrid);
|
var unitFactory = new UnitFactory(units, hexGrid);
|
||||||
|
|
||||||
hexGrid.OnGridLoaded += unitFactory.Spawn;
|
hexGrid.OnGridLoaded += unitFactory.Spawn;
|
||||||
|
|
||||||
var paintedController = new PaintedController();
|
|
||||||
|
|
||||||
hexGrid.OnHexPainted += paintedController.SetHexColors;
|
hexGrid.OnHexPainted += paintedController.SetHexColors;
|
||||||
|
|
||||||
hexGrid.OnHexPainted += itemFabric.UpdateCellToOpenList;
|
hexGrid.OnHexPainted += itemFabric.UpdateCellToOpenList;
|
||||||
hexGrid.OnHexPainted += paintedController.CheckDeathOrDestroy;
|
hexGrid.OnHexPainted += paintedController.CheckDeathOrDestroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Type> SetUpItems()
|
|
||||||
{
|
|
||||||
return new List<Type>() { typeof(Building), typeof(Bonus) };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ namespace HexFiled
|
|||||||
if (neighbours.Any())
|
if (neighbours.Any())
|
||||||
{
|
{
|
||||||
var dir = DirectionHelper.DirectionTo(end.transform.position,
|
var dir = DirectionHelper.DirectionTo(end.transform.position,
|
||||||
neighbours[Random.Range(0, neighbours.Count)].transform.position);
|
neighbours[Random.Range(0, neighbours.Count - 1)].transform.position);
|
||||||
path.Enqueue(DirectionHelper.VectorToDirection(new Vector2(dir.x, dir.z)));
|
path.Enqueue(DirectionHelper.VectorToDirection(new Vector2(dir.x, dir.z)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ namespace HexFiled
|
|||||||
itters++;
|
itters++;
|
||||||
} while (end == null && itters < 5);
|
} while (end == null && itters < 5);
|
||||||
|
|
||||||
if (itters >= 5)
|
if (itters >= 3)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,15 @@ namespace HexFiled
|
|||||||
HexManager.UnitCurrentCell = new Dictionary<UnitColor, (HexCell cell, Unit unit)>();
|
HexManager.UnitCurrentCell = new Dictionary<UnitColor, (HexCell cell, Unit unit)>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PaintOnDeath(Unit unit)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < HexManager.CellByColor[unit.Color].Count; i++)
|
||||||
|
{
|
||||||
|
HexManager.CellByColor[unit.Color][i].PaintHex(UnitColor.GREY);
|
||||||
|
}
|
||||||
|
|
||||||
|
HexManager.CellByColor.Remove(unit.Color);
|
||||||
|
}
|
||||||
public void CheckDeathOrDestroy(HexCell cell)
|
public void CheckDeathOrDestroy(HexCell cell)
|
||||||
{
|
{
|
||||||
List<Unit> unitsToDeath = new List<Unit>();
|
List<Unit> unitsToDeath = new List<Unit>();
|
||||||
|
@ -13,7 +13,7 @@ namespace Items
|
|||||||
|
|
||||||
public void Invoke(Action action)
|
public void Invoke(Action action)
|
||||||
{
|
{
|
||||||
Unit.UseItem(this);
|
|
||||||
OnItemUsed += action;
|
OnItemUsed += action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
Assets/Scripts/Items/CaptureAbility.cs
Normal file
37
Assets/Scripts/Items/CaptureAbility.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using DefaultNamespace;
|
||||||
|
using HexFiled;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace Items
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(fileName = "CaptureAbility", menuName = "Item/Ability")]
|
||||||
|
public class CaptureAbility : Item
|
||||||
|
{
|
||||||
|
[SerializeField] private GameObject AimCanvas;
|
||||||
|
private GameObject _aimInstance;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void Invoke(Action action)
|
||||||
|
{
|
||||||
|
OnItemUsed += action;
|
||||||
|
_aimInstance = SpawnHelper.Spawn(AimCanvas, Vector3.zero, Unit.Instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Aim(Vector2 direction)
|
||||||
|
{
|
||||||
|
_aimInstance.transform.LookAt(HexManager.UnitCurrentCell[Unit.Color].cell
|
||||||
|
.GetNeighbor(DirectionHelper.VectorToDirection(direction)).transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UseAbility()
|
||||||
|
{
|
||||||
|
Unit.UseItem(this);
|
||||||
|
|
||||||
|
OnItemUsed?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Scripts/Items/CaptureAbility.cs.meta
Normal file
3
Assets/Scripts/Items/CaptureAbility.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 461496314fe84e509ae72dd06538b62c
|
||||||
|
timeCreated: 1642532470
|
@ -124,8 +124,8 @@ namespace Units
|
|||||||
{
|
{
|
||||||
_isBusy = true;
|
_isBusy = true;
|
||||||
_isCapturing = _data.color != _cell.GetNeighbor(direction).Color;
|
_isCapturing = _data.color != _cell.GetNeighbor(direction).Color;
|
||||||
HexManager.UnitCurrentCell[_data.color] = (_cell, this);
|
|
||||||
_cell = _cell.GetNeighbor(direction);
|
_cell = _cell.GetNeighbor(direction);
|
||||||
|
HexManager.UnitCurrentCell[_data.color] = (_cell, this);
|
||||||
RotateUnit(new Vector2((_cell.transform.position - _instance.transform.position).normalized.x,
|
RotateUnit(new Vector2((_cell.transform.position - _instance.transform.position).normalized.x,
|
||||||
(_cell.transform.position - _instance.transform.position).normalized.z));
|
(_cell.transform.position - _instance.transform.position).normalized.z));
|
||||||
_animator.SetTrigger("Move");
|
_animator.SetTrigger("Move");
|
||||||
@ -211,9 +211,6 @@ namespace Units
|
|||||||
|
|
||||||
private void RegenMana()
|
private void RegenMana()
|
||||||
{
|
{
|
||||||
if (_mana + _data.manaRegen > _data.maxMana)
|
|
||||||
_mana = _data.maxMana;
|
|
||||||
else
|
|
||||||
_mana += _data.manaRegen;
|
_mana += _data.manaRegen;
|
||||||
UpdateBarCanvas();
|
UpdateBarCanvas();
|
||||||
}
|
}
|
||||||
@ -316,8 +313,6 @@ namespace Units
|
|||||||
MusicController.Instance.AddAudioSource(vfx);
|
MusicController.Instance.AddAudioSource(vfx);
|
||||||
MusicController.Instance.PlayAudioClip(MusicController.Instance.MusicData.SfxMusic.Death, vfx);
|
MusicController.Instance.PlayAudioClip(MusicController.Instance.MusicData.SfxMusic.Death, vfx);
|
||||||
MusicController.Instance.RemoveAudioSource(_instance);
|
MusicController.Instance.RemoveAudioSource(_instance);
|
||||||
HexManager.CellByColor[Color].ToList().ForEach(cell => cell.PaintHex(UnitColor.GREY));
|
|
||||||
HexManager.CellByColor.Remove(Color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,6 +139,11 @@ public class UnitView : MonoBehaviour
|
|||||||
Destroy(other.gameObject);
|
Destroy(other.gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerStay(Collider other)
|
||||||
|
{
|
||||||
ItemView itemView = other.GetComponent<ItemView>();
|
ItemView itemView = other.GetComponent<ItemView>();
|
||||||
|
|
||||||
if (itemView != null && _unit.PickUpItem(itemView.Item))
|
if (itemView != null && _unit.PickUpItem(itemView.Item))
|
||||||
@ -177,7 +182,7 @@ public class UnitView : MonoBehaviour
|
|||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (_mana < _unit.Data.maxHP)
|
while (_mana < _unit.Data.maxMana)
|
||||||
{
|
{
|
||||||
yield return new WaitForSeconds(1f);
|
yield return new WaitForSeconds(1f);
|
||||||
_mana += _manaRegen;
|
_mana += _manaRegen;
|
||||||
|
File diff suppressed because one or more lines are too long
1
JsonDataChosenWeapon.json
Normal file
1
JsonDataChosenWeapon.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"StandartAttac","icon":{"instanceID":28808},"objectToThrow":{"instanceID":21604},"VFXGameObject":{"instanceID":21378},"modifiedDamage":0,"damage":10,"speed":1.0,"disnatce":5,"reloadTime":3.0,"shots":3,"shotSound":{"instanceID":18618},"hitSound":{"instanceID":19910}}
|
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