public void HandleSnapAway(HoldableObject obj) { if (currHeldObject != null && currHeldObject.Equals(obj)) { currHeldObject = null; } }
public void PlatformObjectsUnselectable() { if (platformGuard.isActiveAndEnabled) { foreach (GameObject obj in platformGuard.stuckObjects) { HoldableObject item = obj.GetComponent <HoldableObject>(); if (!obj.CompareTag("Player")) { obj.tag = ("NoTouch"); //makes sure all morphs get unselected when the platform is in motion! if (item.GetComponent <Morph>() && item.selected) { raycastManager.RemoveFromList(obj, false, false); raycastManager.selectedObjs.Remove(obj); item.selected = false; } } if (pickUp.heldObject && pickUp.heldObject.Equals(obj)) { Debug.Log("Yo"); pickUp.PutDown(); } } } }
private void GrabNearestProp() { if (holding) { ReleaseHeldProp(); } Collider2D[] props = Physics2D.OverlapCircleAll(transform.position, maxReach, 1 << LayerMask.NameToLayer("Prop")); if (props.Length == 0) { return; } else { Debug.Log(props.Length); } HoldableObject nearest = props[0].GetComponent <HoldableObject>(); foreach (Collider2D prop in props) { if (Vector2.Distance(prop.transform.position, transform.position) < Vector2.Distance(nearest.transform.position, transform.position)) { nearest = prop.GetComponent <HoldableObject>(); } } if (nearest == null) { return; } StartCoroutine(MovePropToHand(0.5f, nearest)); }
public override bool Interact(HoldableObject carryingObject, PlayerInteraction playerInteraction) { if (locked) { if (base.Interact(carryingObject, playerInteraction)) { Open(); return(true); } else { soundDoorLocked.Play(); return(false); } } else { if (opened) { Close(); } else { Open(); } return(true); } }
public LongTask(GameObject gameObjectToActivate, HoldableObject objectInProgress, float timer) { this.gameObjectToActivate = gameObjectToActivate; this.objectInProgress = objectInProgress; this.timer = timer; this.totalTime = timer; }
// Use this for initialization protected override void Setup() { triggerDown += () => { if (behindPlayer()) { currHeldObject = Instantiate(Singletons.GunHand().getCurrGun().MagazinePrefab).GetComponent <HoldableObject>(); currHeldObject.transform.SetParent(transform); currHeldObject.transform.localPosition = new Vector3(); currHeldObject.transform.localEulerAngles = Vector3.zero; currHeldObject.PickupObject(); } else if (currHeldObject == null && hoveredObjects.Count > 0) { hoveredObjects[0].PickupObject(); currHeldObject = hoveredObjects[0]; hoveredObjects.RemoveAt(0); } }; triggerUp += () => { if (currHeldObject != null) { currHeldObject.DropObject(); if (currHeldObject.GetComponent <Rigidbody>()) { currHeldObject.GetComponent <Rigidbody>().AddForce(currForceVector); } currHeldObject = null; } }; }
void PickTask() { currentWish = availableWishes[(int)Random.Range(0, availableWishes.Length)]; if (previousWish != HoldableObject.NONE && previousWish == currentWish) { PickTask(); } bubbleGameObject.SetActive(true); wishGameObject.SetActive(true); switch (currentWish) { case HoldableObject.COOKED_CHICKEN: Debug.Log("Current wish: hungry"); wishGameObject.GetComponent <SpriteRenderer>().sprite = wishHungry; break; case HoldableObject.TEA_POT: Debug.Log("Current wish: tea"); wishGameObject.GetComponent <SpriteRenderer>().sprite = wishTea; break; case HoldableObject.WATER_BUCKET: Debug.Log("Current wish: water"); wishGameObject.GetComponent <SpriteRenderer>().sprite = wishWater; break; case HoldableObject.LETTER: Debug.Log("Current wish: letter"); wishGameObject.GetComponent <SpriteRenderer>().sprite = wishLetter; break; } }
public SelectedBuildingWindow(HoldableObject b) { InitializeComponent(); Building = b; this.Title = Building.ToString(); }
//private void updateTitle() //{ // this.Title = "Altura: " + this.ActualHeight.ToString() + "; Largura: " + this.ActualWidth.ToString(); // if (XNAgameThread.mapTeste != null) // { // this.Title += "Offiset.X: " + XNAgameThread.mapTeste.Offset.X.ToString() // + "Offiset.Y: " + XNAgameThread.mapTeste.Offset.Y.ToString(); // } //} public void OnSelectBuilding(HoldableObject b) { if (b != null) { SelectedBuildingWindow teste = new SelectedBuildingWindow(b); teste.ShowDialog(); } }
public override bool Interact(HoldableObject carryingObject, PlayerInteraction playerInteraction) { if (!pressing) { StartCoroutine(PressKey()); } return(true); }
public void DropObject() { _holdableObject.StopHold(); _holdableObject = null; AudioManager.Instance.PlaySound(gameObject, _dropSound); HoldEnd?.Invoke(); }
//public float[] rotation; //will do this later public InteractableObjectData(HoldableObject obj) { layer = obj.gameObject.layer; name = obj.gameObject.name; position[0] = obj.gameObject.transform.position.x; position[1] = obj.gameObject.transform.position.y; position[2] = obj.gameObject.transform.position.z; }
public override bool Interact(HoldableObject carryingObject, PlayerInteraction playerInteraction) { if (!fadeInComplete) { FadeIn(1.0f); } return(base.Interact(carryingObject, playerInteraction)); }
void InitNoble() { currentWish = HoldableObject.NONE; currentWishTimeCompletion = 0; delayBeforeNewTask = Random.Range(minDelayBeforeNewTask, maxDelayBeforeNewTask); wishGameObject.SetActive(false); bubbleGameObject.SetActive(false); crossGameObject.SetActive(false); bubbleGameObject.GetComponent <SpriteRenderer>().color = new Color(255, 255, 255); }
public void FulfillWish() { if (!WishExpired(currentWishTimeCompletion)) { previousWish = currentWish; InitNoble(); GameController.INSTANCE.CompleteActiveTask(this); // GameOverManager.INSTANCE.GameOverVictory(); } }
private void OnScreamedAt(IReadOnlyList <ScreamSoundDefinition> screamSounds) { _playerAnimation.PlayEmote(PlayerAnimatorController.EmoteState.Scared); _scaredTimer = ScareDuration; GameStateManager.Instance.PlayerSanity.TakeSanityDamage(ScareSanityDamage); if (_objectHolder.HeldObject != null) { HoldableObject heldObject = _objectHolder.HeldObject; _objectHolder.DropObject(); } }
void OnTriggerStay(Collider col) { HoldableObject myHoldableObject = this.GetComponentInParent <HoldableObject>(); HoldableObject otherHoldableObject = col.GetComponent <HoldableObject>(); string collisionTag = col.tag; if (otherHoldableObject && otherHoldableObject.objectType == HoldableObject.ObjectType.Sokoban1x1) { col.GetComponent <Rigidbody>().isKinematic = false; col.transform.SetParent(this.transform.parent); } }
public override bool Interact(HoldableObject carryingObject, PlayerInteraction playerInteraction) { if (carryingObject is Key && ((Key)carryingObject).keyCode == keyCode) { playerInteraction.Drop(true); locked = false; return(true); } else { return(false); } }
public void HoldObject(HoldableObject holdableObject) { _holdableObject = holdableObject; _holdableObject.StartHold(); _holdableObject.transform.parent = _objectHoldRoot; _holdableObject.transform.localPosition = Vector3.zero; _holdableObject.transform.localRotation = Quaternion.identity; AudioManager.Instance.PlaySound(gameObject, _pickupSound); HoldStart?.Invoke(); }
private void ReleaseHeldProp() { if (!holding) { return; } holding.transform.parent = null; Rigidbody2D propBody = holding.GetComponent <Rigidbody2D>(); propBody.bodyType = RigidbodyType2D.Dynamic; holding = null; }
public void Drop(bool destroy = false) { carryingObject.gameObject.layer = originalCarryLayer; // Todo determine if we can just check top level for these components //carryingObject.GetComponent<Rigidbody>().isKinematic = false; //carryingObject.GetComponentInChildren<Collider>().enabled = true; if (destroy) { Destroy(carryingObject.gameObject); } carryingObject = null; }
public override bool Interact(HoldableObject carryingObject, PlayerInteraction playerInteraction) { lightSound.Play(); if (switchIsOn = !switchIsOn) { SwitchedOn?.Invoke(); } else { SwitchedOff?.Invoke(); } return(true); }
public void Respawn() { // Drop any held object if (_objectHolder.HeldObject != null) { HoldableObject heldObject = _objectHolder.HeldObject; _objectHolder.DropObject(); } // Reset scare stun _scaredTimer = 0.0f; // Teleport back to the spawn location this.transform.position = _spawnLocation; this.transform.rotation = _spawnOrientation; }
private IEnumerator MovePropToHand(float animationTime, HoldableObject prop) { holding = prop; Rigidbody2D propBody = prop.GetComponent <Rigidbody2D>(); propBody.bodyType = RigidbodyType2D.Kinematic; propBody.velocity = Vector2.zero; for (float t = 0; t < animationTime; t += Time.deltaTime) { prop.transform.position = Vector3.Lerp(prop.transform.position, hand.position, t); yield return(new WaitForEndOfFrame()); } prop.transform.parent = hand; }
public override bool Interact(HoldableObject carryingObject, PlayerInteraction playerInteraction) { if (hasBulb) { return(false); } if (carryingObject is LightBulb) { playerInteraction.Drop(true); hasBulb = true; LightToggle(); return(true); } return(false); }
private void InteractWithObject(Interactable interactable) { // Pick up holdable objects if (interactable.InteractionType == "pickup") { HoldableObject holdable = interactable.GetComponentInParent <HoldableObject>(); if (holdable != null) { if (GameStateManager.Instance.BottlesPickedUpCount == 0) { GameUI.Instance.DialogUI.ShowDialog("Hmm... I wonder if I could use this on a monster?", 5, this.transform, Vector3.up * 3); } GameStateManager.Instance.BottlesPickedUpCount++; _objectHolder.HoldObject(holdable); return; } } else if (interactable.InteractionType == "mix") { // Mix bottles if (_objectHolder.IsHoldingObject) { ScreamContainer heldBottle = _objectHolder.HeldObject.GetComponent <ScreamContainer>(); ScreamContainer groundBottle = interactable.GetComponentInParent <ScreamContainer>(); if (heldBottle != null && groundBottle != null) { StartMixingBottles(heldBottle, groundBottle); } } } else if (interactable.InteractionType == "deposit") { // Deposit bottles into bank if (_objectHolder.IsHoldingObject) { ScreamContainer heldBottle = _objectHolder.HeldObject.GetComponent <ScreamContainer>(); GameStateManager.Instance.ScreamBank.DepositScream(heldBottle.ScreamSounds); ReleaseBottleScream(); } } }
public string GetTextFromWish(HoldableObject wish) { switch (wish) { case HoldableObject.COOKED_CHICKEN: return("I'm hungry!"); case HoldableObject.WATER_BUCKET: return("I'm thirsty for water!"); case HoldableObject.TEA_POT: return("I'm thirsty for tea!"); case HoldableObject.LETTER: return("I need to send a letter!"); default: return(null); } }
private int GetExpectedWishCompletionTime(HoldableObject o) { switch (currentWish) { case HoldableObject.COOKED_CHICKEN: return(cookedChickenCompletionTime); case HoldableObject.WATER_BUCKET: return(waterCompletionTime); case HoldableObject.TEA_POT: return(teaCompletionTime); case HoldableObject.LETTER: return(letterCompletionTime); default: return(0); } }
//used by this script internally public virtual void ObjSetup(InteractableObjectData objectData) { if (objectData != null) { Vector3 position = new Vector3(objectData.position[0], objectData.position[1], objectData.position[2]); gameObject.transform.position = position; gameObject.layer = objectData.layer; gameObject.name = objectData.name; Holdable = GetComponent <HoldableObject>(); //Debug.Log(gameObject.name); if (objectData.layer == 11) { Holdable.LoadShader(true); } if (objectData.layer == 10) { Holdable.LoadShader(false); } } }
private void OnTriggerEnter(Collider other) { if (isInUse) { return; } InteractionEvent interactionEvent = other.GetComponent <InteractionEvent>(); if (interactionEvent != null) { if (interactionEvent.GetAction() != InteractionEvent.Action.Interact) { return; } HoldableObject heldObject = interactionEvent.GetPC().GetHeldObject(); // Equip cannon if it is loaded and player is not holding something if (heldObject == null) { BecomeEquippedByPlayer(interactionEvent.GetPC()); } // Begin loading the cannon if (heldObject != null && !loaded) { if (heldObject.name == "Cannonball Item(Clone)" && !loaded) { cannonballBeingLoaded = heldObject; StartLoadingAnimation(); isLoading = true; BecomeEquippedByPlayer(interactionEvent.GetPC()); SetReticleEnabled(false); } } } }