【选中】精简选中规则
parent
54b00f4ebc
commit
c8606f3320
|
|
@ -44,11 +44,6 @@ namespace Gameplay.Character
|
|||
SetName($"Character_{GetID()}");
|
||||
// DebugUtil.Log(Node.GameObject.name);
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
SelecterView.Instance.UnSelect(Node);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using Gameplay.Level;
|
||||
|
||||
namespace Gameplay.Character
|
||||
{
|
||||
public partial class Character
|
||||
{
|
||||
|
||||
protected override void _OnSelect()
|
||||
{
|
||||
// base._OnSelect();
|
||||
var currentState = _downFSM?.currentState;
|
||||
if (currentState != null && runtimeData != null)
|
||||
{
|
||||
var targetPos = LevelManager.Instance.CurrentLevel.Map.TGSCellIndex2WorldPosition(controlData.targetCellIndex);
|
||||
var targetInfo = (currentState.id == EDownState.Move) ? new SelecterView.TargetInfo() { pos = targetPos } : null;
|
||||
SelecterView.Instance.SetSelectAndTarget(Node, targetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
base._OnSelect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ce4453594ab1414393e688b4abb15b9f
|
||||
timeCreated: 1689744459
|
||||
|
|
@ -184,10 +184,6 @@ namespace Gameplay.Character
|
|||
isFinished = true;
|
||||
nextState = EDownState.Idle;
|
||||
owner.controlData.targetCellIndex = -1;
|
||||
if (LevelManager.Instance.CurrentLevel.selectUnit == owner)
|
||||
{
|
||||
SelecterView.Instance.SetSelectAndTarget(owner.Node, null);
|
||||
}
|
||||
Framework.EventManager.Instance.Send(Framework.EventManager.EventName.LevelCharacterArriveBlock, owner);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.NetworkInformation;
|
||||
using cfg;
|
||||
using Framework;
|
||||
using Framework.Condition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gameplay.Level
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
using Gameplay.Level.Select;
|
||||
using Gameplay.Unit;
|
||||
|
||||
namespace Gameplay.Level
|
||||
{
|
||||
public partial class Level
|
||||
{
|
||||
public GameUnit selectUnit { get; private set; }
|
||||
public GameUnit selectUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
return selectView.selectUnit;
|
||||
}
|
||||
}
|
||||
public SelectView selectView { get; private set; }
|
||||
|
||||
public void SelectUnit(GameUnit newUnit)
|
||||
{
|
||||
|
|
@ -13,26 +21,20 @@ namespace Gameplay.Level
|
|||
return;
|
||||
UnSelectUnit();
|
||||
newUnit.OnSelect();
|
||||
selectUnit = newUnit;
|
||||
selectView.SetOwner(newUnit);
|
||||
}
|
||||
|
||||
public void SelectUnit(uint id)
|
||||
{
|
||||
var newUnit = GameUnitManager.instance.infightUnits.Search(id);
|
||||
if (selectUnit == newUnit) return;
|
||||
if (newUnit.commonData.canSelect)
|
||||
{
|
||||
UnSelectUnit();
|
||||
newUnit.OnSelect();
|
||||
selectUnit = newUnit;
|
||||
}
|
||||
SelectUnit(newUnit);
|
||||
}
|
||||
|
||||
public void UnSelectUnit()
|
||||
{
|
||||
if (selectUnit == null) return;
|
||||
selectUnit.OnUnSelect();
|
||||
selectUnit = null;
|
||||
selectView.SetOwner(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ using Gameplay.Effect;
|
|||
using Gameplay.Emoji;
|
||||
using Gameplay.Fight.Capture;
|
||||
using Gameplay.Fight.Flag;
|
||||
using Gameplay.Level.Select;
|
||||
using Gameplay.Pause;
|
||||
using Gameplay.Performance;
|
||||
using Gameplay.Pool;
|
||||
|
|
@ -269,8 +270,9 @@ namespace Gameplay.Level
|
|||
_stateMachine.Update(deltaTime * _speed);
|
||||
// GameUnitManager.instance.LogicUpdate(deltaTime * _speed);
|
||||
AIManager.Instance.Update(deltaTime * _speed);
|
||||
SelecterView.Instance.Update(deltaTime * _speed);
|
||||
}
|
||||
|
||||
selectView?.LogicUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -393,6 +395,9 @@ namespace Gameplay.Level
|
|||
await _InitAfterLoadMap();
|
||||
|
||||
await _LoadOthers();
|
||||
|
||||
selectView = new SelectView();
|
||||
selectView.Init();
|
||||
|
||||
await _LoadNpc();
|
||||
_CreateCapturePoints();
|
||||
|
|
@ -403,7 +408,6 @@ namespace Gameplay.Level
|
|||
RegisterAllEvent();
|
||||
InitRules();
|
||||
_stateMachine.ChangeState(new PrepareState(this));
|
||||
SelecterView.Instance.Init();
|
||||
|
||||
var enableBlackArea = _currLevelInfo.Cfg.LevelTime == DayNightType.Night;
|
||||
BlackAreaManager.instance.Init(enableBlackArea);
|
||||
|
|
@ -660,7 +664,7 @@ namespace Gameplay.Level
|
|||
MapUtils.UnLoadMap(_map);
|
||||
UnRegisterAllEvent();
|
||||
ReleaseRules();
|
||||
SelecterView.Instance.Release();
|
||||
selectView.Dispose();
|
||||
|
||||
await UnLoadScene();
|
||||
await UniTask.NextFrame();
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ namespace Gameplay.Level
|
|||
await ShowTransitionMgr.Instance.EnterBlack();
|
||||
await UniTask.Delay(250);
|
||||
EffectManager.instance.rootObj.SetActive(false);
|
||||
SelecterView.Instance.Release();
|
||||
UITipsManager.CloseClickShield();
|
||||
//播放过程
|
||||
TeamManager.Instance.TeamUIClose();
|
||||
|
|
@ -77,7 +76,6 @@ namespace Gameplay.Level
|
|||
await ShowTransitionMgr.Instance.EnterBlack();
|
||||
await UniTask.Delay(250);
|
||||
EffectManager.instance.rootObj.SetActive(false);
|
||||
SelecterView.Instance.Release();
|
||||
UITipsManager.CloseClickShield();
|
||||
//播放过程
|
||||
TeamManager.Instance.TeamUIClose();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 707850c8b3ad4f85a05bbf7794ad7ea2
|
||||
timeCreated: 1727433252
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
using Gameplay.Area;
|
||||
using Gameplay.Effect;
|
||||
using Gameplay.Unit;
|
||||
using PhxhSDK;
|
||||
using UnityEngine;
|
||||
using Constants = Framework.Constants;
|
||||
|
||||
namespace Gameplay.Level.Select
|
||||
{
|
||||
public class SelectView
|
||||
{
|
||||
|
||||
private GameUnit _selectUnit;
|
||||
public GameUnit selectUnit => _selectUnit;
|
||||
|
||||
private EffectPlayingData _circleEffect;
|
||||
private Transform _groundTrans;
|
||||
|
||||
private const int _circleEffectId = 1;
|
||||
|
||||
private int _lastCellIndex = -1;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
_circleEffect = EffectManager.instance.PlayEffectById(_circleEffectId);
|
||||
var groundSampleObj = AssetManager.Instance.GetPreLoadResult<GameObject>(Constants.CHARACTER_SELECT_GROUND_GFX);
|
||||
var groundObj = Object.Instantiate(groundSampleObj);
|
||||
_groundTrans = groundObj.transform;
|
||||
|
||||
_SetActive(false);
|
||||
}
|
||||
|
||||
private void _SetActive(bool active)
|
||||
{
|
||||
_circleEffect.SetActive(active);
|
||||
_groundTrans.gameObject.SetActive(active);
|
||||
}
|
||||
|
||||
public void SetOwner(GameUnit owner)
|
||||
{
|
||||
if (_selectUnit == owner) return;
|
||||
_selectUnit = owner;
|
||||
if (_selectUnit == null)
|
||||
{
|
||||
_SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_SetActive(true);
|
||||
LogicUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public void LogicUpdate()
|
||||
{
|
||||
if (_selectUnit == null) return;
|
||||
|
||||
// circle 一直跟随
|
||||
var pos = _selectUnit.transform.position;
|
||||
_circleEffect.transform.position = pos;
|
||||
|
||||
// ground 按cellindex 跟随
|
||||
_UpdateGroundEffect();
|
||||
}
|
||||
|
||||
private void _UpdateGroundEffect()
|
||||
{
|
||||
var cellIndex = _selectUnit.transData.cellIndex;
|
||||
if (cellIndex == _lastCellIndex) return;
|
||||
_lastCellIndex = cellIndex;
|
||||
var posGround = AreaManager.instance.GetCellPosByIndex(cellIndex);
|
||||
_groundTrans.position = posGround;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bd7468b28d9345b18df1b71cbcfc8b52
|
||||
timeCreated: 1727433262
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
using Framework;
|
||||
using Gameplay.Effect;
|
||||
using Gameplay.Unit;
|
||||
using PhxhSDK;
|
||||
using UnityEngine;
|
||||
using Constants = Framework.Constants;
|
||||
|
||||
namespace Gameplay.Level
|
||||
{
|
||||
public class SelecterView : Singlenton<SelecterView>, IInitable
|
||||
{
|
||||
// 选中圆圈特效
|
||||
private EffectPlayingData _selectedGFX;
|
||||
|
||||
// 选中的节点
|
||||
private Node _selectedNode;
|
||||
|
||||
private GameObject _selectedGroundGFX;
|
||||
|
||||
// 目标特效
|
||||
private Node _targetGFX;
|
||||
// 目标信息
|
||||
private TargetInfo _targetInfo;
|
||||
|
||||
public class TargetInfo
|
||||
{
|
||||
public Vector3 pos;
|
||||
}
|
||||
|
||||
|
||||
public void SetSelectAndTarget(Node node,
|
||||
TargetInfo targetInfo)
|
||||
{
|
||||
_selectedNode = node;
|
||||
_targetInfo = targetInfo;
|
||||
|
||||
if (_selectedGFX == null)
|
||||
{
|
||||
_selectedGFX = EffectManager.instance.PlayEffectById(Constants.EID_CHARACTER_SELECT);
|
||||
}
|
||||
|
||||
if (_targetGFX == null)
|
||||
{
|
||||
Node n = new Node();
|
||||
var o = AssetManager.Instance.GetPreLoadResult<GameObject>(Constants.CHARACTER_TARGET_GFX);
|
||||
var instObj = Object.Instantiate(o, n.GameObject.transform);
|
||||
instObj.transform.ResetLocals();
|
||||
_targetGFX = n;
|
||||
}
|
||||
BindGfx();
|
||||
UpdateSelectedGround(null);
|
||||
}
|
||||
|
||||
public void UnSelect(Node node)
|
||||
{
|
||||
if (_selectedNode == node)
|
||||
{
|
||||
if (_selectedGFX != null)
|
||||
{
|
||||
_selectedGFX.transform.SetParent(null);
|
||||
_selectedGFX.SetActive(false);
|
||||
}
|
||||
|
||||
if (_targetInfo != null)
|
||||
{
|
||||
if (_targetGFX != null)
|
||||
{
|
||||
_targetGFX.IsActive = false;
|
||||
}
|
||||
|
||||
_targetInfo = null;
|
||||
}
|
||||
|
||||
if (_selectedGroundGFX != null)
|
||||
{
|
||||
_selectedGroundGFX.SetActive(false);
|
||||
}
|
||||
_selectedNode = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
if (_selectedNode != null)
|
||||
{
|
||||
var nodePos = _selectedNode.GetPosition();
|
||||
nodePos.y = 0.1f;
|
||||
_selectedGFX.transform.position = nodePos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void BindGfx()
|
||||
{
|
||||
if (_selectedNode != null)
|
||||
{
|
||||
if (_selectedNode != null)
|
||||
{
|
||||
var nodePos = _selectedNode.GetPosition();
|
||||
nodePos.y = 0.1f;
|
||||
_selectedGFX.transform.position = nodePos;
|
||||
}
|
||||
_selectedGFX.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedGFX.SetActive(false);
|
||||
}
|
||||
|
||||
if (_targetInfo != null)
|
||||
{
|
||||
_targetGFX.transform.position = _targetInfo.pos;
|
||||
_targetGFX.transform.localRotation = Quaternion.identity;
|
||||
_targetGFX.transform.localScale = Vector3.one;
|
||||
_targetGFX.IsActive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetGFX.IsActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
EventManager.Instance.Register<GameUnit>(EventManager.EventName.INFIGHT_UNIT_CELLINDEX_CHANGE, OnCharacterArriveBlock);
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
EventManager.Instance.Unregister<GameUnit>(EventManager.EventName.INFIGHT_UNIT_CELLINDEX_CHANGE, OnCharacterArriveBlock);
|
||||
|
||||
if (_selectedGFX != null)
|
||||
{
|
||||
_selectedGFX.Destroy();
|
||||
_selectedGFX = null;
|
||||
}
|
||||
|
||||
if (_targetGFX != null)
|
||||
{
|
||||
_targetGFX.Dispose();
|
||||
_targetGFX = null;
|
||||
}
|
||||
|
||||
if (_selectedGroundGFX != null)
|
||||
{
|
||||
PhxhSDK.Utils.Destroy(_selectedGroundGFX);
|
||||
_selectedGroundGFX = null;
|
||||
}
|
||||
|
||||
_selectedNode = null;
|
||||
_targetInfo = null;
|
||||
}
|
||||
|
||||
private void OnCharacterArriveBlock(GameUnit gameUnit)
|
||||
{
|
||||
UpdateSelectedGround(gameUnit);
|
||||
}
|
||||
|
||||
private void UpdateSelectedGround(GameUnit gameUnit)
|
||||
{
|
||||
if (_selectedNode == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameUnit != null && gameUnit.Node != null && gameUnit.Node != _selectedNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var map = LevelManager.Instance.CurrentLevel?.Map?.TerrainGridSystem;
|
||||
if (map == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var cell = gameUnit != null
|
||||
? map.cells[gameUnit.transData.cellIndex]
|
||||
: map.CellGetAtPosition(_selectedNode.GetPosition(), true);
|
||||
var pos = map.CellGetPosition(cell);
|
||||
if (_selectedGroundGFX == null)
|
||||
{
|
||||
var sampleObj = AssetManager.Instance.GetPreLoadResult<GameObject>(Constants.CHARACTER_SELECT_GROUND_GFX);
|
||||
_selectedGroundGFX = GameObject.Instantiate(sampleObj);
|
||||
_selectedGroundGFX.transform.position = pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedGroundGFX.SetActive(true);
|
||||
_selectedGroundGFX.transform.position = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1c51544af3da4e2691aeba618ec9009c
|
||||
timeCreated: 1689748136
|
||||
|
|
@ -576,7 +576,6 @@ namespace Gameplay.Unit
|
|||
|
||||
protected virtual void _OnSelect()
|
||||
{
|
||||
SelecterView.Instance.SetSelectAndTarget(Node, null);
|
||||
}
|
||||
|
||||
public void OnUnSelect()
|
||||
|
|
@ -590,7 +589,6 @@ namespace Gameplay.Unit
|
|||
|
||||
protected virtual void _OnUnSelect()
|
||||
{
|
||||
SelecterView.Instance.UnSelect(Node);
|
||||
}
|
||||
|
||||
public void MoveAway(GameUnit unit)
|
||||
|
|
@ -649,12 +647,6 @@ namespace Gameplay.Unit
|
|||
|
||||
if (LevelManager.Instance.CurrentLevel.selectUnit == this)
|
||||
{
|
||||
var wrapCellPos = map.TGSCellIndex2WorldPosition(cellIndex);
|
||||
SelecterView.Instance.SetSelectAndTarget(Node, new SelecterView.TargetInfo()
|
||||
{
|
||||
pos = wrapCellPos
|
||||
});
|
||||
|
||||
EventManager.Instance.Send(EventManager.EventName.INFIGHT_OP_SET_MOVEPOS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,10 +148,6 @@ namespace Gameplay.Vehicle.State
|
|||
isFinished = true;
|
||||
nextState = EVehicleState.Stop;
|
||||
owner.controlData.targetCellIndex = -1;
|
||||
if (LevelManager.Instance.CurrentLevel.selectUnit == owner)
|
||||
{
|
||||
SelecterView.Instance.SetSelectAndTarget(owner.Node, null);
|
||||
}
|
||||
Framework.EventManager.Instance.Send(Framework.EventManager.EventName.LevelCharacterArriveBlock, owner);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue