fixed cheat menu
This commit is contained in:
parent
f222ed4bec
commit
7e09b90397
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HexFiled;
|
||||
using Items;
|
||||
@ -16,12 +17,14 @@ public class CheatMenu : MonoBehaviour
|
||||
[SerializeField] private GameObject gridPrefab;
|
||||
private Unit _player;
|
||||
private Data.Data _data;
|
||||
private GameObject ItemsPrefab;
|
||||
private GameObject _itemsPrefab;
|
||||
private List<GameObject> _buttons;
|
||||
|
||||
public void SetPlayerNData(Unit player, Data.Data data)
|
||||
{
|
||||
_buttons = new List<GameObject>();
|
||||
_player = player;
|
||||
ItemsPrefab = new GameObject("CheatedItems");
|
||||
_itemsPrefab = new GameObject("CheatedItems");
|
||||
|
||||
showButton.onClick.AddListener(() => scrollRect.SetActive(!scrollRect.activeSelf));
|
||||
_data = data;
|
||||
@ -34,6 +37,7 @@ public class CheatMenu : MonoBehaviour
|
||||
{
|
||||
|
||||
var itemGridGo = Instantiate(gridPrefab, grid.transform);
|
||||
_buttons.Add(itemGridGo);
|
||||
var itemGrid = itemGridGo.GetComponentInChildren<GridLayoutGroup>();
|
||||
itemGridGo.GetComponentInChildren<TMP_Text>().text = "Items";
|
||||
_data.ItemsData.ItemInfos.ForEach(x =>
|
||||
@ -43,12 +47,13 @@ public class CheatMenu : MonoBehaviour
|
||||
var cell = HexManager.UnitCurrentCell[_player.Color].cell.GetListNeighbours()
|
||||
.First(hexCell => hexCell != null);
|
||||
|
||||
x.Item.Spawn(cell, ItemsPrefab, ItemFabric.itemIcon[x.Item.Type]);
|
||||
x.Item.Spawn(cell, _itemsPrefab, ItemFabric.itemIcon[x.Item.Type]);
|
||||
scrollRect.SetActive(false);
|
||||
}, "Spawn " + x.Item.name, itemGrid.gameObject);
|
||||
});
|
||||
|
||||
var playerGridGO = Instantiate(gridPrefab, grid.transform);
|
||||
_buttons.Add(playerGridGO);
|
||||
var playerGrid = playerGridGO.GetComponentInChildren<GridLayoutGroup>();
|
||||
playerGridGO.GetComponentInChildren<TMP_Text>().text = "Player";
|
||||
AddButton(() =>
|
||||
@ -56,7 +61,8 @@ public class CheatMenu : MonoBehaviour
|
||||
_player.UnitView.OnHit.Invoke(_player.Data.maxHP);
|
||||
scrollRect.SetActive(false);
|
||||
}, "Kill Player", playerGrid.gameObject);
|
||||
AddButton(() => scrollRect.SetActive(false), "CLOSE", grid);
|
||||
|
||||
_buttons.Add(AddButton(() => scrollRect.SetActive(false), "CLOSE", grid).gameObject);
|
||||
}
|
||||
|
||||
private Button AddButton(Action onClickAction, string buttonText, GameObject parent)
|
||||
@ -66,4 +72,11 @@ public class CheatMenu : MonoBehaviour
|
||||
button.GetComponentInChildren<TMP_Text>().text = buttonText;
|
||||
return button;
|
||||
}
|
||||
|
||||
public void OnPlayerDeath()
|
||||
{
|
||||
showButton.onClick.RemoveAllListeners();
|
||||
scrollRect.SetActive(false);
|
||||
_buttons.ForEach(Destroy);
|
||||
}
|
||||
}
|
@ -354,7 +354,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 979.82007, y: 1820.0002}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &838699094943604228
|
||||
CanvasRenderer:
|
||||
@ -1268,9 +1268,9 @@ RectTransform:
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 540, y: 960}
|
||||
m_SizeDelta: {x: 1080, y: 1920}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &4936557783008875079
|
||||
MonoBehaviour:
|
||||
@ -1400,10 +1400,10 @@ RectTransform:
|
||||
m_Father: {fileID: 838699096359249966}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &7241771076334068699
|
||||
GameObject:
|
||||
|
@ -31,6 +31,7 @@ public class AdsMob : MonoBehaviour
|
||||
{
|
||||
buttonExit.onClick.RemoveAllListeners();
|
||||
SceneManager.LoadScene(0);
|
||||
Time.timeScale = 1f;
|
||||
});
|
||||
//
|
||||
}
|
||||
@ -50,7 +51,7 @@ public class AdsMob : MonoBehaviour
|
||||
{
|
||||
var player = _player;
|
||||
player.spawnPos =
|
||||
HexManager.CellByColor[UnitColor.GREY][Random.Range(0, HexManager.CellByColor[UnitColor.GREY].Count - 1)]
|
||||
HexManager.CellByColor[UnitColor.Grey][Random.Range(0, HexManager.CellByColor[UnitColor.Grey].Count - 1)]
|
||||
.coordinates;
|
||||
|
||||
_factory.Spawn(player);
|
||||
@ -81,14 +82,14 @@ public class AdsMob : MonoBehaviour
|
||||
public void Respawn(GameObject player)
|
||||
{
|
||||
List<HexCell> cells = new List<HexCell>();
|
||||
cells.AddRange(HexManager.CellByColor[UnitColor.GREY]);
|
||||
cells.AddRange(HexManager.CellByColor[UnitColor.Grey]);
|
||||
// for (int i = 0; i < cells.Count; i++)
|
||||
// {
|
||||
|
||||
// }
|
||||
foreach (var cell in cells)
|
||||
{
|
||||
if (cell.Color == UnitColor.GREY)
|
||||
if (cell.Color == UnitColor.Grey)
|
||||
{
|
||||
var randomCell = Random.Range(0, cells.Count);
|
||||
Vector3 respawnPosition = cells[randomCell].transform.position;
|
||||
|
@ -41,10 +41,10 @@ namespace DefaultNamespace.AI
|
||||
currentPath.Clear();
|
||||
}
|
||||
|
||||
private void InitAgent(GameObject unit)
|
||||
private void InitAgent(Unit unit)
|
||||
{
|
||||
AIManager.Instance.AddAgent(this);
|
||||
HexManager.agents.Add(unit, this);
|
||||
HexManager.agents.Add(unit.Instance, this);
|
||||
OnAgentInited?.Invoke(this);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace Controller
|
||||
new MusicController();
|
||||
new VFXController();
|
||||
MusicController.Instance.SetMusicData(data.MusicData);
|
||||
|
||||
Time.timeScale = 1f;
|
||||
var paintedController = new PaintedController();
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace HexFiled
|
||||
private void Awake()
|
||||
{
|
||||
_renderer = GetComponent<MeshRenderer>();
|
||||
_color = UnitColor.GREY;
|
||||
_color = UnitColor.Grey;
|
||||
if (!HexManager.CellByColor.ContainsKey(_color))
|
||||
{
|
||||
HexManager.CellByColor.Add(_color, new List<HexCell>(){this});
|
||||
@ -90,7 +90,7 @@ namespace HexFiled
|
||||
_color = color;
|
||||
HexManager.CellByColor[_color].Add(this);
|
||||
|
||||
if(color == UnitColor.GREY) return;
|
||||
if(color == UnitColor.Grey) return;
|
||||
|
||||
var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[color].VFXCellCapturePrefab, transform.position + new Vector3(0,0.1f,0));
|
||||
MusicController.Instance.AddAudioSource(vfx);
|
||||
|
@ -65,7 +65,7 @@ namespace HexFiled
|
||||
position.z = z * (HexMetrics.outerRadius * 1.5f);
|
||||
var cellGO = Object.Instantiate(_fieldData.cellPrefab);
|
||||
HexCell cell = _cells[i] = cellGO.GetComponent<HexCell>();
|
||||
cell.PaintHex(UnitColor.GREY);
|
||||
cell.PaintHex(UnitColor.Grey);
|
||||
cell.transform.SetParent(_baseGameObject.transform, false);
|
||||
cell.transform.localPosition = position;
|
||||
cell.coordinates = HexCoordinates.FromOffsetCoordinates(x, z);
|
||||
|
@ -19,7 +19,7 @@ namespace HexFiled
|
||||
|
||||
public void PaintOnDeath(Unit unit)
|
||||
{
|
||||
HexManager.PaintHexList(HexManager.CellByColor[unit.Color], UnitColor.GREY);
|
||||
HexManager.PaintHexList(HexManager.CellByColor[unit.Color], UnitColor.Grey);
|
||||
// #if UNITY_EDITOR
|
||||
//
|
||||
//
|
||||
@ -66,7 +66,7 @@ namespace HexFiled
|
||||
});
|
||||
}
|
||||
|
||||
if (item.Value.Count >= 2 && item.Key != UnitColor.GREY && item.Key != cell.Color)
|
||||
if (item.Value.Count >= 2 && item.Key != UnitColor.Grey && item.Key != cell.Color)
|
||||
{
|
||||
item.Value.ForEach(neighbour =>
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace HexFiled
|
||||
var (hasPath, field) = HasPath(neighbour, HexManager.UnitCurrentCell[neighbour.Color].cell);
|
||||
if (!hasPath)
|
||||
{
|
||||
field.ForEach(x => x.PaintHex(UnitColor.GREY));
|
||||
field.ForEach(x => x.PaintHex(UnitColor.Grey));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
{
|
||||
public enum UnitColor
|
||||
{
|
||||
GREEN,
|
||||
RED,
|
||||
GREY,
|
||||
YELLOW,
|
||||
BLUE
|
||||
Green,
|
||||
Red,
|
||||
Grey,
|
||||
Yellow,
|
||||
Blue
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ namespace Items
|
||||
|
||||
public void UpdateCellToOpenList(HexCell cell)
|
||||
{
|
||||
if (cell.Color != UnitColor.GREY)
|
||||
if (cell.Color != UnitColor.Grey)
|
||||
{
|
||||
_openList.Add(cell);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace Units
|
||||
private AnimLength _animLength;
|
||||
private HexCell _cell;
|
||||
private HexGrid _hexGrid;
|
||||
public event Action<GameObject> OnPlayerSpawned;
|
||||
public event Action<Unit> OnPlayerSpawned;
|
||||
private Animator _animator;
|
||||
private UnitView _unitView;
|
||||
private bool _isBusy;
|
||||
@ -111,7 +111,7 @@ namespace Units
|
||||
{
|
||||
DoTransit(direction);
|
||||
}
|
||||
else if (_cell.GetNeighbor(direction).Color != UnitColor.GREY)
|
||||
else if (_cell.GetNeighbor(direction).Color != UnitColor.Grey)
|
||||
{
|
||||
if (_mana - _hexGrid.HexHardCaptureCost <= 0) return;
|
||||
_isHardToCapture = true;
|
||||
@ -210,7 +210,7 @@ namespace Units
|
||||
BarCanvas.transform.position + _camera.transform.rotation * Vector3.back,
|
||||
_camera.transform.rotation * Vector3.up);
|
||||
_isBusy = false;
|
||||
OnPlayerSpawned?.Invoke(_instance);
|
||||
OnPlayerSpawned?.Invoke(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,11 +55,12 @@ namespace Chars
|
||||
_controllers.Add(playerControl);
|
||||
};
|
||||
|
||||
_uiController.CheatMenu.SetPlayerNData(player, _data);
|
||||
|
||||
player.OnPlayerSpawned += unit => _uiController.CheatMenu.SetPlayerNData(unit, _data);
|
||||
player.OnDeath += unit1 => _controllers.Remove(playerControl);
|
||||
player.OnDeath += u => playerControl.Dispose();
|
||||
player.OnPlayerSpawned += cameraControl.InitCameraControl;
|
||||
player.OnPlayerSpawned += unit => cameraControl.InitCameraControl(unit.Instance);
|
||||
player.OnDeath += unit => _uiController.CheatMenu.OnPlayerDeath();
|
||||
|
||||
player.OnDeath += p => _uiController.AdsMob.ShowCanvas(unitInfo, this);
|
||||
player.OnDeath += _paintedController.PaintOnDeath;
|
||||
|
@ -67,7 +67,7 @@ PlayerSettings:
|
||||
preserveFramebufferAlpha: 0
|
||||
disableDepthAndStencilBuffers: 0
|
||||
androidStartInFullscreen: 1
|
||||
androidRenderOutsideSafeArea: 1
|
||||
androidRenderOutsideSafeArea: 0
|
||||
androidUseSwappy: 1
|
||||
androidBlitType: 0
|
||||
defaultIsNativeResolution: 1
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user