public virtual void Start()
        {
            Parameters p = new Parameters();

            p.AddParameter <GameObject>("player", this.gameObject);
            EventBroadcaster.Instance.PostEvent(EventNames.SET_UI_PLAYER_REFERENCE, p);
            characterCenter = GetComponent <CapsuleCollider>();
            justJumped      = false;
            targetRotation  = transform.rotation;
            if (GetComponent <Rigidbody>())
            {
                rBody = GetComponent <Rigidbody>();
            }
            else
            {
                Debug.LogError("Character Needs Rigidbody!");
            }

            if (GetComponent <BareboneCharacter>())
            {
                character = GetComponent <BareboneCharacter>();
            }
            else
            {
                Debug.LogError("Character has no BareboneCharacter! Cant Check Current States!!");
            }
            forwardInput = turnInput = jumpInput = 0;

            // ANIMATION
        }
 public void Initialize()
 {
     if (thisObject == null)
     {
         Debug.Log("Debug Reference Invalid!");
         return;
     }
     thisObjectCharacter = thisObject.GetComponent <BareboneCharacter>();
     thisObjectBase      = thisObject.GetComponent <BareboneObject>();
     // IF PLAYER HAS CHARACTER SCRIPT
     if (thisObjectCharacter != null)
     {
         nameText.text   = thisObjectCharacter.CharacterName;
         typeText.text   = thisObjectCharacter.ObjectType.ToString();
         healthText.text = thisObjectCharacter.CurrentHealth.ToString() + " / " + thisObjectCharacter.MaximumHealth.ToString();
         if (!StatInitialize)
         {
             CreateStats();
         }
     }
     // IF PLAYER HAS NO CHARACTER SCRIPT
     else if (thisObjectBase != null)
     {
         nameText.text = thisObjectBase.GeneralName;
         typeText.text = thisObjectBase.ObjectType.ToString();
     }
     else
     {
         Debug.Log("Cannot Comprehend Object Selected, Object has no Barebone Script!!");
     }
 }
        public void OnTriggerExit(Collider collision)
        {
            if (!collision.isTrigger)
            {
                BareboneCharacter collidingPlayer = (collision.transform.GetComponent <BareboneCharacter>()) ? collision.transform.GetComponent <BareboneCharacter>() : null;

                if (collidingPlayer == null)
                {
                    return;
                }

                Parameters p = new Parameters();
                p.AddParameter <MGColliderHelper>("Checker", this);
                p.UpdateParameter <bool>("Entering", false);
                if (playersWithinRange != null)
                {
                    if (!playersWithinRange.Contains(collidingPlayer))
                    {
                        return;
                    }
                    SwitchFX(0);
                    Debug.Log("Exit");
                    EventBroadcaster.Instance.PostEvent(EventNames.NOTIFY_PLAYER_INTERACTION, p);
                    playersWithinRange.Remove(collidingPlayer);
                }
            }
        }
Example #4
0
 public void NotifyNearNPC(BareboneCharacter thisCharacter = null, bool isEntering = false)
 {
     if (thisCharacter == null)
     {
         return;
     }
     npcInteracting = (npcInteracting == thisCharacter) ? null : thisCharacter;
     interactNotif.SetActive(npcInteracting != null);
 }
Example #5
0
 public void NotifyPlayer(Parameters p = null)
 {
     if (p == null)
     {
         return;
     }
     if (p.HasParameter("Checker"))
     {
         MGColliderHelper tmp = p.GetWithKeyParameterValue <MGColliderHelper>("Checker", null);
         NotifyMinigame(tmp, p.GetWithKeyParameterValue <bool>("Entering", false));
     }
     else if (p.HasParameter("Character"))
     {
         BareboneCharacter tmp = p.GetWithKeyParameterValue <BareboneCharacter>("Character", null);
         NotifyNearNPC(tmp, p.GetWithKeyParameterValue <bool>("Entering", false));
     }
 }
Example #6
0
        public void SetPlayerReference(Parameters param = null)
        {
            if (param == null)
            {
                return;
            }
            if (!param.HasParameter("player"))
            {
                return;
            }

            player = param.GetWithKeyParameterValue <GameObject>("player", null);

            if (player != null)
            {
                playerStats = player.GetComponent <BareboneCharacter>();
            }
        }
        public void OnTriggerEnter(Collider collision)
        {
            if (!collision.isTrigger)
            {
                if (playerInteracting != null)
                {
                    return;
                }

                if (collision.transform.GetComponent <BareboneCharacter>())
                {
                    BareboneCharacter player = collision.transform.GetComponent <BareboneCharacter>();
                    playersWithinRange.Add(collision.transform.GetComponent <BareboneCharacter>());
                    SwitchFX(1);
                    Parameters p = new Parameters();
                    p.AddParameter <MGColliderHelper>("Checker", this);
                    p.UpdateParameter <bool>("Entering", true);
                    Debug.Log("Enter");
                    EventBroadcaster.Instance.PostEvent(EventNames.NOTIFY_PLAYER_INTERACTION, p);
                }
            }
        }
 public void OnEnable()
 {
     if (Owner == null)
     {
         // This allows weapons to be carried as gameobjects
         BareboneCharacter parent = transform.root.GetComponent <BareboneCharacter>();
         if (parent == null)
         {
             // if the weapon is active, it means its an damaging obstacle.
             team = 10;
         }
         else
         {
             Owner = parent;
             team  = Owner.Team;
         }
     }
     else
     {
         team = Owner.Team;
     }
     Initialize();
 }