예제 #1
0
        /// <summary>
        /// Adds the title to the screen.
        /// </summary>
        private void AddTitle()
        {
            UIPosition titlePos = new UIPosition(0, 0);
            UITitle    appTitle = new UITitle("title", titlePos, "Felli", 30, 2);

            this.Screen.Add(appTitle);

            UITitleRef = appTitle;
        }
예제 #2
0
 //serve per settare la posizione del bottone
 public void setVerticalButton(UIPosition pos, bool vertical = true)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             spritesGroup[i].buttonHorizontal = !vertical;
             break;
         }
     }
 }
예제 #3
0
 //serve per settare la distanza delle sprites
 public void setDistance(UIPosition pos, UIDistance distance)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             spritesGroup[i].distance = distance;
             break;
         }
     }
 }
예제 #4
0
 /*
  * assegna le sprites da mostrare nella posizione specificata,
  * come parametro viene passato un array di sprites,
  * chiaramente, se l’array contiene una sola sprite, ne verrà mostrata solo una
  */
 public void setSprites(Sprite[] sprites, UIPosition pos)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             spritesGroup[i].sprites = sprites;
             break;
         }
     }
 }
예제 #5
0
        public void Run(EcsSystems systems)
        {
            var world        = systems.GetWorld();
            var entities     = world.Filter <UIPosition>().Inc <UIText>().End();
            var positionPool = world.GetPool <UIPosition>();
            var textPool     = world.GetPool <UIText>();

            foreach (var entity in entities)
            {
                ref UIPosition pos  = ref positionPool.Get(entity);
                ref UIText     text = ref textPool.Get(entity);
예제 #6
0
 //metodo per settare la sprite del bottone
 public void setButtonSprite(UIPosition pos, Sprite sprite)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             //Debug.Log ("BELLA ZIO! Sono in "+spritesGroup[i].position.ToString());
             spritesGroup[i].buttonSprite = sprite;
         }
     }
 }
 //serve per settare la grandezza delle sprites
 public void setSpritesSize(UIPosition pos, UISize size)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             spritesGroup[i].size = size;
             break;
         }
     }
 }
 public void showIcons(UIPosition pos, bool show = true)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             spritesGroup[i].showing = show;
             spritesGroup[i].hiding  = !show;
             break;
         }
     }
 }
예제 #9
0
 //metodo che può essere chiamato dall'esterno per avere diretto accesso agli oggetti col component Image
 //di default non dovrebbe essere usato
 public GameObject getImageObject(UIPosition pos, int index)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             if (spritesGroup[i].imagesObject[index] != null)
             {
                 return(spritesGroup[i].imagesObject[index]);
             }
         }
     }
     return(null);
 }
예제 #10
0
    private void UpdateArrow(RectTransform r, Vector3 enemyWorldPos, UnityEngine.UI.Image arrow)
    {
        Vector2 enemyUIPos = UIPosition.WorldToUI(r, enemyWorldPos);

        float           width  = r.rect.width / 2;
                float   height = r.rect.height / 2;
                Vector2 uiPos  = new Vector2(Mathf.Clamp(enemyUIPos.x, -width, width), Mathf.Clamp(enemyUIPos.y, -height, height));

        arrow.rectTransform.localPosition = uiPos;
                float angle = Mathf.Atan2(uiPos.y, uiPos.x) * Mathf.Rad2Deg;

        arrow.rectTransform.localEulerAngles = new Vector3(0, 0, angle - 90);
            
    }
예제 #11
0
    public void cleanPositionButtonObject(UIPosition pos)
    {
        for (int i = 0; i < spritesGroup.Length; i++)
        {
            if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
            {
                spritesGroup[i].buttonSprite = null;

                Destroy(spritesGroup[i].imageButtonObject);

                break;
            }
        }
    }
 public GameObject getImageObject(UIPosition pos, int index)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             if (spritesGroup[i].spritesGroupElement != null && spritesGroup[i].spritesGroupElement.Length > index && spritesGroup[i].spritesGroupElement[index] != null && spritesGroup[i].spritesGroupElement[index].imageObject != null)
             {
                 return(spritesGroup[i].spritesGroupElement[index].imageObject);
             }
             break;
         }
     }
     return(null);
 }
예제 #13
0
 public GameObject getButtonObject(UIPosition pos)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             if (spritesGroup[i].imageButtonObject != null)
             {
                 return(spritesGroup[i].imageButtonObject);
             }
             break;
         }
     }
     return(null);
 }
예제 #14
0
        /// <summary>
        /// Add a new <see cref="UIElement"/> to the screen using another
        /// element's anchor point.
        /// </summary>
        /// <param name="newElement">The new <see cref="UIElement"/>.</param>
        /// <param name="anchorPoint">The anchor point to be used.</param>
        public void Add(UIElement newElement, UIPosition anchorPoint)
        {
            UIPosition position;

            position = newElement.TopLeft + anchorPoint;

            if (newElement.IsCentered)
            {
                position -= new UIPosition(newElement.Width / 2, 0);
            }

            newElement.SetPosition(position);

            Elements.Add(newElement);
        }
예제 #15
0
 //per ora inutilizzata
 public void setSpriteSize(UIPosition pos, int index, UISize size)
 {
     /*
      * for (int i = 0; i < spritesGroup.Length; i++) {
      *      if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
      *      {
      *              if (spritesGroup[i].sprites[index] != null)
      *              {
      *
      *
      *              }
      *
      *      }
      * }
      */
 }
예제 #16
0
 public void CreateUIObject(string Obj)
 {
     if (isOwner())
     {
         GameObject UIObj    = Resources.Load <GameObject>(Obj);
         Vector2    newUIPos = UIPosition.WorldToUI(MainUIManager.instance.canvas.GetComponent <RectTransform>(), transform.position);
         GameObject newObj   = Instantiate(UIObj, UIObj.transform.position, UIObj.transform.rotation, MainUIManager.instance.canvas.transform);
         if (newObj.GetComponent <RadiusMoveItem>() != null)
         {
             newObj.GetComponent <RadiusMoveItem>().SetStartPoint(newUIPos);
         }
         RectTransform rect = newObj.GetComponent <RectTransform>();
         rect.anchoredPosition = newUIPos;
         rect.localScale       = UIObj.transform.localScale;
     }
 }
예제 #17
0
        public UILayout(Vector2 size, Vector2 anchorOffset, UIPosition anchor = UIPosition.TopLeft, UIPosition dock = UIPosition.TopLeft, UIItem relative = null)
        {
            _Anchor       = anchor;
            _Dock         = dock;
            _Size         = size;
            _AnchorOffset = anchorOffset;
            _Relative     = relative;

            if (relative != null)
            {
                relative.Layout.Changed += CheckChange;
            }
            else
            {
                Window.Changed += () => CheckChange(null);
            }
        }
예제 #18
0
        /// <summary>
        /// Adds the info panel to the screen.
        /// </summary>
        private void AddInfoPanel()
        {
            UIPosition  position;
            UIText      uiText;
            UIInfoPanel infoPanel;

            position = new UIPosition(0, 0);

            infoPanel = new UIInfoPanel("info", position, 1);

            uiText = new UIText("currentPlayer", position, "", 0, 5,
                                UISettings.ColorInfoPanelBg,
                                ConsoleColor.White,
                                ConsoleColor.Red);

            infoPanel.Add(uiText);

            uiText = new UIText("availableInput0", position, "Available keys:",
                                0, 0, UISettings.ColorInfoPanelBg, ConsoleColor.Black,
                                UISettings.ColorInfoPanelBg);

            infoPanel.Add(uiText);

            uiText = new UIText("availableInput1", position,
                                "    [A] / [D] or [ArrowLeft] / [ArrowRight]", 0, 0,
                                UISettings.ColorInfoPanelBg, ConsoleColor.Black,
                                UISettings.ColorInfoPanelBg);

            infoPanel.Add(uiText);

            uiText = new UIText("availableInput2", position, "    [Enter]", 0, 0,
                                UISettings.ColorInfoPanelBg, ConsoleColor.Black,
                                UISettings.ColorInfoPanelBg);

            infoPanel.Add(uiText);

            uiText = new UIText("availableInput3", position, "    [ESC]", 0, 0,
                                UISettings.ColorInfoPanelBg, ConsoleColor.Black,
                                UISettings.ColorInfoPanelBg);

            infoPanel.Add(uiText);

            Screen.Add(infoPanel, UITitleRef.BottomRight);

            this.UIInfoPanelRef = infoPanel;
        }
    //creo i padri che contengono la sprite contenitore
    void initializeFather(UIPosition pos)
    {
        for (int i = 0; i < spritesGroup.Length; i++)
        {
            if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
            {
                spritesGroup[i].fatherGO = new GameObject();
                spritesGroup[i].fatherGO.transform.parent = transform;
                spritesGroup[i].fatherGO.name             = pos.ToString();

                //creo i component dell'oggetto, solo se è stata indicata una sprite contenitore, da mettere sempre, al massimo trasparente
                if (spritesGroup[i].backgroundSprite != null)
                {
                    //creo i component image e rect
                    UnityEngine.UI.Image tempImage     = spritesGroup[i].fatherGO.AddComponent <UnityEngine.UI.Image>();
                    RectTransform        rectTransform = spritesGroup[i].fatherGO.GetComponent <RectTransform>();
                    spritesGroup[i].fatherRectTransform = spritesGroup[i].fatherGO.GetComponent <RectTransform>();

                    //setto le variabili del rect
                    rectTransform.pivot     = new Vector2(0.5f, 0.5f);
                    rectTransform.sizeDelta = new Vector2(sizeVariables.backgroundSize, sizeVariables.backgroundSize);

                    if (pos == UIPosition.Left)
                    {
                        rectTransform.anchorMin        = new Vector2(0.0f, 0.5f);
                        rectTransform.anchorMax        = new Vector2(0.0f, 0.5f);
                        rectTransform.anchoredPosition = new Vector2(-positionVariables.XHidePosition, 0.0f);
                    }
                    else if (pos == UIPosition.Right)
                    {
                        rectTransform.anchorMin        = new Vector2(1.0f, 0.5f);
                        rectTransform.anchorMax        = new Vector2(1.0f, 0.5f);
                        rectTransform.anchoredPosition = new Vector2(positionVariables.XHidePosition, 0.0f);
                    }

                    //setto le sprites
                    tempImage.sprite         = spritesGroup[i].backgroundSprite;
                    tempImage.preserveAspect = true;

                    rectTransform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                }

                break;
            }
        }
    }
    public void setExclamation(UIPosition pos, int index, bool set = true)
    {
        for (int i = 0; i < spritesGroup.Length; i++)
        {
            if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
            {
                if (spritesGroup[i].spritesGroupElement.Length > index && spritesGroup[i].spritesGroupElement[index] != null)
                {
                    if (spritesGroup[i].spritesGroupElement[index].exclamationObject != null)
                    {
                        Destroy(spritesGroup[i].spritesGroupElement[index].exclamationObject);
                    }
                    if (set)
                    {
                        spritesGroup[i].spritesGroupElement[index].exclamationObject = new GameObject();
                        spritesGroup[i].spritesGroupElement[index].exclamationObject.transform.parent = spritesGroup[i].spritesGroupElement[index].imageObject.transform;
                        string tempName = pos.ToString() + "_" + spritesGroup[i].spritesGroupElement[index].ToString() + "_exclamation";
                        spritesGroup[i].spritesGroupElement[index].exclamationObject.name = tempName;

                        UnityEngine.UI.Image tempImage     = spritesGroup[i].spritesGroupElement[index].exclamationObject.AddComponent <UnityEngine.UI.Image>();
                        RectTransform        rectTransform = spritesGroup[i].spritesGroupElement[index].exclamationObject.GetComponent <RectTransform>();

                        rectTransform.anchorMin = new Vector2(1.0f, 0.0f);
                        rectTransform.anchorMax = new Vector2(1.0f, 0.0f);
                        rectTransform.pivot     = new Vector2(1.0f, 0.0f);

                        //setto la dimensione
                        int tempSize = sizeVariables.exclamationSize;
                        rectTransform.sizeDelta = new Vector2(tempSize, tempSize);

                        //setto le sprites
                        tempImage.sprite = exclamationMark;

                        tempImage.preserveAspect = true;

                        rectTransform.localScale = new Vector3(1.0f, 1.0f, 1.0f);

                        //float YPosition = returnSpritePosition(firstYPosition, spritesGroup[i].spritesGroupElement.Length - j - 1);
                        rectTransform.anchoredPosition = new Vector2(0.0f, 0.0f);
                    }
                }
                break;
            }
        }
    }
예제 #21
0
        /// <summary>
        /// Adds the game's board to the screen.
        /// </summary>
        /// <param name="board"></param>
        public void AddBoard(Board board)
        {
            UIPosition   position;
            UIFelliBoard felliBoard;

            position = new UIPosition(0, 1);

            felliBoard = new UIFelliBoard("board", position, board)
            {
                IsCentered = true
            };

            Screen.Add(felliBoard, UITitleRef.BottomMiddle);

            this.UIBoardRef = felliBoard;

            AddInfoPanel();
        }
 public void showIconsImmediately(UIPosition pos, bool show = true)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             if (spritesGroup[i].fatherRectTransform != null)
             {
                 float actualXPosition = spritesGroup[i].fatherRectTransform.anchoredPosition.x;
                 float objPosition     = 0.0f;
                 if (show)
                 {
                     spritesGroup[i].hiding  = false;
                     spritesGroup[i].showing = true;
                     if (spritesGroup[i].position == UIPosition.Right)
                     {
                         objPosition = -positionVariables.XShowPosition;
                     }
                     else if (spritesGroup[i].position == UIPosition.Left)
                     {
                         objPosition = positionVariables.XShowPosition;
                     }
                 }
                 else
                 {
                     spritesGroup[i].hiding  = true;
                     spritesGroup[i].showing = false;
                     if (spritesGroup[i].position == UIPosition.Right)
                     {
                         objPosition = positionVariables.XHidePosition;
                     }
                     else if (spritesGroup[i].position == UIPosition.Left)
                     {
                         objPosition = -positionVariables.XHidePosition;
                     }
                 }
                 //actualXPosition = Mathf.MoveTowards(actualXPosition, objPosition, positionVariables.speedChangingPosition * Time.deltaTime);
                 spritesGroup[i].fatherRectTransform.anchoredPosition = new Vector2(objPosition, spritesGroup[i].fatherRectTransform.anchoredPosition.y);
             }
             break;
         }
     }
 }
예제 #23
0
        private void Border_norml_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Border     border = sender as Border;
            UIPosition week   = border.DataContext as UIPosition;

            if (week.PositionType != XYKernel.OS.Common.Enums.Position.AB &&
                week.PositionType != XYKernel.OS.Common.Enums.Position.PB &&
                week.PositionType != XYKernel.OS.Common.Enums.Position.Noon)
            {
                var isChecked = week.IsMondayChecked;

                week.IsMondayChecked    = !isChecked;
                week.IsTuesdayChecked   = !isChecked;
                week.IsWednesdayChecked = !isChecked;
                week.IsThursdayChecked  = !isChecked;
                week.IsFridayChecked    = !isChecked;
                week.IsSaturdayChecked  = !isChecked;
                week.IsSundayChecked    = !isChecked;
            }
        }
예제 #24
0
        /// <summary>
        /// Displays the end game screen.
        /// </summary>
        /// <param name="winner">Optional. If a player is provided he will be
        /// congratulated for the win.</param>
        public void DisplayEndGameScreen(Player winner = null)
        {
            string     content;
            UITitle    gameOver;
            UIPosition pos = new UIPosition(0, 0);

            Screen.Clear();

            content = "Game Over!";

            if (winner != null)
            {
                content += $" {winner.Name} has won! Congratulations!";
            }

            gameOver = new UITitle("gameover", pos, content, 30, 2);

            Screen.Add(gameOver);

            RefreshUI();
        }
예제 #25
0
        /// <summary>
        /// Add a new <see cref="UIElement"/> to the screen.
        /// </summary>
        /// <param name="newElement">The new <see cref="UIElement"/>.</param>
        public void Add(UIElement newElement)
        {
            UIPosition delta;

            // If element isn't respecting the screen's margins...
            if (newElement.TopLeft.X < marginLeft || newElement.TopLeft.Y < marginTop)
            {
                // ...calculate necessary move...
                delta = new UIPosition(marginLeft - newElement.TopLeft.X,
                                       marginTop - newElement.TopLeft.Y);

                // ...and make it.
                newElement.Move(delta);
            }

            if (newElement.IsCentered)
            {
                newElement.Move(new UIPosition(-(newElement.Width / 2), 0));
            }

            Elements.Add(newElement);
        }
 public int getSpritesGroupSize(UIPosition pos)
 {
     for (int i = 0; i < spritesGroup.Length; i++)
     {
         if (spritesGroup[i].position != null && spritesGroup[i].position == pos)
         {
             if (spritesGroup[i].size == UISize.Big)
             {
                 return(sizeVariables.bigSprites);
             }
             else if (spritesGroup[i].size == UISize.Normal)
             {
                 return(sizeVariables.normalSprites);
             }
             else if (spritesGroup[i].size == UISize.Small)
             {
                 return(sizeVariables.smallSprites);
             }
         }
     }
     return(0);
 }
 //metodo da chiamare per aggiornare le sprites a schermo
 //potrebbe essere chiamata automaticamente ad ogni aggiornamento, ma preferisco lasciare la scelta al programmatore
 public void updateSpritesOnScreen(UIPosition pos)
 {
     createObject(pos);
 }
예제 #28
0
 /// <summary>
 /// Selects this wire
 /// </summary>
 public override bool Select(DesignerSelectionMode mode, PlatformVisual source, ElementSelection elementSelection, UIPosition position)
 {
     ((SplineWireControl)this.View.AsFrameworkElement).Stroke = Brushes.Orange;
     return(base.Select(mode, source, elementSelection, position));
 }
예제 #29
0
        public static CCPoint ToPoint(this UIPosition pos, CCRect bounds)
        {
            float x, y;

            switch (pos)
            {
            case UIPosition.Left1:
                x = 0;
                y = bounds.MaxY;
                break;

            case UIPosition.Left2:
                x = 0;
                y = bounds.MaxY - Core.Globals.UIButtonSize;
                break;

            case UIPosition.Left3:
                x = 0;
                y = bounds.MaxY - Core.Globals.UIButtonSize * 2;
                break;

            case UIPosition.Left4:
                x = 0;
                y = bounds.MaxY - Core.Globals.UIButtonSize * 3;
                break;

            case UIPosition.Left5:
                x = 0;
                y = Core.Globals.UIButtonSize;
                break;

            case UIPosition.Right1:
                x = bounds.MaxX - Core.Globals.UIButtonSize;
                y = bounds.MaxY;
                break;

            case UIPosition.Right2:
                x = bounds.MaxX - Core.Globals.UIButtonSize;
                y = bounds.MaxY - Core.Globals.UIButtonSize;
                break;

            case UIPosition.Right3:
                x = bounds.MaxX - Core.Globals.UIButtonSize;
                y = bounds.MaxY - Core.Globals.UIButtonSize * 2;
                break;

            case UIPosition.Right4:
                x = bounds.MaxX - Core.Globals.UIButtonSize;
                y = bounds.MaxY - Core.Globals.UIButtonSize * 3;
                break;

            case UIPosition.Right5:
                x = bounds.MaxX - Core.Globals.UIButtonSize;
                y = Core.Globals.UIButtonSize;
                break;

            default:
                throw new System.Exception("Invalid UIPosition");
            }
            return(new CCPoint(x, y));
        }
예제 #30
0
 public UIScrollMenu(UIPosition boundsStart, UIPosition boundsEnd)
     : base(boundsStart, boundsEnd)
 {
 }