Example #1
0
    /// <summary>
    /// Constucts the era at the end of each tier and clears all bois of their responsabilities.
    /// </summary>
    public void ConstructEra()
    {
        myCommunity.FreeBois();
        SphereTerrain terrain = FindObjectOfType <SphereTerrain> ();

        switch (curTier)
        {
        case (1):
            //10 bois
            myCommunity.FreeBois();
            myCommunity.AddBois(5);
            //2 huts
            for (int i = 0; i < 3; i++)
            {
                Vertex v = myCommunity.ChooseNextBuildingLocation();
                if (v != null)
                {
                    terrain.buildAtIndex(v.getIndex(), "wood_house");
                    myCommunity.addHut(v);
                }
            }
            //lithic workshop
            Vertex litho = myCommunity.ChooseNextBuildingLocation();
            if (litho != null)
            {
                terrain.buildAtIndex(litho.getIndex(), "stonecraft_house");
                myCommunity.addBuilding(litho);
            }
            //well
            Vertex well = myCommunity.ChooseNextBuildingLocation();
            if (well != null)
            {
                terrain.buildAtIndex(well.getIndex(), "well");
                myCommunity.addBuilding(well);
            }
            //unlock wheat and iron
            (GameObject.Find("HUD").GetComponent(typeof(ResourceFooBar)) as ResourceFooBar).UnlockWheat();
            (GameObject.Find("HUD").GetComponent(typeof(ResourceFooBar)) as ResourceFooBar).UnlockIron();
            break;

        case (2):
            //20 bois
            for (int i = 0; i < 2; i++)
            {
                Vertex v = myCommunity.ChooseNextBuildingLocation();
                if (v != null)
                {
                    terrain.buildAtIndex(v.getIndex(), "wood_house");
                    myCommunity.addHut(v);
                }
            }
            myCommunity.FreeBois();
            myCommunity.AddBois(10);
            //granary
            Vertex granary = myCommunity.ChooseNextBuildingLocation();
            if (granary != null)
            {
                terrain.buildAtIndex(granary.getIndex(), "granary");
                myCommunity.addBuilding(granary);
            }
            //mill
            Vertex mill = myCommunity.ChooseNextBuildingLocation();
            if (mill != null)
            {
                terrain.buildAtIndex(mill.getIndex(), "windmill");
                myCommunity.addBuilding(mill);
            }
            //smelter
            Vertex smelter = myCommunity.ChooseNextBuildingLocation();
            if (smelter != null)
            {
                terrain.buildAtIndex(smelter.getIndex(), "smelter");
                myCommunity.addBuilding(smelter);
            }
            //unlock coal
            (GameObject.Find("HUD").GetComponent(typeof(ResourceFooBar)) as ResourceFooBar).UnlockCoal();
            break;

        case (3):
            //40 bois
            //2 hut
            for (int i = 0; i < 2; i++)
            {
                Vertex v = myCommunity.ChooseNextBuildingLocation();
                if (v != null)
                {
                    terrain.buildAtIndex(v.getIndex(), "wood_house");
                    myCommunity.addHut(v);
                }
            }
            myCommunity.FreeBois();
            myCommunity.AddBois(20);
            //blast furnace
            Vertex blast = myCommunity.ChooseNextBuildingLocation();
            if (blast != null)
            {
                terrain.buildAtIndex(blast.getIndex(), "blast_furnace");
                myCommunity.addBuilding(blast);
            }
            //castle
            Vertex castle = myCommunity.ChooseNextBuildingLocation();
            if (castle != null)
            {
                terrain.buildAtIndex(castle.getIndex(), "tower");
                myCommunity.addBuilding(castle);
            }
            //unlock sand
            (GameObject.Find("HUD").GetComponent(typeof(ResourceFooBar)) as ResourceFooBar).UnlockSand();
            break;

        case (4):
            //80 bois
            //3 huts
            for (int i = 0; i < 3; i++)
            {
                Vertex v = myCommunity.ChooseNextBuildingLocation();
                if (v != null)
                {
                    terrain.buildAtIndex(v.getIndex(), "wood_house");
                    myCommunity.addHut(v);
                }
            }
            myCommunity.FreeBois();
            myCommunity.AddBois(40);
            //observatory
            Vertex observatory = myCommunity.ChooseNextBuildingLocation();
            if (observatory != null)
            {
                terrain.buildAtIndex(observatory.getIndex(), "observatory");
                myCommunity.addBuilding(observatory);
            }
            //university
            Vertex university = myCommunity.ChooseNextBuildingLocation();
            if (university != null)
            {
                terrain.buildAtIndex(university.getIndex(), "temple");
                myCommunity.addBuilding(university);
            }
            //unlock copper
            (GameObject.Find("HUD").GetComponent(typeof(ResourceFooBar)) as ResourceFooBar).UnlockCopper();
            break;

        case (5):
            //160 bois
            myCommunity.FreeBois();
            myCommunity.AddBois(80);
            //factory
            Vertex factory = myCommunity.ChooseNextBuildingLocation();
            if (factory != null)
            {
                terrain.buildAtIndex(factory.getIndex(), "factory");
                myCommunity.addBuilding(factory);
            }
            //remove huts, replace
            for (int i = 0; i < myCommunity.getHuts().Count; i++)
            {
                myCommunity.getHuts() [i].removeResource();
                myCommunity.getHuts() [i].setIsEditable(true);
                terrain.buildAtIndex(myCommunity.getHuts() [i].getIndex(), "apartment");
            }
            //+ 4 more apartments
            for (int i = 0; i < 4; i++)
            {
                Vertex v = myCommunity.ChooseNextBuildingLocation();
                if (v != null)
                {
                    terrain.buildAtIndex(v.getIndex(), "apartment");
                    myCommunity.addBuilding(v);
                }
            }
            //unlock oil
            (GameObject.Find("HUD").GetComponent(typeof(ResourceFooBar)) as ResourceFooBar).UnlockOil();
            break;

        case (6):
            //320 bois
            for (int i = 0; i < 8; i++)
            {
                Vertex v = myCommunity.ChooseNextBuildingLocation();
                if (v != null)
                {
                    terrain.buildAtIndex(v.getIndex(), "apartment");
                    myCommunity.addBuilding(v);
                }
            }
            myCommunity.FreeBois();
            myCommunity.AddBois(160);
            //gas refinery
            Vertex gas = myCommunity.ChooseNextBuildingLocation();
            if (gas != null)
            {
                terrain.buildAtIndex(gas.getIndex(), "refinery");
                myCommunity.addBuilding(gas);
            }
            //labs
            Vertex lab = myCommunity.ChooseNextBuildingLocation();
            if (lab != null)
            {
                terrain.buildAtIndex(lab.getIndex(), "lab");
                myCommunity.addBuilding(lab);
            }
            //unlock deiton
            (GameObject.Find("HUD").GetComponent(typeof(ResourceFooBar)) as ResourceFooBar).UnlockDieton();
            break;

        case (7):
            //same number of bois
            Vertex launchSite = myCommunity.ChooseNextBuildingLocation();
            if (launchSite != null)
            {
                GameObject bigOlBoy   = Resources.Load("prefabs/bigspacefucker") as GameObject;
                GameObject realBigBoy = Instantiate(bigOlBoy, transform.TransformPoint(launchSite.getSphereVector() * 1.3f), Quaternion.identity);
                realBigBoy.GetComponent <Rigidbody> ().velocity = transform.TransformPoint(launchSite.getSphereVector()).normalized * 0.5f;
            }
            else
            {
                GameObject bigOlBoy   = Resources.Load("prefabs/bigspacefucker") as GameObject;
                GameObject realBigBoy = Instantiate(bigOlBoy, transform.TransformPoint(myCommunity.getCampfireVertex().getSphereVector() * 1.3f), Quaternion.identity);
                realBigBoy.GetComponent <Rigidbody> ().velocity = transform.TransformPoint(myCommunity.getCampfireVertex().getSphereVector()).normalized * 0.5f;
            }
            break;

        default:
            //5 bois
            //fire
            break;
        }
    }