コード例 #1
0
ファイル: Game1.cs プロジェクト: HunterwolfAT/ArtistQuest
        public void LoadSnapshot(Snapshot snapshot)
        {
            // Load Global Variables
            foreach (String[] var in GameVariables)
            {
                int i = 0;
                foreach (String name in snapshot.GVName)
                {
                    if (name == var[0])
                        var[1] = snapshot.GVValue[i];

                    i++;
                }
            }
            // Load Object data
            foreach (SnapObject snapj in snapshot.snapjects)
            {
                Object obj = map.FindObject(snapj.name);
                if (obj != null)
                {
                    obj.color = snapj.color;
                    obj.imagenum = snapj.imagenum;
                    obj.opacity = snapj.opacity;
                    obj.rect = snapj.rect;
                    obj.visible = snapj.visible;
                    obj.walkable = snapj.walkable;

                    for (int i = 0; i < snapj.VBName.Count; i++)
                    {
                        foreach (Script scr in obj.scripts)
                        {
                            if (scr.Name == snapj.VBName[i])
                            {
                                scr.Active = snapj.VBactive[i];
                            }
                        }
                    }
                }
                else
                    Console.WriteLine("SNAPSHOT LOAD ERROR: Object wasn't found!");
            }

            // Load the player inventory
            player.InvList.Clear();
            foreach (Item item in snapshot.snapventory)
                player.InvList.Add(item);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: HunterwolfAT/ArtistQuest
        private void newsnapshotButton_Click(object sender, EventArgs e)
        {
            Snapshot newsnapshot = new Snapshot(game.GameVariables, game.map, game.map.Objects, game.player.InvList);

            game.Snapshots.Add(newsnapshot);

            UpdateEditor();
        }
コード例 #3
0
ファイル: Game1.cs プロジェクト: HunterwolfAT/ArtistQuest
        public void LoadMap(String Filename, bool Startup = false)
        {
            map = (Maps)Maps.Load(Filename, typeof(Maps));

            if (map == null)
            {
                Console.WriteLine("Oh no, something went wrong with the map-file!");
                map = new Maps();
            }

            if (!Startup)
                map.LoadContent(this.Content);

            if (map.Objects.Count > 0)
            {
                foreach (Object obj in map.Objects)
                {
                    obj.LoadContent(this.Content);

                    if (obj.opacity > 1f)
                        obj.opacity = 1f;

                    if (obj.scripts.Count > 0)
                    {
                        foreach (Script script in obj.scripts)
                        {
                            if (script.Commands.Count > 0)
                            {
                                foreach (Command com in script.Commands)
                                {
                                    com.gui = gui;
                                }
                            }
                        }
                    }
                }

                if (!Startup)
                {
                    // If the map has a background song, play it now!
                    if (map.backgroundmusic != null)
                    {
                        //sound.LoadMusic(map.backgroundmusic, Content);    //It loads all the music at the beginning of the game anyway!
                        sound.PlayMusic(map.backgroundmusic);
                    }
                    else
                        sound.StopMusic();
                }

            }

            //Make a new instance of the scripthandler with the freshly loaded map
            scripthandler = new ScriptHandler(map, player, items, this);

            if (!Startup)
            {
                //Also make a snapshot right awayy
                Snapshot newsnapshot = new Snapshot(GameVariables, map, map.Objects);

                Snapshots.Add(newsnapshot);
            }

            Console.WriteLine("MAP LOCKED AND LOADED, SIR!");
        }