コード例 #1
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_Manager.GetPlayer();
         return;
     }
     // IF the players reference to its transform is null.
     if (playerTransform == null)
     {
         // Grab the transform.
         playerTransform = playerGO.transform;
     }
     // IF the camera is capable of moving.
     if (canCameraMove)
     {
         // Refresh the camera bounds.
         RefreshCameraBounds();
         // Clamp values between the bounds.
         camX = Mathf.Clamp(playerTransform.position.x, leftBound, rightBound);
         camY = Mathf.Clamp(playerTransform.position.y + UIVerticalOffset / 200f, bottomBound, topBound);
     }
 }
コード例 #2
0
ファイル: Item_Data.cs プロジェクト: pow752/Tower-Of-Babble
 public void OnEndDrag(PointerEventData data)
 {
     if (data.button == PointerEventData.InputButton.Left)
     {
         // IF we are not hovering the mouse over the inventory then drop the item on the ground.
         if (data.hovered.Count == 0)
         {
             // Spawn the item from it being thrown out of the inventory.
             GameObject goItem = Grid.helper.SpawnObject(Grid.setup.GetGameObjectPrefab(item.Title), Character_Manager.GetPlayer().transform.position, Quaternion.identity, Character_Manager.GetPlayer(), RADIUS);
             // Launch the item in a random direction.
             Grid.helper.LaunchItemAwayFromPosition(goItem, Character_Manager.GetPlayer().transform.position);
             // Clear the old slot.
             GetComponentInParent <Inventory>().items [slotNumber] = new Item();
             // Destroy this gameobject.
             Destroy(this.gameObject);
             // We done so lets GTFO of here.
             return;
         }
         // IF we actually are dragging an item.
         if (item != null)
         {
             // Set this items parent back to the original slot.
             this.transform.SetParent(GetComponentInParent <Inventory>().slots [slotNumber].transform);
             // Set its local position back to 0 so it can be centered in the slot.
             this.transform.localPosition = Vector2.zero;
             // Make sure the scale is set properly to 1.
             this.transform.localScale = Vector2.one;
             // Allow us to block raycast again.
             canvasGroup.blocksRaycasts = true;
         }
     }
 }
コード例 #3
0
ファイル: Exciting_Object.cs プロジェクト: MisterSquishy/game
 // Update is called once per frame
 void Update()
 {
     if (IsInMouth)
     {
         GameObject _scout = null;                                        //cleanup why do we have to pass null to this function?
         _scout = Character_Manager.GetClosestCharacterTypeWithRawTransform(this.transform, CharacterType.Scout, _scout, float.PositiveInfinity);
         this.transform.position = _scout.transform.GetChild(0).position; //get the actual scout, not the scout manager
     }
     else if (IsInHand)
     {
         this.transform.position = Character_Manager.GetPlayer().transform.position;
     }
 }
コード例 #4
0
 void Start()
 {
     // Grab the player GameObject.
     playerGO = Character_Manager.GetPlayer();
     // IF the player gameobject is null.
     if (playerGO == null)
     {
         // Get the player GameObject.
         playerGO = Character_Manager.GetPlayer();
         // Set the camera up where it is supposed to start since we have found the player.
         AlignCamera();
         return;
     }
 }
コード例 #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);
        }
コード例 #6
0
        // Make the text type out based on the text speed.
        public static IEnumerator TypeText(Text txt, float pauseTime, string dialogue, AudioClip typeSound)
        {
            // IF we have a null text.
            if (txt == null)
            {
                yield break;
            }

            txt.text = "";
            for (int i = 0; i <= dialogue.Length; i++)
            {
                txt.text = dialogue.Substring(0, i);
                Grid_Helper.soundManager.PlaySound(typeSound, Character_Manager.GetPlayer().transform.position, 1f, 1f);
                yield return(new WaitForSeconds(pauseTime));

                yield return(null);
            }
        }
コード例 #7
0
ファイル: Weapon_Attack.cs プロジェクト: MisterSquishy/game
        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> ();
            if (weapon != null)
            {
                weaponRenderer.sprite = weapon.SpriteImage;
                weaponRenderer.color  = new Color(weapon.R, weapon.G, weapon.B, weapon.A);
            }
        }
コード例 #8
0
 private void SpawnPlayer()
 {
     // IF we have a player to spawn.
     if (Grid.setup.player != null)
     {
         // IF the player is already spawned,
         // ELSE the player is not spawned and needs to be and will be positioned accordinly.
         if (Character_Manager.GetPlayer() != null)
         {
             // Move this player to the new location.
             Character_Manager.GetPlayer().transform.position = sceneSpawnLocations [Grid.setup.GetSceneSpawnLocation()].position;
         }
         else
         {
             // Create this player at the appropriate location.
             Instantiate(Grid.setup.player, sceneSpawnLocations [Grid.setup.GetSceneSpawnLocation()].position, Quaternion.identity);
         }
     }
 }
コード例 #9
0
 void Update()
 {
     // IF the player gameobject is null.
     if (playerGO == null)
     {
         // Get the player GameObject.
         playerGO = Character_Manager.GetPlayer();
         // Set the camera up where it is supposed to start since we have found the player.
         AlignCamera();
         return;
     }
     // IF the players reference to its transform is null.
     if (playerTransform == null)
     {
         // Grab the transform.
         playerTransform = playerGO.transform;
         // Since we have a player lets set our camera boundaries.
         calcCamPos();
     }
     // Detect IF we are at the edges of the Camera to Pan.
     CameraEdgeDetection();
 }
コード例 #10
0
ファイル: Item_Data.cs プロジェクト: samikim/TielGame
 public void OnEndDrag(PointerEventData data)
 {
     if (data.button == PointerEventData.InputButton.Left)
     {
         // IF we are not hovering the mouse over the inventory then drop the item on the ground.
         if (data.hovered.Count == 0)
         {
             // Spawn the item from it being thrown out of the inventory.
             Vector3 charPosition     = Character_Manager.GetPlayer().transform.position;
             Vector3 clickPosition    = new Vector3(data.position.x, data.position.y);
             Camera  camera           = Camera.main;
             Vector3 clickMapPosition = camera.ScreenToWorldPoint(clickPosition);
             print("Character position: " + charPosition.ToString());
             print("Mouse position: " + clickMapPosition.ToString());
             float xDiff = clickMapPosition.x - charPosition.x;
             float yDiff = clickMapPosition.y - charPosition.y;
             if (System.Math.Abs(xDiff) >= System.Math.Abs(yDiff))
             {
                 if (xDiff >= 0)
                 {
                     Grid.helper.SpawnObjectNextToPlayer(Grid.setup.GetGameObjectPrefab(item.Title), Character_Manager.GetPlayer().transform.position, Quaternion.identity, Character_Manager.GetPlayer(), RADIUS, true);
                 }
                 else
                 {
                     Grid.helper.SpawnObjectNextToPlayer(Grid.setup.GetGameObjectPrefab(item.Title), Character_Manager.GetPlayer().transform.position, Quaternion.identity, Character_Manager.GetPlayer(), -1 * RADIUS, true);
                 }
             }
             else
             {
                 if (yDiff >= 0)
                 {
                     Grid.helper.SpawnObjectNextToPlayer(Grid.setup.GetGameObjectPrefab(item.Title), Character_Manager.GetPlayer().transform.position, Quaternion.identity, Character_Manager.GetPlayer(), RADIUS, false);
                 }
                 else
                 {
                     Grid.helper.SpawnObjectNextToPlayer(Grid.setup.GetGameObjectPrefab(item.Title), Character_Manager.GetPlayer().transform.position, Quaternion.identity, Character_Manager.GetPlayer(), -1 * RADIUS, false);
                 }
             }
             // GameObject goItem = Grid.helper.SpawnObjectToLeftOfPlayer (Grid.setup.GetGameObjectPrefab (item.Title), Character_Manager.GetPlayer ().transform.position, Quaternion.identity, Character_Manager.GetPlayer (), RADIUS);
             // Launch the item in a random direction.
             // Grid.helper.LaunchItemAwayFromPosition (goItem, Character_Manager.GetPlayer ().transform.position);
             // Clear the old slot.
             GetComponentInParent <Inventory>().items [slotNumber] = new Item();
             // Destroy this gameobject.
             Destroy(this.gameObject);
             // We done so lets GTFO of here.
             return;
         }
         // IF we actually are dragging an item.
         if (item != null)
         {
             // Set this items parent back to the original slot.
             this.transform.SetParent(GetComponentInParent <Inventory>().slots [slotNumber].transform);
             // Set its local position back to 0 so it can be centered in the slot.
             this.transform.localPosition = Vector2.zero;
             // Make sure the scale is set properly to 1.
             this.transform.localScale = Vector2.one;
             // Allow us to block raycast again.
             canvasGroup.blocksRaycasts = true;
         }
     }
 }
コード例 #11
0
ファイル: Exciting_Object.cs プロジェクト: MisterSquishy/game
 // Use this for initialization
 void Start()
 {
     playerRenderer = Character_Manager.GetPlayer().GetComponent <SpriteRenderer>();
     objectRenderer = GetComponent <SpriteRenderer>();
 }