コード例 #1
0
        void OnTriggerExit2D(Collider2D coll)
        {
            // Attempt to grab the Player_Manager script
            Player_Manager _player = coll.GetComponentInParent <Player_Manager>();

            // IF the colliding object doesnt have the Player Manager script.
            if (_player == null)
            {
                return;
            }
            // IF the colliding object's tag isn't Player.
            if (coll.tag != "Player")
            {
                return;
            }
            // We remove this script from our player state list.
            _playerManager.ListOfActionKeyDialogues.Remove(this);
            // IF the dialogueBox is still active.
            if (dialogueBox.activeInHierarchy)
            {
                // Stop all coroutines on this script.
                StopAllCoroutines();
                // Finish off all actions while exiting the collider.
                StartCoroutine(ExitCollider());
            }
        }
コード例 #2
0
        void OnTriggerExit2D(Collider2D coll)
        {
            // Attempt to grab the Player_Manager script
            Player_Manager _player = coll.GetComponentInParent <Player_Manager> ();

            // IF the colliding object doesnt have the Player Manager script.
            if (_player == null)
            {
                return;
            }
            // IF the colliding object's tag isn't Player.
            if (coll.tag != "Player")
            {
                return;
            }
            // Since the dialogue is being destroyed we assign the state.
            _playerManager.ListOfAreaDialogues.Remove(this);
            // IF the dialogueBox is active in the hierarchy.
            if (dialogueBox.activeInHierarchy)
            {
                // Stop all coroutines happening on this script
                StopAllCoroutines();
                // Finish up the last transition, destroy and start the timer.
                StartCoroutine(EndDialogue());
            }
        }
コード例 #3
0
ファイル: Equipment.cs プロジェクト: killycal/Riley-Project
 void Awake()
 {
     database      = Grid_Helper.itemDataBase;
     playerManager = GetComponentInParent <Player_Manager> ();
     // Load the player stats, if there is any.
     Load();
 }
コード例 #4
0
 void Awake()
 {
     // Get the Player State in the parent.
     _playerManager = GetComponentInParent <Player_Manager>();
     // Get the Players Stats as we use that to potentially alter movement.
     charStats = _playerManager.GetComponentInChildren <Character_Stats> ();
     // Get the Rigidbody2D Component.
     rb = GetComponent <Rigidbody2D>();
 }
コード例 #5
0
 void Awake()
 {
     // Get the Player State.
     _playerManager = GetComponentInParent <Player_Manager>();
     // Get the Players Stats as we use that to potentially alter movement.
     charStats = _playerManager.GetComponentInChildren <Character_Stats> ();
     // Get the Rigidbody2D Component.
     rb = GetComponent <Rigidbody2D>();
     // Set the horizontalFirst to false as nothing is being pressed.
     firstKeyPressed = false;
     horizontalFirst = false;
     verticalFirst   = false;
 }
コード例 #6
0
        void OnTriggerStay2D(Collider2D coll)
        {
            // Attempt to grab the Player_Manager script
            Player_Manager _player = coll.GetComponentInParent <Player_Manager>();

            // IF the colliding object doesnt have the Player Manager script.
            if (_player == null)
            {
                return;
            }
            // IF the colliding object's tag isn't Player.
            if (coll.tag != "Player")
            {
                return;
            }
            // While we are in this trigger lets keep trying to create a dialogue until it lets us.
            CreateDialogue();
        }
コード例 #7
0
 void Update()
 {
     // IF there isn't a player manager active on the scene.
     if (pm == null)
     {
         // Get the Player Manager GameObject.
         pm = Character_Manager.GetPlayerManager().GetComponent <Player_Manager>();
         return;
     }
     // IF there isn't a Character_Stats (or any script you want that holds your characters data) for your characters data.
     if (charStats == null)
     {
         // Get your Character_Stats.
         charStats = pm.GetComponentInChildren <Character_Stats> ();
         return;
     }
     // Display your hearts.
     DisplayHearts();
 }
コード例 #8
0
        private void HandleTypes(Player_Manager playerManager)
        {
            // IF we pick up a Key,
            // ELSE IF we pick up a Bomb,
            // ELSE IF we pick up a type of Currency,
            // ELSE IF we pick up a stat increase Item,
            // ELSE IF *tbc*
            if (type == "Key")
            {
                // Get the Key script.
                Key key = playerManager.GetComponentInChildren <Key> ();
                // Add to the keys.
                key.AddSubtractKeys(title, amount);
            }
            else if (type == "Bomb")
            {
                // Get the Drop_Bombs script.
                Bombs playerDB = playerManager.GetComponentInChildren <Bombs> ();
                // Add to the keys.
                playerDB.AddSubtractBomb(amount);
            }
            else if (type == "Currency")
            {
                // Get the Money script.
                Money money = playerManager.GetComponentInChildren <Money> ();
                // IF we have a Crystal Currency.
                if (title == "Green Crystal" || title == "Blue Crystal")
                {
                    // Add to the currency.
                    money.AddSubtractMoney("Crystal", amount);
                }
            }
            else if (type == "Stat Increase")
            {
                // Get the Character Stats (or any data structure if you choose to make your own or use another Asset),
                Character_Stats charStats = playerManager.GetComponentInChildren <Character_Stats> ();
                // Then Add to the stats.
                charStats.IncreaseMaxHealth(bonusHealth);
//				charStats.IncreaseMaxMana (bonusMana);
//				charStats.IncreaseBaseDamage (bonusDamage);
//				charStats.IncreaseBaseMoveSpeed (bonusMoveSpeed);
            }
        }
コード例 #9
0
        void OnTriggerEnter2D(Collider2D coll)
        {
            // Attempt to grab the Player_Manager script in this gameobjects parent.
            Player_Manager _player = coll.GetComponentInParent <Player_Manager>();

            // IF the colliding object doesnt have the Player Manager script.
            if (_player == null)
            {
                return;
            }
            // IF the colliding object's tag isn't Player.
            if (coll.tag != "Player")
            {
                return;
            }
            // Assign the Player Manager script.
            _playerManager = _player;
            // We add this Script to our player state list.
            _playerManager.ListOfActionKeyDialogues.Add(this);
        }
コード例 #10
0
        /// <summary>
        /// Add item to the players collection when picked/collided up/with.
        /// </summary>
        /// <param name="coll">Coll.</param>
        private void AddItemByCollision(GameObject coll)
        {
            // IF the colliding gameobject doesnt have a Player_Manager Component.
            if (coll.GetComponentInParent <Player_Manager> () == null)
            {
                return;
            }
            // Set a Player Manager variable for faster referencing.
            Player_Manager playerManager = coll.GetComponentInParent <Player_Manager> ();

            // IF the timer is up so that we can pick up the item.
            if (!canPickUp)
            {
                return;
            }

            // Play the Pickup Sound.
            Grid.soundManager.PlaySound(pickupSound);

            // IF this is an item that goes into your inventory.
            // ELSE there is pre set slots for certain items.  Think of keys and bombs in Binding of Isaac.
            if (inventoryItem)
            {
                // IF there is a Inventory System.
                if (Grid.inventory != null)
                {
                    // Handle Inventory Stuff.  If we ended up NOT collecting the item we just leave. True if we collected the item, False if we didn't.
                    if (!HandleInventory())
                    {
                        return;
                    }
                }
            }
            else
            {
                // Handle the Types Stuff.
                HandleTypes(playerManager);
            }
            // Check if there is a State handler script.
            CheckState();
        }
コード例 #11
0
        void OnTriggerEnter2D(Collider2D coll)
        {
            // Attempt to grab the Player_Manager script
            Player_Manager _player = coll.GetComponentInParent <Player_Manager>();

            // IF the colliding object doesnt have the Player Manager script.
            if (_player == null)
            {
                return;
            }
            // IF the colliding object's tag isn't Player.
            if (coll.tag != "Player")
            {
                return;
            }
            // Assign the Player Manager script.
            _playerManager = _player;
            // Since we have a Player Manager script we assign the state.
            _playerManager.ListOfAreaDialogues.Add(this);
            // We begin the dialogue.
            CreateDialogue();
        }
コード例 #12
0
        protected virtual void OnTriggerExit2D(Collider2D coll)
        {
            // Attempt to grab the Player_Manager script
            Player_Manager _player = coll.GetComponentInParent <Player_Manager>();

            // IF the colliding object doesnt have the Player Manager script.
            if (_player == null)
            {
                return;
            }
            // IF the colliding object's tag isn't Player.
            if (coll.tag != "Player")
            {
                return;
            }
            // IF the players closest Interaction Area is this gameobject.
            if (_playerManager.ClosestInteractionArea == this)
            {
                // Set the closest Interaction Area to null.
                _playerManager.ClosestInteractionArea = null;
                // Set the bool to show if this is an Interaction Area to false.
                _playerManager.IsActionKeyDialogued = false;
            }
            // Unfreeze the player (in case we froze them).
            _playerManager.CanMove = true;
            // IF a Character script exists.
            if (chara != null)
            {
                // Make this GameObject not be able to move.
                chara.CanMove = true;
                // Let everything know that this GameObject has or has not a running dialogue.
                chara.isActionKeyDialogueRunning = false;
                // Let everything know who the focus of this Dialogue is.
                chara.actionKeyFocusTarget = null;
            }
            // We remove this script from our player state list.
            _playerManager.ListOfInteractionAreas.Remove(this);
        }
コード例 #13
0
 void Awake()
 {
     playerManager = GetComponentInParent <Player_Manager> ();
     Load();
 }
コード例 #14
0
ファイル: Item_Data.cs プロジェクト: samikim/TielGame
        public void OnPointerUp(PointerEventData data)
        {
            // IF we Right Click so we can USE or EQUIP an item.
            if (item != null && data.button == PointerEventData.InputButton.Right && !data.dragging)
            {
                // Get the Player_Manager component.
                Player_Manager player = Character_Manager.GetPlayerManager().GetComponent <Player_Manager> ();
                // IF this item is a consumable,
                if (item.Type == "Consumable")
                {
                    // Add "usage" attributes associated with this item.  At this current time if you are looking at the demo we only add HP.
                    player.AddHealth((float)item.RestoreHP);
                    // Play the Pickup Sound.
                    Grid.soundManager.PlaySound(item.UsedSound);
                    if (amount - 1 == 0)
                    {
                        // Clear the old slot.
                        GetComponentInParent <Inventory>().items [slotNumber] = new Item();
                        // Destroy this gameobject as it holds no item.
                        Destroy(gameObject);
                        // Do not show the tooltip.
                        Grid.tooltip.Deactivate();
                        return;
                    }
                    --amount;
                    GetComponentInParent <Inventory>().slots [slotNumber].GetComponentInChildren <Text> ().text = amount.ToString();
                    return;
                }
                // IF this item is a piece of equipment, such as a Weapon, Armour, Ring or a Bracelet.
                if (item.Type == "Weapon" || item.Type == "Armour" || item.Type == "Ring" || item.Type == "Bracelet")
                {
                    // Get the Equipment component.
                    Equipment equipment = player.GetComponentInChildren <Equipment> ();
                    // Play the Pickup Sound.
                    Grid.soundManager.PlaySound(item.UsedSound);
                    Item swappedItem = null;
                    if (item.Type == "Weapon")
                    {
                        // Set the new weapon to the player while returning the old weapon (if the player wielded one).
                        swappedItem = equipment.EquipWeapon(item);
                    }
                    else if (item.Type == "Armour")
                    {
                        // Set the new Armour to the player while returning the old Armour (if the player wearing one).
                        swappedItem = equipment.EquipArmour(item);
                    }
                    else if (item.Type == "Ring")
                    {
                        // Set the new Ring to the player while returning the old Ring (if the player wearing one).
                        swappedItem = equipment.EquipRing(item);
                    }
                    else if (item.Type == "Bracelet")
                    {
                        // Set the new Bracelet to the player while returning the old Bracelet (if the player wearing one).
                        swappedItem = equipment.EquipBracelet(item);
                    }

                    // Remove this item from this List of Items.
                    GetComponentInParent <Inventory>().items [slotNumber] = new Item();
                    // IF we have an item being swapped out.
                    if (swappedItem != null)
                    {
                        // Add the swapped out equipped item to the inventory.
                        GetComponentInParent <Inventory>().AddItem(swappedItem.ID, 1);
                    }
                    // Do not show the tooltip.
                    Grid.tooltip.Deactivate();
                    // Destroy this item in the inventory list.
                    Destroy(gameObject);
                }
            }
        }
コード例 #15
0
 void Start()
 {
     characterAnimator = GetComponent <Animator> ();
     playerManager     = GetComponentInParent <Player_Manager> ();
 }