public void Interact(InteractableController interactingObject) { moveSpeed = 0; interacting = true; this.interactingObject = interactingObject; SliderObject.SetActive(true); }
// Use this for initialization void Awake() { iController = this.GetComponent <InteractableController>(); nodeGrid = new NodeGrid[gridWidth, gridHeight]; gridActualWidth = gridWidth * nodeSize; gridActualHeight = gridHeight * nodeSize; // Generates nodeGrid array based on the height and width of the grid for (int i = 0; i < gridWidth; i++) { for (int j = 0; j < gridHeight; j++) { nodeGrid[i, j] = new NodeGrid(); nodeGrid[i, j].parentGrid = this; // Puts the node at the center of the square. nodeGrid[i, j].loc.x = (i * nodeSize) + (nodeSize / 2); nodeGrid[i, j].loc.y = (j * nodeSize) + (nodeSize / 2); } } currentPath = new List <NodeGrid>(); doneSearching = false; currentHighlightSquares = new List <GameObject>(); currentHighlightTimer = 0.0f; // iController.InitializeInteractables(); gridInitialized = true; DebugDrawGrid(); }
public void ShowInteractions(List <EventAction> interactions, InteractableController controller) { this.controller = controller; while (buttons.Count > 0) { Destroy(buttons[buttons.Count - 1].gameObject); buttons.RemoveAt(buttons.Count - 1); } if (updater != null) { StopCoroutine(updater); updater = null; } if (interactions == null) { return; } Debug.Log("show interactions"); foreach (var interaction in interactions) { CreateButton(interaction); } if (interactions != null) { StartCoroutine(updater = Updater()); } }
public void UpdateLayout(InteractableController controller) { int number; int.TryParse(controller.name.Substring(7, 1), out number); ChangeLayout(number); }
public override void PlayerInRangeUpdate(InteractableController interactable) { if (interactable.displayImage != null) { interactable.ToggleImage(false); } interactable.TransitionToState(interactable.idleState); }
void Start() { Chapter chapter1 = new Chapter1(); _gameEngine = new GameEngine(new Chapter[] { chapter1 }); noticedInteractableController = null; }
public override void EnterState(InteractableController interactable) { interactable.outlineObject.SetActive(true); if (interactable.displayImage != null) { interactable.ToggleImage(true); interactable.ChangeSprite(); } }
// Use this for initialization void Start() { grid = GameObject.Find("MainController").GetComponent <GridController>(); interactableController = GameObject.Find("MainController").GetComponent <InteractableController>(); clicked = false; interactableController.interactables.Add(this); Initialize(); }
/// <summary> /// Attempt to detect any interactables that are within sights. /// </summary> private void DetectInteractable() { // initialize vars for upcoming conditional RaycastHit raycastHit; InteractableController hitInteractable; // get point to fire interact raycast from Transform firePoint = _characterMasterController.CharSight.FirePoint; // if a fired raycast hit an interactable object if (Physics.Raycast(firePoint.position, firePoint.forward, out raycastHit, detectRange, interactableLayerMask)) { // get interactable component from hit interactable object hitInteractable = raycastHit.transform.GetComponent <InteractableController>(); // if no interactable component found on the interactable object if (hitInteractable == null) { // print warning to console Debug.LogWarning("Detected interactable object did NOT have a InteractableController component! " + $"Object name: {raycastHit.transform.name}"); // DONT continue code return; } // if hit interactable is different than the one currently being targeted if (interactTarget != hitInteractable) { // if something was being targeted before if (interactTarget != null) { // denote that interaction targeted has ended on old target interactTarget.OnInteractionTargetingEnd(_characterMasterController); } // set the current interaction target to the new target interactTarget = hitInteractable; // denote that interaction targeted has started on new target interactTarget.OnInteractionTargetingStart(_characterMasterController); } } // else fired raycast did NOT hit any interactables else { // if an interactable was being targeted before if (interactTarget != null) { // denote that interaction targeted has ended on old target interactTarget.OnInteractionTargetingEnd(_characterMasterController); // deselect current targeted interactable interactTarget = null; } } }
public override void Update(InteractableController interactable) { RaycastHit hit; int layerMask = 1 << 10; bool mouseOver = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 50, layerMask, QueryTriggerInteraction.Ignore); if (mouseOver && hit.transform.name == interactable.name) { interactable.TransitionToState(interactable.activeState); } }
public void SpawnObject() { interactableObject = GameObject.Find("InteractableObjectReference"); GameObject newInteractableObject = Instantiate(interactableObject, interactableObjectLocation, Quaternion.identity); newInteractableObject.AddComponent <InteractableController>(); interactableController = newInteractableObject.GetComponent <InteractableController>(); interactableController.interactableInfluence = interactableInfluence; interactableController.interactableObjectLocation = interactableObjectLocation; }
void Awake() { coordinates = transform.position; _interactableController = GetComponent <InteractableController>(); _hasInteractable = _interactableController != default(DoorController); try { if (Application.isPlaying && !KeepSprite) { Destroy(GetComponent <SpriteRenderer>()); } } catch (Exception e) { } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Interactive") { InteractableController interactableController = other.GetComponentInParent <InteractableController>(); // if (!interactableController.interactable.isGoalMet()) { gameEngineController.noticedInteractable(interactableController); // } } if (other.tag == "SolidObject") { playerRB.MovePosition(oldPosition); _collisionActive = true; } }
private void FixedUpdate() { Ray ray = new Ray(thisCam.position, thisCam.forward); RaycastHit hit; Physics.Raycast(ray, out hit, maxObjDist); //Debug.Log(hit.collider ? hit.collider.name : "Not hit"); if (hit.collider != null && hit.collider.tag == "Interactable") { lookAtObj = hit.collider.GetComponent <InteractableController>(); lookAtObj.inRange = true; } else if (lookAtObj != null) { lookAtObj.inRange = false; } }
bool IsGroupActivated() { if (groupID == 0) { return(false); } foreach (GameObject go in interactableList) { InteractableController ic = go.GetComponent <InteractableController>(); if (ic.groupID == groupID && !ic.isActivated) { return(false); } } return(true); }
public void UpdateInteractableState(InteractableController interactable, bool new_locked_state) { var is_match_found = false; foreach (var controller in interactables) { if (controller == interactable) { is_match_found = true; controller.IsObjectLocked = new_locked_state; break; } } if (PlayerController.Instance.debug_mode == true && is_match_found == false) { Debug.Log($"The interactabl component of <color=#ff0000>{interactable.gameObject.name}</color> is not valid!"); } }
void Update() { // Sækja hreyfiskipanir frá notanda moveX = Input.GetAxisRaw("Horizontal"); moveY = Input.GetAxisRaw("Vertical"); // Ef notandi ýtir á Interact-takkann, athuga hvort interactable hlutur sé innan seilingar if (Input.GetButtonDown("Interact")) { // Finna út í hvaða átt leikmaður snýr Direction currentDir = (Direction)animator.GetInteger("Direction"); Vector3 raycastDir = Vector3.zero; if (currentDir == Direction.Left) { raycastDir = Vector3.left; } else if (currentDir == Direction.Right) { raycastDir = Vector3.right; } else if (currentDir == Direction.Up) { raycastDir = Vector3.up; } else if (currentDir == Direction.Down) { raycastDir = Vector3.down; } // Raycast Vector3 raycastOrigin = new Vector3(transform.position.x + 0.5f, transform.position.y - 0.5f, transform.position.z); RaycastHit2D hit = Physics2D.Raycast(raycastOrigin, raycastDir, 1, colliderLayers); // Ef finnst interactable hlutur, kalla á Interact() aðferðina if (hit.collider != null && hit.collider.tag == "Interactable") { InteractableController interactable = hit.collider.GetComponent <InteractableController>(); interactable.Interact(); // Debug.Log("Player interacted with object " + interactable.ToString()); } } }
public virtual void Interact() { if (targetObject.tag == "Interactable") { InteractableController interactObject = targetObject.GetComponent <InteractableController>(); interactObject.Interact(gameObject); //if (targetObject.name == "Interactable") //{ // Debug.Log("Interacting"); // InteractableController interactObject = targetObject.GetComponent<InteractableController>(); // interactObject.Interact(gameObject); //} //else if (targetObject.name == "Person") //{ // Debug.Log("Interacting"); // InteractableController interactObject = targetObject.GetComponent<InteractableController>(); // interactObject.Interact(gameObject); //} } idle = true; }
public override void Update(InteractableController interactable) { RaycastHit hit; int layerMask = 1 << 10; bool mouseOver = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 50, layerMask, QueryTriggerInteraction.Ignore); if (!mouseOver) { if (interactable.displayImage != null) { interactable.ToggleImage(false); interactable.TransitionToState(interactable.playerCloseState); } } else { if (Input.GetKeyDown(KeyCode.Mouse0)) { interactable.ToggleSwitchState(); } } }
// Use this for initialization void Start() { grid = GetComponent <GridController>(); cameraController = GetComponent <MainCameraController>(); itemController = GetComponent <InteractableController>(); uiController = GetComponent <InterfaceController>(); convoController = GetComponent <ConversationController>(); textController = GetComponent <TextController>(); hero = GameObject.Find("Hero").GetComponent <HeroController>(); isScrolling = false; canClick = true; canScroll = true; scrollTimerVal = .2f; isScrollingTimer = scrollTimerVal; supportsMultiTouch = Input.multiTouchEnabled; textShowing = false; clickTimer = 0.0f; mouseX = 0.0f; mouseY = 0.0f; }
public override void EnterState(InteractableController interactable) { interactable.outlineObject.SetActive(false); }
public abstract void Update(InteractableController interactable);
public override void PlayerInRangeUpdate(InteractableController interactable) { interactable.TransitionToState(interactable.idleState); }
public override void Update(InteractableController interactable) { }
public abstract void EnterState(InteractableController interactable);
private void Start() { iController = GetComponent <InteractableController>(); thisAnim = GetComponentInParent <Animator>(); textElement = displayText.GetComponent <Text>(); }
private void Awake() { iController = GetComponent <InteractableController>(); thisRB = GetComponent <Rigidbody>(); thisParent = transform.parent; }
//public AudioSource audio; public void Start() { instance = this; }
void UpdatePlayer() { if (screenFader.isRunning || daysRemaining.isRunning || isForceSleeping) { return; } switch (playerOrientation) { case PlayerOrientation.Up: walkingDirection = Vector2.up; break; case PlayerOrientation.Down: walkingDirection = Vector2.down; break; case PlayerOrientation.Left: walkingDirection = Vector2.left; break; case PlayerOrientation.Right: walkingDirection = Vector2.right; break; } Rect wallRect = new Rect(transform.position - new Vector3(0.5f, 0.5f) + walkingDirection * 0.15f, Vector3.one); Collider2D[] wallColliders = Physics2D.OverlapAreaAll(wallRect.min, wallRect.max); foreach (Collider2D wallCollider in wallColliders) { if (wallCollider != null && currentStairs == null) { walking = walking && wallCollider.isTrigger; } } Rect interactionRect = new Rect(transform.position - new Vector3(0.5f, 0.5f), Vector3.one); Collider2D[] interactionColliders = Physics2D.OverlapAreaAll(interactionRect.min, interactionRect.max); if (interactionColliders.Length == 0) { interactiveObject = null; interacting = false; dialogController.Hide(); } if (interactiveObject != null) { for (int i = 0; i < interactionColliders.Length; i++) { Collider2D interactionCollider = interactionColliders[i]; // Give highest priority to the same task from the previous frame if (interactiveObject == interactionCollider.gameObject) { Collider2D temp = interactionColliders[0]; interactionColliders[0] = interactionCollider; interactionColliders[i] = temp; break; } } } foreach (Collider2D interactionCollider in interactionColliders) { if (interactionCollider.tag == "Interactive") { InteractableController interactableController = interactionCollider.gameObject.GetComponent <InteractableController>(); if (interactableController.playerOrientation == PlayerOrientation.None || interactableController.playerOrientation == playerOrientation) { if (dialogController.Show(interactableController.actions)) { interactiveObject = interactionCollider.gameObject; break; } } } interactiveObject = null; interacting = false; } if (interactiveObject == null) { OnLeavingAction(); } if (currentStairs != null) { switch (currentStairs.ascendingDirection) { case PlayerOrientation.Up: case PlayerOrientation.Down: walking = walking && (playerOrientation == PlayerOrientation.Up || playerOrientation == PlayerOrientation.Down); break; case PlayerOrientation.Left: case PlayerOrientation.Right: walking = walking && (playerOrientation == PlayerOrientation.Left || playerOrientation == PlayerOrientation.Right); break; } } UpdateSpriteZOrder(); UpdatePlayerAnimation(playerOrientation, walking); if (walking) { mplayer.PlayFootsteps(); } transform.position += walkingDirection * (walking ? 1 : 0) * walkingSpeed * Time.deltaTime; }
public abstract void PlayerInRangeUpdate(InteractableController interactable);