Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        GameObject   sax  = GameObject.Find("saveassigner");
        SaveAssigner sa   = sax.GetComponent(typeof(SaveAssigner)) as SaveAssigner;
        int          file = -1;

        pp = GameObject.FindGameObjectWithTag("Player");
        if (sa.isLoading)
        {
            file = sa.savefile;
            SaveData data = SaveData.Load(Application.streamingAssetsPath + "\\" + file + ".uml");
            player = GameObject.FindGameObjectWithTag("Player");
            PlayerController playerscript = player.GetComponent(typeof(PlayerController)) as PlayerController;
            Spells           spells       = player.GetComponent(typeof(Spells)) as Spells;
            PlayerTalents    talents      = player.GetComponent(typeof(PlayerTalents)) as PlayerTalents;
            Items            other        = player.GetComponent(typeof(Items)) as Items;

            playerscript.name            = data.GetValue <string>("name");
            playerscript.gender          = data.GetValue <string>("gender");
            playerscript.CheckpointLevel = data.GetValue <string>("checkpointlevel");
            playerscript.CheckpointName  = data.GetValue <string>("checkpointname");
            playerscript.bagisFull       = data.GetValue <bool>("bagisfull");
            playerscript.equipSpelltoL(data.GetValue <int>("equippedspellL"));
            playerscript.equipSpelltoR(data.GetValue <int>("equippedspellR"));
            playerscript.equipSpellto1(data.GetValue <int>("equippedspell1"));
            playerscript.equipSpellto2(data.GetValue <int>("equippedspell2"));
            playerscript.equipSpelltoQ(data.GetValue <int>("equippedspellQ"));
            playerscript.equipSpelltoQ2(data.GetValue <int>("equippedspellQ2"));
            playerscript.xp          = data.GetValue <float>("xp");
            playerscript.level       = data.GetValue <int>("level");
            playerscript.maxHealth   = data.GetValue <int>("maxhealth");
            playerscript.max_stamina = data.GetValue <int>("maxstamina");
            spells.UnlockedSpells    = data.GetValue <int[]>("unlockedspells");
            spells.UnlockedHats      = data.GetValue <int[]>("unlockedhats");
            spells.UnlockedAmulets   = data.GetValue <int[]>("unlockedamulets");
            spells.UnlockedTunics    = data.GetValue <int[]>("unlockedtunics");
            spells.PickedUpItems     = data.GetValue <int[]>("pickedupitems");
            spells.ItemCount         = data.GetValue <int>("itemcount");
            playerscript.equipHat(data.GetValue <int>("equippedhat"));
            playerscript.equipTunic(data.GetValue <int>("equippedtunic"));
            playerscript.equipAmulet(data.GetValue <int>("equippedamulet"));
            spells.bagSpace        = data.GetValue <int>("bagspace");
            spells.bagIsFull       = data.GetValue <bool>("bagisfull");
            spells.SpellCount      = data.GetValue <int>("spellcount");
            spells.SpellSpace      = data.GetValue <int>("spellspace");
            spells.SpellBookIsFull = data.GetValue <bool>("spellbookisfull");
            spells.HatCount        = data.GetValue <int>("hatcount");
            spells.HatSpace        = data.GetValue <int>("hatspace");
            spells.HatIsFull       = data.GetValue <bool>("hatisfull");
            spells.AmuletCount     = data.GetValue <int>("amuletcount");
            spells.AmuletIsFull    = data.GetValue <bool>("amuletisfull");
            spells.AmuletSpace     = data.GetValue <int>("amuletspace");
            spells.TunicCount      = data.GetValue <int>("tuniccount");
            spells.TunicSpace      = data.GetValue <int>("tunicspace");
            spells.TunicIsFull     = data.GetValue <bool>("tunicisfull");

            talents.Declared      = data.GetValue <bool>("declared");
            talents.declaration   = data.GetValue <string>("declaration");
            playerscript.numheals = 5;


            if (talents.Declared)
            {
                bool[] mys    = data.GetValue <bool[]>("talentsmystery");
                bool[] rea    = data.GetValue <bool[]>("talentsreachable");
                bool[] vis    = data.GetValue <bool[]>("talentsvisible");
                bool[] gotten = data.GetValue <bool[]>("talentsgotten");
                if (talents.declaration == "Inorganic")
                {
                    for (int c = 0; c < talents.Inorganic_Talents_t1.Length; ++c)
                    {
                        talents.Inorganic_Talents_t1[c].mystery   = mys[c];
                        talents.Inorganic_Talents_t1[c].reachable = rea[c];
                        talents.Inorganic_Talents_t1[c].visible   = vis[c];
                        talents.Inorganic_Talents_t1[c].gotten    = gotten[c];
                    }
                }
                else if (talents.declaration == "Organic")
                {
                    for (int c = 0; c < talents.Organic_Talents.Length; ++c)
                    {
                        talents.Organic_Talents[c].mystery   = mys[c];
                        talents.Organic_Talents[c].reachable = rea[c];
                        talents.Organic_Talents[c].visible   = vis[c];
                        talents.Organic_Talents[c].gotten    = gotten[c];
                    }
                }
                else
                {
                    for (int c = 0; c < talents.Biolchem_Talents.Length; ++c)
                    {
                        talents.Biolchem_Talents[c].mystery   = mys[c];
                        talents.Biolchem_Talents[c].reachable = rea[c];
                        talents.Biolchem_Talents[c].visible   = vis[c];
                        talents.Biolchem_Talents[c].gotten    = gotten[c];
                    }
                }
            }
            bool[] wat = data.GetValue <bool[]>("items");
            for (int c = 0; c < wat.Length; ++c)
            {
                other.VodExterior[c] = wat[c];
            }
            wat = data.GetValue <bool[]>("bosses");
            for (int c = 0; c < wat.Length; ++c)
            {
                other.bosses[c] = wat[c];
            }
            if (data.HasKey("spellpower"))
            {
                playerscript.SPELLPOWERBONUS = data.GetValue <float>("spellpower");
            }
            playerscript.currentHealth = playerscript.maxHealth;
            playerscript.savefile      = file;
            StartCoroutine(LoadingScreen.LoadLevelSCREEN(playerscript.CheckpointLevel));
            if (data.HasKey("energyclusterloc"))
            {
                Vector3    pos = data.GetValue <Vector3>("energyclusterloc");
                GameObject wa;
                if (pos != null)
                {
                    wa  = Instantiate(Resources.Load("EnergyCluster")) as GameObject;
                    ecs = wa.GetComponent <EnergyClusterScript>();
                    wa.transform.position = pos;
                    ecs.levelname         = data.GetValue <string>("energyclusterlevel");
                    ecs.worth             = data.GetValue <float>("energyclusterworth");
                }
            }
            StartCoroutine(checkpointerputter(playerscript.CheckpointName));
            if (data.HasKey("energyclusterlevel"))
            {
                StartCoroutine(delayassigner(data.GetValue <string>("energyclusterlevel"), ecs));
            }
        }
        else
        {
            // new game
            GameObject       player       = GameObject.FindGameObjectWithTag("Player");
            PlayerController playerscript = player.GetComponent(typeof(PlayerController)) as PlayerController;
            Spells           s            = player.GetComponent(typeof(Spells)) as Spells;
            playerscript.CheckpointLevel = "Castle_Vod";
            playerscript.CheckpointName  = "Checkpoint1";
            playerscript.currentHealth   = playerscript.maxHealth;
            playerscript.savefile        = sa.savefile;
            playerscript.name            = sa.name;
            s.AddItem(11);
            playerscript.gender = sa.gender;
            Instantiate(Resources.Load("Saved"));
            StartCoroutine(checkpointerputter("Checkpoint1"));
            StartCoroutine(LoadingScreen.LoadLevelSCREEN("Castle_Vod"));
            //StartCoroutine(LoadingScreen.LoadLevelSCREEN("Castle_Vod");
        }
    }
Beispiel #2
0
    void OnGUI()
    {
        float rx = Screen.width / 1920f;
        float ry = Screen.height / 1080f;

        GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(rx, ry, 1));


        GUI.DrawTexture(new Rect(0, 0, 1920, 1080), background);
        if (currmen == "main")
        {
            GUI.DrawTexture(new Rect(left.width / 2, left.height / 4, middle.width, middle.height), middle);
            GUI.DrawTexture(new Rect(-100, -100, left.width, left.height), left);
            GUI.DrawTexture(new Rect(1920 - right.width, -50, right.width, right.height), right);
            if (GUI.Button(new Rect(left.width / 2 + 300 - 276, left.height / 4 + 40, 215, 35), "", newg))
            {
                currmen = "new";
            }
            if (GUI.Button(new Rect(left.width / 2 + 300 - 276 + 215 - 50, left.height / 4 + 40, 215, 35), "", loadg))
            {
                currmen = "load";
            }
            if (GUI.Button(new Rect(left.width / 2 + 300 - 276 + 320, left.height / 4 + 40 + 2, 215, 35), "", settings))
            {
                currmen = "settings";
            }
            if (GUI.Button(new Rect(left.width / 2 + 300 - 276 + 435, left.height / 4 + 40, 215, 35), "", exitg))
            {
                Application.Quit();
            }
        }
        else if (currmen == "new")
        {
            GUI.DrawTexture(new Rect(left.width / 2, left.height / 4, middle.width, middle.height), middle);
            GUI.DrawTexture(new Rect(-100, -100, left.width, left.height), left);
            GUI.DrawTexture(new Rect(left.width / 2 + 300 - 276, left.height / 4 + 40, genderprompt.width, genderprompt.height), genderprompt);
            if (GUI.Button(new Rect(-100, -100, left.width / 3, left.height), "", genderchoose))
            {
                chosengender = "male";
                currmen      = "name";
            }
            if (GUI.Button(new Rect(-100 + left.width / 3, -100, left.width / 2, left.height), "", genderchoose))
            {
                chosengender = "female";
                currmen      = "name";
            }
            if (GUI.Button(new Rect(left.width / 2 + 300 - 276 + 320, left.height / 4 + 40 + 2, 215, 35), "", returns))
            {
                currmen = "main";
            }
        }
        else if (currmen == "name")
        {
            GUI.DrawTexture(new Rect(left.width / 2, left.height / 4, middle.width, middle.height), middle);
            GUI.DrawTexture(new Rect(-100, -100, left.width, left.height), left);
            GUI.Label(new Rect(left.width / 2 + 330 - 276, left.height / 4 + 87, 200, 20), "Gender Chosen: " + chosengender + "\nChoose a name:", genericstyle);
            chosenname = GUI.TextField(new Rect(left.width / 2 + 330 - 276, left.height / 4 + 68 + 90, 200, 20), chosenname, 15, genericstyle);
            if (GUI.Button(new Rect(left.width / 2 + 300 - 276 + 320, left.height / 4 + 40 + 2, 215, 35), "", confirm))
            {
                if (chosenname != "")
                {
                    int savetocreate = 1;
                    for (; savetocreate <= 5; ++savetocreate)
                    {
                        if (!System.IO.File.Exists(Application.streamingAssetsPath + "\\" + savetocreate + ".uml"))
                        {
                            break;
                        }
                    }
                    if (savetocreate > 5)
                    {
                        GameObject ohno  = Instantiate(Resources.Load("Messages/OkMessage")) as GameObject;
                        OkMessage  ohyes = ohno.GetComponent(typeof(OkMessage)) as OkMessage;
                        ohyes.message = "You have too many save files. The Maximum is 5. Please delete one of your saves in the StreamingAssets folder.";
                    }
                    else
                    {
                        GameObject   sax = GameObject.Find("saveassigner");
                        SaveAssigner sa  = sax.GetComponent(typeof(SaveAssigner)) as SaveAssigner;
                        sa.savefile = savetocreate;
                        sa.name     = chosenname;
                        sa.gender   = chosengender;
                        StartCoroutine(LoadingScreen.LoadLevelSCREEN(1));
                    }
                }
            }
            if (GUI.Button(new Rect(left.width / 2 + 300 - 276 + 435, left.height / 4 + 43, 215, 35), "", returns))
            {
                currmen = "new";
            }
        }
        else if (currmen == "load")
        {
            GUI.DrawTexture(new Rect(left.width / 2, left.height / 4, middle.width, middle.height), middle);
            GUI.DrawTexture(new Rect(-100, -100, left.width, left.height), left);
            GUI.DrawTexture(new Rect(1920 - right.width, -50, right.width, right.height), right);
            if (!LOADING)
            {
                if (System.IO.File.Exists(Application.streamingAssetsPath + "\\1.uml"))
                {
                    if (GUI.Button(new Rect(1920 / 2 - 627, left.height / 4 + 68 + 90, 250, 120), s1name + "\nLevel " + s1level + " " + s1spec, loadstyle))
                    {
                        LOADING = true;
                        GameObject   sax = GameObject.Find("saveassigner");
                        SaveAssigner sa  = sax.GetComponent(typeof(SaveAssigner)) as SaveAssigner;
                        sa.isLoading = true;
                        sa.savefile  = 1;
                        StartCoroutine(LoadingScreen.LoadLevelSCREEN(1));
                    }
                }
                if (System.IO.File.Exists(Application.streamingAssetsPath + "\\2.uml"))
                {
                    if (GUI.Button(new Rect(1920 / 2 - 627 + 251, left.height / 4 + 68 + 90, 250, 120), s2name + "\nLevel " + s2level + " " + s2spec, loadstyle))
                    {
                        LOADING = true;
                        GameObject   sax = GameObject.Find("saveassigner");
                        SaveAssigner sa  = sax.GetComponent(typeof(SaveAssigner)) as SaveAssigner;
                        sa.isLoading = true;
                        sa.savefile  = 2;
                        StartCoroutine(LoadingScreen.LoadLevelSCREEN(1));
                    }
                }
                if (System.IO.File.Exists(Application.streamingAssetsPath + "\\3.uml"))
                {
                    if (GUI.Button(new Rect(1920 / 2 - 627 + 502, left.height / 4 + 68 + 90, 250, 120), s3name + "\nLevel " + s3level + " " + s3spec, loadstyle))
                    {
                        LOADING = true;
                        GameObject   sax = GameObject.Find("saveassigner");
                        SaveAssigner sa  = sax.GetComponent(typeof(SaveAssigner)) as SaveAssigner;
                        sa.isLoading = true;
                        sa.savefile  = 3;
                        StartCoroutine(LoadingScreen.LoadLevelSCREEN(1));
                    }
                }
                if (System.IO.File.Exists(Application.streamingAssetsPath + "\\4.uml"))
                {
                    if (GUI.Button(new Rect(1920 / 2 - 627 + 753, left.height / 4 + 68 + 90, 250, 120), s4name + "\nLevel " + s4level + " " + s4spec, loadstyle))
                    {
                        LOADING = true;
                        GameObject   sax = GameObject.Find("saveassigner");
                        SaveAssigner sa  = sax.GetComponent(typeof(SaveAssigner)) as SaveAssigner;
                        sa.isLoading = true;
                        sa.savefile  = 4;
                        StartCoroutine(LoadingScreen.LoadLevelSCREEN(1));
                    }
                }
                if (System.IO.File.Exists(Application.streamingAssetsPath + "\\5.uml"))
                {
                    if (GUI.Button(new Rect(1920 / 2 - 627 + 1004, left.height / 4 + 68 + 90, 250, 120), s5name + "\nLevel " + s5level + " " + s5spec, loadstyle))
                    {
                        LOADING = true;
                        GameObject   sax = GameObject.Find("saveassigner");
                        SaveAssigner sa  = sax.GetComponent(typeof(SaveAssigner)) as SaveAssigner;
                        sa.isLoading = true;
                        sa.savefile  = 5;
                        StartCoroutine(LoadingScreen.LoadLevelSCREEN(1));
                    }
                }
            }
            if (GUI.Button(new Rect(left.width / 2 + 300 - 276 + 320, left.height / 4 + 40 + 2, 215, 35), "", returns))
            {
                currmen = "main";
            }
        }
        else if (currmen == "settings")
        {
            GUI.DrawTexture(new Rect(left.width / 2, left.height / 4, middle.width, middle.height), middle);
            GUI.DrawTexture(new Rect(-100, -100, left.width, left.height), left);
            GUI.DrawTexture(new Rect(1920 - right.width, -50, right.width, right.height), right);

            if (GUI.Button(new Rect(1920 / 2 - 107, 1080 / 2, 215, 70), "View Controls", loadstyle))
            {
                Instantiate(Resources.Load("UI/Controls"));
            }
            if (GUI.Button(new Rect(left.width / 2 + 300 - 276 + 320, left.height / 4 + 40 + 2, 215, 35), "", returns))
            {
                currmen = "main";
            }
        }
    }