Beispiel #1
0
    //draw the description and any needed buttons or arrows based on the required state
    void OnGUI()
    {
        //if the game is paused, do not draw the tutorial gui elements
        if (GM.Paused)
        {
            return;
        }

        //set the style for gui elements
        GUI.skin = GeneralManager.getStyle();
        if (!arrowTex)
        {
            arrowTex = (Texture2D)Resources.Load("guiTex/arrow", typeof(Texture2D));
        }

        GUI.depth = -1;

        GUIStyle gs = new GUIStyle();

        gs.alignment        = TextAnchor.UpperLeft;
        gs.normal.textColor = new Color(1, 1, 1, 1);
        gs.wordWrap         = true;

        GUI.Box(new Rect(175, 10, 300, 200), "");
        GUI.Label(new Rect(185, 10, 280, 200), Title);
        GUI.Label(new Rect(185, 10, 280, 200), "\n\n\t" + TutDesc, gs);


        if (tState == States.EXPLAIN)
        {
            //create the next button to move onto the next step
            if (
                GUI.Button(new Rect(175, 215, 300, 50), "Next")
                )
            {
                setState(States.SELECT);
            }
        }
        else if (tState == States.SELECT)
        {
            //point to the unit that should be selected
            if (firstUnit)
            {
                SoulHost u = (SoulHost)firstUnit.GetComponent("SoulHost");
                Vector3  v = Camera.main.WorldToScreenPoint(u.transform.position);

                GUIUtility.RotateAroundPivot(180, new Vector2(v.x, Screen.height - v.y));
                GUI.DrawTexture(new Rect(v.x - 95, Screen.height - v.y, 100, 100), arrowTex, ScaleMode.ScaleToFit);
            }
        }
        else if (tState == States.MOVEMENT)
        {
        }
        else if (tState == States.ELEVATION || tState == States.ELEVATION_LOW)
        {
            //point to the tile around with tiles have elevated
            drawArrow(ElevationTile.transform.position, new Vector2(100, 100), 90);
        }
        else if (tState == States.DIGGING)
        {
            //point to a unit in order to dig
            if (!GM.UnitMan.getSelected() && firstUnit)
            {
                SoulHost u = (SoulHost)firstUnit.GetComponent("SoulHost");
                Vector3  v = Camera.main.WorldToScreenPoint(u.transform.position);

                GUIUtility.RotateAroundPivot(180, new Vector2(v.x, Screen.height - v.y));
                GUI.DrawTexture(new Rect(v.x - 95, Screen.height - v.y, 100, 100), arrowTex, ScaleMode.ScaleToFit);
            }
        }
        else if (tState == States.TURN_CHANGE)
        {
            //point to the turn change arrow in the bottom right
            Vector2 v = new Vector2(Screen.width - 50, Screen.height - 125);
            GUIUtility.RotateAroundPivot(90, new Vector2(v.x, v.y));
            GUI.DrawTexture(new Rect(v.x - 95, v.y, 150, 150), arrowTex, ScaleMode.ScaleToFit);
        }
        else if (tState == States.SOUL_GENERATION)
        {
            SoulWellTurnChange[] sw = (SoulWellTurnChange[])Component.FindObjectsOfType(typeof(SoulWellTurnChange));

            //find the users soul well where units are generated
            for (int i = 0; i < sw.Length; i++)
            {
                Unit u = sw[i].GetComponent <Unit>();
                if (u.Player == 0)
                {
                    drawArrow(u.transform.position, new Vector2(100, 100), 90);
                    Tile t     = u.CurrentTile;
                    int  count = 0;
                    //point to two souls that were generated around the soul well
                    for (int j = 0; j < t._adjacentTiles.Length; j++)
                    {
                        if (t._adjacentTiles[j] && t._adjacentTiles[j].Resident)
                        {
                            drawArrow(t._adjacentTiles[j].Resident.transform.position + new Vector3(0, 3, 0), new Vector2(50, 50), 90);
                            count++;
                            if (count == 2)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
        else if (tState == States.USE_ITEMS)
        {
            //point the the items that the user has in the upper right
            Vector2 v = new Vector2(Screen.width - 100, 45);
            GUIUtility.RotateAroundPivot(0, new Vector2(v.x, v.y));
            GUI.DrawTexture(new Rect(v.x - 95, v.y, 150, 150), arrowTex, ScaleMode.ScaleToFit);
        }
        else if (tState == States.TILE_RICHNESS)
        {
            //point to the most rich tiles in the world
            Tile[] tiles = (Tile[])Component.FindObjectsOfType(typeof(Tile));
            for (int i = 0; i < tiles.Length; i++)
            {
                if (tiles[i].getRichness() == Tile.MAX_RICHNESS)
                {
                    drawArrow(tiles[i].transform.position, new Vector2(50, 50), 90);
                }
            }
        }
        else if (tState == States.COLLECT_GEMS)
        {
        }
        else if (tState == States.RESOURCE_LIST)
        {
            //point to the list of resources in the upper right
            drawArrow(new Vector2(Screen.width - 105, Screen.height - 15), new Vector2(100, 100), 0);
        }
        else if (tState == States.BUILD)
        {
            //if the user needs to build, point to the build shrine button
            if (GM.FragMan.getSelected() && GM.FragMan.getSelected().GetType() != typeof(MakeBuilding) || !GM.FragMan.getSelected())
            {
                Vector2 v = new Vector2(35, 80);
                GUIUtility.RotateAroundPivot(-75, new Vector2(v.x, v.y));
                GUI.DrawTexture(new Rect(v.x - 95, v.y, 150, 150), arrowTex, ScaleMode.ScaleToFit);
                //if the user has already selected to build, point to the foundation tiels where shrines can be built
            }
            else if (GM.FragMan.getSelected() && GM.FragMan.getSelected().GetType() == typeof(MakeBuilding))
            {
                for (int i = 0; i < FoundationTiles.Length; i++)
                {
                    Tile    t = FoundationTiles[i];
                    Vector3 v = Camera.main.WorldToScreenPoint(t.transform.position);
                    GUIUtility.RotateAroundPivot(75, new Vector2(v.x, Screen.height - v.y));
                    GUI.DrawTexture(new Rect(v.x - 95, Screen.height - v.y, 100, 100), arrowTex, ScaleMode.ScaleToFit);
                    GUIUtility.RotateAroundPivot(-75, new Vector2(v.x, Screen.height - v.y));
                }
            }
        }
        else if (tState == States.MERGING || tState == States.MERGE_FOUR)
        {
        }
        else if (tState == States.MOVE_TO_GLOW)
        {
            Soul[] s = (Soul[])Component.FindObjectsOfType(typeof(Soul));

            for (int i = 0; i < s.Length; i++)
            {
                // if there is a unit with four souls
                if (s[i].Souls >= 4)
                {
                    Shrine sh = (Shrine)Component.FindObjectOfType(typeof(Shrine));
                    Unit   u  = (Unit)sh.GetComponent("Unit");
                    Tile   t2 = u.CurrentTile;
                    //point to highlighted tiles around the shrines in the scene
                    for (int j = 0; j < t2._adjacentTiles.Length; j++)
                    {
                        Tile    t = t2._adjacentTiles[j];
                        Vector3 v = Camera.main.WorldToScreenPoint(t.transform.position);
                        v.y += 30;
                        v.x -= 10;
                        GUIUtility.RotateAroundPivot(75, new Vector2(v.x, Screen.height - v.y));
                        GUI.DrawTexture(new Rect(v.x, Screen.height - v.y, 30, 30), arrowTex, ScaleMode.ScaleToFit);
                        GUIUtility.RotateAroundPivot(-75, new Vector2(v.x, Screen.height - v.y));
                    }
                    return;
                }
            }
        }
        else if (tState == States.ASCEND)
        {
            //draw an arrow pointing to the turn change button in the bottom right
            drawArrow(new Vector2(Screen.width - 40, 65), new Vector2(100, 100), 90);
        }
        else if (tState == States.COLLECT_TREE)
        {
            //point to grown tress in the world to show what needs to be harvested
            TreeFragment[] t = (TreeFragment[])Component.FindObjectsOfType(typeof(TreeFragment));

            for (int i = 0; i < t.Length; i++)
            {
                if (t[i].Growth >= TreeFragment.MAX_GROWTH)
                {
                    drawArrow(t[i].transform.position + new Vector3(0, 10, 0), new Vector2(25, 25), 90);
                }
            }
        }
        else if (tState == States.EXPLAIN_TEMPLE)
        {
            // Point to the Build Temple button in the top left
            Vector2 v = new Vector2(35, 160);
            GUIUtility.RotateAroundPivot(-75, new Vector2(v.x, v.y));
            GUI.DrawTexture(new Rect(v.x - 95, v.y, 150, 150), arrowTex, ScaleMode.ScaleToFit);
        }
        else if (tState == States.WIN)
        {
            // point to the soul vessel of the first player, idicating that he needs to merge to it
            SoulVessel[] sv = (SoulVessel[])Component.FindObjectsOfType(typeof(SoulVessel));
            for (int i = 0; i < sv.Length; i++)
            {
                Unit u = (Unit)sv[i].GetComponent("Unit");
                if (u.Player == 0)
                {
                    drawArrow(u.transform.position + new Vector3(0, 12, 0), new Vector2(100, 100), 180);
                }
            }
        }
        else if (tState == States.MAIN_MENU)
        {
            //Draw buttons to go to advanced tutorial, or back to main menu
            if (
                GUI.Button(new Rect(175, 215, 300, 50), "Main Menu")
                )
            {
                Application.LoadLevel(0);
            }
            if (
                GUI.Button(new Rect(175, 270, 300, 50), "Learn Advanced Tactics")
                )
            {
                setState(States.ADVANCED_TACTIC);
            }
        }
        else if (tState == States.ADVANCED_TACTIC ||
                 tState == States.KILL_SOUL ||
                 tState == States.KILL_SHRINE
                 )
        {
            //point to the surrounding souls around the tile of interest
            Tile[] t        = ElevationTile._adjacentTiles;
            bool   selected = false;
            for (int i = 0; i < t.Length; i++)
            {
                if (t[i].Resident == GM.UnitMan.getSelected() && t[i].Resident != null)
                {
                    selected = true;
                    break;
                }
            }

            //if one of the units is already selected, do not point to it, and instead point to the center
            if (!selected)
            {
                for (int i = 0; i < t.Length; i++)
                {
                    if (t[i].Resident)
                    {
                        drawArrow(t[i].transform.position + new Vector3(0, 3, 0), new Vector2(50, 50), 90);
                    }
                }
            }
            else
            {
                drawArrow(ElevationTile.transform.position + new Vector3(0, 1, 0), new Vector2(100, 100), 90);
            }
        }
        else if (tState == States.END_ADVANCED)
        {
            if (
                GUI.Button(new Rect(175, 215, 300, 50), "Main Menu")
                )
            {
                Application.LoadLevel(0);
            }
        }

        //drawn if a next button is needed
        if (nextButton != -1)
        {
            if (
                GUI.Button(new Rect(175, 215, 300, 50), "Next")
                )
            {
                setState((States)nextButton);
            }
        }
        GUI.depth = 0;
    }