Exemplo n.º 1
0
    // Use this for initialization
    void Awake()
    {
        game = this;
        ResetStatics();
        ResearchMenu.InitializeAllStatics();
        darkOverlayActive = true;
        InitializeBasics();

        ModuleMod.currentMenu = new GameObject[ModuleMod.MAX_DEPTH];

        if (currentScene == Scene.Play)
        {
            assemblyContextMenu.Initialize();

            for (int i = 0; i < purchaseMenu.all.Count; i++)
            {
                Module mod = purchaseMenu.all[i].GetComponent <Module> ();
                if (mod.moduleType == Module.Type.Weapon)
                {
                    GenerateDefaultAssembly(mod);
                }
            }
        }

        ModuleAssemblyLoader.ConvertLegacyAssemblyFiles();
        HideGUI();

        UpdateMusicVolume();
    }
        public void OnLoadAssembly(string file)
        {
            if (rootModule)
            {
                rootModule.DestroyModule();
            }

            for (int i = 0; i < Game.currentModules.Count; i++)
            {
                if (Game.currentModules[i].isRoot)
                {
                    Game.currentModules[i].DestroyModule();
                }
            }

            Assembly ass = Assembly.LoadFromFile(file, true);

            ModuleAssemblyLoader loader = (Instantiate(purchaseMenu.assemblyLoader)).GetComponent <ModuleAssemblyLoader> ();
            GameObject           root   = loader.LoadAssembly(ass, true);

            root.transform.position = new Vector3(0, 0);
            root.transform.rotation = Quaternion.Euler(0, 0, 90);
            root.transform.parent   = null;

            rootModule = root.GetComponent <Module> ();
            for (int i = 0; i < rootModule.modules.Count; i++)
            {
                rootModule.modules[i].isOnBattlefield = true;
            }
        }
Exemplo n.º 3
0
    public void LoadAssembly(Assembly assembly)
    {
        GameObject           ass    = Instantiate(assemblyLoader);
        ModuleAssemblyLoader loader = ass.GetComponent <ModuleAssemblyLoader> ();

        loader.LoadAssembly(assembly);
        Destroy(ass);
    }
Exemplo n.º 4
0
        /// <summary>
        /// 模块加载前期准备
        /// </summary>
        protected override void PreInitializeModules()
        {
            //SetupAppDomain();
            ModuleAssemblyLoader ml = new ModuleAssemblyLoader(this.ModuleCatalog, this.Logger);

            ml.LoadAssembly();
            //base.PreInitializeModules();
        }
Exemplo n.º 5
0
    public static List <Wave> LoadWaveset(string name)
    {
        string path = Game.WAVESET_SAVE_DIRECTORY + name + WAVESET_FILE_EXTENSION;

        string[] content = ModuleAssemblyLoader.GetContents(path);

        List <Wave> locWaves = new List <Wave> ();

        Wave cw = null;

        Wave.Subwave cs = null;
        Wave.Enemy   ce = null;

        for (int i = 0; i < content.Length; i++)
        {
            string c = content [i];

            // Find wave
            if (c.Length > 4)
            {
                if (c.Substring(0, 5) == "\twave")
                {
                    cw = new Wave();
                    locWaves.Add(cw);
                }
            }

            // Find and read subwave
            if (c.Length > 5)
            {
                if (c.Substring(0, 6) == "\t\tsptm")
                {
                    cs           = new Wave.Subwave();
                    cs.spawnTime = float.Parse(c.Substring(7));
                    cw.subwaves.Add(cs);
                }
            }

            // Find and read enemy
            if (c.Length > 6)
            {
                if (c.Substring(0, 7) == "\t\t\tenmy")
                {
                    ce       = new Wave.Enemy();
                    ce.enemy = EnemyManager.cur.GetEnemyFromName(c.Substring(8));
                }

                if (c.Substring(0, 7) == "\t\t\tamnt")
                {
                    ce.spawnAmount = int.Parse(c.Substring(8));
                    cs.enemies.Add(ce);
                }
            }
        }

        return(locWaves);
    }
Exemplo n.º 6
0
    public void Initialize()
    {
        ModuleAssemblyLoader.GetButtonData(assembly, this);
        Texture2D[] sprites   = null;
        Vector3[]   positions = null;
        ModuleAssemblyLoader.GetSpriteData(assembly, out sprites, out positions);
        button.transform.Find("Image").GetComponent <RawImage>().texture = Module.CombineSprites(sprites, positions);

        OnResearchUnlocked();
        ButtonUpdate();
    }
Exemplo n.º 7
0
    public static Assembly LoadFromFile(string fileName, bool isFullPath = false)
    {
        if (!isFullPath)
        {
            fileName = Game.MODULE_ASSEMBLY_SAVE_DIRECTORY + fileName + Module.MODULE_FILE_EXTENSION;
        }

        Assembly data = Utility.LoadObjectFromFile <Assembly> (fileName);

        Texture2D[] sprites   = null;
        Vector3[]   positions = null;

        ModuleAssemblyLoader.GetSpriteData(data, out sprites, out positions);
        data.texture = Module.CombineSprites(sprites, positions);

        List <Research> hls = new List <Research> ();

        if (Game.currentScene == Scene.Play)
        {
            for (int j = 0; j < data.parts.Count; j++)
            {
                for (int i = 0; i < ResearchMenu.cur.research.Count; i++)
                {
                    Research r = ResearchMenu.cur.research[i];
                    if (r.func == "UnlockModule")
                    {
                        Module mod = ResearchMenu.cur.unlockableModules[int.Parse(r.meta)].GetComponent <Module> ();

                        if (mod.moduleName == data.parts[j].type && !hls.Contains(r))
                        {
                            hls.Add(r);
                        }
                    }
                }
            }
        }

        data.requiredResearch = hls.ToArray();
        return(data);
    }
Exemplo n.º 8
0
    public void LoadSavedGame(string fileName)
    {
        // First, clear battlefield of gameobjects, and load the data into a SavedGame object.
        // ClearBattlefieldGameObjects ();
        SavedGame sg = SavedGame.Load(fileName);

        // Load basic battlefield size and walls.
        battlefieldWidth  = sg.battlefieldData.width;
        battlefieldHeight = sg.battlefieldData.height;
        isWalled          = sg.battlefieldData.walls;
        difficulty        = sg.difficulty;
        battlefieldName   = sg.battlefieldData.name;

        // Set purchaseables and spawnpoints.
        if (IngameEditors.AssemblyEditorScene.newAssemblies != null)
        {
            sg.selectedTurrets.AddRange(IngameEditors.AssemblyEditorScene.newAssemblies);
            IngameEditors.AssemblyEditorScene.newAssemblies.Clear();
        }

        purchaseMenu.SetAssemblies(sg.selectedTurrets);
        enemySpawnPoints = new List <EnemySpawnPoint> ();

        for (int i = 0; i < sg.battlefieldData.spawnsX.Length; i++)
        {
            EnemySpawnPoint sp = ScriptableObject.CreateInstance <EnemySpawnPoint> ();
            sp.worldPosition          = new Vector3(sg.battlefieldData.spawnsX[i], sg.battlefieldData.spawnsY[i]);
            sp.endPoint               = ScriptableObject.CreateInstance <EnemyEndPoint> ();
            sp.endPoint.worldPosition = new Vector3(sg.battlefieldData.endsX[i], sg.battlefieldData.endsY[i]);
            enemySpawnPoints.Add(sp);
        }

        // Load in-world turrets.
        for (int i = 0; i < sg.turrets.Count; i++)
        {
            SavedGame.SavedAssembly ass    = sg.turrets[i];
            ModuleAssemblyLoader    loader = ((GameObject)Instantiate(purchaseMenu.assemblyLoader)).GetComponent <ModuleAssemblyLoader> ();
            GameObject root = loader.LoadAssembly(ass.assembly, true);
            root.transform.position = new Vector3(ass.posX, ass.posY);
            root.transform.rotation = Quaternion.Euler(0, 0, ass.rot);
            root.transform.parent   = null;

            Module rootModule = root.GetComponent <Module> ();
            rootModule.score = sg.turrets[i].score;
            for (int j = 0; j < rootModule.modules.Count; j++)
            {
                rootModule.modules[j].SetStartingUpgradeCost();

                for (int a = 0; a < ass.levels.Count; a++)
                {
                    if (rootModule.modules[j].moduleType == (Module.Type)a)
                    {
                        for (int b = 0; b < ass.levels[a]; b++)
                        {
                            rootModule.modules[j].UpgradeModule();

                            // So many bloody loops, though this should now save assembly upgrades in the SavedData data.
                            // Haha, ass.
                        }
                    }
                }
            }
        }

        // Load research. Likely a very unefficient method, but it should do without issues.
        for (int i = 0; i < sg.researchedResearch.Count; i++)
        {
            Research r = ResearchMenu.cur.research[sg.researchedResearch[i]];
            r.Purchase(true);
        }

        // Place research points
        if (sg.researchPoints != null)
        {
            for (int i = 0; i < sg.researchPoints.Length; i++)
            {
                GameObject obj = null;
                Vector3    pos = new Vector3(sg.researchPoints[i].x, sg.researchPoints[i].y);
                if (sg.researchPoints[i].value < 2f)
                {
                    obj = (GameObject)Instantiate(researchPoint, pos, Quaternion.identity);
                }
                else
                {
                    obj = (GameObject)Instantiate(largeResearchPoint, pos, Quaternion.identity);
                }
            }
        }

        // Set resources.
        credits                = sg.credits;
        research               = sg.research;
        researchProgress       = sg.researchProgress;
        PlayerInput.flushTimer = sg.flushTimer;

        // Finalize loading.
        Datastream.healthAmount = sg.health;
        PostInitialization();

        EnemyManager.cur.waveMasteryIndex = sg.masteryNumber;
        EnemyManager.cur.waveNumber       = sg.waveNumber;
        EnemyManager.gameProgress         = sg.gameProgress;
        EnemyManager.cur.enemiesKilled    = sg.enemiesKilled;

        EnemyManager.cur.EndWave(false);
    }