コード例 #1
0
ファイル: LaserTurret.cs プロジェクト: MechaKnightz/Game2Test
        public void UpdateShots()
        {
            _durationCounter--;

            Start.Position = Position;
            Start.Rotation = Rotation;

            var tempPos = Middle.Position;

            tempPos.X       = (float)Math.Cos(Rotation) * Start.Rectangle.Width + Position.X;
            tempPos.Y       = (float)Math.Sin(Rotation) * Start.Rectangle.Width + Position.Y;
            Middle.Position = tempPos;
            Middle.Rotation = Rotation;

            var tempPos2 = End.Position;

            tempPos2.X   = (float)Math.Cos(Rotation) * Middle.Rectangle.Width + Middle.Position.X;
            tempPos2.Y   = (float)Math.Sin(Rotation) * Middle.Rectangle.Width + Middle.Position.Y;
            End.Position = tempPos2;
            End.Rotation = Rotation;

            if (_durationCounter > 00)
            {
                IsFiring = true;
                return;
            }
            SpriteList.Clear();
            IsFiring = false;
        }
コード例 #2
0
 public void Populate(List <AirlockPainterEntry> entries)
 {
     SpriteList.Clear();
     foreach (var entry in entries)
     {
         SpriteList.AddItem(entry.Name, entry.Icon);
     }
 }
コード例 #3
0
ファイル: LaserTurret.cs プロジェクト: MechaKnightz/Game2Test
        public float Update(float energy)
        {
            if (energy - EnergyCost <= 0)
            {
                SpriteList.Clear();
                IsFiring = false;
            }

            if (IsFiring)
            {
                UpdateShots();
                TurnRate = BaseTurnrate * 0.1f;
                return(EnergyCost);
            }
            // VVV is not firing VVV
            TurnRate = BaseTurnrate;
            if (CooldownCounter != Cooldown)
            {
                CooldownCounter++;
            }
            SoundEffectInstance?.Stop();
            return(0f);
        }
コード例 #4
0
        private void Open_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog
            {
                Title           = "Select data.win to open",
                CheckPathExists = true,
                CheckFileExists = true,
                Filter          = "Game Maker .win files|*.win",
                FilterIndex     = 0,
                Multiselect     = false
            };

            Stream fs = null;

            if (dialog.ShowDialog() == true)
            {
                fs = dialog.OpenFile();
            }
            else
            {
                return;
            }

            using (BinaryReader br = new BinaryReader(fs))
            {
                GEN8.Load(br);
                //GEN8 g = GEN8.Instance;
                //Console.WriteLine(string.Format("Filename: {0}\nName: {1}\nDisplayName: {2}\nSteamAppID: {3}", g.Filename, g.Name, g.DisplayName, g.SteamAppID));

                TXTR.Load(br);
                SPRT.Load(br);
                BGND.Load(br);
            }

            List <Sprite> sprites = SPRT.Instance.Contents;

            SpriteList.Clear();

            for (int i = 0; i < sprites.Count; i++)
            {
                Sprite spr = sprites[i];
                if (spr.GetFrames().Length < 1)
                {
                    continue;
                }

                AssetItem ai = new AssetItem(spr.Name, spr);
                SpriteList.Add(ai);
            }

            List <Background> backgrounds = BGND.Instance.Contents;

            BackgroundList.Clear();

            for (int i = 0; i < backgrounds.Count; i++)
            {
                AssetItem ai = new AssetItem(backgrounds[i].Name, backgrounds[i]);
                BackgroundList.Add(ai);
            }

            GEN8 g = GEN8.Instance;

            GameInfoText.Inlines.Clear();
            GameInfoText.Inlines.Add(new Bold(new Run("Name: ")));
            GameInfoText.Inlines.Add(new Run(g.DisplayName + "\n"));
            GameInfoText.Inlines.Add(new Bold(new Run("Development Name: ")));
            GameInfoText.Inlines.Add(new Run(g.Name + "\n"));
            GameInfoText.Inlines.Add(new Bold(new Run("Version: ")));
            GameInfoText.Inlines.Add(new Run(string.Format("{0}.{1}\n", g.MajorVersion, g.MinorVersion)));
            GameInfoText.Inlines.Add(new Bold(new Run("Build Version: ")));
            GameInfoText.Inlines.Add(new Run(g.BuildVersion + "\n"));
            GameInfoText.Inlines.Add(new Bold(new Run("Release Version: ")));
            GameInfoText.Inlines.Add(new Run(g.ReleaseVersion + "\n"));
        }
コード例 #5
0
ファイル: Display.cs プロジェクト: ARLM-Attic/wordplay
        /// <summary>
        /// Triggered on the animation loop.
        /// </summary>
        private bool OnTick()
        {
            // Check state
            if (Game.State == GameState.Started)
            {
                Game.State = GameState.InProgress;
            }

            if (lastState != Game.State)
            {
                // Check for game over
                if (Game.State == GameState.Completed)
                {
                    // Wipe everything
                    sprites.Clear();

                    // Add game over screen
                    AddGameOver();
                }

                // Save the state
                lastState = Game.State;
            }

            // Update the sprites
            sprites.Update();

            // Remove any completed animations
            LinkedList <BurntSprite> list = new LinkedList <BurntSprite>();

            foreach (ISprite sprite in sprites)
            {
                BurntSprite bs = sprite as BurntSprite;

                if (bs != null && bs.CanRemove)
                {
                    list.Add(bs);
                }
            }

            foreach (BurntSprite bs in list)
            {
                sprites.Remove(bs);
            }

            // Render the pane
            viewport.FireQueueDraw(this);

            // Handle the tick updating
            tickCount++;

            if (tickCount % 100 == 0)
            {
                int    fps  = (int)Game.Config.FramesPerSecond;
                double diff = (DateTime.UtcNow.Ticks - start) / 10000000.0;
                double efps = exposeCount / diff;
                double tfps = tickCount / diff;
                Console.WriteLine(
                    "FPS: Exposed {0:N1} FPS ({3:N1}%), " + "Ticks {1:N1} FPS ({4:N1}%), " +
                    "Maximum {2:N0} FPS",
                    efps,
                    tfps,
                    fps,
                    efps * 100 / fps,
                    tfps * 100 / fps);
                start       = DateTime.UtcNow.Ticks;
                exposeCount = tickCount = 0;
            }

            // Re-request the animation
            Timeout.Add(1000 / Game.Config.FramesPerSecond, OnTick);
            return(false);
        }