protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); isMouseDown = false; if (interactionState == InteractionState.Selection) { selectedElements = GetElementsByRectangle(SelectionRectangle); interactionState = InteractionState.None; Cursor = Cursors.Default; } else if (interactionState == InteractionState.Pan) { if (panSource == PanSource.Mouse) { interactionState = InteractionState.None; panSource = PanSource.None; Cursor = Cursors.Default; } else if (panSource == PanSource.Keyboard) { Cursor = CursorHelper.LoadFromResource(Properties.Resources.grab); } } else { interactionState = InteractionState.None; Cursor = Cursors.Default; } Refresh(); }
public static void Assert(this InteractionState state, InteractionState correct) { if (state != correct) { throw Error.Internal("Interaction was in an invalid state"); } }
/// <summary> /// Initialize interactor /// </summary> public RectangleInteractor() { _target = null; _state = InteractionState.Idle; _current = Rectangle.Empty; _unscaled_size = Size.Empty; _clip_cursor = false; }
public virtual IInteraction CreateInteraction(string pId, DateTime pStartDateTime, DateTime pEndDateTime, bool pIsActive, string pText, InteractionType pType, InteractionState pState, IUser pOwner, IUser pCreator, DateTime pCreated, DateTime pModified) { if (string.IsNullOrEmpty(pId)) pId = GenericHelper.GenerateId(); return (new Interaction(pId, pStartDateTime, pEndDateTime, pCreated, pModified, pIsActive, pText, pType, pCreator, pOwner, pState)); }
private void LateUpdate() { switch (m_interactionState) { case InteractionState.NEUTRAL: m_crosshairAnimation.ResetColor(); m_crosshairAnimation.ResetScale(); m_crosshairAnimation.ResetAlpha(); break; case InteractionState.IS: m_crosshairAnimation.SetAlpha(0.0f); break; case InteractionState.CAN: m_crosshairAnimation.ResetAlpha(); m_crosshairAnimation.SetColor(Color.yellow); m_crosshairAnimation.SetRelativeScale(2.0f); break; case InteractionState.CANNOT: m_crosshairAnimation.ResetAlpha(); m_crosshairAnimation.SetColor(Color.red); m_crosshairAnimation.ResetScale(); break; } m_interactionState = InteractionState.NEUTRAL; }
public void ShowDialog(object dialog, DialogType type, InteractionState? interactionState = null) { var dialogHost = Screen as IIsDialogHost; var revert = ChangeMode(interactionState); if (dialogHost == null) { Dialog = dialog; } else { dialogHost.AddDialog(dialog, type); } ((IClosable) dialog).Closed += delegate { if (dialogHost == null) { Dialog = null; } else { dialogHost.RemoveDialog(dialog); } ChangeMode(revert); }; }
public static void Assert(this InteractionState state, InteractionState correct) { if (state != correct) { throw Error.Internal("Interaction was in an invalid state"); } }
void Update() { if (IsActive()) { // Retrieve selection result VRSelection selection = m_Wand.GetSelection(); if (selection == null || !selection.SelectedObject.GetComponent <VRActor>().Grabable) { return; } m_CurrentSelectedObject = selection.SelectedObject; switch (m_State) { case InteractionState.Inactive: if (m_it.IsManipulationStarted()) { GrabInitialPosition(m_CurrentSelectedObject); Grab(m_CurrentSelectedObject); m_State = InteractionState.Running; } break; case InteractionState.Running: if (m_it.IsManipulationStopped()) { Ungrab(); m_State = InteractionState.Inactive; } break; } } }
// This sets up the variables we need when entering dialogue public void StartDialogue() { // Set the interaction state m_interactionState = InteractionState.Talking; // Unlock the cursor Cursor.lockState = CursorLockMode.None; // Deactivate the crosshair m_crosshair.gameObject.SetActive(false); // Deactivate the hover image m_hoverImage.gameObject.SetActive(false); // Set the look point m_lookPoint = hitInRange.transform.gameObject.GetComponent <DialogueNode>().LookPoint; UpdateDialogueName(); // Reset the text m_dialogueText.text = ""; // Get the dialogue we beed m_dialogue = hitInRange.collider.GetComponent <DialogueNode>().Dialogue[0]; // Creating a new stack for the previous dialogues m_dialoguePrev = new Stack <DNode>(); // Getting the outline width m_interactObjectOutlineBeforeDialogue = GetObjectMaterialFloat(hitInRange.collider.gameObject, "_OutlineWidth"); // Setting this enum so that we move into the setup // IEnumerator after this function m_dialogueEnum = dialogueEnumerator.Setup; }
private static void SetInteractionState(InteractionState p_newState) { if (GetPriority(p_newState) > GetPriority(m_interactionState)) { m_interactionState = p_newState; } }
/// <summary> /// Initialize interactor /// </summary> public RectangleInteractor() { _target = null; _state = InteractionState.Idle; _current = Rectangle.Empty; _unscaled_size = Size.Empty; _clip_cursor = false; }
private void begin(InteractionState interactionState, InteractionDefinition.Track track, int trackIndex) { interaction = interactionState; Track = track; TrackIndex = trackIndex; Action = getNextAction(); base.enabled = true; }
public void SetState(InteractionState newState) { if (newState != myState) { Debug.Log("My new state " + newState); myState = newState; } }
private void SetInteractionState(ref InteractionState interactionState, SteamVR_Action_Boolean_Source action) { // Pressed this frame // Released this frame // Is pressed }
private void onObjectManipulationInputControllerInteractionStateChanged(InteractionState state) { if (state == InteractionState.ActiveSelectedItem && previousState == InteractionState.DragItem) { Service.Get <EventDispatcher>().DispatchEvent(new IglooEvents.PlayIglooSound(SoundPath)); } previousState = state; }
private void OnObjectManipulationInputControllerInteractionStateChanged(InteractionState state) { if (state == InteractionState.ActiveSelectedItem && previousState == InteractionState.DragItem) { ShowParticlesOnSelectedObject(); } previousState = state; }
protected void Update() { var newInteractionState = InteractionState.Unassigned; if (m_handsInteractingWithMe.Count > 0) { newInteractionState = InteractionState.Interacting; } else if (m_handsHighlightingMe.Count > 0) { newInteractionState = InteractionState.Highlighted; } else { newInteractionState = InteractionState.Idle; } if (newInteractionState != m_currentInteractionState) { switch (m_currentInteractionState) { case InteractionState.Idle: OnIdleEnded.Invoke(); break; case InteractionState.Highlighted: OnHighlightEnded.Invoke(); break; case InteractionState.Interacting: OnInteractionEnded.Invoke(); break; default: break; } switch (newInteractionState) { case InteractionState.Idle: OnIdleStarted.Invoke(); break; case InteractionState.Highlighted: OnHighlightStarted.Invoke(); break; case InteractionState.Interacting: OnInteractionStarted.Invoke(); break; default: break; } m_currentInteractionState = newInteractionState; } }
public void TriggerHold() { if (this.m_enabled) { this.m_interactionState = InteractionState.Down; this.OnHold(); this.DispatchEvent(new UIEvent(UIEventType.HOLD, this)); } }
private void Awake() { lever0 = levers[0].GetComponent <InteractionState>(); lever1 = levers[1].GetComponent <InteractionState>(); lever2 = levers[2].GetComponent <InteractionState>(); lever3 = levers[3].GetComponent <InteractionState>(); lever4 = levers[4].GetComponent <InteractionState>(); lever5 = levers[5].GetComponent <InteractionState>(); }
public void TriggerDoubleClick() { if (this.m_enabled) { this.m_interactionState = InteractionState.Down; this.OnDoubleClick(); this.DispatchEvent(new UIEvent(UIEventType.DOUBLECLICK, this)); } }
public virtual void TriggerRelease() { if (this.m_enabled) { this.m_interactionState = InteractionState.Up; this.OnRelease(); this.DispatchEvent(new UIEvent(UIEventType.RELEASE, this)); } }
public void TriggerReleaseAll(bool mouseIsOver) { if (this.m_enabled) { this.m_interactionState = InteractionState.Up; this.OnReleaseAll(mouseIsOver); this.DispatchEvent(new UIReleaseAllEvent(mouseIsOver, this)); } }
public void TouchesBegan(CanvasTouch[] touches) { var touch = touches.First(); if (Frame.Contains(touch.CanvasLocation)) { istate = InteractionState.Pressed; } }
private void DrawInteractionState(Graphics graphics, InteractionState interactionState) { Font font = new Font("Arial", 10); Brush brush = new SolidBrush(Color.Black); graphics.DrawString(string.Format("InteractionState : {0}", interactionState), font, brush, new Point(10, Height - 40)); graphics.DrawString(string.Format("Ratio : {0:0.00}", ZoomRatio), font, brush, new Point(10, Height - 60)); graphics.DrawString(string.Format("MouseLocation : {0}", GetWorkspaceLocationFromControlLocation(controlMouseMoveLocation)), font, brush, new Point(10, Height - 80)); }
public void ChangeInteractionStateTo(InteractionState interactionState) { if (interactionState == currentInteractionState) { Debug.Log($"INFO INTERACTION STATE: State stayed the same: State {currentInteractionState.ToString("g")}. "); return; } ActivateCorrespondingInteractionHandler(interactionState); currentInteractionState = interactionState; }
public virtual void TriggerPress() { if (this.m_enabled) { this.m_focused = true; this.m_interactionState = InteractionState.Down; this.OnPress(); this.DispatchEvent(new UIEvent(UIEventType.PRESS, this)); } }
private void onObjectManipulationInputControllerInteractionStateChanged(InteractionState state) { if (state == InteractionState.ActiveSelectedItem) { InitializeControls(); return; } HideScaleControls(); HideRotationControls(); }
// wait until the player is close enough and then pick up void PlayerProximityPickup() { Vector3 playerPosition = Object.FindObjectOfType<PlayerCharacterController>().transform.position; float distanceToPlayer = Vector3.Distance(this.transform.position, playerPosition); if (distanceToPlayer < PickupProximity) { m_state = InteractionState.ReadyForPickup; } }
public IEnumerator TestTouchEventConfiguration() { // Create an interactive cube InteractiveElement interactiveElement = CreateInteractiveCube(); yield return(null); // Add the touch state InteractionState touchState = interactiveElement.AddNewState(touchStateName); yield return(null); // Get the event configuration for the touch state var eventConfiguration = interactiveElement.GetStateEvents <TouchEvents>(touchStateName); bool onTouchStarted = false; bool onTouchCompleted = false; bool onTouchUpdated = false; eventConfiguration.OnTouchStarted.AddListener((eventData) => { onTouchStarted = true; }); eventConfiguration.OnTouchCompleted.AddListener((eventData) => { onTouchCompleted = true; }); eventConfiguration.OnTouchUpdated.AddListener((eventData) => { onTouchUpdated = true; }); // Create a new hand and initialize it with an object in focus var leftHand = new TestHand(Handedness.Left); // Show hand at starting position yield return(ShowHandWithObjectInFocus(leftHand)); // Move hand to Touch the object yield return(MoveHandTouchObject(leftHand)); Assert.True(onTouchStarted); yield return(null); Assert.True(onTouchUpdated); yield return(null); yield return(MoveHandOutOfFocus(leftHand)); // Make sure the touch has completed when the hand moves off the object Assert.True(onTouchCompleted); yield return(null); }
private void OnEngaged(Hand grabbingHand) { _state = InteractionState.On; Engage(); if (_events.Engaged != null) { _events.Engaged.Invoke(new MetaInteractionData(null, grabbingHand.Palm)); } }
private void OnWilt() { if (GhostPath.Count < 1) { GhostPath.Add(Vector3.zero); GhostRotation.Add(Vector3.zero); InteractionState.Add(false); } status = Player_Status.wilting; AC.SetTrigger("OnWilt"); }
public virtual void TriggerOver() { if (this.m_enabled && !this.m_focused) { this.m_focused = true; InteractionState interactionState = this.m_interactionState; this.m_interactionState = InteractionState.Over; this.OnOver(interactionState); this.DispatchEvent(new UIEvent(UIEventType.ROLLOVER, this)); } }
public void OnPlayerTriggerExit() { if (ReviveTimer < MAX_REVIVE_TIME && downPlayer != null) { ReviveTimer = 0; // reset as player went away from down player downPlayer.OnReviveCancel(); downPlayer = null; InteractionState = InteractionState.OPEN_STATE; myCamera.orthographicSize = CameraOriginalPosition; } }
private void CalculateInteraction(HoverOver hoveringOver, ref InteractionState interactionState) { switch (hoveringOver) { case HoverOver.Menu: case HoverOver.Land: //Normal Interaction interactionState = InteractionState.Nothing; break; case HoverOver.FriendlyBuilding: //Select interaction interactionState = InteractionState.Select; //Unless a support item is selected if (m_GuiManager.GetSupportSelected == Const.MAINTENANCE_Sell) { //Sell if (currentObject.GetComponent <Building>().CanSell()) { interactionState = InteractionState.Sell; } else { interactionState = InteractionState.CantSell; } } else if (m_GuiManager.GetSupportSelected == Const.MAINTENANCE_Fix) { //Fix if (currentObject.GetComponent <Building>().GetHealthRatio() < 1) { interactionState = InteractionState.Fix; } else { interactionState = InteractionState.CantFix; } } else if (m_GuiManager.GetSupportSelected == Const.MAINTENANCE_Disable) { //Disable } break; case HoverOver.FriendlyUnit: case HoverOver.EnemyUnit: case HoverOver.EnemyBuilding: //Select Interaction interactionState = InteractionState.Select; break; } }
private void OnDisengaged(Hand releasingHand) { _state = InteractionState.Off; Disengage(); if (_events.Disengaged != null) { _events.Disengaged.Invoke(new MetaInteractionData(null, releasingHand.Palm)); } }
internal InteractionState startDraw(PointF pt, Graphics g) { InteractionState ist = null; int handle = 0; Arrow arrow = null; int segmentToSplit = 0; // draw a selection rectangle if the appropriate modifier key is pressed if ((fc.ModifierKeyActions.GetKeys(ModifierKeyAction.Select) & Control.ModifierKeys) != 0) { ist = new InteractionState(fc.Selection, 8, Action.Create); } else // or move selection if the mouse points to a handle in multiple selection if (fc.Selection.HitTestHandle(pt, ref handle)) { ist = new InteractionState(fc.Selection, handle, Action.Modify); } else // or split the arrow if appropriate if ((arrow = shouldSplitArrow(pt, ref segmentToSplit)) != null) { ist = new InteractionState(arrow, segmentToSplit, Action.Split); } else { // select the auto-handles object if (fc.getAutoHObj() != null && fc.getAutoHObj().HitTestHandle(pt, ref handle)) { RectangleF rcInv = fc.Selection.getRepaintRect(false); fc.Selection.Change(fc.getAutoHObj()); rcInv = Utilities.unionNonEmptyRects( rcInv, fc.Selection.getRepaintRect(false)); fc.setAutoHObj(null); rcInv.Inflate(fc.SelHandleSize, fc.SelHandleSize); Utilities.addToRect(ref rcInv, fc.ShadowOffsetX, fc.ShadowOffsetY); Rectangle rcInvDev = Utilities.docToDevice(g, rcInv); fc.Invalidate(rcInvDev); } // start operation defined by the distinct behavior types ist = StartDraw(pt); } return ist; }
private Interaction(Bundle.HTTPVerb method, IKey key, DateTimeOffset? when, Resource resource) { if (resource != null) { key.ApplyTo(resource); } else { this.Key = key; } this.Resource = resource; this.Method = method; this.When = when ?? DateTimeOffset.Now; this.State = InteractionState.Undefined; }
void Update() { if (!isCoroutineRunning && m_state == InteractionState.PendingPickup) { StartCoroutine("ProximityCheck"); } if (m_state == InteractionState.ReadyForPickup) { if (Inventory._instance.AddItem(this.gameObject)) { Destroy(this.gameObject); } else { // Too many items in bag Debug.Log("Too many items in bag!"); m_state = InteractionState.NoInteraction; // TODO: play sound? } } }
public Interaction(string pId, DateTime pstartDateTime, DateTime pendDateTime, DateTime pcreatedDateTime, DateTime pDateTimemodified, bool pisActive, string ptext, InteractionType ptype, IUser pcreator, IUser powner, InteractionState pstate) { _id = pId; StartDateTime = pstartDateTime; EndDateTime = pendDateTime; _createdDateTime= pcreatedDateTime; ModifiedDateTime = pDateTimemodified; _isActive = pisActive; Text = ptext; _type = ptype; _creator = pcreator; Owner = powner; _state = pstate; }
void OnMouseDown() { // Prevent Player from walking when doing inventory clicks InputHandler inputHandler = FindObjectOfType(typeof(InputHandler)) as InputHandler; // Don't pick up items if you're in inventory mode if (inputHandler.GetInputMode() == InputHandler.InputMode.IN_INVENTORY) { return; } m_state = InteractionState.PendingPickup; }
private void OnInteractionChanged(object sender, InteractionEventArgs e) { var interaction = e.Interaction; if (interaction.GetAttribute(InteractionAttributes.InteractionType) != InteractionAttributeValues.InteractionType.Call) { return; } var oldInteractionState = _interactions[interaction.InteractionId]; var newInteractionState = new InteractionState(interaction); if (oldInteractionState.State != newInteractionState.State) { if (newInteractionState.State == InteractionAttributeValues.State.ExternalDisconnect || newInteractionState.State == InteractionAttributeValues.State.InternalDisconnect) { _deviceManager.CallEnded(interaction.InteractionId); } else if (oldInteractionState.State == InteractionAttributeValues.State.Held && newInteractionState.State == InteractionAttributeValues.State.Connected) { _deviceManager.CallResumed(interaction.InteractionId); } else if (newInteractionState.State == InteractionAttributeValues.State.Held) { _deviceManager.CallHeld(interaction.InteractionId); } else if (newInteractionState.State == InteractionAttributeValues.State.Connected && oldInteractionState.State == InteractionAttributeValues.State.Alerting) { _deviceManager.CallAnswered(interaction.InteractionId); } } _interactions[interaction.InteractionId] = newInteractionState; }
private void CalculateInteraction(IOrderable obj, HoverOver hoveringOver, ref InteractionState interactionState) { if (obj.IsAttackable()) { if (hoverOver == HoverOver.EnemyUnit || hoverOver == HoverOver.EnemyBuilding) { //Attack Interaction interactionState = InteractionState.Attack; return; } } if (obj.IsDeployable()) { if (((RTSObject)obj).gameObject.Equals (currentObject)) { //Deploy Interaction interactionState = InteractionState.Deploy; return; } } if (obj.IsInteractable ()) { if (hoverOver == HoverOver.FriendlyUnit) { //Check if object can interact with unit (carry all for example) if (((IInteractable)obj).InteractWith(currentObject)) { //Interact Interaction interactionState = InteractionState.Interact; return; } } } if (obj.IsMoveable()) { if (hoverOver == HoverOver.Land) { //Move Interaction interactionState = InteractionState.Move; return; } } if (hoverOver == HoverOver.FriendlyBuilding) { //Check if building can interact with object (repair building for example) if (currentObject.GetComponent<Building>().InteractWith (obj)) { //Interact Interaction interactionState = InteractionState.Interact; return; } } if (hoverOver == HoverOver.FriendlyUnit || hoverOver == HoverOver.FriendlyBuilding || hoverOver == HoverOver.EnemyUnit || hoverOver == HoverOver.EnemyBuilding) { //Select Interaction interactionState = InteractionState.Select; return; } //Invalid interaction interactionState = InteractionState.Invalid; }
/// <summary> /// Changes the state of this interaction and thus causes the stateCHanged event to be fired /// </summary> /// <param name="pState"></param> public virtual void ChangeState(InteractionState pState) { this.State = pState; if (State == InteractionState.Finished || State == InteractionState.Cancelled) ChangeIsActive(false); List<InteractionAttributes> changedAttributes = new List<InteractionAttributes>(); changedAttributes.Add(InteractionAttributes.State); OnStateChanged(new InteractionEventArgs($"Survey state changed [Id={Id}]", DateTime.Now, InteractionType.Account)); }
// TODO: // Break the loop and return the desired interaction private void CalculateInteraction(List<IOrderable> list, HoverOver hoveringOver, ref InteractionState interactionState) { foreach (IOrderable obj in list) { bool ShouldInterractB = obj.ShouldInteract(hoveringOver); if (ShouldInterractB) { if (hoveringOver == HoverOver.EnemyUnit) { CalculateInteraction(obj, hoveringOver, ref interactionState); return; } } } CalculateInteraction (hoveringOver, ref interactionState); }
/// <summary> /// Start player - NPC conversation /// </summary> /// <param name='npc'> /// NPC to interact with /// </param> /// <param name='force'> /// Force the interactino even if player is already talking with someone /// </param> public void TalkNPC(NPC npc, bool force = false) { // If player is not talking with someone, or it's a force interaction if (interactionState != InteractionState.TALKING_NPC || force) { // Make player stand Stand(); // Switch player interaction state to talking with NPC interactionState = InteractionState.TALKING_NPC; if (npc != null) { interactingNPC = npc; //Debug.Log("Clear NPC"); } // and start conversation with NPC interactingNPC.StartConversation(); } }
public IInteraction CreateTask(string pId, string pText, IUser pCreator, DateTime pStartDT, DateTime pEndDT, DateTime pDueDT, decimal pBudget, int pDuration, int pPriority, InteractionState pState, decimal pBudgetUsed, int pTimeUsed, List<ITask> pSubTask, int pProgress) { if (string.IsNullOrEmpty(pId)) pId = Helper.GenerateId(); return (new Task(pId, pText, pCreator, pStartDT, pEndDT, pDueDT, pBudget, pDuration, pPriority, pState, pBudgetUsed, pTimeUsed, pSubTask, pProgress)); }
public void ResetState() { Stand(); interactionState = InteractionState.NONE; interactingNPC = null; SetCutscene(false); }
public virtual ITask CreateTask(string pId, string pText, IUser pCreator, DateTime pStartDT, DateTime pEndDT, DateTime pDueDT, decimal pBudget, int pDuration, int pPriority, InteractionState pState, List<IExpense> pExpenses, List<ITimeslice> pTime, List<ITask> pSubTask, int pProgress = 0) { throw new System.NotImplementedException(); }
public void PlayIntroAnimation(Vector3 target) { cutscene = true; playerNavigation.speed = 8f; playerNavigation.SetDestination(target); Walk(6); interactionState = InteractionState.IN_INTROANIM; }
/// <summary> /// Handle Event: MoveTo (3D) /// </summary> /// <param name='target'> /// Target location transform /// </param> public void MoveToNPC(Transform target) { // Set navigation mesh agent target playerNavigation.SetDestination(target.position); // Make player walk Walk(7); // Set interaction state to approaching event interactionState = InteractionState.APPROACH_NPC; }
public void TouchesEnded(CanvasTouch[] touches) { if (istate == InteractionState.Pressed) { istate = InteractionState.None; var c = Click; if (c != null) { c (this, EventArgs.Empty); } } }
// Use this for initialization void Start() { // Find the navigation mesh agent in the gameobject (2D) //playerNavigation = GetComponent<PlayerNavigation>(); // Set interaction state to none if(interactionState != InteractionState.IN_INTROANIM){ interactionState = InteractionState.NONE; // Make the player stand Stand(); } GameObject interactionGO = Instantiate(interactionBubblePrefab) as GameObject; interactionGO.transform.parent = GameObject.Find("GUICamera").transform; interactionBubble = interactionGO.GetComponent<PlayerInteractionBubble>(); NormalizeHeight(); InvokeRepeating("NormalizeHeight", 0, 0.5f); }
public void TouchesBegan(CanvasTouch[] touches) { var touch = touches.First (); if (Frame.Contains (touch.CanvasLocation)) { istate = InteractionState.Pressed; } }
void Update() { //Depth calculations (2D) // if(listReferenceObjects.Length == 0){ // listReferenceObjects = GameObject.FindGameObjectsWithTag("Depth_Reference"); // } // // Vector3 newDepth; // foreach(GameObject go in listReferenceObjects){ // if(playerNavigation.Distance(go.gameObject.transform.position) < 4){ // if(this.transform.position.y > go.transform.position.y){ // newDepth = new Vector3(); // newDepth = go.transform.position; // newDepth.z = this.transform.position.z - 0.5f; // go.transform.position = newDepth; // } // else{ // newDepth = new Vector3(); // newDepth = go.transform.position; // newDepth.z = this.transform.position.z + 0.5f; // go.transform.position = newDepth; // } // } // } // If the player is approaching an event if (interactionState == InteractionState.APPROACH_EVENT) { // and it's close enough to the target event if (interactingNPC != null && interactingNPC.conversationTree != null) { // Get current dialogue from npc and retrieve the actual event and trigger it again SCEvent dialogueEvent = interactingNPC.conversationTree.GetCurrentEvent(); // If there is a dialogue event associated with the current dialogue and the player is close enough //if (dialogueEvent != null && PlayerDistance(dialogueEvent.location.position) < 3f) if (dialogueEvent != null && playerNavigation.remainingDistance < 3f) { interactionState = InteractionState.IN_EVENT; // Trigger the event dialogueEvent.TriggerEvent(true); } } } else if (interactionState == InteractionState.APPROACH_NPC) { // If the player is close enough if (playerNavigation.remainingDistance < 3) { TalkNPC(interactingNPC, true); } } // If the player is walking //if (playerNavigation.walking) if(walking) { // If the player is close to the destination //if (playerNavigation.remainingDistance < 1 /*&& !startedWalking*/) if (playerNavigation.remainingDistance < 0.1 /*&& !startedWalking*/) { // Make him stand Stand(); } else // Otherwise update animation sprite { //startedWalking = false; GetCurrentAngle(); //Get angle (2D) //currentAngle = playerNavigation.GetCurrentAngle(); Walk(7); previousPosition = transform.position; } } else Stand(); if(interactionState == InteractionState.IN_INTROANIM && playerNavigation.remainingDistance < 1f){ Stand(); cutscene = false; interactionState = InteractionState.NONE; } // If the player clicks on screen if (InputManager.Instance.HasReceivedClick() && !cutscene) { // if the player is approaching an event if (interactionState == InteractionState.APPROACH_EVENT) { } // if the player is in an event else if (interactionState == InteractionState.IN_EVENT) { } // if the player is talking to an NPC else if (interactionState == InteractionState.TALKING_NPC) { } else // otherwise { // if the player has not just finished an interaction with an NPC or an event if (/*false && */!finishedInteraction && !InputManager.Instance.HasReceivedUIInput()) { // Get ray from given input position RaycastHit hit; Vector3 screenPoint = Input.mousePosition; Ray sceneRay = sceneCamera.ScreenPointToRay(screenPoint); // and raycast it in scene Physics.Raycast(sceneRay, out hit); // and set destination to given position //playerNavigation.SetDestination(UICamera.lastHit.point); NavMeshPath possiblePath = new NavMeshPath(); if (playerNavigation.CalculatePath(hit.point, possiblePath)) { playerNavigation.SetDestination(hit.point); if (Vector3.Distance (hit.point, transform.position) > 30) { animationControl.SetFPS(8); playerNavigation.speed = runnignSpeed; playerNavigation.acceleration = runningAcceleration; // Start walking animation Walk(8); } else { animationControl.SetFPS(6); playerNavigation.speed = walkingSpeed; playerNavigation.acceleration = walkingAcceleration; // Start walking animation Walk(6); } } } } } // // If player is near NPC if (interactionState == InteractionState.NEAR_NPC && interactingNPC != null) { //if the player is close to the NPC if (playerNavigation.remainingDistance < 25 && Vector3.Distance(transform.position, interactingNPC.transform.position) < 18) { // and he / she has stopped walking if (playerNavigation.desiredVelocity.magnitude < 0) { // then stop player navigation playerNavigation.Stop(); } } // If navigation speed is 0 if (playerNavigation.speed == 0) Stand(); // then change to standing animation //player nav stop (2D) /* playerNavigation.Stop(); // If navigation speed is 0 if (!playerNavigation.walking) // then change to standing animation */ } //} }
public void PlayRewardPortrait(Texture winningSprite, Texture missingToy, Color foundToyColor, float winningCelSec) { // animationSprite.ChangeAnimation(AnimationPrefix.PLAYER_REWARD_PORTRAIT); // animationSprite.Play(); //animationSprite.gameObject.GetComponent<UITextureAnimation>().enabled = false; //animationSprite.gameObject.GetComponent<UITexture>().mainTexture = winningSprite; PlayAnimation(NPCAnimations.AnimationIndex.RECEIVE_TOY, 2); UISprite toySprite; if(currentAngle <= 94f || currentAngle >= 276f){ toySprite = toyInLeftHand.GetComponent<UISprite>(); } //Walk Left else{ toySprite = toyInRightHand.GetComponent<UISprite>(); //toyInHand.transform.position = new Vector3(0,0,0); } toySprite.spriteName = missingToy.name; toySprite.color = foundToyColor; toySprite.gameObject.SetActive(true); Stand(); interactionState = InteractionState.NONE; interactingNPC = null; SetCutscene(false); winningCelebrationTime = winningCelSec; StartCoroutine(ResumeWalkingAnimation()); }
public virtual void ChangeState(InteractionState pState) { throw new System.NotImplementedException(); }
/// <summary> /// Handle Event: BeginMinigame /// </summary> /// <param name='minigame'> /// Minigame /// </param> public void BeginMinigame(Minigame minigame) { // Set mnigame owner to interacting NPC minigame.owner = interactingNPC; // Set scene minigame to give minigame GameManager.Instance.minigame = minigame; // Set interaction state to in event interactionState = InteractionState.IN_EVENT; }
public void PreDialogueMinigameStart(NPC npc) { interactingNPC = npc; interactionState = InteractionState.TALKING_NPC; npc.StartEvent (); }
private void CalculateInteraction(HoverOver hoveringOver, ref InteractionState interactionState) { switch (hoveringOver) { case HoverOver.Menu: case HoverOver.Land: //Normal Interaction interactionState = InteractionState.Nothing; break; case HoverOver.FriendlyBuilding: //Select interaction interactionState = InteractionState.Select; //Unless a support item is selected if (m_GuiManager.GetSupportSelected == Const.MAINTENANCE_Sell) { //Sell if (currentObject.GetComponent<Building>().CanSell ()) { interactionState = InteractionState.Sell; } else { interactionState = InteractionState.CantSell; } } else if (m_GuiManager.GetSupportSelected == Const.MAINTENANCE_Fix) { //Fix if (currentObject.GetComponent<Building>().GetHealthRatio () < 1) { interactionState = InteractionState.Fix; } else { interactionState = InteractionState.CantFix; } } else if (m_GuiManager.GetSupportSelected == Const.MAINTENANCE_Disable) { //Disable } break; case HoverOver.FriendlyUnit: case HoverOver.EnemyUnit: case HoverOver.EnemyBuilding: interactionState = InteractionState.Select; break; } }
/// <summary> /// End current minigame. /// </summary> public void EndMinigame() { Destroy(GameManager.Instance.minigame.gameObject); Resources.UnloadUnusedAssets(); // Clear scene minigame GameManager.Instance.minigame = null; if (interactionState != InteractionState.APPROACH_EVENT && interactionState != InteractionState.APPROACH_NPC) { // Set interaction state to none interactionState = InteractionState.NONE; } SetCutscene(false); }