示例#1
0
 private void SavePlayerSetup()
 {
     // Save the player data.
     Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ().SavePlayer();
     // Save the action bars.
     //Grid_Helper.actionbarManager.SaveActionBars ();
 }
示例#2
0
        override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            // IF we have made a full cycle through our animation AND we are currently not in a transition,
            // ELSE we are midway in the cycle so we care about sorting order.
            if (animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1 && !animator.IsInTransition(0))
            {
                // Destroy our weapon.
                Destroy(weaponGameObject);
                // Set our IsAttacking to false.
                animator.SetBool("IsAttacking", false);
                // Make it so that our player can move.
                Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ().canMove = true;
            }
            else
            {
//				// IF the weapon should be displayed behind of the player,
//				// ELSE the weapon should be displayed infront the player.
//				if (animator.GetInteger ("Direction") == 1) {
//					// Set the weapon behind the player.
//					weaponRenderer.sortingOrder = playerRenderer.sortingOrder - sortOrderGap;
//				} else {
//					// Set the weapon infront of the player.
//					weaponRenderer.sortingOrder = playerRenderer.sortingOrder + sortOrderGap;
//				}
            }
        }
示例#3
0
        /// <summary>
        /// Uses the consumable.  Since our type is a consumable we will use it and reduce it by 1 but if its amount is 0 after usage we remove it from the inventory.
        /// </summary>
        public void UseConsumable(Item usedItem)
        {
            // Get the Character_Manager component.
            Character_Manager character = Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ();

            // Loop the amount of inventory spaces we have.
            for (int i = 0; i < defaultSlotAmount + extraInventorySlots; i++)
            {
                // IF the IDs match.
                if (items [i].ID == usedItem.ID)
                {
                    // Play the Pickup Sound.
                    Grid_Helper.soundManager.PlaySound(usedItem.UsedSound);
                    // Add "usage" attributes associated with this item.  At this current time if you are looking at the demo we only add HP.
                    character.GetComponentInChildren <Character_Stats> ().AddHealth((float)usedItem.RestoreHP);

                    // Remove the item from our inventory.
                    RemoveItemFromInventory(usedItem.ID, 1);
                    // Do not show the tooltip.
                    Grid_Helper.tooltip.DeactivateItemTooltip();
                    // Leave this loop because we can only use 1 item at a time so we are done.
                    return;
                }
            }
        }
示例#4
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     // Lets get our casting period.
     //skillCastingTime = Grid_Helper.skillManager.GetCurrentlyUsedSkill ().CastTime;
     // We do not want our player to move while casting.
     Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ().canMove = false;
 }
示例#5
0
 // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
 override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     // Leaving this state no matter what results in our IsCasting to be false.
     animator.SetBool("IsCasting", false);
     // Casting is done so we either are going to cast the skill right after OR we got interrupted which means no more skill.
     animator.SetInteger("CastType", 0);
     // Since we are no longer casting we can move again.
     Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ().canMove = true;
 }
示例#6
0
 override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     // Destroy our weapon.
     Destroy(weaponGameObject);
     // We are not longer attacking in our animation since we are leaving this state.
     animator.SetBool("IsAttacking", false);
     // Make it so that our player can move.
     Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ().canMove = true;
 }
 void Awake()
 {
     // Get the Character Manager component.
     characterManager = Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ();
     // Get the characters stats as we use that to potentially alter movement.
     charStats = characterManager.GetComponentInChildren <Character_Stats> ();
     // Get the Rigidbody2D Component.
     rb = GetComponent <Rigidbody2D> ();
 }
示例#8
0
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            // Reference the Character Manager.
            Character_Manager charManager = animator.GetComponentInParent <Character_Manager> ();

            // Get our player Renderer.
            playerRenderer = charManager.characterEntity.GetComponent <SpriteRenderer> ();
            // Get our weapon.
            Item meleeWeapon = Character_Helper.GetPlayerManager().GetComponentInChildren <Equipment> ().GetWeapon();


            // Now we need to know which way we are facing to position the weapon.
            weaponGameObject = Instantiate(Grid_Helper.setup.GetGameObjectPrefab(meleeWeapon.WeaponSlug), charManager.GetMeleeLocation(animator.GetInteger("Direction")));
            // Get our weapon Renderer.
            weaponRenderer = weaponGameObject.GetComponent <SpriteRenderer> ();
            // Set the layer of the character entity.
            weaponRenderer.sortingLayerName = playerRenderer.sortingLayerName;
            // Set the owner to this weapon.
            weaponGameObject.GetComponent <Owner> ().owner = animator.gameObject;
            // Set the damage to this weapon by putting the Item's damage as the parameter.
            weaponGameObject.GetComponent <Owner> ().damage = charManager.GetComponentInChildren <Character_Stats> ().GetCurrentDamage();


//			// IF this is NOT a full body sprite and we are going into the children to find a body reference.
//			if (playerRenderer == null) {
//				// Cache the Transform of the player.
//				Transform charTransform = charManager.characterEntity.transform;
//				// Loop the amount of children we have.
//				for (int x = 0; x < charTransform.childCount; x++) {
//					// IF the tag of the child gameobject is Body
//					if (charTransform.GetChild (x).tag == "Body") {
//						// Get the Sprite Renderer for the body reference.
//						playerRenderer = charTransform.GetChild (x).GetComponent <SpriteRenderer> ();
//						// Leave.
//						break;
//					}
//				}
//			}

            // Set the order layer it needs to be in.
            // IF the weapon should be displayed behind of the player,
            // ELSE the weapon should be displayed infront the player.
            if (animator.GetInteger("Direction") == 1)
            {
                // Set the weapon behind the player.
                weaponRenderer.sortingOrder = playerRenderer.sortingOrder - sortOrderGap;
            }
            else
            {
                // Set the weapon infront of the player.
                weaponRenderer.sortingOrder = playerRenderer.sortingOrder + sortOrderGap;
            }
            // Play the attack sound (if there is one).
            Grid_Helper.soundManager.PlaySound(meleeWeapon.AttackSound);
        }
示例#9
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_Helper.GetPlayerManager());
     // Clear our State_Manager Lists.
     Grid_Helper.stateManager.ClearList();
     // Handle all the middle meaty stuff here.
     Grid_Helper.helper.ReloadManagers();
     // Load the last scene that was saved.
     SceneManager.LoadScene(Grid_Helper.setup.GetSceneStartName());
 }
示例#10
0
        void Awake()
        {
            // Get the player managers gameobject
            GameObject player = Character_Helper.GetPlayerManager();

            // IF we found the player.
            if (player != null)
            {
                // Destroy the player.
                Destroy(player);
            }
        }
 void Awake()
 {
     // Get the Characters Manager component.
     characterManager = Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ();
     // Get the characters stats as we use that to potentially alter movement.
     charStats = characterManager.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;
 }
示例#12
0
 void Update()
 {
     // IF there isn't a player manager gameobject active on the scene.
     if (playerGO == null)
     {
         // Get the Player Manager GameObject.
         playerGO = Character_Helper.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 = playerGO.GetComponentInChildren <Key> ();
         return;
     }
     // Set the Text component.
     keyText.text = "x " + key.GetKeys(keyToUpdate).ToString();
 }
示例#13
0
 void Update()
 {
     // IF there isn't a character manager active on the scene.
     if (characterManager == null)
     {
         // Get the Character Manager GameObject.
         characterManager = Character_Helper.GetPlayerManager().GetComponent <Character_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 = characterManager.GetComponentInChildren <Character_Stats> ();
         return;
     }
     // Display your hearts.
     DisplayHearts();
 }
示例#14
0
 void Update()
 {
     // IF there isn't a player gameobject active on the scene.
     if (playerGO == null)
     {
         // Get the Player GameObject.
         playerGO = Character_Helper.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 = playerGO.GetComponentInChildren <Bombs> ();
         return;
     }
     // Set the Text component.
     bombText.text = "x " + dropBombs.GetBombs(bombToUpdate).ToString();
 }
        void Update()
        {
            // IF there isn't a player active on the scene.
            if (playerGO == null)
            {
                // Get the Player GameObject.
                playerGO = Character_Helper.GetPlayerManager();
                return;
            }
            // IF the equipment component isn't set yet
            if (equipment == null)
            {
                // Get the Equipment script that is on the player GameObject.
                equipment = playerGO.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,
            // ELSE IF we have a helmet 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();
            }
            else if (itemSlot == "Helmet")
            {
                // Get the helmet from the Equipment script.
                equip = equipment.GetHelmet();
            }

            // 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);
            }
        }
示例#16
0
        /// <summary>
        /// Equips/Swaps the equipment.  This will check the types of equipment to send that Item and its stat to the player.
        /// </summary>
        public void UseEquipment(Item usedItem)
        {
            // Get the Character_Manager component.
            Character_Manager character = Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ();

            // Get the Equipment component.
            Equipment equipment = character.GetComponentInChildren <Equipment> ();
            // Create a temp variable for our item that is swapped out by whatever we are currently equipping.
            Item swappedItem = null;

            // IF we have a weapon item,
            // ELSE IF we have a armour item,
            // ELSE IF we have a ring item,
            // ELSE IF we have a bracelet item,
            // ELSE we dont have an item to equip and we made an error somewhere as we should of not been in here.  One of the IF statements SHOULD work.
            if (usedItem.Type == "Weapon")
            {
                // Set the new weapon to the player while returning the old weapon (if the player wielded one).
                swappedItem = equipment.EquipWeapon(usedItem);
            }
            else if (usedItem.Type == "Armour")
            {
                // Set the new Armour to the player while returning the old Armour (if the player wearing one).
                swappedItem = equipment.EquipArmour(usedItem);
            }
            else if (usedItem.Type == "Ring")
            {
                // Set the new Ring to the player while returning the old Ring (if the player wearing one).
                swappedItem = equipment.EquipRing(usedItem);
            }
            else if (usedItem.Type == "Bracelet")
            {
                // Set the new Bracelet to the player while returning the old Bracelet (if the player wearing one).
                swappedItem = equipment.EquipBracelet(usedItem);
            }
            else
            {
                // Nothing we can equip so lets leave.
                Debug.Log("We entered the UseEquipment method but didnt equip anything.  Something isnt right with the labeling of the Types.");
                return;
            }

            // Loop the amount of times we have inventory spaces.
            for (int i = 0; i < defaultSlotAmount + extraInventorySlots; i++)
            {
                // IF the IDs match.
                if (items [i].ID == usedItem.ID)
                {
                    // IF we have an item being swapped out.
                    if (swappedItem != null)
                    {
                        // Add the swapped out equipped item to the inventory.
                        AddItem(swappedItem.ID, 1);
                    }
                    // Play the Pickup Sound.
                    Grid_Helper.soundManager.PlaySound(usedItem.UsedSound);
                    // Do not show the tooltip.
                    Grid_Helper.tooltip.DeactivateItemTooltip();
                    // Clear the inventory slot.
                    ClearSlotInInventory(i, slots [i].GetComponentInChildren <Item_Data> ().gameObject);
                    // Since we found a match lets get out of this loop.
                    break;
                }
            }
        }
示例#17
0
        /// <summary>
        /// Showing our tooltip.
        /// </summary>
        public void OnPointerEnter(PointerEventData data)
        {
            //// DEALING WITH A PRESET BAR ////

            // IF we are dealing with a weapon,
            // ELSE IF we are dealing with armour,
            // ELSE IF if you want to add more.
            if (weaponOnly)
            {
                // Get the equipment that is on our player.
                Equipment charEquipment = Character_Helper.GetPlayerManager().GetComponentInChildren <Character_Manager> ().characterEquipment;
                // IF we don't have a weapon.
                if (charEquipment.GetWeapon() == null)
                {
                    // We leave.
                    return;
                }
                // Since we have a weapon we can now display our tooltip.
                Grid_Helper.tooltip.ActivateItemTooltip(charEquipment.GetWeapon(), transform.parent.gameObject);
                // We leave.
                return;
            }
            else if (armourOnly)
            {
                // Get the equipment that is on our player.
                Equipment charEquipment = Character_Helper.GetPlayerManager().GetComponentInChildren <Character_Manager> ().characterEquipment;
                // IF we don't have armour.
                if (charEquipment.GetArmour() == null)
                {
                    // We leave.
                    return;
                }
                // Since we have armour we can now display our tooltip.
                Grid_Helper.tooltip.ActivateItemTooltip(charEquipment.GetArmour(), transform.parent.gameObject);
                // We leave.
                return;
            }
            else if (helmetOnly)
            {
                // Get the equipment that is on our player.
                Equipment charEquipment = Character_Helper.GetPlayerManager().GetComponentInChildren <Character_Manager> ().characterEquipment;
                // IF we don't have helmet.
                if (charEquipment.GetHelmet() == null)
                {
                    // We leave.
                    return;
                }
                // Since we have a helmet we can now display our tooltip.
                Grid_Helper.tooltip.ActivateItemTooltip(charEquipment.GetHelmet(), transform.parent.gameObject);
                // We leave.
                return;
            }
            //// END OF DEALING WITH A PRESET BAR ////


            // IF we have a tooltip.
            if (Grid_Helper.tooltip != null)
            {
                // IF there is an item in this action bar,
                // ELSE IF there is a skill in this action bar.
                if (itemBar != null)
                {
                    // Show the tooltip.
                    Grid_Helper.tooltip.ActivateItemTooltip(itemBar, transform.parent.gameObject);
                }
            }
        }
示例#18
0
 void ChangePlayerMovement(bool isMovable)
 {
     // Change the player variable for movement purposes.
     Character_Helper.GetPlayerManager().GetComponent <Character_Manager>().canMove = isMovable;
 }
示例#19
0
 void Start()
 {
     //Fetch the Input Field component from the GameObject
     inputField       = GetComponent <InputField>();
     characterManager = Character_Helper.GetPlayerManager().GetComponent <Character_Manager>();
 }