Exemplo n.º 1
0
        public Play(string level, Settings settings, Worlds worlds)
        {
            allDone.Reset();
            InitializeComponent();
            Sound_music.CheckMusic(settings);
            Visible  = false;
            readFile = new ReadFile(level);
            string[]     data          = readFile.SearchData().Split('|');
            LoadingLevel loadingScreen = new LoadingLevel("Level " + level, data[0].Split('#')[1], data[1], data[3]);

            loadingScreen.Show();
            new Thread(LoadingScreen).Start();

            this.level      = level;
            this.worlds     = worlds;
            FormBorderStyle = FormBorderStyle.None;
            WindowState     = FormWindowState.Maximized;
            this.settings   = settings;
            engine          = new Engine(readFile.InterpretFile(settings), Controls);

            allDone.WaitOne();
            Visible = true;
            loadingScreen.Close();

            Focus();
            engine.Start();
        }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (ReadFile.IsFirst())
     {
         ReadFile.SetFirst("1");
     }
     new Story(this).Show();
     btnStart.Enabled = true;
 }
Exemplo n.º 3
0
 public Form1()
 {
     InitializeComponent();
     settings = ReadFile.GetSettings();
     Sound_music.CheckMusic(settings);
     if (ReadFile.IsFirst())
     {
         btnStart.Enabled = false;
     }
 }
Exemplo n.º 4
0
        public static void ResetLevel(ReadFile readFile, string four)
        {
            string[] help = readFile.SearchData().Split('|');
            help[1] = "-1";
            help[3] = "0,0,0";
            help[4] = four;
            string setdata = "";

            for (int f = 0; f < help.Length - 1; f++)
            {
                setdata += help[f] + "|";
            }
            setdata += help[help.Length - 1];
            readFile.SetData(setdata);
        }
Exemplo n.º 5
0
 private void SetText(string level)
 {
     for (int f = 0; f < Controls.Count; f++)
     {
         if (Controls[f].Tag != null)
         {
             if (Controls[f].Tag.ToString().Equals(level))
             {
                 string[] help = new ReadFile(level).SearchData().Split('|');
                 if (help[4].Equals("1"))
                 {
                     if (!help[1].Equals("-1"))
                     {
                         string[] help2 = level.Split('-');
                         if (Convert.ToInt32(help2[1]) == 3)
                         {
                             int      ricecoinamount = 0;
                             string[] data           = new ReadFile("1-1").SearchData().Split('|')[3].Split(',');
                             foreach (string s in data)
                             {
                                 if (s.Equals("1"))
                                 {
                                     ricecoinamount++;
                                 }
                             }
                             data = new ReadFile("1-2").SearchData().Split('|')[3].Split(',');
                             foreach (string s in data)
                             {
                                 if (s.Equals("1"))
                                 {
                                     ricecoinamount++;
                                 }
                             }
                             data = help[3].Split(',');
                             foreach (string s in data)
                             {
                                 if (s.Equals("1"))
                                 {
                                     ricecoinamount++;
                                 }
                             }
                             if (ricecoinamount > 8)
                             {
                                 ReadFile.UnlockLevel(help2[0] + "-" + (Convert.ToInt32(help2[1]) + 1));
                             }
                         }
                         else
                         {
                             ReadFile.UnlockLevel(help2[0] + "-" + (Convert.ToInt32(help2[1]) + 1));
                         }
                         Controls[f].Text = level + " " + help[0].Split('#')[1] + " | " + help[1] + "sek";
                     }
                     else
                     {
                         Controls[f].Text = level + " " + help[0].Split('#')[1] + " | no record";
                     }
                 }
                 else
                 {
                     Controls[f].Text = "";
                 }
                 return;
             }
         }
     }
 }
Exemplo n.º 6
0
        private void MoveBackgroundRight()
        {
            if (pointer >= controls.Length - gameWidth)
            {
                return;
            }
            Point help = players.Location;

            if (help.X > gameWidth * Settings.width - border)
            {
                for (int f = 0; f < controls[0].Length; f++)
                {
                    if (controls[pointer][f] != null)
                    {
                        if (controls[pointer][f].Tag.Equals("coin"))
                        {
                            if (!players.IsGameControl(controls[pointer][f]))
                            {
                                controls[pointer][f] = null;
                            }
                        }
                        else if ((controls[pointer][f].Tag.ToString().Split('_').Length > 1))
                        {
                            if (controls[pointer][f].Tag.ToString().Split('_')[1].Equals("coin"))
                            {
                                if (!players.IsGameControl(controls[pointer][f]))
                                {
                                    controls[pointer][f] = ReadFile.NewControl(Properties.Resources.box, "obstacle_destroy");;
                                }
                            }
                        }
                        int index = players.GetGameControlIndexOf(controls[pointer][f]);
                        if (index != -1)
                        {
                            controlCollection.Remove(players.GetGameControlItem(index));
                            players.GameControlRemoveAt(index);
                        }
                    }
                }
                foreach (Control control in players.GetGameControl())
                {
                    if (control != null)
                    {
                        Point location = control.Location;
                        location.Offset(-Settings.width, 0);
                        control.Location = location;
                    }
                }
                for (int f = 0; f < controls[0].Length; f++)
                {
                    if (controls[pointer + gameWidth][f] != null)
                    {
                        controls[pointer + gameWidth][f].Location = new Point((gameWidth - 1) * Settings.width, f * Settings.height);
                        players.GameControlAdd(controls[pointer + gameWidth][f]);
                        controlCollection.Add(controls[pointer + gameWidth][f]);
                        if (controls[pointer + gameWidth][f] is Enemy)
                        {
                            players.GameControlRemove(controls[pointer + gameWidth][f]);
                            players.EnemyAdd(controls[pointer + gameWidth][f] as Enemy);
                            players.StartEnemies();
                            controls[pointer + gameWidth][f] = null;
                        }
                    }
                }
                pointer++;
                Point temp = players.Location;
                temp.Offset(-Settings.width, 0);
                players.Location = temp;
                foreach (Enemy enemy in players.GetEnemy())
                {
                    if (enemy != null)
                    {
                        Point help2 = enemy.Location;
                        help2.Offset(-Settings.width, 0);
                        enemy.Location = help2;
                        if (help.X < 0)
                        {
                            players.EnemyRemove(enemy);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void MoveBackgroundLeft()
        {
            if (pointer < 1)
            {
                return;
            }
            Point help = players.Location;

            if (help.X < border)
            {
                for (int f = 0; f < controls[0].Length; f++)
                {
                    if (controls[pointer + gameWidth - 1][f] != null)
                    {
                        if (controls[pointer + gameWidth - 1][f].Tag.Equals("coin"))
                        {
                            if (!players.IsGameControl(controls[pointer + gameWidth - 1][f]))
                            {
                                controls[pointer + gameWidth - 1][f] = null;
                            }
                        }
                        else if ((controls[pointer + gameWidth - 1][f].Tag.ToString().Split('_').Length > 1))
                        {
                            if (controls[pointer + gameWidth - 1][f].Tag.ToString().Split('_')[1].Equals("coin"))
                            {
                                if (!players.IsGameControl(controls[pointer + gameWidth - 1][f]))
                                {
                                    controls[pointer + gameWidth - 1][f] = ReadFile.NewControl(Properties.Resources.box, "obstacle_destroy");
                                }
                            }
                        }
                        int index = players.GetGameControlIndexOf(controls[pointer + gameWidth - 1][f]);
                        if (index != -1)
                        {
                            controlCollection.Remove(players.GetGameControlItem(index));
                            players.GameControlRemoveAt(index);
                        }
                    }
                }
                foreach (Control control in players.GetGameControl())
                {
                    if (control != null)
                    {
                        Point location = control.Location;
                        location.Offset(Settings.width, 0);
                        control.Location = location;
                    }
                }
                for (int f = 0; f < controls[0].Length; f++)
                {
                    if (controls[pointer - 1][f] != null)
                    {
                        controls[pointer - 1][f].Location = new Point(0, f * Settings.height);
                        players.GameControlAdd(controls[pointer - 1][f]);
                        controlCollection.Add(controls[pointer - 1][f]);
                        if (controls[pointer - 1][f] is Enemy)
                        {
                            players.GameControlRemove(controls[pointer - 1][f]);
                            players.EnemyAdd(controls[pointer - 1][f] as Enemy);
                            players.StartEnemies();
                            controls[pointer - 1][f] = null;
                        }
                    }
                }

                /* for (int f = 0; f < players.GetEnemy().Count; f++)
                 * {
                 *   if (players.GetEnemy()[f].Location.Y == Settings.width * (pointer - 1))
                 *   {
                 *       try
                 *       {
                 *           controlCollection.Add(players.GetEnemy()[f]);
                 *           players.GetEnemy()[f].Start(players);
                 *       }
                 *       catch (Exception) { }
                 *   }
                 * }*/
                pointer--;
                Point temp = players.Location;
                temp.Offset(Settings.width, 0);
                players.Location = temp;
                foreach (Enemy enemy in players.GetEnemy())
                {
                    if (enemy != null)
                    {
                        Point help2 = enemy.Location;
                        help2.Offset(Settings.width, 0);
                        enemy.Location = help2;
                        if (help.X > Screen.PrimaryScreen.WorkingArea.Width)
                        {
                            players.EnemyRemove(enemy);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
 private void Setting_FormClosing(object sender, FormClosingEventArgs e)
 {
     ReadFile.SetSettings(settings);
 }
Exemplo n.º 9
0
 private void btnResetAll_Click(object sender, EventArgs e)
 {
     ReadFile.ResetAll(settings);
     Application.Restart();
 }