/// <summary>
        /// Inicijalizacija igre
        /// mora se dodati u prvu scenu prije pozivanja
        /// </summary>
        public void Initialize()
        {
            OnBegin = delegate
            {
                Neprijatelj.Postavljanje();
                Stit.Postavljanje();
                GlavnaScena scene = Program.Igra.GetScene <GlavnaScena>();

                Ufo = new UFO();

                Program.Igra.GetScene <GlavnaScena>().Add(Ufo);

                // Create player and add to scene
                Igrac = new Igrac();
                Add(Igrac);
                // Gametext for the entire game pretty much
                #region gameText

                var background = new Image("Slike/background.png");
                background.Alpha = 0.4f;
                scene.AddGraphic(background);

                //Setting a default config file for the RichText to use
                var txtConfig = new RichTextConfig()
                {
                    TextAlign = TextAlign.Center,
                    CharColor = Color.Green,
                    FontSize  = 18,
                    SineAmpX  = 1,
                    SineAmpY  = 2,
                    SineRateX = 1,
                    Font      = new Font("Slike/VCR_OSD_MONO.ttf"),
                };

                // Writing the text graphics and setting position
                var livesLeftTxtLabel = new RichText("Zivoti", txtConfig);
                livesLeftTxtLabel.SetPosition(50, 16);

                scene.PreostaloZivotaText      = new RichText(scene.Igrac.ZivotiIgraca.ToString(), txtConfig);
                scene.PreostaloZivotaText.Name = "livesLeftTxt";
                scene.PreostaloZivotaText.SetPosition(70, 32);

                var curScoreTxtLabel = new RichText("Bodovi", txtConfig);
                curScoreTxtLabel.SetPosition(650, 15);

                scene.TrenutniBodoviText      = new RichText(scene.Igrac.IznosBodova.ToString(), txtConfig);
                scene.TrenutniBodoviText.Name = "curScoreTxt";
                scene.TrenutniBodoviText.SetPosition(670, 32);

                // Adds Graphic to Scene
                scene.AddGraphic(livesLeftTxtLabel);
                scene.AddGraphic(curScoreTxtLabel);

                scene.AddGraphic(scene.PreostaloZivotaText);
                scene.AddGraphic(scene.TrenutniBodoviText);

                #endregion gameText
            };
        }
Пример #2
0
        /// <summary>
        /// provjeri sudaranje sa štitom
        /// </summary>
        /// <param name="glavnaScena">scene</param>
        void CheckBarricade(GlavnaScena glavnaScena)
        {
            Stit stit = (Stit)Collider.CollideEntity(X, Y, Oznake.Stit);

            if (stit != null)
            {
                // provjera je li igračev metak pogodio štit
                if (Collider.Tags[0] == (int)Oznake.Igrac)
                {
                    stit.OstetiSe();
                    Visible    = false;
                    Collidable = false;
                }

                // provjera je li neprijateljev metak pogodio štit
                else
                {
                    stit.OstetiSe();
                    RemoveSelf();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Postavlja stitove
        /// </summary>
        static void PostaviStitove()
        {
            List <Tocka> tocke = new List <Tocka>()
            {
                new Tocka(50, 450),
                new Tocka(50, 474),
                new Tocka(50, 498),
                new Tocka(74, 450),
                new Tocka(98, 450),
                new Tocka(122, 450),
                new Tocka(122, 474),
                new Tocka(122, 498)
            };

            foreach (Tocka t in tocke)
            {
                for (int i = 0; i < 4; i++)
                {
                    Stit stit = new Stit();
                    stit.Position = new Vector2(t.X + i * 200, t.Y);
                    Program.Igra.GetScene <GlavnaScena>().Add(stit);
                }
            }
        }