Final
This commit is contained in:
parent
858dd43fed
commit
3a31050f81
@ -99,7 +99,7 @@ MonoBehaviour:
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Bits: 319
|
||||
--- !u!1 &4408587040574959135
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -165,8 +165,7 @@ MonoBehaviour:
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 4007780875627063171, guid: e816ecf82b202d0449267fe992da842e,
|
||||
type: 3}
|
||||
m_Sprite: {fileID: 4007780875627063171, guid: e816ecf82b202d0449267fe992da842e, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
|
@ -55,7 +55,7 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_AdditionalShaderChannelsFlag: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
@ -98,4 +98,4 @@ MonoBehaviour:
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Bits: 319
|
||||
|
1485
Assets/Prefab/CreateWarior.prefab
Normal file
1485
Assets/Prefab/CreateWarior.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Prefab/CreateWarior.prefab.meta
Normal file
7
Assets/Prefab/CreateWarior.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5491a92bf650d0840bc8a356a8463340
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1036,7 +1036,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &7535381195931813741
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -268,7 +268,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8135886326569738822, guid: 56fae09712773584fb63896d473a98ee, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: -600
|
||||
value: -1793.1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8135886326569738822, guid: 56fae09712773584fb63896d473a98ee, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -437,7 +437,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8135886326569738822, guid: 56fae09712773584fb63896d473a98ee, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: -600
|
||||
value: -1793.068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8135886326569738822, guid: 56fae09712773584fb63896d473a98ee, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -491,6 +491,10 @@ PrefabInstance:
|
||||
propertyPath: timeToFade
|
||||
value: 0.3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8135886326569738823, guid: 56fae09712773584fb63896d473a98ee, type: 3}
|
||||
propertyPath: handleRange
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8135886326569738823, guid: 56fae09712773584fb63896d473a98ee, type: 3}
|
||||
propertyPath: transparency
|
||||
value: 0.3
|
||||
|
@ -19,3 +19,4 @@ MonoBehaviour:
|
||||
inventoryView: {fileID: 1527356263590969195, guid: ff3bc3b17ddefd14eb798b22cf0a854f, type: 3}
|
||||
adsMob: {fileID: 4936557783008875079, guid: 85d07d76a184d2446b7055ffc6293eeb, type: 3}
|
||||
cheatMenu: {fileID: 791049004453965678, guid: 33deb58e3852451419239c8df4119f91, type: 3}
|
||||
wariorSpawnView: {fileID: 5306195404982712185, guid: 5491a92bf650d0840bc8a356a8463340, type: 3}
|
||||
|
@ -19,3 +19,4 @@ MonoBehaviour:
|
||||
inventoryView: {fileID: 1527356263590969195, guid: ff3bc3b17ddefd14eb798b22cf0a854f, type: 3}
|
||||
adsMob: {fileID: 4936557783008875079, guid: 85d07d76a184d2446b7055ffc6293eeb, type: 3}
|
||||
cheatMenu: {fileID: 791049004453965678, guid: 33deb58e3852451419239c8df4119f91, type: 3}
|
||||
wariorSpawnView: {fileID: 5306195404982712185, guid: 5491a92bf650d0840bc8a356a8463340, type: 3}
|
||||
|
@ -19,3 +19,4 @@ MonoBehaviour:
|
||||
inventoryView: {fileID: 1527356263590969195, guid: ff3bc3b17ddefd14eb798b22cf0a854f, type: 3}
|
||||
adsMob: {fileID: 4936557783008875079, guid: 85d07d76a184d2446b7055ffc6293eeb, type: 3}
|
||||
cheatMenu: {fileID: 791049004453965678, guid: 33deb58e3852451419239c8df4119f91, type: 3}
|
||||
wariorSpawnView: {fileID: 5306195404982712185, guid: 5491a92bf650d0840bc8a356a8463340, type: 3}
|
||||
|
@ -158,7 +158,7 @@ MonoBehaviour:
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Bits: 319
|
||||
--- !u!114 &763084230
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -30,16 +30,15 @@ namespace Controller
|
||||
UIController uiController = new UIController(data.UIData);
|
||||
uiController.Spawn(); //TODO при паузе Dotween ругается
|
||||
|
||||
|
||||
var unitFactory = new UnitFactory(hexGrid, data, uiController, paintedController, controllers);
|
||||
var wariorFactory = new WariorFactory(hexGrid, controllers, data);
|
||||
var unitFactory = new UnitFactory(hexGrid, data, uiController, paintedController, controllers);
|
||||
|
||||
|
||||
hexGrid.OnGridLoaded += () => unitFactory.SpawnList(data.UnitData.Units);
|
||||
|
||||
hexGrid.OnHexPainted += paintedController.SetHexColors;
|
||||
|
||||
hexGrid.SpawnField();
|
||||
unitFactory.Player.OnShoot += wariorFactory.Spawn;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ namespace Data
|
||||
[SerializeField] private PlayerInventoryView inventoryView;
|
||||
[SerializeField] private AdsMob adsMob;
|
||||
[SerializeField] private CheatMenu cheatMenu;
|
||||
[SerializeField] private WariorSpawnView wariorSpawnView;
|
||||
public List<GameObject> ObjectsToSpawn => _objectsToSpawn;
|
||||
public PlayerControlView PlayerControlView => joystickView;
|
||||
|
||||
public PlayerInventoryView InventoryView => inventoryView;
|
||||
public WariorSpawnView WariorSpawnView => wariorSpawnView;
|
||||
|
||||
public AdsMob AdsMob => adsMob;
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace Data
|
||||
public class WariorsData : ScriptableObject
|
||||
{
|
||||
[SerializeField] private List<WariorInfo> _wariors;
|
||||
public List<WariorInfo> Wariors { get { return _wariors; } }
|
||||
public WariorInfo Wariors { get { return _wariors[0]; } }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
@ -16,6 +16,7 @@ namespace GameUI
|
||||
public AdsMob AdsMob { get; private set; }
|
||||
|
||||
public CheatMenu CheatMenu { get; private set; }
|
||||
public WariorSpawnView WariorSpawnView { get; private set; }
|
||||
|
||||
public UIController(UIData uiData)
|
||||
{
|
||||
@ -25,13 +26,14 @@ namespace GameUI
|
||||
public void Spawn()
|
||||
{
|
||||
var canvasGroup = Object.Instantiate(_uiData.Canvas);
|
||||
|
||||
|
||||
PlayerControlView = Object.Instantiate(_uiData.PlayerControlView, canvasGroup.transform);
|
||||
PlayerInventoryView = Object.Instantiate(_uiData.InventoryView, canvasGroup.transform);
|
||||
_uiData.ObjectsToSpawn.ForEach(x => Object.Instantiate(x, canvasGroup.transform));
|
||||
CheatMenu = Object.Instantiate(_uiData.CheatMenu, canvasGroup.transform);
|
||||
WariorSpawnView = Object.Instantiate(_uiData.WariorSpawnView, canvasGroup.transform);
|
||||
AdsMob = Object.Instantiate(_uiData.AdsMob, canvasGroup.transform);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -21,14 +21,12 @@ namespace Units.Unit
|
||||
{
|
||||
private UnitInfo _unitData;
|
||||
public UnitInfo UnitData => _unitData;
|
||||
private WariorsData wariorData;
|
||||
public bool IsPlayer => _unitData.isPlayer;
|
||||
public event Action<ItemContainer> OnItemPickUp;
|
||||
public event WariorFactory.SpawnWarior OnShoot;
|
||||
private List<UnitBase> NotEnemy;
|
||||
|
||||
|
||||
public Unit(UnitInfo unitData, Weapon weapon, HexGrid hexGrid, Data.Data data)
|
||||
public Unit(UnitInfo unitData, Weapon weapon, HexGrid hexGrid)
|
||||
{
|
||||
Initialize(weapon, hexGrid);
|
||||
_unitData = unitData;
|
||||
@ -36,7 +34,6 @@ namespace Units.Unit
|
||||
maxHP = _unitData.maxHP;
|
||||
maxMana = _unitData.maxMana;
|
||||
InventoryCapacity = _unitData.inventoryCapacity;
|
||||
wariorData = data.WariorsData;
|
||||
}
|
||||
|
||||
public override void Retreet(HexDirection dir)
|
||||
@ -238,8 +235,6 @@ namespace Units.Unit
|
||||
Aim(_direction);
|
||||
|
||||
_weapon.Fire(_instance.transform, _direction, this);
|
||||
if (IsPlayer)
|
||||
OnShoot.Invoke(wariorData.Wariors[1], _unitData.color);
|
||||
}
|
||||
|
||||
protected override void UpdateBarCanvas()
|
||||
|
@ -56,7 +56,7 @@ namespace Chars
|
||||
|
||||
if (unitInfo.isPlayer)
|
||||
{
|
||||
var player = new Units.Unit.Unit(unitInfo, _chosenWeapon, _hexGrid, _data);
|
||||
var player = new Units.Unit.Unit(unitInfo, _chosenWeapon, _hexGrid);
|
||||
PlayerControl playerControl = null;
|
||||
|
||||
CameraControl cameraControl =
|
||||
@ -87,7 +87,7 @@ namespace Chars
|
||||
else
|
||||
{
|
||||
var enemy = new Units.Unit.Unit(unitInfo,
|
||||
_data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid, _data);
|
||||
_data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid);
|
||||
|
||||
|
||||
enemy.OnDeath += unit => RandomSpawn(unitInfo);
|
||||
|
110
Assets/Scripts/Units/Views/WariorSpawnView.cs
Normal file
110
Assets/Scripts/Units/Views/WariorSpawnView.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using Units.Wariors;
|
||||
using System;
|
||||
using HexFiled;
|
||||
using System.Linq;
|
||||
using Units.Wariors.AbstractsBase;
|
||||
using Random = UnityEngine.Random;
|
||||
using DefaultNamespace.AI;
|
||||
|
||||
public class WariorSpawnView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button wariorPanelOpen;
|
||||
[Space]
|
||||
[SerializeField] private GameObject panel;
|
||||
[SerializeField] private Button closePanel;
|
||||
[SerializeField] private Button warior1;
|
||||
[SerializeField] private Button warior2;
|
||||
[SerializeField] private Button warior3;
|
||||
|
||||
[HideInInspector] public Button Warior1 => warior1;
|
||||
[HideInInspector] public Button Warior2 => warior2;
|
||||
[HideInInspector] public Button Warior3 => warior3;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
spawnAttacked attacked = new spawnAttacked(SpawnAttacked);
|
||||
spawnPatrol patrol = new spawnPatrol(SpawnPatrol);
|
||||
spawnInvader invader = new spawnInvader(SpawnInvader);
|
||||
War1 += SpawnInvader;
|
||||
War2 += patrol.Invoke;
|
||||
War3 += attacked.Invoke;
|
||||
closePanel.onClick.AddListener(OpenClosePanel(false));
|
||||
wariorPanelOpen.onClick.AddListener(OpenClosePanel(true));
|
||||
warior1.onClick.AddListener(War1);
|
||||
warior2.onClick.AddListener(War2);
|
||||
warior3.onClick.AddListener(War3);
|
||||
}
|
||||
private UnityAction OpenClosePanel(bool state) => () => panel.SetActive(state);
|
||||
public UnityAction War1;
|
||||
public UnityAction War2;
|
||||
public UnityAction War3;
|
||||
|
||||
public delegate void spawnInvader();
|
||||
public delegate void spawnPatrol();
|
||||
public delegate void spawnAttacked();
|
||||
|
||||
public void SpawnInvader()
|
||||
{
|
||||
Debug.Log("заспавнил врага1");
|
||||
var unitColor = UnitColor.Yellow;
|
||||
var spawnPos =
|
||||
HexManager.CellByColor[unitColor].Where(x => x != null).ToList()[
|
||||
Random.Range(0, HexManager.CellByColor[unitColor].Count - 1)];
|
||||
|
||||
var patrol = new TestInvader(WariorFactory._wariorData.Wariors, WariorFactory._data.WeaponsData.WeaponsList[Random.Range(0, WariorFactory._data.WeaponsData.WeaponsList.Count - 1)], WariorFactory._hexGrid, unitColor);
|
||||
|
||||
AIInvader agent = new AIInvader(patrol);
|
||||
patrol.OnSpawned += x => WariorFactory._controllers.Add(agent);
|
||||
patrol.OnDeath += x => { WariorFactory._controllers.Remove(agent); };
|
||||
|
||||
patrol.Spawn(spawnPos.coordinates, spawnPos);
|
||||
spawnPos.isSpawnPos = false;
|
||||
|
||||
patrol.BaseView.SetBar(WariorFactory._data.UnitData.BotBarCanvas, WariorFactory._data.UnitData.AttackAimCanvas);
|
||||
}
|
||||
public void SpawnPatrol()
|
||||
{
|
||||
var unitColor = UnitColor.Yellow;
|
||||
var spawnPos =
|
||||
HexManager.CellByColor[unitColor].Where(x => x != null).ToList()[
|
||||
Random.Range(0, HexManager.CellByColor[unitColor].Count - 1)];
|
||||
|
||||
var patrol = new Holem(WariorFactory._wariorData.Wariors, WariorFactory._data.WeaponsData.WeaponsList[Random.Range(0, WariorFactory._data.WeaponsData.WeaponsList.Count - 1)], WariorFactory._hexGrid, unitColor);
|
||||
|
||||
AIWarior agent = new AIWarior(patrol);
|
||||
patrol.OnSpawned += x => WariorFactory._controllers.Add(agent);
|
||||
patrol.OnDeath += x => { WariorFactory._controllers.Remove(agent); };
|
||||
|
||||
patrol.Spawn(spawnPos.coordinates, spawnPos);
|
||||
spawnPos.isSpawnPos = false;
|
||||
|
||||
patrol.BaseView.SetBar(WariorFactory._data.UnitData.BotBarCanvas, WariorFactory._data.UnitData.AttackAimCanvas);
|
||||
Debug.Log("заспавнил врага2");
|
||||
}
|
||||
public void SpawnAttacked()
|
||||
{
|
||||
var unitColor = UnitColor.Yellow;
|
||||
var spawnPos =
|
||||
HexManager.CellByColor[unitColor].Where(x => x != null).ToList()[
|
||||
Random.Range(0, HexManager.CellByColor[unitColor].Count - 1)];
|
||||
|
||||
var patrol = new AssailantTest(WariorFactory._wariorData.Wariors, WariorFactory._data.WeaponsData.WeaponsList[Random.Range(0, WariorFactory._data.WeaponsData.WeaponsList.Count - 1)], WariorFactory._hexGrid, unitColor);
|
||||
|
||||
AIWarior agent = new AIWarior(patrol);
|
||||
patrol.OnSpawned += x => WariorFactory._controllers.Add(agent);
|
||||
patrol.OnDeath += x => { WariorFactory._controllers.Remove(agent); };
|
||||
|
||||
patrol.Spawn(spawnPos.coordinates, spawnPos);
|
||||
spawnPos.isSpawnPos = false;
|
||||
|
||||
patrol.BaseView.SetBar(WariorFactory._data.UnitData.BotBarCanvas, WariorFactory._data.UnitData.AttackAimCanvas);
|
||||
Debug.Log("заспавнил врага3");
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Units/Views/WariorSpawnView.cs.meta
Normal file
11
Assets/Scripts/Units/Views/WariorSpawnView.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f4aebd6e48899d479fcb8561afb8aa5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -6,42 +6,27 @@ using HexFiled;
|
||||
using System.Linq;
|
||||
using Units.Wariors.AbstractsBase;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using Weapons;
|
||||
|
||||
namespace Units.Wariors
|
||||
{
|
||||
public class WariorFactory
|
||||
{
|
||||
private readonly HexGrid _hexGrid;
|
||||
private readonly Controllers _controllers;
|
||||
private readonly Data.Data _data;
|
||||
public static HexGrid _hexGrid;
|
||||
public static Controllers _controllers;
|
||||
public static Data.Data _data;
|
||||
public static UIData _uiData;
|
||||
public static WariorsData _wariorData;
|
||||
|
||||
public WariorFactory(HexGrid grid, Controllers controllers, Data.Data data)
|
||||
{
|
||||
_hexGrid = grid;
|
||||
_data = data;
|
||||
_controllers = controllers;
|
||||
_uiData = data.UIData;
|
||||
_wariorData = data.WariorsData;
|
||||
}
|
||||
|
||||
public delegate UnitBase SpawnWarior(WariorInfo wariorInfo, UnitColor unitColor);
|
||||
public UnitBase Spawn(WariorInfo wariorInfo , UnitColor unitColor)
|
||||
{
|
||||
unitColor = UnitColor.Yellow;
|
||||
var spawnPos =
|
||||
HexManager.CellByColor[unitColor].Where(x => x != null).ToList()[
|
||||
Random.Range(0, HexManager.CellByColor[unitColor].Count - 1)];
|
||||
|
||||
var patrol = new TestInvader(wariorInfo,_data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid,unitColor);
|
||||
|
||||
AIInvader agent = new AIInvader (patrol);
|
||||
patrol.OnSpawned += x => _controllers.Add(agent);
|
||||
patrol.OnDeath += x => { _controllers.Remove(agent); };
|
||||
|
||||
patrol.Spawn(spawnPos.coordinates, spawnPos);
|
||||
spawnPos.isSpawnPos = false;
|
||||
|
||||
patrol.BaseView.SetBar(_data.UnitData.BotBarCanvas, _data.UnitData.AttackAimCanvas);
|
||||
return patrol;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user