|
|
|
@ -11,6 +11,7 @@ public class Servant : MonoBehaviour |
|
|
|
{ |
|
|
|
public int startPositionX, startPositionY; |
|
|
|
public HashSet<MapUnity> influencePreviewPool = new HashSet<MapUnity>();//记录预览影响的对象池
|
|
|
|
public HashSet<MapUnity> effectRangePreviewPool = new HashSet<MapUnity>();//效果作用范围
|
|
|
|
|
|
|
|
[Header("层级检测")] |
|
|
|
public LayerMask chooseNodeLayerMask;//移动射线选择的层级
|
|
|
|
@ -22,7 +23,11 @@ public class Servant : MonoBehaviour |
|
|
|
public Animator anim; |
|
|
|
[Header("跑步速度")] |
|
|
|
public float speed = 2; |
|
|
|
|
|
|
|
[Header("瞄准箭头")] |
|
|
|
public ArrowInMap arrowInMap; |
|
|
|
[Header("技能瞄准上一帧瞄准格子")] |
|
|
|
public MapUnity latestMapUnity;//与当前帧不一致刷新范围
|
|
|
|
private bool isRefresh; |
|
|
|
[Header("步数标识个数集(UI)")] |
|
|
|
public int stepIconCount; |
|
|
|
public Transform StepIconFather; |
|
|
|
@ -47,6 +52,7 @@ public class Servant : MonoBehaviour |
|
|
|
|
|
|
|
private void Start() |
|
|
|
{ |
|
|
|
GameManager.Instance.servant = this; |
|
|
|
Invoke("StartSevent", 4f); |
|
|
|
|
|
|
|
InstantiateSkillUI(); |
|
|
|
@ -58,40 +64,37 @@ public class Servant : MonoBehaviour |
|
|
|
GameManager.Instance.servantOn = currentNode; |
|
|
|
this.gameObject.transform.position = new Vector3(currentNode.transform.position.x, 0.5f, currentNode.transform.position.z); |
|
|
|
} |
|
|
|
public void Update() |
|
|
|
public virtual void Update() |
|
|
|
{ |
|
|
|
|
|
|
|
if (Mouse.current.leftButton.wasReleasedThisFrame && TurnMaster.Instance.playerAction != TurnMaster.PlayerAction.useCard && TurnMaster.Instance.servantAction != TurnMaster.ServantAction.banAction) |
|
|
|
{ |
|
|
|
//if (GameManager.Instance.servantState.currentStepRange > 0 && !Usermanager.playerAbnormalCondition.ContainsKey(AbnormalCondition.banStep))
|
|
|
|
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|
|
|
|
|
|
|
if (Physics.Raycast(ray, out RaycastHit raycastHit, 500, playerLayerMask.value)) |
|
|
|
{ |
|
|
|
if (raycastHit.collider.gameObject.tag == "Servant") |
|
|
|
{ |
|
|
|
GameManager.Instance.character = GameManager.SelectedCharacter.servant; |
|
|
|
Debug.Log(raycastHit.collider.gameObject.name); |
|
|
|
|
|
|
|
//Debug.Log(raycastHit.collider.gameObject.name);
|
|
|
|
//展开技能表
|
|
|
|
ShowSkillUI(); |
|
|
|
} |
|
|
|
else if (raycastHit.collider.gameObject.tag == "ServantSkillUI")//检测到是技能
|
|
|
|
{ |
|
|
|
GameManager.Instance.character = GameManager.SelectedCharacter.servant; |
|
|
|
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.useSkill; |
|
|
|
//技能范围预览(button触发添加技能序号)
|
|
|
|
//MovePreView();
|
|
|
|
if (skillList[currentSkillInex].currentStorageTimes > 0) |
|
|
|
{ |
|
|
|
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.useSkill; |
|
|
|
isRefresh = true; |
|
|
|
SkillePreviewSelector(currentSkillInex); |
|
|
|
ColorInUseSkillUI(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else if (Physics.Raycast(ray, out RaycastHit raycastHitMap, 500, chooseNodeLayerMask.value)) |
|
|
|
{ |
|
|
|
isRefresh = false; |
|
|
|
//检测到地面,释放技能实际效果
|
|
|
|
if (GameManager.Instance.character == GameManager.SelectedCharacter.servant && TurnMaster.Instance.servantAction == TurnMaster.ServantAction.useSkill) |
|
|
|
{ |
|
|
|
@ -99,7 +102,13 @@ public class Servant : MonoBehaviour |
|
|
|
ColorResrtUseSkillUI(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ResetPreView(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (Mouse.current.rightButton.wasPressedThisFrame) |
|
|
|
@ -107,6 +116,22 @@ public class Servant : MonoBehaviour |
|
|
|
ResetPreView(); |
|
|
|
} |
|
|
|
|
|
|
|
//鼠标移动就刷新范围预览
|
|
|
|
if (isRefresh ==true) |
|
|
|
{ |
|
|
|
Ray rayMap = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|
|
|
if (Physics.Raycast(rayMap, out RaycastHit raycastHitRefresh, 500, chooseNodeLayerMask.value)) |
|
|
|
{ |
|
|
|
MapUnity currentMapUnity = raycastHitRefresh.transform.GetComponent<MapUnity>(); |
|
|
|
if (currentMapUnity != latestMapUnity) |
|
|
|
{ |
|
|
|
CleanEffectRange(); |
|
|
|
SkillePreviewEffectSelector(currentSkillInex,currentMapUnity); |
|
|
|
latestMapUnity = currentMapUnity; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//同步步数UI标识
|
|
|
|
if (GameManager.Instance.servantState.currentStepRange != stepIconCount) |
|
|
|
{ |
|
|
|
@ -127,12 +152,36 @@ public class Servant : MonoBehaviour |
|
|
|
public virtual void SkillePreviewSelector(int index) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
//技能效果范围预览
|
|
|
|
public virtual void SkillePreviewEffectSelector(int index,MapUnity currentMapUnity ) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
//技能效果释放
|
|
|
|
public virtual void SkilleEffectSelector(int index) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
//高亮效果作用范围
|
|
|
|
public void HighLightEffectRange() |
|
|
|
{ |
|
|
|
foreach (MapUnity mapUnity in effectRangePreviewPool ) |
|
|
|
{ |
|
|
|
mapUnity.infHighLight = true; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//消除效果作用范围
|
|
|
|
public void CleanEffectRange() |
|
|
|
{ |
|
|
|
foreach (MapUnity mapUnity in effectRangePreviewPool) |
|
|
|
{ |
|
|
|
mapUnity.infHighLight = false; |
|
|
|
} |
|
|
|
effectRangePreviewPool.Clear(); |
|
|
|
} |
|
|
|
|
|
|
|
//展开技能表
|
|
|
|
public void ShowSkillUI() |
|
|
|
{ |
|
|
|
@ -198,9 +247,11 @@ public class Servant : MonoBehaviour |
|
|
|
{ |
|
|
|
// StepPreviewInfluencedNode(step);
|
|
|
|
CloseStepPreviewInfluencedNode();//取消格子预览
|
|
|
|
CleanEffectRange();//取消范围预览
|
|
|
|
|
|
|
|
ColorResrtUseSkillUI();//恢复技能UI
|
|
|
|
|
|
|
|
arrowInMap.gameObject.SetActive(false);//关闭箭头
|
|
|
|
isRefresh = false; |
|
|
|
if (TurnMaster.Instance.servantAction != TurnMaster.ServantAction.banAction) |
|
|
|
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.none; |
|
|
|
} |
|
|
|
@ -220,11 +271,15 @@ public class Servant : MonoBehaviour |
|
|
|
} |
|
|
|
public IEnumerator MoveToChooseNode()//射线检测选择一个mapNode
|
|
|
|
{ |
|
|
|
//关闭箭头
|
|
|
|
arrowInMap.gameObject.SetActive(false); |
|
|
|
//关闭高亮预览
|
|
|
|
CleanEffectRange(); |
|
|
|
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|
|
|
if (Physics.Raycast(ray, out RaycastHit raycastHit, 500, chooseNodeLayerMask.value)) |
|
|
|
{ |
|
|
|
Debug.Log(raycastHit.collider.gameObject.name); |
|
|
|
|
|
|
|
// Debug.Log(raycastHit.collider.gameObject.name);
|
|
|
|
MapUnity mapNode = raycastHit.collider.transform.GetComponent<MapUnity>(); |
|
|
|
|
|
|
|
//改变缩放翻转
|
|
|
|
@ -250,16 +305,11 @@ public class Servant : MonoBehaviour |
|
|
|
GameManager.Instance.servantOn.playerOn = false; |
|
|
|
GameManager.Instance.servantOn.influenced = false; |
|
|
|
} |
|
|
|
|
|
|
|
//遍历影响池变色
|
|
|
|
foreach (MapUnity mapUnity in influencePreviewPool) |
|
|
|
{ |
|
|
|
mapUnity.influenced = false; |
|
|
|
} |
|
|
|
influencePreviewPool.Clear(); |
|
|
|
CloseStepPreviewInfluencedNode(); |
|
|
|
|
|
|
|
//标记终点
|
|
|
|
mapNode.markInfluenced = true; |
|
|
|
mapNode.infHighLight = true; |
|
|
|
|
|
|
|
for (int i = 1; i < movePath.Count; i++) |
|
|
|
{ |
|
|
|
@ -278,8 +328,8 @@ public class Servant : MonoBehaviour |
|
|
|
yield return 0; |
|
|
|
} |
|
|
|
//判断寄生,流血是否生效
|
|
|
|
Usermanager.Instance.ParasitismnRealize(movePath[i]);//´«È뵱ǰnode
|
|
|
|
Usermanager.Instance.bleedRealize(); |
|
|
|
//Usermanager.Instance.ParasitismnRealize(movePath[i]);//传入当前node
|
|
|
|
// Usermanager.Instance.bleedRealize();
|
|
|
|
//减体力
|
|
|
|
GameManager.Instance.servantState.currentStepRange -= 1; |
|
|
|
//同步技能UI
|
|
|
|
@ -298,7 +348,7 @@ public class Servant : MonoBehaviour |
|
|
|
anim.SetBool("move", false); |
|
|
|
|
|
|
|
//取消标记终点
|
|
|
|
mapNode.markInfluenced = false; |
|
|
|
mapNode.infHighLight = false; |
|
|
|
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.none; |
|
|
|
|
|
|
|
|
|
|
|
|