コード例 #1
0
        public virtual void CreateSquares()
        {
            if (HasCreatedSquares)
            {
                return;
            }

            mCollidersEnabled = false;

            if (EnablerDisplayPrefab == null)
            {
                EnablerDisplayPrefab = GUIManager.Get.InventorySquareEnabler;
            }

            if (UseVisualEnabler)
            {
                if (EnablerDisplay == null)                                                     //create the square that will display the object
                {
                    GameObject enablerGameObject = NGUITools.AddChild(gameObject, EnablerDisplayPrefab);
                    EnablerDisplay = enablerGameObject.GetComponent <InventoryEnabler>();
                    if (EnablerDisplay == null)
                    {
                        Debug.Log("Couldn't get component inventory enabler from enabler display prefab " + EnablerDisplayPrefab.name + " in " + name);
                    }
                    //DO NOT ever set its stack here or create its stack for it
                    //always let RefreshSquares set its stack
                }
                EnablerDisplay.transform.localPosition = EnablerOffset;
                EnablerDisplay.TargetPosition          = EnablerOffset;
            }

            switch (DisplayMode)
            {
            case StackContainerDisplayMode.OneRow:
                CreateOneRowSquares();
                break;

            case StackContainerDisplayMode.TwoRow:
                CreateTwoRowSquares();
                break;

            case StackContainerDisplayMode.Circle:
                break;

            case StackContainerDisplayMode.TwoRowVertical:
                CreateTwoRowVerticalSquares();
                break;

            default:
                break;
            }

            if (mOneSquareMode)
            {
                //set it to false so we can set it up
                mOneSquareMode = false;
                SetOneSquareMode(mOneSquareMode, mActiveSquare);
            }
        }
コード例 #2
0
        protected void CreateTwoRowSquares()
        {
            Vector2 squareDimensions = Vector2.zero;
            //int numberOfSquares = Globals.MaxStacksPerContainer;
            int squaresPerRow = Globals.MaxStacksPerContainer / 2;

            if (SquarePrefab == null)
            {
                SquarePrefab = GUIManager.Get.InventorySquare;
            }
            int currentRow    = 0;
            int currentSquare = 0;

            for (int y = 0; y < 2; y++)
            {
                for (int x = 0; x < squaresPerRow; x++)
                {
                    GameObject      instantiatedSquare = NGUITools.AddChild(InventorySlotsParent, SquarePrefab);
                    InventorySquare square             = instantiatedSquare.GetComponent <InventorySquare>();
                    if (square.Panel != null)
                    {
                        GameObject.Destroy(square.Panel);
                    }
                    square.NGUICamera              = NGUICamera;
                    squareDimensions               = square.Dimensions;
                    square.TargetPosition          = new Vector3(x * (square.Dimensions.x), currentRow * (-square.Dimensions.y), 0f);
                    square.transform.localPosition = square.TargetPosition;
                    square.Enabler = Enabler;
                    square.Index   = currentSquare;
                    InventorySquares.Add(square);
                    square.UpdateDisplay();
                    currentSquare++;
                }
                currentRow++;
            }
            FrameSprite.transform.localScale = new Vector3((squaresPerRow * squareDimensions.x) - mFramePadding, (2 * squareDimensions.y) - mFramePadding, 0f);
            if (UseVisualEnabler)
            {
                EnablerDisplay.NGUICamera = NGUICamera;
                                                                #if UNITY_EDITOR
                EnablerDisplay.name = DisplayName + " enabler ";
                                                                #endif
            }

            if (mOneSquareMode)
            {
                //set it to false so we can set it up
                mOneSquareMode = false;
                SetOneSquareMode(mOneSquareMode, mActiveSquare);
            }
        }
コード例 #3
0
 public void SetActiveQuickslots(int activeQuickslot)
 {
     if (!VRManager.VRMode)
     {
         if (QuickslotsDisplay.HasEnabler && QuickslotsDisplay.Enabler.IsEnabled)
         {
             InventorySquare square = QuickslotsDisplay.InventorySquares[activeQuickslot];
             QuickslotHighlightParent.parent        = square.transform;
             QuickslotHighlightParent.localPosition = Vector3.zero;
             //QuickslotHighlightParent.parent = QuickslotsDisplay.transform;
             //mQuickslotHighlightTarget = QuickslotHighlightParent.localPosition;
             //mQuickslotHighlightTarget.z -= 50f;
         }
     }
 }
コード例 #4
0
        protected void CreateContainerDisplays()
        {
            if (QuickslotsDisplay == null)                                      //don't build stuff twice!
            {
                GameObject instantiatedContainerDisplay   = null;
                GameObject instantiatedCarryDisplay       = null;
                GUIStackContainerDisplay containerDisplay = null;
                InventorySquare          carrySquare      = null;

                for (int i = 0; i < Globals.NumInventoryStackContainers; i++)
                {
                    instantiatedContainerDisplay             = NGUITools.AddChild(ContainerDisplayParentTransform.gameObject, GUIManager.Get.StackContainerDisplay);
                    containerDisplay                         = instantiatedContainerDisplay.GetComponent <GUIStackContainerDisplay>();
                    containerDisplay.NGUICamera              = NGUICamera;
                    containerDisplay.transform.localPosition = new Vector3(0f, i * -containerDisplay.FrameHeight, 0f);
                    StackContainerDisplays.Add(containerDisplay);
                    containerDisplay.Refresh();
                }

                instantiatedContainerDisplay             = NGUITools.AddChild(QuickslotsParent.gameObject, GUIManager.Get.StackContainerDisplay);
                containerDisplay                         = instantiatedContainerDisplay.GetComponent <GUIStackContainerDisplay>();
                containerDisplay.NGUICamera              = NGUICamera;
                containerDisplay.transform.localPosition = Vector3.zero;
                QuickslotsDisplay                        = containerDisplay;
                containerDisplay.Refresh();

                instantiatedCarryDisplay = NGUITools.AddChild(QuickslotsParent.gameObject, GUIManager.Get.InventorySquare);
                carrySquare                 = instantiatedCarryDisplay.GetComponent <InventorySquare>();
                carrySquare.NGUICamera      = NGUICamera;
                carrySquare.RequiresEnabler = false;
                //get the last position of the last square in the stack
                //then add 1.5 times a square's width to that so it feels 'left hand' ish
                carrySquare.transform.localPosition = new Vector3(-((carrySquare.Dimensions.x * (Globals.MaxStacksPerContainer + 2)) + (carrySquare.Dimensions.x / 2)), -60f, 0f);

                QuickslotsCarrySquare = carrySquare;
                //add the little hand icons
                EquippedIconLeft.transform.parent        = QuickslotsCarrySquare.transform;
                EquippedIconLeft.transform.localPosition = Vector3.zero;
                EquippedIconLeft.color  = Colors.Get.GeneralHighlightColor;
                EquippedIconRight.color = Colors.Get.GeneralHighlightColor;
                EquippedIconLeft.alpha  = QuickslotHighlight.alpha;
                EquippedIconRight.alpha = QuickslotHighlight.alpha;

                StackContainerInterface.NGUICamera = NGUICamera;

                QuickslotHighlight.transform.localScale = new Vector3(carrySquare.Dimensions.x, carrySquare.Dimensions.y, 1f);
            }
        }