public void InventoryToggle() { if (Input.GetButtonDown("Inventory")) { //If the player is dead or the player won if (playerState == PlayerState.Dead || playerState == PlayerState.Win) { //Exit the function return; } if (playerState != PlayerState.InventoryOpen) { //Raise the inventory open event toggleInventoryEvent.Raise(); //Change player state to inventory playerState = PlayerState.InventoryOpen; } else { //Raise the inventory open event toggleInventoryEvent.Raise(); //Change player state to inventory playerState = PlayerState.Active; } } }
void interactionRaisEvent(Collision col, VoidEvent eventToTrigger) { wasRaisedThisFrame = false; if (checkInteractionBy == Filter.Tag) { if (col.gameObject.CompareTag(tagToLookFor)) { eventToTrigger.Raise(); if (isOneTimeEvent) { gameObject.SetActive(false); Destroy(gameObject); } wasRaisedThisFrame = true; } } //safety so we don't encounter a nullpointer if if (checkInteractionBy == Filter.Object) { if (collidableObject == null) { return; } if (col.gameObject == collidableObject) { eventToTrigger.Raise(); if (isOneTimeEvent) { gameObject.SetActive(false); Destroy(gameObject); } wasRaisedThisFrame = true; } } }
void OnTriggerEnter2D(Collider2D col) { if ((triggerLayers.value & 1 << col.gameObject.layer) != 0) { onCutsceneEvent?.Raise(); } }
private void OnDisable() { if (isHovering) { onMouseOverEnd.Raise(); isHovering = false; } }
private void OnDisable() { if (isHovering) { onMouseEndHoverItem.Raise(); isHovering = false; } }
void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); switch (touch.phase) { case TouchPhase.Began: initPosition = touch.position; isDragging = true; break; case TouchPhase.Canceled: isDragging = false; break; case TouchPhase.Ended: endPosition = touch.position; swipeDirection = (endPosition - initPosition); if (swipeDirection.magnitude > 50f) { swipeAngle = Vector2.SignedAngle(Vector2.right, swipeDirection); if (swipeAngle < 0) { swipeAngle = swipeAngle + 360; } isFacingRight = CharacterMovement.GetIsFacingRight(); mostRecentSwipeType = SwipeTypeOfAngle(swipeAngle, isFacingRight); string mostRecentInput = mostRecentSwipeType == SwipeType.swipeDown ? "Down" : mostRecentSwipeType == SwipeType.swipeBackwards ? "Backwards" : mostRecentSwipeType == SwipeType.swipeForwardUp ? "Forward" : "Unknown input"; if (inputText != null) { inputText.text = (intoTextString + mostRecentInput + " " + swipeAngle); } //Might have to make this a switch-case: if (GameManager.GetGameState() == GameStateScriptableObject.GameState.mainGameplayLoop) { onSwipeEvent.Raise(); } if (GameManager.GetGameState() == GameStateScriptableObject.GameState.cinematic) { onSwipeInCinematicEvent.Raise(); } } else if (timeDragged < 0.125f) { onClickEvent.Raise(); } isDragging = false; break; } timeDragged = isDragging ? timeDragged += Time.deltaTime : 0; } }
private void OnTriggerExit(Collider other) { //If the player moves away from the shop item if (other.CompareTag("Player")) { //Hide item information onDistanceEvent.Raise(); } }
private void OnDisable() { //End hovering if we are when disabled. if (isHovering) { onMouseEndHoverItem.Raise(); isHovering = false; } }
//[SerializeField] public FloatEvent dupeChecking; //initall ///Inventory functions /// inventory intializer public void initDick() { if (inventoryInitialized == false) { inventory = new DictionaryOfChewAndInt(); inventoryInitialized = true; } currencyDisplaying.Raise(); }
//When the Handler is disabled private void OnDisable() { if (isHovering) { //Call Event onMouseEndHoverItem.Raise(); //Hovering is now false isHovering = false; } }
private void Update() { m_HandLastPosition = m_HandPosition.position; var mask = !m_IsObjectPickup ? DetectionMask.HandHoldObject : DetectionMask.DropZone; m_ClosestObject = GetClosestObject(mask); if (m_LastClosestObj != m_ClosestObject) { if (m_ClosestObject != null) { m_OnClosestObjectGet.Raise(HandHoldObject.GetObject(m_ClosestObject.GetInstanceID())); } else { m_OnClosestObjectLost.Raise(); } } m_LastClosestObj = m_ClosestObject; if (Input.GetButtonDown("Interact")) { if (!m_IsObjectPickup) { if (!m_ClosestObject) { return; } var interact = m_ClosestObject.GetComponent <HandHoldObject>(); if (!interact) { return; } m_IsObjectPickup = true; m_OnDeselect = interact.OnDrop; interact.OnPickup(m_HandPosition); m_AudioSource.PlayOneShot(m_PickupSound); m_OnClosestObjectLost.Raise(); } else { m_OnDeselect(); m_IsObjectPickup = false; m_OnDeselect = null; m_LastClosestObj = null; } } }
/// <summary> /// Moves to selected scene /// </summary> /// public void _Move(string scene) { if (sceneNames.ContainsKey(scene)) { try{ GameManager.current.MoveScene(sceneNames[scene], false); onSceneMove?.Raise(); } catch { //prevents error in case the developer plays directly at the scene //instead of playing it at the persistent scene SceneManager.LoadScene(scene); } } }
public void Interact(GameObject other) { if (statBuff == null) { Debug.Log("Trying to upgrade but nothing's there"); return; } //Get reference to the player Player player = other.GetComponent <Player>(); if (player == null) { return; } //Add the upgrade to the player player.UpgradeStat(statBuff); //Play the pickup sound playSFXEvent.Raise(pickupSound); //Call the upgrade taken event onUpgradeTakenEvent.Raise(); //Destroy this object Destroy(this.gameObject); }
public void Move(Move move) { if (logMoves) { DebugGUI.LogPersistent("RobotMove", $"Robot moved: {move}"); } switch (move) { case global::Move.Up: Up(); break; case global::Move.Down: Down(); break; case global::Move.Left: Left(); break; case global::Move.Right: Right(); break; } onMoved.Raise(); }
private void TakeLifeToTarget() { switch (_creatureManager.CurrentState) { case CreatureState.OnCharacter: if (_currentTimer >= _playerAttack.TimeBetweenAttack && _canAttackPlayer) { onPlayer?.Raise(); _playerAttack.InflictDamage(this.gameObject, GameObject.FindGameObjectWithTag("Player")); ResetTimer(); } break; case CreatureState.OnEnemy: if (_currentTimer >= _enemyAttack.TimeBetweenAttack) { _alreadyOnPlayer = false; Attack attack = _enemyAttack.InflictDamage(this.gameObject, _creatureSearching.Enemy.gameObject); AddCurrentHealth(attack.Damage); ResetTimer(); } break; default: break; } }
private void OnTriggerExit2D(Collider2D other) { if (other.CompareTag("teleport")) { hideTeleportButton.Raise(); } }
private void HandleAttackInput() { if (Input.GetButtonDown("Attack")) { onPlayerAttackEvent.Raise(); } }
/// <summary> /// Puts down a specific disc /// </summary> /// /// <param name="p_pole">The pole where the disc will be placed</param> public void PutdownDisc(HanoiPole p_pole) { // Check if you are holding a disc if (_currentlyHeldDisc) { // The topmost disc of the p_pole HanoiDisc currentPoleTopDisc = p_pole.PeekTopDisc; // Checks if there is a stack on the current pole if (currentPoleTopDisc) { if (_currentlyHeldDisc.Rank <= currentPoleTopDisc.Rank) // Places the disc on the stack if it is smaller than the current top of the stack { PutDiscOnTopOfStack(currentPoleTopDisc, p_pole); } else { // if not, reset the position ResetDiscPosition(); // Raise the Error putdown disc Event _onDiscPutdownError.Raise(); } } else // If there is no stack, you can safely place the disc on the pole { PutDiscOnTopOfStack(currentPoleTopDisc, p_pole); } } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.layer == LayerMask.NameToLayer("Player") && triggeredThisPlaythrough == false) { SendMessageUpwards("SetCurrentCheckpoint", spawnPoint, SendMessageOptions.RequireReceiver); triggeredThisPlaythrough = true; AkSoundEngine.PostEvent("Checkpoint_Crystal", gameObject); //Liveplayerstats listens for this and uses it for setting the right direction in OnReset if (respawnRunDirection == RespawnRunDirection.RunLeft) { respawnFacingLeftEvent.Raise(); } else { respawnFacingRightEvent.Raise(); } foreach (Animator anim in crystalAnimators) { anim.Play("checkPointEntry"); } //Maybe need to optimize this: //other.GetComponentInChildren<LivePlayerStats>().playerStats.resetHealth(); //other.GetComponentInChildren<ZoeScarfColor>().OnResetLevel(); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { onButtonPress.Raise(); } }
private void OnTriggerStay(Collider col) { if (!_interacted && _interactedInformer != null) { _interacted = true; _interactedInformer.Raise(); } if (col.CompareTag("PlayerHand") && _trigger.GetState(SteamVR_Input_Sources.Any)) { Vector3 targetPosition = new Vector3(0, 0, 0); switch (_type) { case joyStickType.horizontal: targetPosition = new Vector3(col.transform.position.x, col.transform.position.y, transform.position.z); break; case joyStickType.vertical: targetPosition = new Vector3(transform.position.x, col.transform.position.y, col.transform.position.z); break; case joyStickType.dualAxis: targetPosition = col.transform.position; break; } transform.LookAt(targetPosition, transform.up); } else if (col.CompareTag("PlayerHand") && !_trigger.GetState(SteamVR_Input_Sources.Any)) { transform.LookAt(_joystickDefaultPosition, transform.up); } }
private void Update() { if (Input.GetKeyDown(KeyCode.Space)) { eventToRaise.Raise(); } }
public IEnumerator WaitLoadingScene(float delay, bool activate = true) { //pattern: load -> activate yield return(new WaitForSeconds(delay)); //waits until the scene is loaded in memory //if it reaches 90%, allow the activation of the scene while (loadedScene.progress != .9f) { yield return(null); } if (!loadedScene.allowSceneActivation) { onSceneLoaded?.Raise(); if (activate) { ActivateNewScene(); } yield return(new WaitForEndOfFrame()); } }
public void Serve() { if (isGamePlaying) { startServeEvent?.Raise(); } }
/// <summary> /// Evaluate Discs whether or not this pole has all the discs on it /// </summary> private void EvaluateDiscs() { if (_pole.DiscCount == _discQuantity.Value) { _onDiscComplete.Raise(); } }
public void StartGame() { Time.timeScale = 1; startGame.Raise(); spawnPlayer.Raise(); _isPlaying = true; }
private void HandleInteractCycleInput() { if (Input.GetButtonDown("Interact Cycle")) { onPlayerInteractCycleEvent.Raise(); } }
public static bool PlayerSpawned = false; //Player has spawned private void Start() { //If the player has been spawned if (PlayerSpawned) { Debug.Log("Setting up player in new scene"); //Call the event to set the character's position setPlayerPosEvent.Raise(transform); //Call the event to start up the player startPlayerEvent.Raise(); } else { if (SelectedCharacter == null) { //Set the default character to be the selected character SelectedCharacter = defaultCharacter; } //Spawn the player prefab GameObject playerObject = Instantiate(SelectedCharacter.characterObject, transform.position, transform.rotation); //Set the player object not to be destroyed on load DontDestroyOnLoad(playerObject); PlayerSpawned = true; } }
// Start is called before the first frame update public override void OnStep() { base.OnStep(); Debug.Log("Ranged Enemey On Step"); if (IsShootStep()) { ShootEvent?.Raise(); if (GameManager.instance.PreviousAction != CounterAction) { Debug.Log("DIEE LMAO"); StartCoroutine(RayAnimation(true)); // DIE BOY } else { Debug.Log("SHOOT BOOM"); StartCoroutine(RayAnimation(false)); } } if (IsPrepareStep()) { StartPrepareEvent?.Raise(); } }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.layer == 9) { onWallCollide?.Raise(); } }