Exemple #1
0
            public void Add(IGameControl control)
            {
                var wasFound = false;

                for (var index = _controls.Count - 1; index >= 0; index--)
                {
                    var controlRef = _controls[index];
                    if (controlRef.IsAlive)
                    {
                        if (controlRef.Target == control)
                        {
                            wasFound = true;
                        }
                    }
                    else
                    {
                        _controls.RemoveAt(index);
                    }
                }

                if (!wasFound)
                {
                    _controls.Add(new WeakReference(control));
                }
            }
Exemple #2
0
 public PlayWindow(IGameControl gameControl, string title, GuiMatrix guiMatrix)
 {
     this.Text = title;
     InitializeComponent();
     matrix  = guiMatrix;
     control = gameControl;
 }
Exemple #3
0
 public WindowManager(IGameControl game_control)
 {
     PANELS        = new List <Aptima.Asim.DDD.Client.Common.GLCore.Controls.Panel>();
     WINDOWS       = new List <Aptima.Asim.DDD.Client.Common.GLCore.Window>();
     _visible_rect = Rectangle.Empty;
     _game_control = game_control;
 }
Exemple #4
0
 public WindowManager(IGameControl game_control)
 {
     PANELS = new List<Aptima.Asim.DDD.Client.Common.GLCore.Controls.Panel>();
     WINDOWS = new List<Aptima.Asim.DDD.Client.Common.GLCore.Window>();
     _visible_rect = Rectangle.Empty;
     _game_control = game_control;
 }
Exemple #5
0
        /// <summary>
        /// Starts the Game Framework, registers a form and a gamecontroller.
        /// The form is required to intercept keyboard and mouse input.
        /// The GameController initializes scenes and feeds them to the GameController.
        /// </summary>
        /// <param name="form"></param>
        /// <param name="game_control"></param>
        public void Run(Form form, IGameControl game_control)
        {
            if (form == null)
            {
                throw new ApplicationException("Must supply a windows Form.");
            }
            _main_window = form;
            if (game_control == null)
            {
                throw new ApplicationException("Game Control is uninitialized.");
            }
            _CANVAS_ = new Canvas();
            QueryPerformanceFrequency(ref _ticks_per_second);

            _game_control          = game_control;
            _CANVAS_.TargetControl = _game_control.GetTargetControl();

            _game_control.InitializeCanvasOptions(_CANVAS_.Options);
            _CANVAS_.InitializeCanvas();

            _AvailableScenes_ = _game_control.InitializeScenes(this);
            _AvailableScenes_[CURRENT_SCENE].Initialize(this);
            _game_control.SceneChanged(CURRENT_SCENE);

            Idle              = new EventHandler(GameLoop);
            Application.Idle += Idle;
        }
Exemple #6
0
 public PlayWindow(IGameControl gameControl, string title, GuiMatrix guiMatrix)
 {
     this.Text = title;
     InitializeComponent ();
     matrix = guiMatrix;
     control = gameControl;
 }
Exemple #7
0
        public SplashScene2(IGameControl game_control, ICommand commands): base(game_control)
        {
            _background_color_material.Diffuse = _background_color;
            _background_window_material.Diffuse = Window.BackgroundColor;

            _commands = commands;
            _game_control = game_control;
        }
Exemple #8
0
        public SplashScene2(IGameControl game_control, ICommand commands) : base(game_control)
        {
            _background_color_material.Diffuse  = _background_color;
            _background_window_material.Diffuse = Window.BackgroundColor;

            _commands     = commands;
            _game_control = game_control;
        }
 public void Init(
     IGameControl gameControl
     )
 {
     View.UpdateGold(gameControl.GetCurrentGold());
     View.UpdateWood(gameControl.GetCurrentWood());
     View.UpdateIron(gameControl.GetCurrentIron());
 }
        public Task Initialize(IGameControl control, IGameMessenger messenger, IGameModeData gameMode, Player[] players)
        {
            Control   = control;
            Messenger = messenger;
            Players.AddRange(players);

            return(InitGameMode(gameMode.Settings));
        }
Exemple #11
0
 public GetMoveRequest(
     [NotNull] GameBoard board,
     CancellationToken cancellationToken,
     [NotNull] IGameControl gameControl)
 {
     Board             = board ?? throw new ArgumentNullException(nameof(board));
     CancellationToken = cancellationToken;
     GameControl       = gameControl ?? throw new ArgumentNullException(nameof(gameControl));
 }
Exemple #12
0
        public WinForm_Splash(IGameControl game_control, ICommand commands)
            : base(game_control)
        {
            _background_color_material.Diffuse = _background_color;
            _background_window_material.Diffuse = Window.BackgroundColor;

            _commands = commands;
            _game_control = game_control;
            _dm_dialog = new DM_Dialog(_commands);
        }
Exemple #13
0
        public WinForm_Splash(IGameControl game_control, ICommand commands)
            : base(game_control)
        {
            _background_color_material.Diffuse  = _background_color;
            _background_window_material.Diffuse = Window.BackgroundColor;

            _commands     = commands;
            _game_control = game_control;
            _dm_dialog    = new DM_Dialog(_commands);
        }
Exemple #14
0
        public HeadsUpDisplay(IGameControl game_control)
        {
            PANELS = new List<Aptima.Asim.DDD.Gui.Common.GameLib.Gui.Panel>();

            game_control.GetTargetControl().MouseClick += new MouseEventHandler(MouseClick);
            game_control.GetTargetControl().MouseDoubleClick += new MouseEventHandler(MouseDoubleClick);
            game_control.GetTargetControl().MouseDown += new MouseEventHandler(MouseDown);
            game_control.GetTargetControl().MouseMove += new MouseEventHandler(MouseMove);
            game_control.GetTargetControl().MouseUp += new MouseEventHandler(MouseUp);
            game_control.GetTargetControl().MouseWheel += new MouseEventHandler(MouseWheel);
            game_control.GetTargetControl().KeyDown += new KeyEventHandler(KeyDown);
            game_control.GetTargetControl().KeyPress += new KeyPressEventHandler(KeyPress);
            game_control.GetTargetControl().KeyUp += new KeyEventHandler(KeyUp);
        }
Exemple #15
0
        private void randomizeControls(List <IGameControl> wanted)
        {
            Random random = new Random();
            int    index  = wanted.Count - 1;

            while (index > 0)
            {
                int          next = random.Next(index + 1);
                IGameControl temp = wanted[next];
                wanted[next]  = wanted[index];
                wanted[index] = temp;
                index--;
            }
        }
Exemple #16
0
        /// <summary>
        /// Получение урона
        /// </summary>
        /// <param name="phisic">физический</param>
        /// <param name="magic">магический</param>
        /// <param name="pure">чистый</param>
        public IUnit GatDamage(int phisic, int magic, int pure, IUnit demagedUnit)
        {
            Player playerDemaged = demagedUnit as Player;

            int magicDemagePlus = magic;

            ///Действие аганима
            if (playerDemaged != null)
            {
                foreach (var item in playerDemaged.Items)
                {
                    if (item.BonusMagicDemage > 0)
                    {
                        magicDemagePlus = magicDemagePlus + (int)(magic * item.BonusMagicDemage);
                    }
                }
            }

            int demage = StaticVaribl.DemageAndArmor(phisic, Arrmor) + StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor) + pure;

            Health -= demage;

            IUnitControl chpView = GameObject.View as IUnitControl;

            if (chpView != null)
            {
                chpView.ShowHealth(Health, MaxHealth);
            }

            if (GetDemageEvent != null)
            {
                GetDemageEvent(StaticVaribl.DemageAndArmor(phisic, Arrmor),
                               StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor),
                               pure, this);
            }

            IGameControl control = (this.GameObject.View as IGameControl);

            if (control != null)
            {
                ///Отображаем сколько урона получил юнит
                control.GetDemage("-" + demage);
            }

            if (Health <= 0)
            {///Значит объект унечтожен
                return(RemoveUnit(demagedUnit));
            }
            return(null);
        }
Exemple #17
0
        public HeadsUpDisplay(IGameControl game_control)
        {
            PANELS = new List <Aptima.Asim.DDD.Gui.Common.GameLib.Gui.Panel>();

            game_control.GetTargetControl().MouseClick       += new MouseEventHandler(MouseClick);
            game_control.GetTargetControl().MouseDoubleClick += new MouseEventHandler(MouseDoubleClick);
            game_control.GetTargetControl().MouseDown        += new MouseEventHandler(MouseDown);
            game_control.GetTargetControl().MouseMove        += new MouseEventHandler(MouseMove);
            game_control.GetTargetControl().MouseUp          += new MouseEventHandler(MouseUp);
            game_control.GetTargetControl().MouseWheel       += new MouseEventHandler(MouseWheel);
            game_control.GetTargetControl().KeyDown          += new KeyEventHandler(KeyDown);
            game_control.GetTargetControl().KeyPress         += new KeyPressEventHandler(KeyPress);
            game_control.GetTargetControl().KeyUp            += new KeyEventHandler(KeyUp);
        }
        public void SetUp()
        {
            var boardModel       = Substitute.For <IBoardModel>();
            var figureModel      = Substitute.For <IFigureModel>();
            var gameMaster       = Substitute.For <IGameMaster>();
            var gameSwitcherTurn = Substitute.For <IGameSwitcherTurn>();

            var gameControls = new IGameControl[]
            {
                new PlayerGameControl(),
                new AiRandomGameControl(boardModel, figureModel, gameMaster, gameSwitcherTurn)
            };

            GameControlRepository = new GameControlRepository(gameControls);
        }
Exemple #19
0
 public void Remove(IGameControl control)
 {
     for (var index = _controls.Count - 1; index >= 0; index--)
     {
         var controlReference = _controls[index];
         if (controlReference.IsAlive)
         {
             if (controlReference.Target == control)
             {
                 _controls.RemoveAt(index);
             }
         }
         else
         {
             _controls.RemoveAt(index);
         }
     }
 }
Exemple #20
0
        protected override void BaseGameForm_Init(IGameControl sender, GameControlTimedEventArgs args)
        {
            this.AltSkins = null;
            this.ChildForms = new Dictionary<string, IGameForm>();
            this.Controls = new Dictionary<string, IGameControl>();
            this.CurrentSkin = null;
            this.DefaultSkin = null;
            this.Enabled = true;
            this.Focus = true;
            this.Location = Vector3.Zero;
            this.ParentForm = null;
            this.RenderColour = Vector4.One;
            this.RenderRectangle = Rectangle.Empty;
            this.Root = true;
            this.Shader = null;
            this.Visible = true;
            this.ElapsedTime = args.ElapsedTime;
            this.TotalTime = args.TotalTime;

            base.BaseGameForm_Init(sender, args);
        }
Exemple #21
0
        private Menu createRandomMenu()
        {
            List <IGameControl> randomized_controls = parser.getAllControls();
            Random random = new Random();
            int    index  = randomized_controls.Count - 1;

            while (index > 0)
            {
                int          next = random.Next(index + 1);
                IGameControl temp = randomized_controls[next];
                randomized_controls[next]  = randomized_controls[index];
                randomized_controls[index] = temp;
                index--;
            }

            SubMenu             sub    = new SubMenu(logger, String.Empty, randomized_controls);
            List <IGameControl> wanted = parser.getWantedControls((int)MenuType.RANDOM);

            return(new Menu(MenuType.RANDOM, new List <SubMenu>()
            {
                sub
            }, wanted, logger));
        }
Exemple #22
0
        public void CreateNewPopup(
            BigBuildingModel model,
            bool buildingIsWorking,
            ISignalService signalService,
            IGameControl gameControl)
        {
            BuildingPopupBase prefab = _simplePopup;

            if (model.BuildingInfo.GoldProduction == 0 &&
                model.BuildingInfo.WoodProduction == 0 &&
                model.BuildingInfo.IronProduction == 0)
            {
                prefab = _simplePopup;
            }
            else if (buildingIsWorking)
            {
                prefab = _workinPopup;
            }
            else
            {
                prefab = _readyPopup;
            }

            BuildingPopupBase newPopup = Instantiate(prefab, transform, false);

            Vector3 screenPos = _camera.WorldToScreenPoint(model.BuildingGameObject.transform.position);
            Vector2 movePos;

            RectTransformUtility.ScreenPointToLocalPointInRectangle(parentCanvas.transform as RectTransform, screenPos, parentCanvas.worldCamera, out movePos);
            Vector3 viewPos = parentCanvas.transform.TransformPoint(movePos);

            newPopup.transform.localPosition = movePos;

            newPopup.SetInfo(model);
            newPopup.SignalService = signalService;
            newPopup.GameControl   = gameControl;
        }
Exemple #23
0
 /// <summary>
 /// Add a new root level control to this form.
 /// </summary>
 /// <param name="control">The control to add</param>
 public void AddControl(IGameControl control)
 {
     Controls.Add(control.Name, control);
     control.ParentForm = this;
 }
Exemple #24
0
        /// <summary>
        /// Dfault Render Event Handler
        /// </summary>
        protected virtual void BaseGameControl_Render(IGameControl sender, GameControlRenderEventArgs args)
        {
            //The basic render for a control is just to draw the skin texture at its location (relative to the form location
            Vector3 absolute = GetAbsoluteLocation();
            Vector2 screenloc = new Vector2(absolute.X, absolute.Y);
            float depth = absolute.Z;
            Color c = new Color(RenderColour);

            //Draw
            args.spriteBatch.Draw(CurrentSkin, screenloc, RenderRectangle, c, 0, Vector2.Zero,1.0f, SpriteEffects.None, depth);
            FocusRectangle = new Rectangle((int)screenloc.X, (int)screenloc.Y, RenderRectangle.Width, RenderRectangle.Height);
        }
Exemple #25
0
 /// <summary>
 /// Default Init Event Handler
 /// </summary>
 protected virtual void BaseGameControl_Init(IGameControl sender, GameControlTimedEventArgs args)
 {
     mSourceRectangles = new Dictionary<string, Rectangle>();
     if (args != null)
     {
         ElapsedTime = args.ElapsedTime;
         TotalTime = args.TotalTime;
     }
 }
Exemple #26
0
 public GameControlInfo([NotNull] IGameControl gameControl, CancellationToken cancellationToken)
 {
     GameControl       = gameControl.EnsureNotNull();
     CancellationToken = cancellationToken;
 }
Exemple #27
0
        /// <summary>
        /// Do this instead of the usual render method
        /// </summary>
        protected override void BaseGameControl_Render(IGameControl sender, GameControlRenderEventArgs args)
        {
            //The basic render for a control is just to draw the skin texture at its location (relative to the form location
            Vector3 absolute = GetAbsoluteLocation();
            Vector2 screenloc = new Vector2(absolute.X, absolute.Y);
            float depth = absolute.Z;

            //Draw locations for current
            Vector2 roleloc = screenloc + new Vector2((float)CurrentCredit.RoleOffset.X, (float)CurrentCredit.RoleOffset.Y);
            Vector2 nameloc = screenloc + new Vector2((float)CurrentCredit.NamesOffset.X, (float)CurrentCredit.NamesOffset.Y);
            Vector4 cv = CurrentCredit.Colour;
            cv.W = CurrentFadeLevel;
            Color colour = new Color(cv);

            //Draw locations for next
            Vector2 nextroleloc = screenloc + new Vector2((float)CurrentCredit.RoleOffset.X, (float)CurrentCredit.RoleOffset.Y);
            Vector2 nextnameloc = screenloc + new Vector2((float)CurrentCredit.NamesOffset.X, (float)CurrentCredit.NamesOffset.Y);
            Vector4 ncv = NextCredit.Colour;
            ncv.W = (1.0f - CurrentFadeLevel);
            Color nextcolour = new Color(ncv);

            //Draw Current
            args.spriteBatch.DrawString(Font, CurrentCredit.Role, roleloc, colour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);
            //Draw Next
            args.spriteBatch.DrawString(Font, NextCredit.Role, nextroleloc, nextcolour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth+0.1f);

            //Current Names
            if (CurrentCredit.Names.Length > 0)
            {
                string currentnames = CurrentCredit.Names;
                args.spriteBatch.DrawString(Font, currentnames, nameloc, colour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);
            }
            //Next Names
            if (NextCredit.Names.Length > 0)
            {
                string nextnames = NextCredit.Names;
                args.spriteBatch.DrawString(Font, nextnames, nextnameloc, nextcolour, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);
            }
        }
Exemple #28
0
 /// <summary>
 /// Recursively add to the location vector to get the absolute vector adjusting by the locations of the
 /// parent forms up through the hierarchy to the root form.
 /// </summary>
 /// <param name="control">The control to position</param>
 /// <param name="vector">The vector to hold the adjusted location</param>
 private void AdjustAbsoluteVector(IGameControl control, ref Vector3 vector)
 {
     if (control != null)
     {
         vector += control.Location;
         AdjustAbsoluteVector(control.ParentForm, ref vector);
     }
 }
Exemple #29
0
 public Unknown(IBlock block, IGameControl control)
 {
     _block   = block;
     _control = control;
     _active  = Initialize;
 }
Exemple #30
0
        /// <summary>
        /// Handle the OK click button (return to main screen from sub screen.
        /// </summary>
        void ClickOk(IGameControl sender, GameControlEventArgs args)
        {
            //If this is the options screen, save the selected values;
            if (((TestRootForm)UI.RootForm).ScreenState == UIScreenEnum.Options)
            {
                //Populate local

                //floats
                OptionsTextureSampler = ((GOOS.JFX.UI.Controls.Slider)UI.RootForm.GetControl("SliderSampling")).Value;
                OptionsParticleDensity = ((GOOS.JFX.UI.Controls.Slider)UI.RootForm.GetControl("SliderParticles")).Value;
                OptionsSFXVolume = ((GOOS.JFX.UI.Controls.Slider)UI.RootForm.GetControl("SliderSFX")).Value;
                OptionsMusicVolume = ((GOOS.JFX.UI.Controls.Slider)UI.RootForm.GetControl("SliderMusic")).Value;
                OptionsViewDistance = ((GOOS.JFX.UI.Controls.Slider)UI.RootForm.GetControl("SliderViewDist")).Value;
                OptionsBloomLevel = ((GOOS.JFX.UI.Controls.Slider)UI.RootForm.GetControl("SliderBloom")).Value;

                //bools
                //((GOOS.JFX.UI.Controls.Checkbox)UI.RootForm.GetControl("OptionsCheckFullscreen")).Checked = Stage.ConfigurationSettings.Fullscreen; //HMMMMM
                OptionsMuteMusic = ((GOOS.JFX.UI.Controls.Checkbox)UI.RootForm.GetControl("OptionsCheckMusicMute")).Checked;
                OptionsMuteSFX = ((GOOS.JFX.UI.Controls.Checkbox)UI.RootForm.GetControl("OptionsCheckSFXMute")).Checked;
                OptionsBloomOn = ((GOOS.JFX.UI.Controls.Checkbox)UI.RootForm.GetControl("OptionsCheckBloom")).Checked;

                //Populate config object

                ExtraConfigFile.ExtraFloatSettings["BloomLevel"] = OptionsBloomLevel;
                ExtraConfigFile.ExtraFloatSettings["ParticleDensity"] = OptionsParticleDensity;
                ExtraConfigFile.ExtraFloatSettings["SoundVolume"] = OptionsSFXVolume;
                ExtraConfigFile.ExtraFloatSettings["TextureSampler"] = OptionsTextureSampler;
                ExtraConfigFile.ExtraFloatSettings["ViewDistance"] = OptionsViewDistance;
                ExtraConfigFile.ExtraFloatSettings["MusicVolume"] = OptionsMusicVolume;

                ExtraConfigFile.ExtraBoolSettings["BloomOn"] = OptionsBloomOn;
                ExtraConfigFile.ExtraBoolSettings["MusicMute"] = OptionsMuteMusic;
                ExtraConfigFile.ExtraBoolSettings["SFXMute"] = OptionsMuteSFX;

                //Save config object

                ExtraConfigFile.SaveTofile("CCExtra.config");

                //Set sounds if sounds playing
                if (Ambient_Heart != null)
                    Ambient_Heart.Volume = (OptionsSFXVolume / 100);
                if (Ambient_Monster != null)
                    Ambient_Monster.Volume = (OptionsSFXVolume / 100);
                if(Ambient_Wind != null)
                    Ambient_Wind.Volume = (OptionsSFXVolume / 100);
                if (MusicPlaying)
                    MediaPlayer.Volume = (OptionsMusicVolume / 100);

                //Set particle density
                ((SmokePlumeParticleSystem)smokePlumeParticles).Density = (int)OptionsParticleDensity;
                ((AntiFireParticleSystem)antifireParticles).Density = (int)OptionsParticleDensity;
                ((FireParticleSystem)fireParticles).Density = (int)OptionsParticleDensity;

                //Bloom
                bloom.Settings.BloomIntensity = 3.0f * (OptionsBloomLevel / 100);

            }

            if (((TestRootForm)UI.RootForm).ScreenState == UIScreenEnum.EnterName)
            {
                CurrentScoreInfo.ExtendedValues["name"] = ((TextBox)UI.RootForm.GetControl("KeyboardTestLabel")).Text;
                HiScores.AddScore(CurrentScoreInfo);
                HiScores.SaveToFile("CreatureCave.hiscores");
                SwitchMenuScreen(UIScreenEnum.Hiscore);
            }
            else
                SwitchMenuScreen(UIScreenEnum.MainMenu);
        }
Exemple #31
0
 public SplashScene(IGameControl control) : base(control)
 {
 }
Exemple #32
0
 //tracks when something is clicked/entered/changed on a control
 public void logResult(IGameControl control, string answer, DateTime time)
 {
     answer_string.AppendLine("Answered | " + control.Title + " (" + control.ControlType.ToString() + ") " + " | "
                              + answer + " (" + control.Correct + ") " + "|" + time.ToString("HH:mm:ss"));
 }
Exemple #33
0
 /// <summary>
 /// Handle the New Game button click event
 /// </summary>
 void ClickNew(IGameControl sender, GameControlEventArgs args)
 {
     Stage.GameState.DemoMode = false;
     Stage.GameState.Pause = false;
     Stage.GameState.Menu = false;
     Stage.GameState.Intro = false;
     Stage.GameState.Console = false;
     Score = 0;
     Level = 0;
     GenerateNewMap();
 }
Exemple #34
0
        /// <summary>
        /// Do this in addiition to the main update.
        /// </summary>
        protected override void BaseGameControl_Update(IGameControl sender, GameControlTimedEventArgs args)
        {
            //First update
            if (LastSwitchTime == 0)
            {
                LastSwitchTime = (int)args.TotalTime;
                CurrentcreditIndex = 0;

                CurrentCredit = mCredits[CurrentcreditIndex];
                NextCredit = mCredits[(CurrentcreditIndex + 1) % mCredits.Count];
            }

            //All updates
            if (mCredits != null && mCredits.Count > 0)
            {
                //time to next switch is delay time - time since last switch
                int timeToSwitch = CurrentCredit.Delay - ((int)args.TotalTime - LastSwitchTime);

                if (timeToSwitch > 0)
                {
                    //If in last 2 seconds, apply fade
                    if (timeToSwitch < 4001)
                        CurrentFadeLevel = (float)timeToSwitch / 4000.0f;
                    else
                        CurrentFadeLevel = 1.0f;
                }
                else //Switch
                {
                    //Set credit and next credit.
                    CurrentFadeLevel = 1.0f;
                    CurrentcreditIndex = (CurrentcreditIndex + 1) % mCredits.Count;
                    CurrentCredit = mCredits[CurrentcreditIndex];
                    NextCredit = mCredits[(CurrentcreditIndex + 1) % mCredits.Count];
                    LastSwitchTime = (int)args.TotalTime;
                }
            }

            //Do the base update
            base.BaseGameControl_Update(sender, args);
        }
Exemple #35
0
 /// <summary>
 /// Default Change focus Event Handler
 /// </summary>
 protected virtual void BaseGameForm_ChangeFocus(IGameControl sender, GameControlEventArgs args)
 {
 }
Exemple #36
0
        /// <summary>
        /// Dfault Render Event Handler
        /// </summary>
        protected virtual void BaseGameForm_Render(IGameControl sender, GameControlRenderEventArgs args)
        {
            ElapsedTime = args.ElapsedTime;
            TotalTime = args.TotalTime;

            //Render all controls at root level
            foreach (IGameControl control in Controls.Values)
                if(control.Visible)
                    control.RaiseEvent(BaseControlEvents.Render, control, args);

            //Render all child forms
            foreach (IGameForm form in ChildForms.Values)
                if(form.Visible)
                    form.RaiseEvent(BaseControlEvents.Render,form,args);
        }
Exemple #37
0
 public SplashScene(IGameControl control):base(control)
 {
 }
 public MapPlayfieldContainer(IGameControl game_control, ICommand commands)
     : base(game_control)
 {
     _commands = commands;
     _game_control = game_control;
     _mini_map_background.Diffuse = Color.FromArgb(180, 63, 63, 63);
     _mini_map_track_material.Diffuse = Color.Red;
 }
 public static IDictionary <Point, IBlock> CreateMap(this IGameControl control)
 => new Size(control.Size.Width + 2, control.Size.Height + 2)
 .CreateMap()
 .ToDictionary <Point, Point, IBlock>(x => x, x => (x.X, x.Y) switch {
     (0, _) => new OutSide(x),
Exemple #40
0
 /// <summary>
 /// Handle the transition to the hi score screen.
 /// </summary>	
 void ClickHiScore(IGameControl sender, GameControlEventArgs args)
 {
     SwitchMenuScreen(UIScreenEnum.Hiscore);
 }
Exemple #41
0
        /// <summary>
        /// This control completely overrides the base render functionality (it has two textures to draw)
        /// </summary>
        protected override void BaseGameControl_Render(IGameControl sender, GameControlRenderEventArgs args)
        {
            //The basic render for a control is just to draw the skin texture at its location (relative to the form location
            Vector3 absolute = GetAbsoluteLocation();
            Vector2 screenloc = new Vector2(absolute.X, absolute.Y);
            float depth = absolute.Z;
            Color c = new Color(RenderColour);

            //Draw Groove
            args.spriteBatch.Draw(CurrentSkin, screenloc, GrooveSource, c, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth);
            FocusRectangle = new Rectangle((int)screenloc.X, (int)screenloc.Y, GrooveSource.Width, GrooveSource.Height);

            //Draw Bar
            //express the current value as a fraction
            float fraction = (Value - MinValue) / (MaxValue - MinValue);
            int barOffsetX=0, baroffsetY=0;

            //If the value is the highest it can be without stepping over the max it should be defaulted to 100
            if (Value + Step > MaxValue) fraction = 1.0f;

            if (this.Alignment == SliderAlignment.Horizontal)
            {
                barOffsetX = (int)((float)GrooveSource.Width * fraction) - (int)(BarSource.Width/2);
                baroffsetY = 0;
            }
            else if (this.Alignment == SliderAlignment.Vertical)
            {
                int barOffsetY = (int)((float)GrooveSource.Height * fraction) - (int)(BarSource.Height/2);
                barOffsetX = 0;
            }

            //Draw bar
            args.spriteBatch.Draw(CurrentSkin, new Vector2(screenloc.X+(float)barOffsetX,screenloc.Y + (float)baroffsetY), BarSource, c, 0, Vector2.Zero, 1.0f, SpriteEffects.None, depth-0.1f);
        }
 public void Init(IGameControl gameControl)
 {
     _gameControl = gameControl;
 }
Exemple #43
0
        /// <summary>
        /// The slidebar should move (and the selected value change) on mousedown
        /// </summary>
        protected void Slider_MouseHeld(IGameControl sender, GameControlEventArgs args)
        {
            //Get mouse position
            Point mousepos = ParentForm.UI.CurrentMousePointer.PickedScreenCoordinate;
            int relativeX = mousepos.X - (int)GetAbsoluteLocation().X;
            int relativeY = mousepos.Y - (int)GetAbsoluteLocation().Y;
            float fraction = 0.0f;

            if (Alignment == SliderAlignment.Horizontal)
                fraction = (float)relativeX / (float)GrooveSource.Width;
            else if (Alignment == SliderAlignment.Vertical)
                fraction = (float)relativeY / (float)GrooveSource.Height;

            float rawvalue = (fraction * (MaxValue - MinValue)) + MinValue;
            if (StepMode == SliderStepMode.Smooth)
                Value = rawvalue;
            else if (StepMode == SliderStepMode.Snap) // If in snap mode, snap to nearest value.
            {
                float mod = rawvalue % Step;
                if (mod >= Step / 2)
                    Value = rawvalue + Step - mod;
                else
                    Value = rawvalue - mod;
            }

            if (Value < MinValue)
                Value = MinValue;
            if (Value > MaxValue)
                Value = MaxValue;
        }
Exemple #44
0
 /// <summary>
 /// Default Click Event Handler
 /// </summary>
 protected virtual void BaseGameControl_Click(IGameControl sender, GameControlEventArgs args)
 {
 }
Exemple #45
0
 public Bomb(Point location, IGameControl control)
 {
     _control = control;
     Location = location;
 }
Exemple #46
0
 /// <summary>
 /// Default Mounse Leave Event Handler
 /// </summary>
 protected virtual void BaseGameControl_MouseLeave(IGameControl sender, GameControlEventArgs args)
 {
 }
Exemple #47
0
 /// <summary>
 /// Handle the transition to the Options screen.
 /// </summary>
 void ClickOptions(IGameControl sender, GameControlEventArgs args)
 {
     SwitchMenuScreen(UIScreenEnum.Options);
 }
Exemple #48
0
 /// <summary>
 /// Default Update Event Handler
 /// </summary>	
 protected virtual void BaseGameControl_Update(IGameControl sender, GameControlTimedEventArgs args)
 {
     //Set focus
     Focus = (ParentForm.UI.ControlWithFocus == this);
 }
Exemple #49
0
        /// <summary>
        /// Перемещение юнита
        /// </summary>
        /// <param name="map">Карта</param>
        /// <param name="obj">нет</param>
        /// <param name="unit">Кто перемещается</param>
        /// <param name="property"></param>
        public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property)
        {
            UnitGenerator.UpdatePlayerView(unit);
            if (unit.UnitFrozen == false && !CuldaunBool)
            {
                CuldaunBool = true;
                EAngel ang = (EAngel)property;
                _map  = map;
                _unit = unit;
                ///Проверим в какую сторону смотрит юнит, может его нужно просто развернуть
                ///а не перемещать
                if (unit.Angel == ang)
                {///Можно перемещать
                    Rotation = false;

                    int xNew = 0;
                    int yNew = 0;
                    if (unit.Angel == EAngel.Left)
                    {
                        xNew = unit.PositionX - 1;
                        yNew = unit.PositionY;
                    }
                    else if (unit.Angel == EAngel.Right)
                    {
                        xNew = unit.PositionX + 1;
                        yNew = unit.PositionY;
                    }
                    else if (unit.Angel == EAngel.Top)
                    {
                        xNew = unit.PositionX;
                        yNew = unit.PositionY - 1;
                    }
                    else if (unit.Angel == EAngel.Bottom)
                    {
                        xNew = unit.PositionX;
                        yNew = unit.PositionY + 1;
                    }


                    ///Теперь проверка можно ли переместится в данную ячейку
                    if (map.AllowMoveUnit(unit, xNew, yNew))
                    {   ///Можно
                        _invisMuve = unit.Invisibility;

                        ///Отмечаем что в заданную ячейку идет перемещение юнита
                        map.Calls.Single(p => p.IndexLeft == xNew && p.IndexTop == yNew).Using = true;
                        //  unit.UnitFrozen = true;
                        _xNew = xNew;
                        _yNew = yNew;

                        ///Сохраняем ячейку с которой был выполнен переход
                        UnitGenerator.EditWay(map.Calls.Single(p => p.IndexLeft == unit.PositionX &&
                                                               p.IndexTop == unit.PositionY), _unit);

                        ///Запуск анимации перемещения
                        StartStoryboard(unit, xNew, yNew);
                    }
                    else
                    {
                        CuldaunBool = false;

                        if (CompletedUseSpell != null)
                        {
                            CompletedUseSpell(this, null);
                        }
                    }
                }
                else
                {///Только развернуть
                    IGameControl contrGame = unit.GameObject.View as IGameControl;
                    unit.Angel = ang;
                    contrGame.ChengAngel(ang);
                    Rotation = true;

                    CuldaunBool = false;

                    if (CompletedUseSpell != null)
                    {
                        CompletedUseSpell(this, null);
                    }
                }
            }
            else if (CompletedUseSpell != null)
            {
                CompletedUseSpell(this, null);
            }
        }
Exemple #50
0
 /// <summary>
 /// Use this method to raise a base GameControl event. (typically called by the observer.)
 /// </summary>
 /// <param name="e">The event to raise</param>
 /// <param name="sender">The GameControl sending the event</param>
 /// <param name="args">The event arguments</param>
 public void RaiseEvent(BaseControlEvents e, IGameControl sender, GameControlEventArgs args)
 {
     switch (e)
     {
         case BaseControlEvents.ChangeFocus: ChangeFocus(sender, args); break;
         case BaseControlEvents.Click: Click(sender, args); break;
         case BaseControlEvents.Init: Init(sender, (GameControlTimedEventArgs)args); break;
         case BaseControlEvents.MouseDown: MouseDown(sender, args); break;
         case BaseControlEvents.MouseEnter: MouseEnter(sender, args); break;
         case BaseControlEvents.MouseLeave: MouseLeave(sender, args); break;
         case BaseControlEvents.MouseUp: MouseUp(sender, args); break;
         case BaseControlEvents.Render: Render(sender, (GameControlRenderEventArgs)args); break;
         case BaseControlEvents.Update: Update(sender, (GameControlTimedEventArgs)args); break;
     }
 }
Exemple #51
0
 public Clear(Point location, IGameControl control)
 {
     _control = control;
     Location = location;
 }
Exemple #52
0
 /// <summary>
 /// Default Mouse Up Event Handler
 /// </summary>
 protected virtual void BaseGameForm_MouseUp(IGameControl sender, GameControlEventArgs args)
 {
 }
Exemple #53
0
 public ClickEvent(IGameControl control, string answer, DateTime time)
 {
     Control = control;
     Time    = time;
     Answer  = answer;
 }
Exemple #54
0
        /// <summary>
        /// Default Update Event Handler
        /// </summary>	
        protected virtual void BaseGameForm_Update(IGameControl sender, GameControlTimedEventArgs args)
        {
            //Focus
            this.Focus = (UI.FormWithFocus == this);

            ElapsedTime = args.ElapsedTime;
            TotalTime = args.TotalTime;

            //Update all controls at root level
            foreach (IGameControl control in Controls.Values)
                control.RaiseEvent(BaseControlEvents.Update, control, args);

            //update all child forms
            foreach (IGameForm form in ChildForms.Values)
                form.RaiseEvent(BaseControlEvents.Update, form, args);
        }
Exemple #55
0
 //The quit button handler
 void ClickQuit(IGameControl sender, GameControlEventArgs args)
 {
     Stage.DumpDebugToFile();
     this.Exit();
 }
Exemple #56
0
        internal static void HookCommands(IGameControl control, ICommand oldCommand, ICommand newCommand)
        {
            var wasAttached = control.Flags.GetFlag(GameControlFlags.IsAttachedToCommandCanExecuteChanged);

            if ((wasAttached) && (oldCommand != null))
            {
                control.Flags.SetFlag(GameControlFlags.IsAttachedToCommandCanExecuteChanged, false);
                if (control.CommandCanExecuteHandler != null)
                {
                    oldCommand.CanExecuteChanged    -= control.CommandCanExecuteHandler;
                    control.CommandCanExecuteHandler = null;
                }
            }

            if (!control.Flags.GetFlag(GameControlFlags.IsAttachedToCommandCanExecuteChanged) &&
                (newCommand != null) &&
                (control.CanUpdateCanExecuteWhenHidden || control.IsVisible))
            {
                control.Flags.SetFlag(GameControlFlags.IsAttachedToCommandCanExecuteChanged, true);
                control.CommandCanExecuteHandler = new EventHandler(control.OnCanExecuteChanged);
                newCommand.CanExecuteChanged    += control.CommandCanExecuteHandler;
            }

            // If no change was made, don't bother updating the CanExecute since this was called by an IsVisible change
            if (((oldCommand != newCommand) ||
                 !wasAttached ||
                 !control.Flags.GetFlag(GameControlFlags.IsAttachedToCommandCanExecuteChanged)))
            {
                control.UpdateCanExecute();
            }

            wasAttached = control.Flags.GetFlag(GameControlFlags.IsAttachedToCommandUIProvider);
            if ((wasAttached) && (oldCommand != null))
            {
                var commandUIProvider = GameCommandUIManager.GetUIProviderResolved(oldCommand);
                if (commandUIProvider != null)
                {
                    control.Flags.SetFlag(GameControlFlags.IsAttachedToCommandUIProvider, false);

                    CommandUIProviderPropertyChangedRouter router;
                    if (_uiProviderPropertyChangedRouter.TryGetValue(commandUIProvider, out router))
                    {
                        router.Remove(control);
                        if (!router.HasLiveReferences)
                        {
                            commandUIProvider.PropertyChanged -= router.OnCommandUIProviderPropertyChanged;
                            _uiProviderPropertyChangedRouter.Remove(commandUIProvider);
                        }
                    }
                }
            }

            if ((!control.Flags.GetFlag(GameControlFlags.IsAttachedToCommandUIProvider)) &&
                (newCommand != null) &&
                ((control.CanUpdateCanExecuteWhenHidden) || (control.IsVisible)))
            {
                var commandUIProvider = GameCommandUIManager.GetUIProviderResolved(newCommand);
                if (commandUIProvider != null)
                {
                    control.Flags.SetFlag(GameControlFlags.IsAttachedToCommandUIProvider, true);

                    CommandUIProviderPropertyChangedRouter router;
                    if (!_uiProviderPropertyChangedRouter.TryGetValue(commandUIProvider, out router))
                    {
                        router = new CommandUIProviderPropertyChangedRouter();
                        commandUIProvider.PropertyChanged += router.OnCommandUIProviderPropertyChanged;
                        _uiProviderPropertyChangedRouter.Add(commandUIProvider, router);
                    }

                    router.Add(control);
                }
            }

            // Update the UI based on the command
            UpdateUIFromCommand(control);
        }
Exemple #57
0
        /// <summary>
        /// Starts the Game Framework, registers a form and a gamecontroller.
        /// The form is required to intercept keyboard and mouse input.
        /// The GameController initializes scenes and feeds them to the GameController.
        /// </summary>
        /// <param name="form"></param>
        /// <param name="game_control"></param>
        public void Run(Form form, IGameControl game_control)
        {
            if (form == null)
            {
                throw new ApplicationException("Must supply a windows Form.");
            }
            _main_window = form;
            if (game_control == null)
            {
                throw new ApplicationException("Game Control is uninitialized.");
            }
            _CANVAS_ = new Canvas();
            QueryPerformanceFrequency(ref _ticks_per_second);

            _game_control = game_control;
            _CANVAS_.TargetControl = _game_control.GetTargetControl();

            _game_control.InitializeCanvasOptions(_CANVAS_.Options);
            _CANVAS_.InitializeCanvas();

            _AvailableScenes_ = _game_control.InitializeScenes(this);
            _AvailableScenes_[CURRENT_SCENE].Initialize(this);
            _game_control.SceneChanged(CURRENT_SCENE);

            Idle = new EventHandler(GameLoop);
            Application.Idle += Idle;

        }
Exemple #58
0
 public Flag(IBlock block, IGameControl control)
 {
     _block   = block;
     _control = control;
 }
Exemple #59
0
 internal static void UpdateUIFromCommand(IGameControl control)
 {
     control.CoerceValue(ImageSourceLargeProperty);
     control.CoerceValue(ImageSourceSmallProperty);
     control.CoerceValue(LabelProperty);
 }