V3.1.5 修正PlayMode中TargetUI问题
修正TargetUI初始化StayMode Button可使用的问题 修正TargetUI可使用按钮逻辑问题 修正TargetUI与TargetController联动问题 修正Enemy击杀后不死亡问题
This commit is contained in:
@@ -4,14 +4,14 @@ public class MouseInMap : MonoBehaviour
|
||||
{
|
||||
public Camera playCamera;
|
||||
public GameObject environmentObj;
|
||||
public GameObject selectEffect;
|
||||
public GameObject mousePreviewObj;
|
||||
public GameObject enemyContainerObj;
|
||||
public GameObject sceneBlockContainerObj;
|
||||
public GameObject targetControllerObj;
|
||||
public GameObject HUDObj;
|
||||
|
||||
private Vector3 mouseInMapPosition = Vector3.zero;
|
||||
private Vector3 nowHitPosition = Vector3.zero;
|
||||
private Vector3 nowHitPositionRelative = Vector3.zero;
|
||||
private LayerMask groundMask;
|
||||
private int randBlockNum;
|
||||
private GameObject preSet;
|
||||
@@ -35,7 +35,7 @@ public class MouseInMap : MonoBehaviour
|
||||
{
|
||||
groundMask = LayerMask.GetMask("Ground");
|
||||
targetCon = targetControllerObj.GetComponent<TargetController>();
|
||||
mousePreviewCon = this.GetComponent<MousePreview>();
|
||||
mousePreviewCon = mousePreviewObj.GetComponent<MousePreview>();
|
||||
enemyCon = enemyContainerObj.GetComponent<EnemyContainer>();
|
||||
sceneBlockCon = sceneBlockContainerObj.GetComponent<SceneBlockContainer>();
|
||||
targetUICon = HUDObj.GetComponent<TargetUIController>();
|
||||
@@ -44,32 +44,32 @@ public class MouseInMap : MonoBehaviour
|
||||
private void Update()
|
||||
{
|
||||
nowHitPosition = GetMouseOnMapPosition();
|
||||
nowHitPositionRelative = nowHitPosition - environmentObj.transform.position;
|
||||
// if mouse position in area, update mouseInMapPosition as nowHitPosition
|
||||
if (nowHitPosition.x < targetCon.maxAgentAreaX && nowHitPosition.x > targetCon.minAgentAreaX && nowHitPosition.z < targetCon.maxEnemyAreaZ && nowHitPosition.z > targetCon.minAgentAreaZ)
|
||||
if (nowHitPositionRelative.x < targetCon.maxAgentAreaX && nowHitPositionRelative.x > targetCon.minAgentAreaX && nowHitPositionRelative.z < targetCon.maxEnemyAreaZ && nowHitPositionRelative.z > targetCon.minAgentAreaZ)
|
||||
{
|
||||
mouseInMapPosition = nowHitPosition;
|
||||
mousePreviewCon.UpdatePreviewPosition(mouseInMapPosition);
|
||||
mousePreviewCon.UpdatePreviewPosition(nowHitPosition);
|
||||
// Mouse button R pressed
|
||||
if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
switch (mouseMode)
|
||||
{
|
||||
case MouseMode.AttackSet:
|
||||
sceneBlockCon.CreateNewBlock(SceneBlockContainer.Targets.Attack, randBlockNum, mouseInMapPosition);
|
||||
sceneBlockCon.CreateNewBlock(SceneBlockContainer.Targets.Attack, randBlockNum, nowHitPositionRelative);
|
||||
sceneBlockCon.InitializeBlock(environmentObj);
|
||||
targetCon.AttackModeChange();
|
||||
targetCon.AttackModeChange(nowHitPositionRelative);
|
||||
ChangeMouseModeTo(MouseMode.Default);
|
||||
break;
|
||||
|
||||
case MouseMode.GotoSet:
|
||||
sceneBlockCon.CreateNewBlock(SceneBlockContainer.Targets.Go, randBlockNum, mouseInMapPosition);
|
||||
sceneBlockCon.CreateNewBlock(SceneBlockContainer.Targets.Go, randBlockNum, nowHitPositionRelative);
|
||||
sceneBlockCon.InitializeBlock(environmentObj);
|
||||
targetCon.GotoModeChange();
|
||||
targetCon.GotoModeChange(nowHitPositionRelative);
|
||||
ChangeMouseModeTo(MouseMode.Default);
|
||||
break;
|
||||
|
||||
case MouseMode.EnemySet:
|
||||
enemyCon.InitEnemyAtHere(new Vector3(mouseInMapPosition.x, 1, mouseInMapPosition.z));
|
||||
enemyCon.InitEnemyAtHere(new Vector3(nowHitPositionRelative.x, 1, nowHitPositionRelative.z));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -109,20 +109,18 @@ public class MouseInMap : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// get mouse position on map, return a Vector3
|
||||
// get mouse position on map, return an absolute Vector3 coordinate
|
||||
public Vector3 GetMouseOnMapPosition()
|
||||
{
|
||||
// shoot raycast from mainCamera center to mousepositon
|
||||
RaycastHit thisHit;
|
||||
Color rayColor = Color.red;
|
||||
Vector3 onMapPosition;
|
||||
Ray ray = playCamera.ScreenPointToRay(Input.mousePosition);
|
||||
// if raycast hit gameobject
|
||||
if (Physics.Raycast(ray, out thisHit, Mathf.Infinity, groundMask))
|
||||
{
|
||||
//draw raycast
|
||||
Debug.DrawRay(ray.origin, ray.direction * 100, rayColor);
|
||||
return onMapPosition = thisHit.point;
|
||||
Debug.DrawRay(ray.origin, ray.direction * 100, Color.red);
|
||||
return thisHit.point;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using UnityEngine;
|
||||
|
||||
public class MousePreview : MonoBehaviour
|
||||
{
|
||||
|
||||
// show mousePreviewObj in mouse position
|
||||
public void ChangePreviewTo(GameObject mousePreviewObj)
|
||||
{
|
||||
DeleteAllPreviewModele();
|
||||
Instantiate(mousePreviewObj, this.transform.position, Quaternion.identity, this.transform);
|
||||
Instantiate(mousePreviewObj, transform.position, Quaternion.identity, this.transform);
|
||||
}
|
||||
|
||||
public void UpdatePreviewPosition(Vector3 previewPos)
|
||||
{
|
||||
// move this gameobject to previewPos
|
||||
this.transform.position = previewPos;
|
||||
transform.position = previewPos;
|
||||
}
|
||||
|
||||
public void DeleteAllPreviewModele()
|
||||
{
|
||||
// delete all child object
|
||||
@@ -26,4 +24,4 @@ public class MousePreview : MonoBehaviour
|
||||
Destroy(childObj.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ public class TargetUIController : MonoBehaviour
|
||||
// Controller to control the UI of the target,
|
||||
// select target type, select prefeb to set or sth.
|
||||
public GameObject targetControllerObj;
|
||||
|
||||
public GameObject mouseSelectorObj;
|
||||
public GameObject environmentUIObj;
|
||||
|
||||
@@ -24,6 +23,7 @@ public class TargetUIController : MonoBehaviour
|
||||
targetCon = targetControllerObj.GetComponent<TargetController>();
|
||||
mouseInMapCon = mouseSelectorObj.GetComponent<MouseInMap>();
|
||||
envUICon = environmentUIObj.GetComponent<EnvironmentUIControl>();
|
||||
ClearGamePressed();
|
||||
}
|
||||
|
||||
public void ClearGamePressed()
|
||||
@@ -47,11 +47,19 @@ public class TargetUIController : MonoBehaviour
|
||||
public void SetGotoPressed()
|
||||
{
|
||||
mouseInMapCon.ChangeMouseModeTo(MouseInMap.MouseMode.GotoSet);
|
||||
setStayButton.interactable = true;
|
||||
setAttackButton.interactable = true;
|
||||
setGotoButton.interactable = false;
|
||||
setFreeButton.interactable = true;
|
||||
}
|
||||
|
||||
public void SetAttackPressed()
|
||||
{
|
||||
mouseInMapCon.ChangeMouseModeTo(MouseInMap.MouseMode.AttackSet);
|
||||
setStayButton.interactable = true;
|
||||
setAttackButton.interactable = false;
|
||||
setGotoButton.interactable = true;
|
||||
setFreeButton.interactable = true;
|
||||
}
|
||||
|
||||
public void SetFreePressed()
|
||||
|
||||
Reference in New Issue
Block a user