コード例 #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
        void Update()
        {
            // Store the input variable.  We multiply by 10 as the actual increments by default are 0.1f, if you wish to alter these yourself make sure to check out the Edit -> Project Settings -> Input -> Mouse ScrollWheel.
            axisNum = Input.GetAxisRaw("Mouse ScrollWheel") * 10f;
            // IF the input is not the middle mouse wheel OR we have a coroutine already running OR we dont have a player in the scene.
            // (Normally all mouses these days have a middle button so just code for that, if someone really doesnt have a middle mouse button then this isnt on you, it's on them at this point in time with technology.
            // We stop coding for ancient devices after a while or the most simple scripts would be loaded with a lot of crap we dont need to deal with which destroys time and time is the most valuable asset we have.)
            if (axisNum == 0f || isRunning || Character_Helper.GetPlayer() == null)
            {
                // No zoom so we do nothing.
                return;
            }
            // Get the amount to move based on the axisNum and the zoomAmount;
            float amountToMove = axisNum * zoomAmount;

            // Lets get our destination of where we want to move.
            destinationOrthoSize = referenceSize - amountToMove;
            // Now lets check if we are in the boundaries.
            // IF our destinationOrthoSize is bigger than our maxZoom we want,
            // ELSE IF our destinationOrthoSize is less than our minZoom we want,
            if (destinationOrthoSize >= maxZoom)
            {
                // Set the destinationOrthoSize to be our maxZoom.
                destinationOrthoSize = maxZoom;
            }
            else if (destinationOrthoSize <= minZoom)
            {
                // Set the destinationOrthoSize to be our minZoom.
                destinationOrthoSize = minZoom;
            }
        }
コード例 #3
0
        /// <summary>
        /// We check to see whenever the player is spawned in the scene and then we act.
        /// </summary>
        void Update()
        {
            // IF the player gameobject is null.
            if (playerGO == null)
            {
                // Get the player GameObject.
                playerGO = Character_Helper.GetPlayer();
                return;
            }
            // IF the players reference to its transform is null.
            if (playerTransform == null)
            {
                // Grab the transform.
                playerTransform = playerGO.transform;
            }

            // IF we have not set our bounds yet.
            if (!isBounds)
            {
                // Leave as we have no boundaries so we do not know wtf to do in terms of any restriction on how this camera mechanic is supposed to work
                return;
            }
            // IF we are currently in a cutscene.
            if (isCutScene)
            {
                // We are in a cutscene so we do not care about how this camera operates as in a cutscene we are manually controlling the camera.
                return;
            }
            // In-case we have any sort of zoom feature along with boundaries we def need to refresh our cameras width and height.
            RefreshBounds();
            // We passed all of our prequisites so lets clamp values between the bounds.
            camX = Mathf.Clamp(playerTransform.position.x + (rightUILength - leftUILength) / 2f, finalLeftBound - leftUILength, finalRightBound - rightUILength);
            camY = Mathf.Clamp(playerTransform.position.y + (topUILength - botUILength) / 2f, finalBottomBound - botUILength, finalTopBound + topUILength);
        }
コード例 #4
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;
//				}
            }
        }
コード例 #5
0
 /// <summary>
 /// We check to see whenever the player is spawned in the scene and then we act.
 /// </summary>
 void Update()
 {
     // IF the player gameobject is null.
     if (playerGO == null)
     {
         // Get the player GameObject.
         playerGO = Character_Helper.GetPlayer();
         return;
     }
     // IF the players reference to its transform is null.
     if (playerTransform == null)
     {
         // Grab the transform.
         playerTransform = playerGO.transform;
     }
     // IF the bounds have been set and we are not in a cutscene.
     if (isBounds && !isCutScene)
     {
         // Incase we have any sort of zoom feature along with boundaries we def need to refresh our cameras width and height.
         RefreshBounds();
         // Clamp values between the bounds.
         camX = Mathf.Clamp(playerTransform.position.x + (rightUILength - leftUILength) / 2f, finalLeftBound - leftUILength, finalRightBound + rightUILength);
         camY = Mathf.Clamp(playerTransform.position.y + (topUILength - botUILength) / 2f, finalBottomBound - botUILength, finalTopBound + topUILength);
     }
 }
コード例 #6
0
 void OnTriggerExit2D(Collider2D coll)
 {
     // IF this is the player.
     if (coll.gameObject == Character_Helper.GetPlayer())
     {
         // IF we want to destroy the spawned gameobject when we leave this section.
         if (destroyOnExit)
         {
             // Loop through all of our Monster_Spawners.
             for (int i = 0; i < mobSpawner.Length; i++)
             {
                 // Destroy all the monsters.
                 mobSpawner [i].DestroyAllMonsters();
             }
             // We leave.
             return;
         }
         // Loop through all of our Monster_Spawners.
         for (int i = 0; i < mobSpawner.Length; i++)
         {
             // Deactivate the monsters left in this area.
             mobSpawner [i].SetMonstersActiveness(false);
         }
     }
 }
コード例 #7
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;
 }
コード例 #8
0
ファイル: Inventory.cs プロジェクト: deankeinan/FantasySim
        /// <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;
                }
            }
        }
コード例 #9
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;
 }
コード例 #10
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     // IF this is the player.
     if (coll.gameObject == Character_Helper.GetPlayer())
     {
         // Set to true for spawning.
         timeToSpawn = true;
     }
 }
コード例 #11
0
 void OnTriggerExit2D(Collider2D coll)
 {
     // IF the colliding GameObject is the player.
     if (coll.gameObject == Character_Helper.GetPlayer())
     {
         // We are NOT close enough for when we use the KeyCode it will spawn monsters.
         isCloseEnough = false;
     }
 }
コード例 #12
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     // IF the colliding GameObject is the player.
     if (coll.gameObject == Character_Helper.GetPlayer())
     {
         // We are close enough for when we use the KeyCode it will spawn monsters.
         isCloseEnough = true;
     }
 }
コード例 #13
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;
 }
コード例 #14
0
 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> ();
 }
コード例 #15
0
ファイル: Inventory.cs プロジェクト: deankeinan/FantasySim
        /// <summary>
        /// Tosses the item out of inventory.
        /// </summary>
        public void TossItemOutOfInventory(string itemTitle, int slotNumber, int amount)
        {
            // Spawn the item from it being thrown out of the inventory.
            GameObject goItem = Grid_Helper.helper.SpawnObject(Grid_Helper.setup.GetGameObjectPrefab(itemTitle), Character_Helper.GetPlayer().transform.position, Quaternion.identity, Character_Helper.GetPlayer(), radius);

            // Store the amount that was tossed out.
            goItem.GetComponent <Item_GameObject> ().amount = amount;
            // Launch the item in a random direction.
            Grid_Helper.helper.LaunchAwayFromPosition(goItem, Character_Helper.GetPlayer().transform.position, forcePower);
        }
コード例 #16
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);
        }
コード例 #17
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     // IF the colliding GameObject is NOT the player.
     if (coll.gameObject != Character_Helper.GetPlayer())
     {
         // We leave.
         return;
     }
     // Lets change our scene.
     StartSceneVisualTransition();
 }
コード例 #18
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());
 }
コード例 #19
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);
            }
        }
コード例 #20
0
 void Start()
 {
     // Get the player GameObject.
     playerGO = Character_Helper.GetPlayer();
     // IF the player GameObject is null.
     if (playerGO == null)
     {
         // IF after searching and no player at the Start, then we can assume this scene doesnt have a player in it and we will not control the positioning of this Camera from here.
         return;
     }
     // Grab the transform.
     playerTransform = playerGO.transform;
 }
コード例 #21
0
 void LateUpdate()
 {
     // IF the input is not the middle mouse wheel OR there is a zoom already happening OR there isnt a player in the scene.
     if (axisNum == 0 || isRunning || Character_Helper.GetPlayer() == null)
     {
         // Do nothing as we didn't zoom.
         return;
     }
     // We need to stop all of our current zooming as we have a new destination for our Orthographic Size.
     StopAllCoroutines();
     // Start the coroutine which zooms.
     StartCoroutine(ZoomTime(cam.orthographicSize, destinationOrthoSize, zoomTime));
 }
コード例 #22
0
 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;
 }
コード例 #23
0
 // Incase you want to have a 1 use camera we need to set defaults on a scene change and set up the boundary variables before we track the player.
 void OnLoadedLevel(Scene scene, LoadSceneMode mode)
 {
     // Set defaults.
     isBounds = false;
     // Get the player GameObject.
     playerGO = Character_Helper.GetPlayer();
     // IF we have a player to get when changing the scene.
     if (playerGO == null)
     {
         return;
     }
     // Grab the transform of the player.
     playerTransform = playerGO.transform;
 }
コード例 #24
0
 // Incase you want to have a 1 use camera we need to set defaults on a scene change and set up the boundary variables before we track the player.
 void OnLoadedLevel(Scene scene, LoadSceneMode mode)
 {
     // Set defaults.
     isBounds = false;
     // Get the player GameObject.
     playerGO = Character_Helper.GetPlayer();
     // IF the player does not exists... yet.
     if (playerGO == null)
     {
         return;
     }
     // Cache the transform.
     playerTransform = playerGO.transform;
 }
コード例 #25
0
 void Start()
 {
     // Need to check if the playeris inside the bounds.
     if (IsPlayerInBounds(Character_Helper.GetPlayer().transform.position))
     {
         // IF the Follow_Slide_Camera exists.
         if (cameraFollowSlide != null)
         {
             // Set the new boundaries.
             SetNewBounds();
             return;
         }
     }
 }
コード例 #26
0
        void Start()
        {
            // Get the player.
            charaManager = Character_Helper.GetPlayerManager().GetComponent <Character_Manager> ();

            // Create our pool size.
            pooledObjects            = ObjectPooler.SharedInstance.CreatePool(maxAmount, weatherObject, weatherSpritesParent.transform, false);
            pooledObjectsWhileMoving = ObjectPooler.SharedInstance.CreatePool(maxAmountWhileMoving, weatherObject, weatherSpritesMovingParent.transform, false);

            // Lets get our min and max emission locations.
            topEmissionMinTransform    = GameObject.FindGameObjectWithTag(topWeatherEmissionMinTag).transform;
            topEmissionMaxTransform    = GameObject.FindGameObjectWithTag(topWeatherEmissionMaxTag).transform;
            bottomEmissionMinTransform = GameObject.FindGameObjectWithTag(bottomWeatherEmissionMinTag).transform;
            bottomEmissionMaxTransform = GameObject.FindGameObjectWithTag(bottomWeatherEmissionMaxTag).transform;
        }
コード例 #27
0
 /// <summary>
 /// Currently in the Demo we save valuable information when we transfer to another scene only as this is to prevent any unwanted hiccups while playing.
 /// When you enter an area that is where you will start if your game were to crash or if the player wants to stop playing and come back later
 /// (Remember this is only in the demo, you can have your save setup however you want).
 ///
 /// This only differs by loading the scene with LoadSceneAsync as it allows for a smoother transfer of scene loading.
 /// If you have some sort of animation happening like a twirling/spinning camera while you want to change scenes like in some Turn-Based games like Final Fantasy.
 /// </summary>
 public void ChangeSceneAsync(string newScene, int spawnLocation)
 {
     // IF there is a player.
     if (Character_Helper.GetPlayer() != null)
     {
         // Save the player setup.
         SavePlayerSetup();
     }
     // Save any scene based information.
     SaveSceneSetup(newScene, spawnLocation);
     // Save the player prefs to disk.
     PlayerPrefs.Save();
     // Change the scene in a more smooth manner.
     SceneManager.LoadSceneAsync(newScene);
 }
コード例 #28
0
 /// <summary>
 /// Displays the dialogue panel.
 /// </summary>
 public void DisplayDialoguePanel(bool display)
 {
     // Display the dialogue panel based on 'display'.
     dialoguePanel.SetActive(display);
     // IF we are displaying the dialogue panel,
     // ELSE we are removing the dialogue panel.
     if (display)
     {
         // Lets Setup.
         SendCharacterInfo(GetClosestDialogue().gameObject, false, true, Character_Helper.GetPlayer());
     }
     else
     {
         // Reset to start standards.
         GetClosestDialogue().ResetDialogue();
         ResetDialogue();
     }
 }
コード例 #29
0
 /// <summary>
 /// Spawns the player.
 /// </summary>
 private void SpawnPlayer()
 {
     // IF we have a player to spawn.
     if (Grid_Helper.setup.player != null)
     {
         // IF the player is already spawned,
         // ELSE the player is not spawned and needs to be and will be positioned accordingly.
         if (Character_Helper.GetPlayer() != null)
         {
             // Move this player to the new location.
             Character_Helper.GetPlayer().transform.position = sceneSpawnLocations [Grid_Helper.setup.GetSceneSpawnLocation()].position;
         }
         else
         {
             // Create this player at the appropriate location.
             Instantiate(Grid_Helper.setup.player, sceneSpawnLocations [Grid_Helper.setup.GetSceneSpawnLocation()].position, Quaternion.identity);
         }
     }
 }
コード例 #30
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 Money component set yet.
     if (currency == null)
     {
         // Get the Money script that is on the player GameObject.
         currency = playerGO.GetComponentInChildren <Money> ();
         return;
     }
     // Update the text to this currency.
     moneyText.text = "x " + currency.GetCurrency(currencyToUpdate).ToString();
 }