Exemplo n.º 1
0
        public override void Start()
        {
            ((Game)Engine.Objects["game"]).AudioSource.Pause();

            GameManager.MainWindow = "gameover";
            Engine.TimeModifier = 0f;

            Timer.Set("limit", 1f, ignoreTimeModifier: true);

            var background = new RectangleObject(Engine.Width, Engine.Height)
            {
                Order = 20, 
                Color = Color.FromArgb(225, 52, 6, 6),
                IgnoreCamera = true,
                Fill = true,
            };
            Engine.SpawnObject("gameOverBg", background);

            var gameOverText = new TextObject(2f, Color.Crimson, 0.9f)
            {
                Order = 20,
                Text = "GAMEOVER"
            };
            var gameOverMeasure = gameOverText.Measure();
            gameOverText.X = Engine.Width/2 - gameOverMeasure.X/2;
            gameOverText.Y = Engine.Height/2 - gameOverMeasure.Y/2;
            gameOverText.IgnoreCamera = true;
            Engine.SpawnObject("gameOverTxt", gameOverText);
        }
Exemplo n.º 2
0
        public override void Start()
        {
            base.Start();

            var game = (Game) Engine.Objects["game"];
            game.AudioSource.Pause();

            Engine.TimeModifier = 0f;

            speed = 350f + GameManager.GlobalTimer;
            KeyPadding = 250f;

            AudioSource.Volume = 1f;
            AudioSource.Play(((AudioAsset) Engine.GetAsset("sound_ritual_intro")).Clip);

            QteLogo0 = new TextObject(3f, Color.Crimson)
            {
                Order = 12,
                Text = "RITUAL"
            };
            QteLogo1 = new TextObject(3f, Color.Crimson)
            {
                Order = 12,
                Text = "TIME !"
            };
            var logoMeasure0 = QteLogo0.Measure();
            var logoMeasure1 = QteLogo1.Measure();
            QteLogo0.X = Engine.Width/2 - logoMeasure0.X/2;
            QteLogo0.Y = Engine.Height/2 - (logoMeasure0.Y + logoMeasure1.Y)/2;
            QteLogo1.X = Engine.Width/2 - logoMeasure1.X/2;
            QteLogo1.Y = QteLogo0.Y + logoMeasure0.Y;
            Engine.SpawnObject($"{Name}_logo0", QteLogo0);
            Engine.SpawnObject($"{Name}_logo1", QteLogo1);
            Timer.Set("startQte", 1.5f, ignoreTimeModifier: true);
        }
Exemplo n.º 3
0
        private void StartGameOver()
        {
            Engine.TimeModifier = 0f;

            AudioSource.Pause();
            MainWindow = "gameover";
            var background = new RectangleObject(Engine.Width, Engine.Height)
            {
                Color        = Color.FromArgb(125, 0, 0, 0),
                Fill         = true,
                Order        = 10,
                IgnoreCamera = true
            };

            Engine.SpawnObject("gameover_background", background);
            var gameOver = new TextObject(1.33f, Color.White)//Color.Red)
            {
                Text         = "GAMEOVER",
                Order        = 11,
                IgnoreCamera = true
            };
            // replace with alignment.center or use TextObject.Measure
            var gameOverSize = gameOver.Measure();

            gameOver.X = Engine.Width / 2f - gameOverSize.X / 2;
            gameOver.Y = Engine.Height / 2f - gameOverSize.Y / 2;
            Engine.SpawnObject("gameover_text", gameOver);

            Timer.Set("gameOverTimer", GameOverDelay, ignoreTimeModifier: true);
        }
Exemplo n.º 4
0
        public override void Start()
        {
            Console.WriteLine("Paused");

            var background = new RectangleObject();
            background.color = Color.Black;
            background.fill = true;
            background.width = engine.width;
            background.height = engine.height;
            background.order = 10;
            engine.SpawnObject("pause_background", background);
            var pauseText = new TextObject("Phosphate", 80, "darkgreen");
            pauseText.text = "PAUSE";
            var pauseTextSize = TextRenderer.MeasureText(pauseText.text, pauseText.font);
            pauseText.x = engine.width/2 - pauseTextSize.Width/2;
            pauseText.y = engine.height/2 - pauseTextSize.Height/2;
            pauseText.order = 11;
            engine.SpawnObject("pause_text", pauseText);
        }
Exemplo n.º 5
0
        public Hud()
        {
            var fontSize = 0.4f;
            hp = new TextObject(fontSize, Color.IndianRed);
            hp.Order = 10;
            xp = new TextObject(fontSize, Color.DarkBlue);
            xp.Order = 10;
            lvl = new TextObject(fontSize, Color.ForestGreen);
            lvl.Order = 10;
            timer = new TextObject(fontSize, Color.BurlyWood);
            timer.Order = 10;
            wave = new TextObject(fontSize, Color.BlanchedAlmond);
            wave.Order = 10;
            waveTimer = new TextObject(fontSize, Color.Beige);
            waveTimer.Order = 10;
            hpNumber = new TextObject(fontSize/2, Color.DarkGray);
            hpNumber.Order = 11;
            xpNumber = new TextObject(fontSize/2, Color.DarkGray);
            xpNumber.Order = 11;

            Padding = 20;
            InnerPadding = Padding/2;
        }
Exemplo n.º 6
0
        public override void Start()
        {
            int border = 1;
            int padding = 10;
            TextObject HP = new TextObject ("Arial Black", 18, "darkred");
            HP.order = this.order;
            HP.text = "HP";
            HP.x = padding;
            HP.y = padding;
            Size HPSize = TextRenderer.MeasureText (HP.text, HP.font);
            hpBarContainer = new RectangleObject ();
            hpBarContainer.x = HP.x + padding + HPSize.Width;
            hpBarContainer.y = HP.y;
            hpBarContainer.order = this.order;
            hpBarContainer.width = hudWidth;
            hpBarContainer.height = HPSize.Height;
            hpBarContainer.color = Color.Black;
            hpBar = new RectangleObject ();
            hpBar.order = this.order;
            hpBar.x = hpBarContainer.x + border;
            hpBar.y = hpBarContainer.y + border;
            hpBar.color = Color.DarkRed;
            hpBar.fill = true;
            hpBar.height = hpBarContainer.height - border * 2;
            hpTextObj = new TextObject ("Arial Black", 18, "darkred");
            hpTextObj.order = this.order;
            hpTextObj.x = hpBarContainer.x + hpBarContainer.width + padding;
            hpTextObj.y = HP.y;

            TextObject XP = new TextObject ("Arial Black", 18, "darkgreen");
            XP.order = this.order;
            XP.text = "XP";
            XP.x = padding;
            XP.y = padding + HP.y + HPSize.Height;
            Size XPSize = TextRenderer.MeasureText (XP.text, XP.font);
            xpBarContainer = new RectangleObject ();
            xpBarContainer.x = XP.x + padding + XPSize.Width;
            xpBarContainer.y = XP.y;
            xpBarContainer.order = this.order;
            xpBarContainer.width = hudWidth;
            xpBarContainer.height = XPSize.Height;
            xpBarContainer.color = Color.Black;
            xpBar = new RectangleObject ();
            xpBar.order = this.order;
            xpBar.x = xpBarContainer.x + border;
            xpBar.y = xpBarContainer.y + border;
            xpBar.color = Color.DarkOliveGreen;
            xpBar.fill = true;
            xpBar.height = xpBarContainer.height - border * 2;
            levelTextObj = new TextObject ("Arial Black", 18, "darkgreen");
            levelTextObj.order = this.order;
            levelTextObj.text = "0% to 1";
            levelTextObj.x = xpBarContainer.x + xpBarContainer.width + padding;
            levelTextObj.y = XP.y;

            engine.SpawnObject (this.name + "_hpText", HP);
            engine.SpawnObject (this.name + "_hpBarContainer", hpBarContainer);
            engine.SpawnObject (this.name + "_hpBar", hpBar);
            engine.SpawnObject (this.name + "_hpTextObj", hpTextObj);
            engine.SpawnObject (this.name + "_xpText", XP);
            engine.SpawnObject (this.name + "_xpBarContainer", xpBarContainer);
            engine.SpawnObject (this.name + "_xpBar", xpBar);
            engine.SpawnObject (this.name + "_levelTextObj", levelTextObj);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Engine engine = new Engine("test", 1024, 768, 60, false, false);
            engine.debugCollisions = true;

            // set default directory for assets, will be appened to all assets's path
            Asset.BasePath = "..\\..\\Assets";

            // load repeating texture
            var repeatingGoblins = new SpriteAsset("goblins.png", 100, 100, 150, 150, repeatx: true, repeaty: true);
            // auto hitbox and spriteasset with repeatx or/and repeaty are NOT compatible
            var obj = new SpriteObject(repeatingGoblins.Width + 20, repeatingGoblins.Height + 100);
            obj.CurrentSprite = repeatingGoblins;

            obj.OnUpdate += sender =>
            {
                var s = (SpriteObject)sender;
                s.SpriteOffset += new Vector2(10f, 0f) * s.DeltaTime;
            };

            // text
            TextConfig.Default = new TextConfig(new Asset("font.png"), charToSprite);
            var semiTransparentText = new TextObject(0.66f, Color.Red, 0.8f);
            semiTransparentText.Text = "SEMI TRANSPARENT";
            semiTransparentText.Y = obj.Height;
            var bigText = new TextObject(1.1f, Color.CadetBlue);
            bigText.Text = "BIG TEXT";
            var semiTransparentTextMeasure = semiTransparentText.Measure();
            bigText.Y = semiTransparentTextMeasure.Y + semiTransparentText.Y;
            var bigTextMeasure = bigText.Measure();

            // hitboxes
            var spriteSheet = new SpriteAsset("rob.png");
            var tileWidth = spriteSheet.Width/22;
            var tileHeight = spriteSheet.Height/1;
            var spriteAsset = new SpriteAsset("rob.png", 0, 0, tileWidth, tileHeight);
            var spriteH = new SpriteObject(spriteAsset.Width, spriteAsset.Height, true);
            spriteH.Y = bigText.Y + bigTextMeasure.Y;
            spriteH.CurrentSprite = spriteAsset;
            spriteH.Scale = new Vector2(5f, 5f);

            // spawn gameobjects
            engine.SpawnObject("obj", obj);

            engine.SpawnObject("semiTransparentText", semiTransparentText);
            engine.SpawnObject("bigText", bigText);

            engine.SpawnObject("spriteH", spriteH);

            engine.Run();
        }
Exemplo n.º 8
0
        private void StartEvent()
        {
            started = true;

            var xPos = 0f;
            var maxHeight = 0f;
            foreach (var key in Utils.RandomKeys((int) (15 + GameManager.GlobalTimer/30f), KeyCodeForQte))
            {
                var text = new TextObject(FontSize, Color.Crimson)
                {
                    Text = $"{KeyToText(key)}",
                    Order = 10,
                    IgnoreCamera = true
                };
                var textMeasure = text.Measure();
                text.X = Engine.Width - textMeasure.X/2f + xPos;
                text.Y = Engine.Height - textMeasure.Y - Padding;
                qteList.Add(text);

                xPos += textMeasure.X + KeyPadding;
                Engine.SpawnObject($"QTE_key_{Name}_{key}", text);
                if (textMeasure.Y > maxHeight)
                    maxHeight = textMeasure.Y;
            }
            var qteBoxAsset = (SpriteAsset) Engine.GetAsset("qteContainer");
            qteBox = new SpriteObject(qteBoxAsset.Width, (int) (qteBoxAsset.Height*0.66f))
            {
                Order = 11,
                CurrentSprite = qteBoxAsset,
                IgnoreCamera = true
            };
            qteBox.X = Engine.Width/2 - qteBox.Width/2;
            qteBox.Y = Engine.Height - qteBox.Height - Padding*0.5f;
            Engine.SpawnObject($"{Name}_qteBox", qteBox);

            AudioSource.Volume = 0.7f;
            AudioSource.Play(((AudioAsset) Engine.GetAsset("sound_ritual_soundtrack")).Clip);
        }
Exemplo n.º 9
0
 public void GameOver()
 {
     mainWindow = "gameover";
     var background = new RectangleObject();
     background.color = Color.Black;
     background.fill = true;
     background.width = engine.width;
     background.height = engine.height;
     background.order = 10;
     engine.SpawnObject("gameover_background", background);
     var gameOver = new TextObject("Phosphate", 80, "red");
     gameOver.text = "GAMEOVER";
     var gameOverSize = TextRenderer.MeasureText(gameOver.text, gameOver.font);
     gameOver.x = engine.width/2 - gameOverSize.Width/2;
     gameOver.y = engine.height/2 - gameOverSize.Height/2;
     gameOver.order = 11;
     engine.SpawnObject("gameover_text", gameOver);
     gameOverTimer = gameOverDelay;
 }
Exemplo n.º 10
0
        public override void Start()
        {
            base.Start();

            MainClass.LoadAssets(Engine);

            TextConfig.Default = new TextConfig(new Asset("font.png"), charToSprite,
                                                paddingFunc: (float width) =>
            {
                float result = width;
                result      *= -0.066f;
                return(result);
            });

            GameBackground.Initialize(Engine);

            Engine.SpawnObject(new CharactersInfo());

            var logoAsset = (SpriteAsset)Engine.GetAsset("logo");
            var logoObj   = new SpriteObject(logoAsset.Width, logoAsset.Height)
            {
                CurrentSprite = logoAsset
            };

            logoObj.X = Engine.Width / 2 - logoObj.Width / 2;
            logoObj.Y = Engine.Height / 2 - logoObj.Height / 2;
            // game controls text
            var padding      = 3f;
            var fontSize     = 0.66f;
            var gameControls = new TextObject(fontSize, Color.White);

            gameControls.Text = "WASD: movements";
            var gameControlsSize = gameControls.Measure();

            gameControls.X = Engine.Width / 2 - gameControlsSize.X / 2;
            gameControls.Y = logoObj.Y + logoObj.Height + padding;
            var gameControls2 = new TextObject(fontSize, Color.White);

            gameControls2.Text = "Arrows+QEZC: shot";
            var gameControls2Size = gameControls2.Measure();

            gameControls2.X = Engine.Width / 2 - gameControls2Size.X / 2;
            gameControls2.Y = gameControls.Y + gameControlsSize.Y + padding;
            var gameControls3 = new TextObject(fontSize, Color.White);

            gameControls3.Text = "F: change spell";
            var gameControls3Size = gameControls3.Measure();

            gameControls3.X = Engine.Width / 2 - gameControls3Size.X / 2;
            gameControls3.Y = gameControls2.Y + gameControls2Size.Y + padding;
            var gameControls4 = new TextObject(fontSize, Color.White);

            gameControls4.Text = "M: map - Esc: pause";
            var gameControls4Size = gameControls4.Measure();

            gameControls4.X = Engine.Width / 2 - gameControls4Size.X / 2;
            gameControls4.Y = gameControls3.Y + gameControls3Size.Y + padding;
            var continueText = new TextObject(fontSize, Color.White);

            continueText.Text = "Press anything to play!";
            var continueTextSize = continueText.Measure();

            continueText.X = Engine.Width / 2 - continueTextSize.X / 2;
            continueText.Y = Engine.Height - padding - continueTextSize.Y;

            Engine.SpawnObject("logo", logoObj);
            Engine.SpawnObject("logo_controls", gameControls);
            Engine.SpawnObject("logo_controls2", gameControls2);
            Engine.SpawnObject("logo_controls3", gameControls3);
            Engine.SpawnObject("logo_controls4", gameControls4);
            Engine.SpawnObject("logo_continueText", continueText);
            MainWindow = "logo";

            BasicItems.Initialize(Engine);

            AudioSource.Volume = 0.66f;
            AudioSource.Stream(((AudioAsset)Engine.GetAsset("sound_soundtrack")).FileName, true);
        }