1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using Fort23.Mono;
- using GameLogic.Combat.Hero;
- using UnityEngine;
- using Utility;
- namespace GameLogic.Combat.CombatTool
- {
- public class CombatGestureController : Singleton<CombatGestureController>
- {
- private HeroEntityMono heroEntityMono;
- private RaycastHit[] hit = new RaycastHit[10];
- public void Dispose()
- {
- }
- public void Update()
- {
- if (Input.GetMouseButtonDown(0))
- {
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- // LayerMask layerMask = LayerMask.NameToLayer("hero");
- if (Physics.Raycast(ray.origin, ray.direction, out RaycastHit hit))
- {
- HeroEntityMono mono = hit.transform.gameObject.GetComponent<HeroEntityMono>();
- if (mono != null && !mono.combatHeroEntity.IsEnemy)
- {
- heroEntityMono= mono;
- heroEntityMono.combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.PickUp);
- CombatHeroEntity[] combatHeroEntities = CombatController.currActiveCombat.CombatHeroController.GetHero(false);
- if (CombatController.currActiveCombat.CombatCameraControllder.FollowHeroId== heroEntityMono.combatHeroEntity.CurrCombatHeroInfo.modelID||combatHeroEntities!=null&&combatHeroEntities.Length == 1)
- {
- CombatController.currActiveCombat.CombatCameraControllder.isStop = true;
- }
- }
- }
- }
- if (Input.GetMouseButton(0))
- {
- if (heroEntityMono != null && heroEntityMono.combatHeroEntity != null)
- {
- // Vector2 pos = Input.mousePosition;
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- int layerMask = LayerMask.NameToLayer("hongpei");
- int count = Physics.RaycastNonAlloc(ray.origin, ray.direction, hit);
- if (count > 0)
- {
- for (int i = 0; i < count; i++)
- {
- if (hit[i].transform.gameObject.layer == layerMask)
- {
- heroEntityMono.gameObject.transform.position =
- hit[i].point;
- }
- }
- }
- }
- }
- if (Input.GetMouseButtonUp(0))
- {
- if (heroEntityMono != null)
- {
- heroEntityMono.combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.idle);
- }
- heroEntityMono = null;
- CombatController.currActiveCombat.CombatCameraControllder.isStop = false;
- }
- }
- }
- }
|