Пример #1
0
 void BeginBuild(Building b)
 {
     if (Selected && Selected.GetType() == typeof(MakeBuilding) && ((MakeBuilding)Selected).GetBuilding().GetType() == b.GetType())
     {
         Deselect();
     }
     else
     {
         MakeBuilding f = (MakeBuilding)CreateFragment("MakeBuilding");
         f.Build(b);
         //if(MakeBuilding.CanBuild(b)){
         Select(f);
         //}else{
         //	setInfoFragment(f);
         //	Destroy(f.gameObject);
         //}
     }
 }
Пример #2
0
    //* GUI Display *//
    void OnGUI()
    {
        if (!drawGUI)
        {
            return;
        }

        GUI.skin = GeneralManager.getStyle();

        //Don't Draw anything if it's paused
        if (GM.Paused)
        {
            return;
        }


        //* Display Alert for items *//
        if (getFragCount(GM.PlayerMan.CurrTurn) >= MAX_FRAGS)
        {
            fragGlowTime++;
            if (fragGlowTime > maxFragGlowTime * 2)
            {
                fragGlowTime = 0;
            }
        }
        else
        {
            fragGlowTime = 0;
        }

        GUI.color = new Color(1, 0, .15f, (1 - (float)fragGlowTime / maxFragGlowTime) * .45f);

        const int sizeDelta = 550;
        float     f         = (float)fragGlowTime / maxFragGlowTime;

        //f = Mathf.Sqrt(f);

        GUI.DrawTexture(new Rect(Screen.width - (sizeDelta / 2) * f - sizeDelta / 4, (-sizeDelta / 4.0f) * f, sizeDelta * f, (sizeDelta / (2.0f)) * f), (Texture2D)Resources.Load("GUITextures/glowDot", typeof(Texture2D)), ScaleMode.StretchToFill, true);
        //GUI.DrawTexture(new Rect(-sizeDelta/2,0,sizeDelta * f,(sizeDelta/2)*f), (Texture2D)Resources.Load("guiTex/glowDot",typeof(Texture2D)),ScaleMode.ScaleToFit,true);
        GUI.color = new Color(1, 1, 1);


        GUIStyle s2 = GUI.skin.GetStyle("Label");

        s2.alignment = TextAnchor.UpperLeft;

        GUIStyle butStyle = GUI.skin.GetStyle("Button");

        butStyle.padding = new RectOffset(2, 2, 2, 2);

        //* Draw Player Boxes *//
        for (int i = 0; i < GM.PlayerMan.PlayerCount; i++)
        {
            //* Define box postions and heights *//
            int w = 250;
            int h = 75;

            int x       = Screen.width - w - 5;
            int y       = 5 + i * h + 10 * i;
            int fragDim = 50;

            Color c = GUI.color;
            //* Make the player's box more opaque if it is that user's ture *//
            if (i == GM.PlayerMan.CurrTurn)
            {
                c.a = 1.0f;
            }
            else
            {
                c.a = .4f;
            }
            GUI.color = c;

            //* Draw the background for the box*//
            GUI.DrawTexture(
                new Rect(x - 5, y, w + 10, h + 5),
                (Texture2D)Resources.Load("GUITextures/PlayerInfoBox"));


            //* Draw the player label *//
            GUI.Label(
                new Rect(x, y + 2, w / 2, 20),
                "Player " + (i + 1));

            //* Draw the icon labels *//
            GUI.DrawTexture(
                new Rect(x + w - w / 2, y, w / 2, 25),
                (Texture2D)Resources.Load("GUITextures/BuildFragIcons"));

            //* Draw the values for the frags *//
            GUI.Label(
                new Rect(x + w - w / 2 + 25, y + 2, w / 2, 20),
                GemFrags[i] + "");
            GUI.Label(
                new Rect(x + w - w / 2 + 66, y + 2, w / 2, 20),
                WoodFrags[i] + "");
            GUI.Label(
                new Rect(x + w - w / 2 + 107, y + 2, w / 2, 20),
                StoneFrags[i] + "");
            //get the gui color
            //* Draw the frag buttons/icons *//
            for (int j = 0; j < MAX_FRAGS; j++)
            {
                Fragment tempFrag = PlayerFrags[i, j];

                // make it transparent
                c.a = .5f;
                //if its selected make it solid
                if (getSelected() == tempFrag)
                {
                    c.a = 1.0f;
                }
                GUI.color = c;

                if (tempFrag)
                {
                    Texture2D icon = (Texture2D)Resources.Load("GUITextures/FragmentIcons/" + tempFrag.GetType(), typeof(Texture2D));


                    if (tempFrag.Fresh && i == GM.PlayerMan.CurrTurn)
                    {
                        c.a       = .25f;
                        GUI.color = c;

                        if (icon)
                        {
                            GUI.DrawTexture(
                                new Rect(x + fragDim * j, y + 25, fragDim, fragDim),
                                icon, ScaleMode.ScaleToFit);
                        }
                        else
                        {
                            GUI.Label(
                                new Rect(x + fragDim * j, y + 25, fragDim, fragDim),
                                tempFrag.GetType().ToString());
                        }
                    }
                    else
                    {
                        if ((new Rect(x + fragDim * j, Screen.height - (y + 25) - fragDim, fragDim, fragDim)).Contains(Input.mousePosition))
                        {
                            if (c.a != 1.0f)
                            {
                                c.a = .75f;
                            }
                            if (Input.GetMouseButton(0))
                            {
                                c.a = .6f;
                            }
                        }
                        else if (c.a != 1.0f)
                        {
                            c.a = .6f;
                        }

                        GUI.color = c;

                        bool buttonDo = false;

                        if (icon)
                        {
                            buttonDo = GUI.Button(
                                new Rect(x + fragDim * j, y + 25, fragDim, fragDim),
                                icon);
                        }
                        else
                        {
                            buttonDo = GUI.Button(
                                new Rect(x + fragDim * j, y + 25, fragDim, fragDim),
                                tempFrag.GetType().ToString());
                        }

                        if (buttonDo)
                        {
                            if (GM.PlayerMan.CurrTurn == i)
                            {
                                Select(j);
                            }
                            else
                            {
                                if (Selected)
                                {
                                    Deselect();
                                }
                                setInfoFragment(PlayerFrags[i, j]);
                            }
                        }
                    }
                }
            }
            //always make the color 1 again
            c.a       = 1.0f;
            GUI.color = c;
        }

        //* Display name and instructions of current selected fragment *//
        if (infoDisplayFrag)
        {
            GUI.Label(new Rect(Screen.width - 250, 220, 250, 25), infoDisplayFrag.getName(), s2);
            GUI.Label(new Rect(Screen.width - 250, 247, 250, 200), infoDisplayFrag.getDescription(), s2);
        }


        // TODO: Display the buttons as transparent if they cannot be built (or something like that)

        if (MakeBuilding.CanBuild(Building_Shrine) || true)
        {
            //GUI.Label(new Rect(85,5,110,50),"SG: " + Building_Shrine.getGem() + "\nW: " + Building_Shrine.getWood() + "\nS: " + Building_Shrine.getStone());
            GUI.Label(new Rect(100, 5, 110, 50), CountGem(GM.PlayerMan.CurrTurn) + "/" + Building_Shrine.getGem() + "\n" + CountWood(GM.PlayerMan.CurrTurn) + "/" + Building_Shrine.getWood() + "\n" + CountStone(GM.PlayerMan.CurrTurn) + "/" + Building_Shrine.getStone());
            GUI.DrawTexture(new Rect(80, 10, 20, 40), (Texture2D)Resources.Load("GUITextures/BuildFragIconsButton"));


            if (GUI.Button(new Rect(5, 5, 75, 50), "Build\nShrine") /*&& MakeBuilding.CanBuild(Building_Shrine)*/)
            {
                BeginBuild(Building_Shrine);
            }
        }
        if (MakeBuilding.CanBuild(Building_Church) || true)
        {
            //GUI.Label(new Rect(85,60,110,50),"SG: " + Building_Church.getGem() + "\nW: " + Building_Church.getWood() + "\nS: " + Building_Church.getStone());

            GUI.Label(new Rect(100, 60, 110, 50), CountGem(GM.PlayerMan.CurrTurn) + "/" + Building_Church.getGem() + "\n" + CountWood(GM.PlayerMan.CurrTurn) + "/" + Building_Church.getWood() + "\n" + CountStone(GM.PlayerMan.CurrTurn) + "/" + Building_Church.getStone());
            GUI.DrawTexture(new Rect(80, 65, 20, 40), (Texture2D)Resources.Load("GUITextures/BuildFragIconsButton"));

            if (GUI.Button(new Rect(5, 60, 75, 50), "Build\nTemple") /*&& MakeBuilding.CanBuild(Building_Church)*/)
            {
                //GM.FragMan.Collect (CreateFragment(FragType.KINGS_RING));
                BeginBuild(Building_Church);
            }
        }
        //GUI.Button(new Rect(65, 10, 100,100), "Shrine");

        //* Display current plane along with amount of souls per level *//
        SoulHost[] sh        = (SoulHost[])Component.FindObjectsOfType(typeof(SoulHost));
        int[]      soulCount = new int[3] {
            0, 0, 0
        };

        for (int i = 0; i < sh.Length; i++)
        {
            Unit uh = (Unit)sh[i].GetComponent("Unit");
            if (uh.Player == GM.PlayerMan.CurrTurn && !sh[i].Dug)
            {
                if (uh.CurrentTile.transform.parent.tag == "HighPlane")
                {
                    soulCount[2]++;
                }
                else if (uh.CurrentTile.transform.parent.tag == "MidPlane")
                {
                    soulCount[1]++;
                }
                else if (uh.CurrentTile.transform.parent.tag == "LowPlane")
                {
                    soulCount[0]++;
                }
            }
        }

        //* Display for which Plane is currently being viewed *//
        for (int i = 0; i < 3; i++)
        {
            int delta = 0;
            if (GM.PlaneMan.getDestPlane() < i)
            {
                delta = 45;
            }
            if (GM.PlaneMan.getDestPlane() != i)
            {
                GUI.color = new Color(.375f, .35f, .4f);
            }
            GUI.DrawTexture(new Rect(10, Screen.height - 100 - i * 30 - delta, 125, 125), (Texture2D)Resources.Load("GUITextures/GuiPlane", typeof(Texture2D)), ScaleMode.ScaleToFit, true);
            //GUI.Button(new Rect(10,300 - i*20 - delta,100,45), (i+1)+"");
            GUI.color = new Color(1.0f, 1.0f, 1.0f);

            GUI.Label(new Rect(140, Screen.height - 100 - i * 30 - delta + 50, 125, 125), soulCount[i] + "");
        }
    }