Ejemplo n.º 1
0
        public Game(string ime)
        {
            InitializeComponent();
            this.DoubleBuffered = true;

            between_level = false;
            use           = false;
            maze_assets   = new List <Asset>();
            Vertex st = new Vertex(0, 0);

            character  = new Character(ime, st);
            assets     = new List <Asset>();
            num_assets = 2;

            level = 1;
            setUpLevel();//set up level generira info za maze


            if (ime == "Varda")
            {
                ExtraTime  et1 = new ExtraTime(5);
                FreezeTime ft  = new FreezeTime();
                assets.Add(ft);
                assets.Add(et1);
            }
            else
            {
                SlowdownTime slt = new SlowdownTime();
                ExtraTime    et1 = new ExtraTime(10);
                assets.Add(et1);
                assets.Add(slt);
            }
            updategraphics();
        }
Ejemplo n.º 2
0
        public void checkifasset()
        {
            for (int i = 0; i < maze_assets.Count; i++)
            {
                if (character.getLocation().i == maze_assets.ElementAt(i).location.i&& character.getLocation().j == maze_assets.ElementAt(i).location.j)
                {
                    //open Question form , challenge
                    timer.Stop();
                    if (maze_assets.ElementAt(i).challenge())
                    {
                        if (maze_assets.ElementAt(i).t_asset == type_of_asset.LIFE)
                        {
                            character.lives += 1; updategraphics(); timer.Start();
                        }

                        if (maze_assets.ElementAt(i).t_asset == type_of_asset.EXTRA_TIME)
                        {
                            ExtraTime et = (ExtraTime)maze_assets.ElementAt(i);
                            assets.Add(et); updategraphics(); timer.Start();
                        }

                        if (maze_assets.ElementAt(i).t_asset == type_of_asset.SLOWDOWN_TIME)
                        {
                            SlowdownTime slt = (SlowdownTime)maze_assets.ElementAt(i);
                            assets.Add(slt); updategraphics(); timer.Start();
                        }

                        if (maze_assets.ElementAt(i).t_asset == type_of_asset.FREEZE_TIME)
                        {
                            FreezeTime ft = (FreezeTime)maze_assets.ElementAt(i);
                            assets.Add(ft); updategraphics(); timer.Start();
                        }
                    }
                    else
                    {
                        if (maze_assets.ElementAt(i).t_asset == type_of_asset.EXTRA_TIME)
                        {
                            ExtraTime et = (ExtraTime)maze_assets.ElementAt(i);
                            time -= et.penalty;
                        }

                        if (maze_assets.ElementAt(i).t_asset == type_of_asset.SLOWDOWN_TIME)
                        {
                            time -= 3;
                        }

                        if (maze_assets.ElementAt(i).t_asset == type_of_asset.FREEZE_TIME)
                        {
                            time -= 3;
                        }

                        timer.Start();
                    }

                    Asset tmp = maze_assets.ElementAt(i);
                    maze_assets.Remove(tmp); updategraphics();
                }
            }
        }
Ejemplo n.º 3
0
        private void asset2_Click(object sender, EventArgs e)
        {
            if (assets.Count >= 2 && !use && !between_level)
            {
                bool b = false;

                if (!b && assets.Count > 0 && assets.ElementAt(1).t_asset == type_of_asset.EXTRA_TIME)
                {
                    ExtraTime et = (ExtraTime)assets.ElementAt(1);
                    asset_in_use = et;
                    if (et.seconds == 5)
                    {
                        assetInUse.Image = The_Valar_Quest.Properties.Resources.petsec;
                    }
                    else
                    {
                        assetInUse.Image = The_Valar_Quest.Properties.Resources.desetsec;
                    }
                    assetInUse.Visible = true;
                    time_asset         = et.seconds;
                    use = true; useAsset(assets.ElementAt(1), time_asset); b = true;
                }

                if (!b && assets.Count > 0 && assets.ElementAt(1).t_asset == type_of_asset.FREEZE_TIME)
                {
                    FreezeTime ft = (FreezeTime)assets.ElementAt(1);
                    asset_in_use       = ft;
                    assetInUse.Image   = The_Valar_Quest.Properties.Resources.FreezeTime;
                    assetInUse.Visible = true;
                    time_asset         = ft.interval;
                    use = true; useAsset(assets.ElementAt(1), time_asset); b = true;
                }

                if (!b && assets.Count > 0 && assets.ElementAt(1).t_asset == type_of_asset.SLOWDOWN_TIME)
                {
                    SlowdownTime slt = (SlowdownTime)assets.ElementAt(1);
                    asset_in_use       = slt;
                    assetInUse.Image   = The_Valar_Quest.Properties.Resources.slow_down_time_assets;
                    assetInUse.Visible = true;
                    time_asset         = slt.seconds;
                    use = true; useAsset(assets.ElementAt(1), time_asset); b = true;
                }
            }
        }
Ejemplo n.º 4
0
        public void setAssets()
        {
            //postavi lista maze_assets random
            int rndasset = 4 - num_assets;

            if (rndasset >= 1)
            {
                int rd = r.Next(0, 4);
                if (character.lives == 3)
                {
                    rd = r.Next(0, 3);
                }
                Vertex l = pickRandomVertexFromPath();
                if (rd == (int)type_of_asset.EXTRA_TIME)
                {
                    int rd1 = r.Next(200); int s = 0; if (rd1 % 2 == 0)
                    {
                        s = 5;
                    }
                    else
                    {
                        s = 10;
                    } ExtraTime et = new ExtraTime(s); et.location = l; maze_assets.Add(et);
                }
                if (rd == (int)type_of_asset.SLOWDOWN_TIME)
                {
                    SlowdownTime slt = new SlowdownTime(); slt.location = l; maze_assets.Add(slt);
                }
                if (rd == (int)type_of_asset.FREEZE_TIME)
                {
                    FreezeTime ft = new FreezeTime(); ft.location = l; maze_assets.Add(ft);
                }
                if (rd == (int)type_of_asset.LIFE)
                {
                    Life life = new Life(); life.location = l; maze_assets.Add(life);
                }
            }
            rndasset -= 1;
            for (int i = 0; i < rndasset; i++)
            {
                int    x  = r.Next(0, height);
                int    y  = r.Next(0, width);
                Vertex l  = matrix[x][y];
                int    rd = r.Next(0, 4); if (character.lives == 3)
                {
                    rd = r.Next(0, 3);
                }
                if (rd == (int)type_of_asset.EXTRA_TIME)
                {
                    int rd1 = r.Next(200); int s = 0; if (rd1 % 2 == 0)
                    {
                        s = 5;
                    }
                    else
                    {
                        s = 10;
                    } ExtraTime et = new ExtraTime(s); et.location = l; maze_assets.Add(et);
                }
                if (rd == (int)type_of_asset.SLOWDOWN_TIME)
                {
                    SlowdownTime slt = new SlowdownTime(); slt.location = l; maze_assets.Add(slt);
                }
                if (rd == (int)type_of_asset.FREEZE_TIME)
                {
                    FreezeTime ft = new FreezeTime(); ft.location = l; maze_assets.Add(ft);
                }
                if (rd == (int)type_of_asset.LIFE)
                {
                    Life life = new Life(); life.location = l; maze_assets.Add(life);
                }
            }
        }