private CreatureStateHud.TUIElement GetElementForTouch(TouchData touchData, CreatureState creatureState, UnityEngine.Vector2 currentPosition) { for (int index = 0; index < _weaponUIDataArray.Count; ++index) { WeaponUIData weaponUIData = _weaponUIDataArray[index]; if ((false == weaponUIData.clickedOn) && (weaponUIData.rect.Contains(touchData.start))) { CreatureStateHud.THandPose pose = CreatureStateHud.THandPose.Swing; var distance = (currentPosition - touchData.start).magnitude; var position = currentPosition; if (distance < weaponUIData.rect.width * 0.5f) { pose = CreatureStateHud.THandPose.Shoot; position = new UnityEngine.Vector2(UnityEngine.Screen.width * 0.5f, UnityEngine.Screen.height * 0.5f) + (currentPosition - touchData.start); } creatureState.creatureStateHud.handPoseArray.Add(new CreatureStateHud.HandPoseData() { handPose = pose, position = position }); weaponUIData.clickedOn = true; _weaponUIDataArray[index] = weaponUIData; return(CreatureStateHud.TUIElement.None); } } //dont start a move/ hand action if click was on foreach (CreatureStateHud.UIElementData uiElementData in creatureState.creatureStateHud.uiElementDataArray) { //uiElementData.r var rect = CreatureHud2D.UIPositionToRect(uiElementData.position); if (rect.Contains(touchData.start)) { return(CreatureStateHud.TUIElement.None); } } CreatureStateHud.TUIElement uiElement = CreatureStateHud.TUIElement.None; if (touchData.start.x < (UnityEngine.Screen.width * 0.25f)) { uiElement = CreatureStateHud.TUIElement.Movement; } else if ((UnityEngine.Screen.width * 0.75f) < touchData.start.x) { uiElement = CreatureStateHud.TUIElement.View; } else { uiElement = CreatureStateHud.TUIElement.None; creatureState.creatureStateHud.handPoseArray.Add(new CreatureStateHud.HandPoseData() { handPose = CreatureStateHud.THandPose.Empty, position = currentPosition }); } return(uiElement); }
private void Start() { UnityEngine.Debug.Log("CreatureComponent.Start", this); _thirdPersonCameraComponent = GetComponent <ThirdPersonCameraComponent>(); _creatureState = new CreatureState(typeName, gameObject); _creatureBodyVisual = new CreatureBodyVisual(); _creatureBodyPhysics = new CreatureBodyPhysics(gameObject, _creatureState); if (true == startHumanControlled) { GameComponent.SetHumanPlayer(0, this); _creatureController = new CreatureControllerHuman(); } else { _creatureController = new CreatureControllerAI(); } _creatureHud2D = new CreatureHud2D(); }