void Update()
        {
            // IF there isn't a player active on the scene.
            if (playerManager == null)
            {
                // Get the Player GameObject.
                playerManager = Character_Manager.GetPlayerManager();
                return;
            }
            // IF the equipment component isn't set yet
            if (equipment == null)
            {
                // Get the Equipment script that is on the player GameObject.
                equipment = playerManager.GetComponentInChildren <Equipment> ();
                return;
            }

            // Create a variable to hold the item.
            Item equip = null;

            // IF we have a weapon image we want to update,
            // ELSE IF we have a armour image we want to update,
            // ELSE IF we have a bracelet image we want to update,
            // ELSE IF we have a ring image we want to update.
            if (itemSlot == "Weapon")
            {
                // Get the weapon from the Equipment script.
                equip = equipment.GetWeapon();
            }
            else if (itemSlot == "Armour")
            {
                // Get the armour from the Equipment script.
                equip = equipment.GetArmour();
            }
            else if (itemSlot == "Bracelet")
            {
                // Get the bracelet from the Equipment script.
                equip = equipment.GetBracelet();
            }
            else if (itemSlot == "Ring")
            {
                // Get the ring from the Equipment script.
                equip = equipment.GetRing();
            }

            // IF there is an item,
            // ELSE there is not a item.
            if (equip != null)
            {
                // Grab the weapon.
                equipmentImage.sprite = equip.SpriteImage;
                // Set the color.
                equipmentImage.color = new Color(equip.R, equip.G, equip.B, equip.A);
            }
            else
            {
                // Set the color.
                equipmentImage.color = new Color(0f, 0f, 0f, 0f);
            }
        }
Beispiel #2
0
 /// <summary>
 /// IF we are to Continue a Game then we are either doing this from the Start Screen or a Death Screen in which we want to try again.  IF you know any other ideas for this then make sure to code for that situation.
 /// </summary>
 public void ContinueGame()
 {
     // Destroy the Player.
     Destroy(Character_Manager.GetPlayerManager());
     // Clear our State_Manager Lists.
     Grid.stateManager.ClearList();
     // Load the last scene that was saved.
     SceneManager.LoadScene(Grid.setup.GetSceneStartName());
 }
Beispiel #3
0
        void Awake()
        {
            GameObject player = Character_Manager.GetPlayerManager();

            if (player != null)
            {
                Destroy(player);
            }
        }
Beispiel #4
0
 void OnLoadedLevel(Scene scene, LoadSceneMode mode)
 {
     // IF the player exists then so does our UI.
     // ELSE the player does not exists then our UI does not.
     if (Character_Manager.GetPlayerManager() != null)
     {
         // Set the UI Active.
         UICanvas.SetActive(true);
     }
     else
     {
         // Set the UI NOT Active.
         UICanvas.SetActive(false);
     }
     // Load any states associated with this current scene.
     Grid.stateManager.Load();
 }
Beispiel #5
0
        void OnEnable()
        {
            // Get the Equipment script.
            Equipment equipment = Character_Manager.GetPlayerManager().GetComponentInChildren <Equipment> ();

            // Get the Sprite Renderer of the player.
            playerRenderer = Character_Manager.GetPlayer().GetComponent <SpriteRenderer> ();
            // Get the Weapon the player has.
            Item weapon = equipment.GetWeapon();

            // Get the sprite renderer of the this weapon.
            weaponRenderer = GetComponent <SpriteRenderer> ();
            // Get the Sprite Image of the weapon and set it to this GameObject's Sprite.
            weaponRenderer.sprite = weapon.SpriteImage;
            // Set the coloring of the Sprite renderer.
            weaponRenderer.color = new Color(weapon.R, weapon.G, weapon.B, weapon.A);
        }
 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 #7
0
 void Update()
 {
     // IF there isn't a player manager active on the scene.
     if (playerManager == null)
     {
         // Get the Player GameObject.
         playerManager = Character_Manager.GetPlayerManager();
         return;
     }
     // IF there isn't a Key component set yet.
     if (key == null)
     {
         // Get the Key script that is on the player GameObject.
         key = playerManager.GetComponentInChildren <Key> ();
         return;
     }
     // Set the Text component.
     keyText.text = "x " + key.GetKeys(keyToUpdate).ToString();
 }
Beispiel #8
0
 void Update()
 {
     // IF there isn't a player active on the scene.
     if (playerManager == null)
     {
         // Get the Player GameObject.
         playerManager = Character_Manager.GetPlayerManager();
         return;
     }
     // IF there isn't a Bomb component set.
     if (dropBombs == null)
     {
         // Get the Bomb script that is a child to the Player GameObject.
         dropBombs = playerManager.GetComponentInChildren <Bombs> ();
         return;
     }
     // Set the Text component.
     bombText.text = "x " + dropBombs.GetBombs().ToString();
 }
Beispiel #9
0
 void Update()
 {
     // IF there isn't a player manager active on the scene.
     if (playerManager == null)
     {
         // Get the Player GameObject.
         playerManager = Character_Manager.GetPlayerManager();
         return;
     }
     // IF there isn't a Money component set yet.
     if (currency == null)
     {
         // Get the Money script that is on the player GameObject.
         currency = playerManager.GetComponentInChildren <Money> ();
         return;
     }
     // Update the text to this currency.
     moneyText.text = "x " + currency.GetCurrency(currencyToUpdate).ToString();
 }
Beispiel #10
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);
                }
            }
        }
Beispiel #11
0
 void ChangePlayerMovement(bool isMovable)
 {
     // Change the player variable for movement purposes.
     Character_Manager.GetPlayerManager().GetComponent <Player_Manager>().CanMove = isMovable;
 }