Beispiel #1
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>();
 }
Beispiel #2
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);
            }
        }
 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;
 }
Beispiel #4
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();
 }
Beispiel #5
0
        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);
                }
            }
        }