Exemplo n.º 1
0
        public bool DrawList(List <List <Card> > cList)
        {
            bool isMoving     = true;
            int  maxPerColumn = 0;

            foreach (List <Card> list in cList)
            {
                maxPerColumn = Mathf.Max(list.Count, maxPerColumn);
            }

            for (int i = 0; i < maxPerColumn; i++)
            {
                for (int j = cList.Count - 1; j >= 0; j--)
                {
                    if (i >= cList[j].Count)
                    {
                        continue;
                    }

                    Card temp = cList[j][i];

                    if (temp.isMoving)
                    {
                        isMoving = false;
                    }
                    else
                    {
                        if (isExpanded && isReady && temp.GetRect().Contains(Event.current.mousePosition))
                        {
                            mouseOverList.Insert(0, temp);
                        }
                    }

                    if (temp == lastCardToDraw)
                    {
                        continue;
                    }

                    temp.Draw();
                }
            }

            return(isMoving);
        }
Exemplo n.º 2
0
        void OnGUI()
        {
            if (cardList.Count > 0)
            {
                GUI.depth = 0;

                GUI.BeginGroup(windowRect, GUI.skin.box);
                GUIStyle style = new GUIStyle(GUI.skin.label);
                style.alignment = TextAnchor.UpperCenter;
                style.font      = font;
                style.fontSize  = 18;

                bool isMovingA = DrawList(predatorList), isMovingB = DrawList(preyList);

                isReady = isMovingA && isMovingB;

                if (isExpanded)
                {
                    float y = Mathf.Min(
                        predatorList.Count > 0 ? predatorList[0][0].y : cardList[0].y,
                        preyList.Count > 0 ? preyList[0][0].y : cardList[0].y
                        );

                    style.normal.textColor = Color.red;
                    GUI.Label(new Rect(cardList[0].x - 145, y - 40, 100, 30), "Predators", style);

                    style.normal.textColor = Color.green;
                    GUI.Label(new Rect(cardList[0].x + 205, y - 40, 100, 30), "Preys", style);
                }

                if (lastCardToDraw != null)
                {
                    lastCardToDraw.Draw();
                }

                for (int i = cardList.Count - 1; i >= 0; i--)
                {
                    cardList[i].Draw();

                    if (cardList[i] == lastCardToDraw)
                    {
                        Functions.DrawBackground(lastCardToDraw.GetRect(), selectTexture, Color.yellow);
                    }

                    if (cardList[i].GetRect().Contains(Event.current.mousePosition))
                    {
                        mouseOverList.Insert(0, cardList[i]);
                    }
                }

                if (GUI.Button(new Rect(cardList[0].x + (cardList[0].width - 80) / 2, cardList[0].y + cardList[0].height + 10, 80, 30), "Close"))
                {
                    Destroy(this);
                }
                GUI.EndGroup();

                if (lastCardToDraw != null && !cardList.Contains(lastCardToDraw))
                {
                    Functions.DrawBackground(lastCardToDraw.GetRect(), selectTexture, lastCardToDraw.color);
                }
            }
        }
Exemplo n.º 3
0
        public void DrawCard(Card card)
        {
            Color color = Color.clear;
            if (selected != null) {
            if (card.name == selected) {
                color = Color.blue;  //.yellow;
            } else if (card.species.preyList.ContainsValue (selected)) {
                color = Color.red;
            } else if (card.species.predatorList.ContainsValue (selected)) {
                color = Color.green;
            }
            }

            if (color == Color.clear || card.name == selected) {
            card.color = Color.black;
            } else {
            card.color = color;
            }

            //jtc - override with info from manager
            string name = manager.MatchSeriesLabel (card.name);
            if (name != null) {
            color = manager.seriesColors [name];
            card.color = color;

            }
            card.Draw ();

            // Selection
            if (color != Color.clear) {
            Functions.DrawBackground (card.GetRect (), cardHighlightFullTexture, color);

            if (card.name == selected && card.species.preyList.ContainsValue (selected)) { // Prey = Self
                Functions.DrawBackground (new Rect (card.x + 5, card.y + 5, card.width - 10, card.height - 10),
                                          cardHighlightFullTexture,
                                          Color.green
                );
            }
            }

            if (card.GetRect ().Contains (Event.current.mousePosition)) {
            mouseOverList.Add (card.name);

            Functions.DrawBackground (card.GetRect (), cardHighlightTexture, Color.yellow);
            }

            if (GUI.Button (card.GetRect (), "", GUIStyle.none)) {
            if (card.name == selected) {
                selected = null;
            } else {
                selected = card.name;
            }
            }
        }
Exemplo n.º 4
0
        public void DrawCard(Card card)
        {
            Color color = Color.clear;

            if (selected != null)
            {
                if (card.name == selected)
                {
                    color = Color.blue;              //.yellow;
                }
                else if (card.species.preyList.ContainsValue(selected))
                {
                    color = Color.red;
                }
                else if (card.species.predatorList.ContainsValue(selected))
                {
                    color = Color.green;
                }
            }

            if (color == Color.clear || card.name == selected)
            {
                card.color = Color.black;
            }
            else
            {
                card.color = color;
            }

            //jtc - override with info from manager
            string name = manager.MatchSeriesLabel(card.name);

            if (name != null)
            {
                color      = manager.seriesColors [name];
                card.color = color;
            }
            card.Draw();

            // Selection
            if (color != Color.clear)
            {
                Functions.DrawBackground(card.GetRect(), cardHighlightFullTexture, color);

                if (card.name == selected && card.species.preyList.ContainsValue(selected))            // Prey = Self
                {
                    Functions.DrawBackground(new Rect(card.x + 5, card.y + 5, card.width - 10, card.height - 10),
                                             cardHighlightFullTexture,
                                             Color.green
                                             );
                }
            }

            if (card.GetRect().Contains(Event.current.mousePosition))
            {
                mouseOverList.Add(card.name);

                Functions.DrawBackground(card.GetRect(), cardHighlightTexture, Color.yellow);
            }

            if (GUI.Button(card.GetRect(), "", GUIStyle.none))
            {
                if (card.name == selected)
                {
                    selected = null;
                }
                else
                {
                    selected = card.name;
                }
            }
        }