示例#1
0
    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;
        }
    }
示例#2
0
        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!");
                    }
                }
            }
        }
示例#3
0
        /// <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;
        }
示例#4
0
 /// <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;
     }
 }
示例#5
0
 /// <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;
     }
 }
示例#6
0
 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>());
            }
        }
示例#8
0
    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;
        }
    }
示例#9
0
    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);
    }
示例#10
0
 private void RegisterPossessable(IPossessable newPossessable)
 {
     possessables.Add(newPossessable);
 }
示例#11
0
 /// <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;
 }
示例#12
0
 public void AddPossession(IPossessable possession)
 {
     possessions.Add(possession);
 }
示例#13
0
 /// <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));
 }
示例#14
0
 /// <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);
 }
示例#15
0
 /// <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);
 }