コード例 #1
0
ファイル: Program.cs プロジェクト: alexSatov/univer-csharp
        public GameField(Size elementSize, Game game)
        {
            SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
            UpdateStyles();
            this.game       = game;
            MonsterGraphics = new List <UnitGraphics>();
            ElementSize     = elementSize;
            ClientSize      = new Size(ElementSize.Width * Game.MapWidth, ElementSize.Height * Game.MapHeight + ElementSize.Width);

            WizardGraphics = new UnitGraphics(ElementSize, game.Wizard, 200, this);
            WizardGraphics.UpdateLocation();

            Controls.Add(WizardGraphics);
            BuildCastleWalls(this);
            var AnimationTimer = new Timer();

            AnimationTimer.Interval = 1;
            AnimationTimer.Tick    += TimerTick;
            AnimationTimer.Start();

            var offenceTimer = new Timer();

            offenceTimer.Interval = 1000;
            offenceTimer.Tick    += OffenceTick;
            offenceTimer.Start();

            var magicTimer = new Timer();

            magicTimer.Interval = 150;
            magicTimer.Tick    += MagicTick;
            magicTimer.Start();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: alexSatov/univer-csharp
        void TimerTick(object sender, EventArgs args)
        {
            WizardGraphics.UpdateLocation();
            if (SpellGraphic != null)
            {
                SpellGraphic.UpdateLocation();
            }
            else
            {
                SpellGraphic = new SpellGraphics(game.Wizard.spells[game.Wizard.CurrentSpell], ElementSize, this);
                Controls.Add(SpellGraphic);
            }

            foreach (var monster in game.Monsters)
            {
                var monsterGraphics = new UnitGraphics(ElementSize, monster, 200, this);
                monsterGraphics.DirectionX = -1;
                monsterGraphics.DirectionY = 0;
                if (!MonsterGraphics.Contains(monsterGraphics))
                {
                    MonsterGraphics.Add(monsterGraphics);
                    Controls.Add(monsterGraphics);
                }
            }

            try
            {
                foreach (var monsterGraph in MonsterGraphics)
                {
                    monsterGraph.UpdateLocation();
                }
            }
            catch
            {
                foreach (var monsterGraph in MonsterGraphics)
                {
                    monsterGraph.UpdateLocation();
                }
            }

            Invalidate();
        }