Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #4
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();
        }
Пример #5
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);
        }
Пример #6
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);
        }