2021-04-08 20:09:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using ET;
|
|
|
|
|
using FairyGUI;
|
|
|
|
|
using Cal.DataTable;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
public class OperaComponentAwakeSystem: AwakeSystem<OperaComponent>
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
public override void Awake(OperaComponent self)
|
|
|
|
|
{
|
|
|
|
|
self.Awake();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-20 00:25:04 +08:00
|
|
|
|
public class OperaComponentUpdateSystem: UpdateSystem<OperaComponent>
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
public override void Update(OperaComponent self)
|
|
|
|
|
{
|
|
|
|
|
self.Update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-20 00:25:04 +08:00
|
|
|
|
public class OperaComponent: Entity
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
public Vector3 ClickPoint;
|
|
|
|
|
|
|
|
|
|
public int mapMask;
|
|
|
|
|
private int m_OtherPlayerLayerMask;
|
|
|
|
|
private int m_NPCLayerMask;
|
|
|
|
|
private int m_SceneUnitLayerMask;
|
|
|
|
|
private int m_MonsterLayerMask;
|
|
|
|
|
|
|
|
|
|
private Dictionary<int, Action> shortKeyDic = new Dictionary<int, Action>();
|
|
|
|
|
|
|
|
|
|
private Unit unit;
|
|
|
|
|
private const float AtkDis = 2.5f;
|
|
|
|
|
|
|
|
|
|
private readonly Frame_ClickMap frameClickMap = new Frame_ClickMap();
|
2021-04-20 00:25:04 +08:00
|
|
|
|
private Scene zoneScene;
|
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
public void Awake()
|
|
|
|
|
{
|
|
|
|
|
this.mapMask = LayerMask.GetMask("Map");
|
|
|
|
|
m_OtherPlayerLayerMask = 1 << LayerMask.NameToLayer("Player");
|
|
|
|
|
m_NPCLayerMask = 1 << LayerMask.NameToLayer("NPC");
|
|
|
|
|
m_MonsterLayerMask = 1 << LayerMask.NameToLayer("Monster");
|
|
|
|
|
m_SceneUnitLayerMask = 1 << LayerMask.NameToLayer("SceneUnit");
|
|
|
|
|
|
|
|
|
|
frameClickMap.UnitInfo = new UnitPosInfo();
|
2021-04-20 00:25:04 +08:00
|
|
|
|
zoneScene = this.ZoneScene();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
|
|
|
|
|
InitShortKey();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitShortKey()
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
var zoneScene = this.ZoneScene();
|
|
|
|
|
shortKeyDic[(int) KeyCode.F1] = () => { SendMainUISlot(0).Coroutine(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.F2] = () => { SendMainUISlot(1).Coroutine(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.F3] = () => { SendMainUISlot(2).Coroutine(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.F4] = () => { SendMainUISlot(3).Coroutine(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.F5] = () => { SendMainUISlot(4).Coroutine(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.F6] = () => { SendMainUISlot(5).Coroutine(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.F7] = () => { SendMainUISlot(6).Coroutine(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.F8] = () => { SendMainUISlot(7).Coroutine(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.F9] = () => { SendMainUISlot(8).Coroutine(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.Escape] = () => { ET.FUIHelper.CloseAllWindows(); };
|
|
|
|
|
shortKeyDic[(int) KeyCode.B] = () =>
|
|
|
|
|
{
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.OpenBagUI { zoneScene = MainUI.ui.ZoneScene() }).Coroutine();
|
|
|
|
|
};
|
|
|
|
|
shortKeyDic[(int) KeyCode.C] = () =>
|
|
|
|
|
{
|
|
|
|
|
zoneScene.GetComponent<GlobalVariable>().IsMineCharacter = true;
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.OpenCharacterUI { zoneScene = MainUI.ui.ZoneScene() }).Coroutine();
|
|
|
|
|
};
|
|
|
|
|
shortKeyDic[(int) KeyCode.S] = () =>
|
|
|
|
|
{
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.OpenSkillUI { zoneScene = MainUI.ui.ZoneScene() }).Coroutine();
|
|
|
|
|
};
|
|
|
|
|
shortKeyDic[(int) KeyCode.T] = () =>
|
|
|
|
|
{
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.TaskUI_Open { zoneScene = MainUI.ui.ZoneScene() }).Coroutine();
|
|
|
|
|
};
|
|
|
|
|
shortKeyDic[(int) KeyCode.M] = () =>
|
|
|
|
|
{
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.OpenMarketUI { zoneScene = MainUI.ui.ZoneScene() }).Coroutine();
|
|
|
|
|
};
|
|
|
|
|
shortKeyDic[(int) KeyCode.Keypad0] = async () =>
|
|
|
|
|
{
|
|
|
|
|
M2C_RequestPersonalPvp ret = await zoneScene.GetComponent<SessionComponent>()
|
|
|
|
|
.Call<M2C_RequestPersonalPvp>(new C2M_RequestPersonalPvp { });
|
|
|
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
TipHelper.OpenUI(ret.Message);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
shortKeyDic[(int) KeyCode.O] = async () =>
|
|
|
|
|
{
|
|
|
|
|
M2C_OpenGMUI ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_OpenGMUI>(new C2M_OpenGMUI { });
|
|
|
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-08 20:09:59 +08:00
|
|
|
|
|
2021-04-20 00:25:04 +08:00
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.OpenGMUI { zoneScene = MainUI.ui.ZoneScene() }).Coroutine();
|
|
|
|
|
};
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
private async ETTask SendMainUISlot(int index)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
MainUISlot mainUISlot = MainUISlotComponent.Instance.Get(index);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (mainUISlot.MainUIType == MainUIType.SkillSlot)
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
M2C_UseMainUISkill ret = await zoneScene.GetComponent<SessionComponent>()
|
|
|
|
|
.Call<M2C_UseMainUISkill>(new C2M_UseMainUISkill() { SlotId = index });
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
M2C_UseMainUIGoods ret = await zoneScene.GetComponent<SessionComponent>()
|
|
|
|
|
.Call<M2C_UseMainUIGoods>(new C2M_UseMainUIGoods() { SlotId = index });
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
TipHelper.OpenUI(ret.Message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
|
|
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.UpdateBagUI { list = ret.BagMapList });
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.UpdateMainUISlot { list = ret.MainUISlotList }).Coroutine();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if UNITY_ANDROID
|
|
|
|
|
private int escapeCount;
|
|
|
|
|
private float lastQuitTime;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
{
|
|
|
|
|
if (!unit)
|
2021-09-04 14:55:51 +08:00
|
|
|
|
{
|
|
|
|
|
unit = zoneScene.GetComponent<UnitComponent>().MyUnit;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return;
|
2021-09-04 14:55:51 +08:00
|
|
|
|
}
|
2021-04-08 20:09:59 +08:00
|
|
|
|
//暂时回城
|
|
|
|
|
if (!unit.IsFight &&
|
|
|
|
|
Input.GetKey(KeyCode.LeftControl) &&
|
|
|
|
|
Input.GetKeyDown(KeyCode.G))
|
|
|
|
|
{
|
|
|
|
|
if (Stage.inst.focus is InputTextField input)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.BackMainCity {zoneScene = this.zoneScene}).Coroutine();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (Input.anyKeyDown)
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
if (Stage.inst.focus is InputTextField input)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
foreach (var kv in shortKeyDic)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
KeyCode keyCode = (KeyCode) kv.Key;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (Input.GetKeyDown(keyCode))
|
|
|
|
|
{
|
|
|
|
|
kv.Value?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
//FGUI
|
|
|
|
|
if (FairyGUI.Stage.isTouchOnUI) return;
|
|
|
|
|
int hasTarget = ClickTarget();
|
|
|
|
|
switch (hasTarget)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
case -1:
|
|
|
|
|
//!没按左键
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
//!不用移动
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
//!移动操作
|
|
|
|
|
if (!unit.IsFight)
|
|
|
|
|
{
|
|
|
|
|
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
|
|
|
RaycastHit2D hit = Physics2D.Raycast(mousePos, Vector2.zero, 100, layerMask: mapMask);
|
|
|
|
|
{
|
|
|
|
|
if (hit.collider != null)
|
|
|
|
|
{
|
|
|
|
|
this.ClickPoint = hit.point;
|
|
|
|
|
frameClickMap.UnitInfo.X = ClickPoint.x;
|
|
|
|
|
frameClickMap.UnitInfo.Y = ClickPoint.y;
|
2021-04-20 00:25:04 +08:00
|
|
|
|
frameClickMap.UnitInfo.YAngle = ClickPoint.x >= unit.Position.x? 0 : 180;
|
|
|
|
|
zoneScene.GetComponent<SessionComponent>().Session.Send(frameClickMap);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
//!点击目标
|
|
|
|
|
if (Input.GetMouseButtonUp(0) && unit.IsFight)
|
|
|
|
|
{
|
|
|
|
|
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
|
|
|
//射线检测怪物
|
|
|
|
|
RaycastHit2D hit = Physics2D.Raycast(mousePos, Vector2.zero, 100, m_MonsterLayerMask);
|
|
|
|
|
if (hit.collider != null)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
GameObject go = hit.collider.gameObject;
|
2021-04-20 00:25:04 +08:00
|
|
|
|
zoneScene.GetComponent<GlobalVariable>().SelectBattleUnitId =
|
|
|
|
|
((UnitView) go.GetComponentInParent<ComponentView>().Component).Parent.Id;
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.ClickBattleTarget { zoneScene = this.ZoneScene(), unitType = UnitType.Enermy })
|
|
|
|
|
.Coroutine();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//射线检测玩家
|
|
|
|
|
hit = Physics2D.Raycast(mousePos, Vector2.zero, 100, m_OtherPlayerLayerMask);
|
|
|
|
|
if (hit.collider != null)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
GameObject go = hit.collider.gameObject;
|
2021-04-20 00:25:04 +08:00
|
|
|
|
zoneScene.GetComponent<GlobalVariable>().SelectBattleUnitId =
|
|
|
|
|
((UnitView) go.GetComponent<ComponentView>().Component).Parent.Id;
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.ClickBattleTarget { zoneScene = this.ZoneScene(), unitType = UnitType.TeamMember })
|
|
|
|
|
.Coroutine();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
}
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//!关闭游戏
|
|
|
|
|
#if UNITY_ANDROID
|
|
|
|
|
if (Input.GetKey(KeyCode.Escape))
|
|
|
|
|
{
|
|
|
|
|
var now = Time.time;
|
|
|
|
|
if( now-lastQuitTime > 1)
|
|
|
|
|
{
|
|
|
|
|
lastQuitTime = now;
|
|
|
|
|
escapeCount = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
escapeCount++;
|
|
|
|
|
if (escapeCount >= 2)
|
|
|
|
|
ET.Init.Quit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>-1: 没点击; 0:不移动; 1:移动;</returns>
|
|
|
|
|
private int ClickTarget()
|
|
|
|
|
{
|
|
|
|
|
#if UNITY_STANDALONE
|
|
|
|
|
if (Input.GetMouseButtonUp(0))
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (Input.GetMouseButtonUp(1) &&
|
|
|
|
|
!unit.IsFight)
|
|
|
|
|
#elif UNITY_ANDROID
|
|
|
|
|
if (Input.GetMouseButtonUp(0) &&
|
|
|
|
|
!unit.IsFight)
|
|
|
|
|
#endif
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
var zoneScene = this.ZoneScene();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
//!移动的时候不能操作
|
2021-04-20 00:25:04 +08:00
|
|
|
|
Team team = zoneScene.GetComponent<TeamComponent>().Get(zoneScene.GetComponent<GlobalVariable>().LeaderId);
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Unit unit in team.GetAll())
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
if (unit.GetComponent<MoveComponent>().MoveTimer != 0)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
#if UNITY_STANDALONE
|
|
|
|
|
return -1;
|
|
|
|
|
#else
|
|
|
|
|
return 1;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
|
|
|
|
|
|
|
|
//射线检测怪物
|
|
|
|
|
RaycastHit2D hit = Physics2D.Raycast(mousePos, Vector2.zero, 100, m_MonsterLayerMask);
|
|
|
|
|
if (hit.collider != null)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
GameObject go = hit.collider.gameObject;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (CheckDis(go)) return 0;
|
|
|
|
|
UnitView unit = go.GetComponentInParent<ComponentView>().Component as UnitView;
|
|
|
|
|
MonsterInfo monsterInfo = unit.Parent.GetComponent<MonsterInfo>();
|
2021-04-20 00:25:04 +08:00
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.OnClickMonster {zoneScene=zoneScene, monsterInfo = monsterInfo }).Coroutine();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
ClickActionComponent clickAction = unit.Parent.GetComponent<ClickActionComponent>();
|
|
|
|
|
if (clickAction)
|
|
|
|
|
clickAction.Run();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-11-26 23:20:12 +08:00
|
|
|
|
//射线检测NPC
|
|
|
|
|
hit = Physics2D.Raycast(mousePos, Vector2.zero, 100, m_NPCLayerMask);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (hit.collider != null)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
GameObject go = hit.collider.gameObject;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (CheckDis(go)) return 0;
|
2022-11-26 23:20:12 +08:00
|
|
|
|
|
|
|
|
|
UnitView unit = go.GetComponentInParent<ComponentView>().Component as UnitView;
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.OnClickNPC { zoneScene = zoneScene,configId = unit.GetParent<Unit>().ConfigId }).Coroutine();
|
|
|
|
|
ClickActionComponent clickAction = unit.Parent.GetComponent<ClickActionComponent>();
|
|
|
|
|
if (clickAction)
|
|
|
|
|
clickAction.Run();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-11-26 23:20:12 +08:00
|
|
|
|
//射线检测玩家
|
|
|
|
|
hit = Physics2D.Raycast(mousePos, Vector2.zero, 100, m_OtherPlayerLayerMask);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (hit.collider != null)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
GameObject go = hit.collider.gameObject;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (CheckDis(go)) return 0;
|
2022-11-26 23:20:12 +08:00
|
|
|
|
|
|
|
|
|
if (!go.Equals(zoneScene.GetComponent<UnitComponent>().MyUnit.GetComponent<UnitView>()?.gameObject))
|
|
|
|
|
{
|
|
|
|
|
UnitView unit = go.GetComponentInParent<ComponentView>().Component as UnitView;
|
|
|
|
|
zoneScene.GetComponent<GlobalVariable>().SelectUnitId = unit.Parent.Id;
|
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.ClickOtherPlayer { zoneScene = zoneScene }).Coroutine();
|
|
|
|
|
ClickActionComponent clickAction = unit.Parent.GetComponent<ClickActionComponent>();
|
|
|
|
|
if (clickAction)
|
|
|
|
|
clickAction.Run();
|
|
|
|
|
}
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//射线检测Unit
|
|
|
|
|
hit = Physics2D.Raycast(mousePos, Vector2.zero, 100, m_SceneUnitLayerMask);
|
|
|
|
|
if (hit.collider != null)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
GameObject go = hit.collider.gameObject;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (CheckDis(go)) return 0;
|
|
|
|
|
UnitView unit = go.GetComponentInParent<ComponentView>().Component as UnitView;
|
|
|
|
|
ClickActionComponent clickAction = unit.Parent.GetComponent<ClickActionComponent>();
|
|
|
|
|
if (clickAction)
|
|
|
|
|
clickAction.Run();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#if UNITY_STANDALONE
|
|
|
|
|
return -1;
|
|
|
|
|
#else
|
|
|
|
|
return 1;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-20 00:25:04 +08:00
|
|
|
|
return 0;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
private bool CheckDis(GameObject go)
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
Vector2 v2 = go.transform.position - zoneScene.GetComponent<UnitComponent>().MyUnit.Position;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (v2.sqrMagnitude > AtkDis * AtkDis)
|
|
|
|
|
{
|
|
|
|
|
TipHelper.OpenUI("您离目标太远!");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
}
|