void OnTriggerEnter(Collider other) { if (haveEntered) { return; } if (!other.GetComponent(typeof(IPossessable))) { return; } IPossessable iPossessable = other.GetComponent(typeof(IPossessable)) as IPossessable; if (iPossessable.GetIsPossessed()) { ERobotType typeOfPlayer = iPossessable.GetRobotType(); bool isSameType = false; foreach (ERobotType i in listOfAllowedRobotType) { if (typeOfPlayer == i) { isSameType = true; break; } } em.BroadcastRoomEntered(levelOfSecurity, isSameType); haveEntered = true; } }
private void OnCollisionStay2D(Collision2D collision) { if (canPossess) { // making a variable so it is easier to read (I use it like 3/4 times here so made sense). IPossessable _poss = collision.gameObject.GetComponent <IPossessable>(); if (_poss != null) { if (!_poss.IsPossessed) { Debug.Log("Possess Me!"); _poss.IsPossessed = true; // set the player to control the hit IPossessable object. player.SetAm(_poss); // disables the orb gameObject.SetActive(false); } else { Debug.Log("Im Possessed!"); } } } }
/// <summary> /// (Co) - gives a slight cooldown between exiting a person/object/thing. /// </summary> /// <returns></returns> private IEnumerator ExitHostCooldown(IPossessable was) { canPossess = false; yield return(wait); // stops the old object from being defined as possessed. was.IsPossessed = false; canPossess = true; }
/// <summary> /// Adds an IPossessible construct, such as a person place or thing, to the collection of IEntity instances the RelativePronoun "Owns", /// and sets its owner to be the RelativePronoun. /// If the item is already possessed by the current instance, this method has no effect. /// </summary> /// <param name="possession">The possession to add.</param> public void AddPossession(IPossessable possession) { if (IsBound) { RefersTo.AddPossession(possession); } else { possessions = possessions.Add(possession); possession.Possessor = this; } }
/// <summary> /// Adds an IPossessible construct, such as a person place or thing, to the collection of Pronoun "Owns", /// and sets its owner to be the Pronoun. /// If the item is already possessed by the current instance, this method has no effect. /// </summary> /// <param name="possession">The possession to add.</param> public virtual void AddPossession(IPossessable possession) { if (RefersTo != null) { RefersTo.AddPossession(possession); } else { possessions.Add(possession); possession.Possessor = this; } }
public void Possess(IPossessable obj) { if (obj != null) { // unpossess the current object if (controlledObject != null) { controlledObject.UnPossess(); } // possess the new object controlledObject = obj; controlledObject.Possess(); } }
/// <summary> /// Sets the player to possess the IPossessable object passed through. /// </summary> /// <param name="pos">To Possess</param> public void SetAm(IPossessable pos) { am = pos.GetGameObject; if (am.GetComponent <IMoveable>() != null) { moveAM = am.GetComponent <IMoveable>(); } rb = am.GetComponent <Rigidbody2D>(); inBody = true; vCam.SetTargetAndFollow(am.transform); // thoughts if (am.GetComponentInChildren <Dialogue.DialogueThought>()) { ShowThought(am.GetComponentInChildren <Dialogue.DialogueThought>()); } }
private void PossessPossessable(IPossessable newPossession) { switch (newPossession.GetPossessableType()) { case EPossessableType.PRIMARY: if (primaryPossession != null) { primaryPossession.UnPossess(); } newPossession.Possess(); primaryPossession = newPossession; primaryPossessionTransform = primaryPossession.GetGameObject().transform; break; case EPossessableType.SECONDARY: newPossession.Possess(); secondaryPossessions.Add(newPossession); break; default: break; } }
private bool PossessClosestPossessable() { if (possInfo.possessables.Count > 0) { IPossessable closestPossessable = possInfo.possessables[0]; float distanceToClosest = -1; bool first = true; int count = possInfo.possessables.Count; for (int i = 0; i < count; i++) { if (possInfo.possessables[i] != primaryPossession) { float distanceToThis = (transform.position - possInfo.possessables[i].GetGameObject().transform.position).magnitude; if (first || distanceToThis < distanceToClosest) { first = false; closestPossessable = possInfo.possessables[i]; distanceToClosest = distanceToThis; } } } //Debug.Log("ClosestPossessable found, distanceToClosest: " + distanceToClosest); if (distanceToClosest > possessionRange) { return(false); } PossessPossessable(closestPossessable); return(true); } Debug.LogWarning("No possessables found"); return(false); }
private void RegisterPossessable(IPossessable newPossessable) { possessables.Add(newPossessable); }
/// <summary> /// Adds an IPossessible construct, such as a person place or thing, to the collection of the NounPhrase "Owns", /// and sets its owner to be the NounPhrase. /// If the item is already possessed by the current instance, this method has no effect. /// </summary> /// <param name="possession">The possession to add.</param> public void AddPossession(IPossessable possession) { possessions = possessions.Add(possession); possession.Possessor = this; }
public void AddPossession(IPossessable possession) { possessions.Add(possession); }
/// <summary> /// Fire!!!! - just runs the co, that stops the player ending up in the same obj as they were in. /// </summary> public void Yeet(IPossessable was) { StartCoroutine(ExitHostCooldown(was)); }
/// <summary> /// Adds an IPossessable construct, such as a person place or thing, to the collection of Entity instances the PossessivePronoun "Owns", /// and sets its owner to be the PossessivePronoun. /// If the item is already possessed by the current instance, this method has no effect. /// </summary> /// <param name="possession">The possession to add.</param> public void AddPossession(IPossessable possession) { PossessesFor?.AddPossession(possession); possessions = possessions.Add(possession); }
/// <summary> /// Adds a possession to the collection of items this instance possesses. /// </summary> /// <param name="possession">The possession to add.</param> public void AddPossession(IPossessable possession) { PossessesFor = PossessesFor ?? PreviousWord as IEntity; PossessesFor?.AddPossession(possession); possessions = possessions.Add(possession); }