예제 #1
0
    //called when the current selected unit has a host - used to validate tiles
    override public bool UpdateValidatedTiles()
    {
        SoulHost[] sh = (SoulHost[])Component.FindObjectsOfType(typeof(SoulHost));

        if (!first)
        {
            for (int i = 0; i < sh.Length; i++)
            {
                ((Unit)sh[i].GetComponent("Unit")).CurrentTile.Validate();
            }
        }
        else
        {
            string tag = ((Unit)first.GetComponent("Unit")).CurrentTile.transform.parent.tag;

            Unit fu = ((Unit)first.GetComponent("Unit"));
            //fu.CurrentTile.Validate();

            for (int i = 0; i < sh.Length; i++)
            {
                Unit u = ((Unit)sh[i].GetComponent("Unit"));

                if (fu.Player == u.Player)
                {
                    continue;
                }

                Tile t = u.CurrentTile;
                if (t.transform.parent.tag == tag)
                {
                    t.Validate();
                }
            }
        }

        return(true);
    }
예제 #2
0
    //Check the tutorial state and act accordingly
    void Update()
    {
        GM.FragMan.Building_Shrine.Gem = 1;

        SoulHost[] sh    = (SoulHost[])Component.FindObjectsOfType(typeof(SoulHost));
        Unit[]     units = (Unit[])Component.FindObjectsOfType(typeof(Unit));
        Soul[]     souls = (Soul[])Component.FindObjectsOfType(typeof(Soul));

        if (tState == States.EXPLAIN)
        {
            // start at showing all planes and explaining them
            GM.UnitMan.Deselect();
            GM.PlaneMan.setDestPlane(0);
            GM.PlaneMan.viewAllPlanes = true;

            if (!firstUnit)
            {
                for (int i = 0; i < sh.Length; i++)
                {
                    if (sh[i].getUnit().CurrentTile.transform.parent.tag == "LowPlane")
                    {
                        firstUnit = sh[i];
                        break;
                    }
                }
            }
            // SELECT TUTORIAL //
        }
        else if (tState == States.SELECT)
        {
            //move on when a soul has been selected
            GM.PlaneMan.viewAllPlanes = false;
            GM.PlaneMan.setDestPlane(0);
            if (GM.UnitMan.getSelected() && GM.UnitMan.getSelected().Player == 0)
            {
                setState(States.MOVEMENT);
            }
            // MOVEMENT TUTORIAL //
        }
        else if (tState == States.MOVEMENT)
        {
            //continue when a soul has been moved
            GM.PlaneMan.setDestPlane(0);
            if (!GM.UnitMan.getSelected() || GM.UnitMan.getSelected().Player != 0)
            {
                setState(States.SELECT);
            }

            if (GM.UnitMan.getSelected() && GM.UnitMan.getSelected().isMoving())
            {
                setState(States.ELEVATION);
            }
            //ELEVATION TUTORIAL //
        }
        else if (tState == States.ELEVATION)
        {
            //shows how elevation effects movement
            //creates a unit to be placed at the tile
            if (!ElevationTile.Resident)
            {
                GM.PlayerMan.CreateUnit(ElevationTile, GM.PlayerMan.instance_BasicSoul);
            }
            else
            {
                if (GM.UnitMan.getSelected() != ElevationTile.Resident)
                {
                    GM.UnitMan.Select(ElevationTile.Resident);
                }
                ElevationTile.setHeight(0);
                for (int i = 0; i < ElevationTile._adjacentTiles.Length / 2; i++)
                {
                    ElevationTile._adjacentTiles[i].setHeight(2);
                    ElevationTile._adjacentTiles[i + 3].setHeight(-2);
                }
                //ElevationTile._adjacentTiles[0].setHeight(0);
            }
        }
        else if (tState == States.ELEVATION_LOW)
        {
            //shows how low tiles do not affect the movement of souls
            if (GM.UnitMan.getSelected() != ElevationTile.Resident)
            {
                GM.UnitMan.Select(ElevationTile.Resident);
            }
            ElevationTile.setHeight(0);
            for (int i = 0; i < ElevationTile._adjacentTiles.Length / 2; i++)
            {
                ElevationTile._adjacentTiles[i].setHeight(1);
                ElevationTile._adjacentTiles[i + 3].setHeight(-1);
            }
            //ElevationTile._adjacentTiles[0].setHeight(0);

            // DIGGING TUTORIAL //
        }
        else if (tState == States.DIGGING)
        {
            //continue once a tile has been dug into
            GM.PlaneMan.setDestPlane(0);

            if (GM.UnitMan.getSelected())
            {
                firstUnit = GM.UnitMan.getSelected().GetComponent <SoulHost>();
            }

            //if no item was found, create one
            if (firstUnit)
            {
                Tile t = firstUnit.GetComponent <Unit>().CurrentTile;
                if (t.getHeight() != t.ORIG_HEIGHT)
                {
                    int fragCount = GM.FragMan.getFragCount(0) + GM.FragMan.CountGem(0);

                    if (fragCount == 0)
                    {
                        Fragment f = FragmentManager.CreateFragment(t.PeekFragment());
                        GM.FragMan.Collect(f);
                        t.CreateFragRemains(f);
                    }

                    setState(States.TURN_CHANGE);
                }
            }

            // TURN CHANGE TUTORIAL //
        }
        else if (tState == States.TURN_CHANGE)
        {
            //if the turn has been changed, move forward
            GM.PlaneMan.setDestPlane(0);
            if (GM.PlayerMan.CurrTurn != 0)
            {
                setState(States.SOUL_GENERATION);
            }
            // USE ITEMS TUTORIAL //
        }
        else if (tState == States.SOUL_GENERATION)
        {
            GM.PlaneMan.setDestPlane(0);
        }
        else if (tState == States.TILE_FLATTENING)
        {
            GM.PlaneMan.setDestPlane(0);
        }
        else if (tState == States.USE_ITEMS)
        {
            GM.PlaneMan.setDestPlane(0);

            //if an itme has been used, move forward
            if (GM.FragMan.getFragCount(0) < fragStartAmount)
            {
                setState(States.TILE_RICHNESS);
            }
            fragStartAmount = GM.FragMan.getFragCount(0);
            // COLLECT GEMS TUTORIAL //
        }
        else if (tState == States.TILE_RICHNESS)
        {
            GM.PlaneMan.setDestPlane(0);
        }
        else if (tState == States.COLLECT_GEMS)
        {
            GM.PlaneMan.setDestPlane(0);

            //if a soul can still be moved, do not reset their move and dig variables
            bool found = false;
            for (int i = 0; i < sh.Length; i++)
            {
                if (sh[i].getUnit() && sh[i].getUnit().Player == 0 && !sh[i].Dug)
                {
                    found = true;
                    break;
                }
            }

            //otherwise, if one cant be found, allow all souls to move and dig again
            if (!found)
            {
                for (int i = 0; i < sh.Length; i++)
                {
                    sh[i].getUnit().Moved = false;
                    sh[i].Dug             = false;
                }
            }

            //once a gem has been found, move on
            if (GM.FragMan.CountGem(0) >= GM.FragMan.Building_Shrine.getGem())
            {
                setState(States.RESOURCE_LIST);
            }

            // BUILD SHRINE TUTORIAL //
        }
        else if (tState == States.BUILD)
        {
            GM.PlaneMan.setDestPlane(0);

            //if a shrine has been built, move on
            if (Component.FindObjectsOfType(typeof(Shrine)).Length > 0)
            {
                MergeCount = souls.Length;
                setState(States.MERGING);
            }
            // MERGE TUTORIAL //
        }
        else if (tState == States.MERGING)
        {
            //once a soul has been merged, move on
            GM.PlaneMan.setDestPlane(0);

            int newCount = souls.Length;

            if (newCount < MergeCount)
            {
                setState(States.MERGE_FOUR);
            }
            MergeCount = newCount;
            // ASCEND TUTORIAL //
        }
        else if (tState == States.MERGE_FOUR)
        {
            //once a unit has been merged with four souls, move on
            GM.PlaneMan.setDestPlane(0);
            for (int i = 0; i < souls.Length; i++)
            {
                if (souls[i].Souls >= 4)
                {
                    setState(States.MOVE_TO_GLOW);
                }
            }
        }
        else if (tState == States.MOVE_TO_GLOW)
        {
            //once a unit with four souls has been move to the ascend tiles around the shrine, continue on
            GM.PlaneMan.setDestPlane(0);
            for (int i = 0; i < sh.Length; i++)
            {
                if (sh[i].getSoul() && sh[i].getSoul().Souls >= 4)
                {
                    if (sh[i].getUnit().CurrentTile.GetComponentInChildren(typeof(AscendLight)))
                    {
                        setState(States.ASCEND);
                    }
                }
                sh[i].getUnit().Moved = false;
                sh[i].Dug             = false;
            }
        }
        else if (tState == States.ASCEND)
        {
            GM.PlaneMan.setDestPlane(0);

            //once a soul has been ascended, move on
            for (int i = 0; i < units.Length; i++)
            {
                if (units[i].CurrentTile.transform.parent.tag == "MidPlane")
                {
                    setState(States.POST_ASCEND);
                    break;
                }
            }

            // GOAL TUTORIAL //
        }
        else if (tState == States.POST_ASCEND)
        {
            if (GM.FragMan.getSelected() && GM.FragMan.getSelected().GetType() == typeof(MakeBuilding) && ((MakeBuilding)GM.FragMan.getSelected()).GetBuilding().GetType() == typeof(Shrine))
            {
                GM.FragMan.Deselect();
            }
            GM.PlaneMan.setDestPlane(1);
        }
        else if (tState == States.EXPLAIN_STONE)
        {
            if (GM.FragMan.getSelected() && GM.FragMan.getSelected().GetType() == typeof(MakeBuilding) && ((MakeBuilding)GM.FragMan.getSelected()).GetBuilding().GetType() == typeof(Shrine))
            {
                GM.FragMan.Deselect();
            }
            GM.PlaneMan.setDestPlane(1);
            for (int i = 0; i < sh.Length; i++)
            {
                if (sh[i].Dug)
                {
                    sh[i].getUnit().Moved = false;
                    sh[i].Dug             = false;
                }
            }

            if (GM.FragMan.CountStone(0) > 0)
            {
                setState(States.COLLECT_TREE);
            }
        }
        else if (tState == States.COLLECT_TREE)
        {
            if (GM.FragMan.getSelected() && GM.FragMan.getSelected().GetType() == typeof(MakeBuilding) && ((MakeBuilding)GM.FragMan.getSelected()).GetBuilding().GetType() == typeof(Shrine))
            {
                GM.FragMan.Deselect();
            }
            GM.PlaneMan.setDestPlane(1);

            //once some wood has been found, move on
            if (GM.FragMan.CountWood(0) != 0)
            {
                setState(States.EXPLAIN_TEMPLE);
            }

            //make sure all souls can move and dig always
            for (int i = 0; i < sh.Length; i++)
            {
                sh[i].getUnit().Moved = false;
                sh[i].Dug             = false;
            }
        }
        else if (tState == States.EXPLAIN_TEMPLE)
        {
            //once a temple has been built, move on
            if (GM.FragMan.getSelected() && GM.FragMan.getSelected().GetType() == typeof(MakeBuilding) && ((MakeBuilding)GM.FragMan.getSelected()).GetBuilding().GetType() == typeof(Shrine))
            {
                GM.FragMan.Deselect();
            }

            if (Component.FindObjectOfType(typeof(Temple)))
            {
                setState(States.SCROLL);
            }

            GM.PlaneMan.setDestPlane(1);
        }
        else if (tState == States.SCROLL)
        {
            if (GM.PlaneMan.getDestPlane() == 2)
            {
                setState(States.WIN);
            }
        }
        else if (tState == States.WIN)
        {
            if (GM.PlayerMan.CheckWin() == 0)
            {
                setState(States.MAIN_MENU);
            }
        }
    }