Esempio n. 1
0
		private void createStartDialog(IGameFactory factory, IDialog questionsDialog, IDialog shadersDialog)
		{
			StartDialog.StartupActions.AddPlayerText("Hello there!");
			StartDialog.StartupActions.AddText(Characters.Beman, "Hello yourself!");
			StartDialog.StartupActions.AddConditionalActions(() => Repeat.OnceOnly("BemanStartDialog"));
			StartDialog.StartupActions.AddText(Characters.Beman, "God, that's a relief.", "It's good to see I'm not alone in this place.");

			IDialogOption option1 = factory.Dialog.GetDialogOption("Who are you?", showOnce: true);
			option1.AddText(Characters.Beman, "I am Beman, and you are?");
			option1.AddPlayerText("I am Cris.");

			IDialogOption option2 = factory.Dialog.GetDialogOption("What is this place?");
			option2.AddText(Characters.Beman, "I have no idea. I just woke up here.");
			option2.AddPlayerText("Wow, seems like we share a similar story.");

			IDialogOption option3 = factory.Dialog.GetDialogOption("Tell me a little bit about yourself.", speakOption: false);
			option3.AddText(Characters.Beman, "What do you want to know?");
			option3.ChangeDialogWhenFinished = questionsDialog;

			IDialogOption option4 = factory.Dialog.GetDialogOption("Can I set a shader?");
			option4.AddText(Characters.Beman, "Sure, choose a shader...");
			option4.ChangeDialogWhenFinished = shadersDialog;

			IDialogOption option5 = factory.Dialog.GetDialogOption("I'll be going now.");
			option5.AddText(Characters.Beman, "Ok, see you around.");
			option5.ExitDialogWhenFinished = true;

			StartDialog.AddOptions(option1, option2, option3, option4, option5);
		}
Esempio n. 2
0
 public GameController(IGameFactory game)
 {
     _random = new Random(10);
     _fighter = game.CreateFighter();
     _victim = game.CreateVictim();
     _weapon = game.CreateWeapon();
 }
Esempio n. 3
0
        public Form1(IGameFactory gameFactory = null, IPlayerFactory playerFactory = null)
        {
            InitializeComponent();

            GameFactory = gameFactory;
            PlayerFactory = playerFactory;
        }
Esempio n. 4
0
		public async Task LoadAsync(IGameFactory factory)
		{
            AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new AGS.API.Point(0, 0));
			Bottle = await factory.Inventory.GetInventoryItemAsync("Bottle", "../../Assets/Rooms/EmptyStreet/bottle.bmp", null, loadConfig);
			VoodooDoll = await factory.Inventory.GetInventoryItemAsync("Voodoo Doll", _baseFolder + "voodooDoll.bmp", null, loadConfig, true);
			Poster = await factory.Inventory.GetInventoryItemAsync("Poster", _baseFolder + "poster.bmp", playerStartsWithItem: true);
			Manual = await factory.Inventory.GetInventoryItemAsync("Manual", _baseFolder + "manual.bmp", null, loadConfig, true);
		}
Esempio n. 5
0
		private async Task<IObject> loadCursor(string filename, IGameFactory factory)
		{
			IAnimation animation = await factory.Graphics.LoadAnimationFromFilesAsync(loadConfig: _loadConfig, files: new[]{ _baseFolder + filename });
            var cursor = factory.Object.GetObject(string.Format("Cursor_{0}", filename));
            cursor.Anchor = new PointF(0f, 1f);
            cursor.IgnoreScalingArea = true;
            cursor.IgnoreViewport = true;
            cursor.StartAnimation(animation);
			return cursor;
		}
Esempio n. 6
0
		public IMask CreateMask(IGameFactory factory, string path, bool transparentMeansMasked = false, 
			AGS.API.Color? debugDrawColor = null, string saveMaskToFile = null, string id = null)
		{
			Bitmap debugMask = null;
			FastBitmap debugMaskFast = null;
			if (saveMaskToFile != null || debugDrawColor != null)
			{
				debugMask = new Bitmap (Width, Height);
				debugMaskFast = new FastBitmap (debugMask, ImageLockMode.WriteOnly, true);
			}

			bool[][] mask = new bool[Width][];
			System.Drawing.Color drawColor = debugDrawColor != null ? debugDrawColor.Value.Convert() : System.Drawing.Color.Black;

			using (FastBitmap bitmapData = new FastBitmap (_bitmap, ImageLockMode.ReadOnly))
			{
				for (int x = 0; x < Width; x++)
				{
					for (int y = 0; y < Height; y++)
					{
						var pixelColor = bitmapData.GetPixel(x, y);

						bool masked = pixelColor.A == 255;
						if (transparentMeansMasked)
							masked = !masked;

						if (mask[x] == null)
							mask[x] = new bool[Height];
						mask[x][Height - y - 1] = masked;

						if (debugMask != null)
						{
							debugMaskFast.SetPixel(x, y, masked ? drawColor : System.Drawing.Color.Transparent);
						}
					}
				}
			}

			if (debugMask != null)
				debugMaskFast.Dispose();

			//Save the duplicate
			if (saveMaskToFile != null)
				debugMask.Save (saveMaskToFile);

			IObject debugDraw = null;
			if (debugDrawColor != null)
			{
				debugDraw = factory.Object.GetObject(id ?? path ?? "Mask Drawable");
                debugDraw.Image = factory.Graphics.LoadImage(new DesktopBitmap(debugMask, _graphics), null, path);
				debugDraw.Anchor = new AGS.API.PointF ();
			}

			return new AGSMask (mask, debugDraw);
		}
Esempio n. 7
0
        private static IButton getDropDownButton(string id, IGameFactory factory)
        {
            var textConfig = FontIcons.ButtonConfig;

            var idle           = new ButtonAnimation(GameViewColors.ComboboxButtonBorder, textConfig, GameViewColors.TextEditor);
            var hover          = new ButtonAnimation(GameViewColors.HoveredComboboxButtonBorder, null, GameViewColors.HoveredTextEditor);
            var pushed         = new ButtonAnimation(GameViewColors.ComboboxButtonBorder, null, GameViewColors.PushedTextEditor);
            var dropDownButton = factory.UI.GetButton($"{id}_DropDownButton", idle, hover, pushed, 0f, 0f, null, FontIcons.CaretDown, textConfig, false, 25f, 25f);

            return(dropDownButton);
        }
Esempio n. 8
0
        public GameAPI(IGameFactory gameFactory,
                       IPlayerFactory playerFactory,
                       ILogger logger)
        {
            Requires.IsNotNull(gameFactory, "gameFactory");
            Requires.IsNotNull(playerFactory, "playerFactory");

            this.gameFactory   = gameFactory;
            this.playerFactory = playerFactory;
            this.logger        = logger;
        }
Esempio n. 9
0
 public GameService(IGameFactory gameFactory, IGameRepository gameRepository,
                    IGameStateRepository gameStateRepository, IIdGenerator idGenerator,
                    IUnitOfWork unitOfWork, IUserRepository userRepository)
 {
     _gameFactory         = gameFactory;
     _gameRepository      = gameRepository;
     _gameStateRepository = gameStateRepository;
     _idGenerator         = idGenerator;
     _unitOfWork          = unitOfWork;
     _userRepository      = userRepository;
 }
Esempio n. 10
0
 public InspectorTreeNodeProvider(ITreeNodeViewProvider provider, IGameFactory factory,
                                  IGameEvents gameEvents, IObject inspectorPanel)
 {
     _inspectorPanel    = inspectorPanel;
     _onResize          = new AGSEvent <float>();
     _provider          = provider;
     _factory           = factory;
     _gameEvents        = gameEvents;
     _layouts           = new Dictionary <string, ITreeTableLayout>();
     _resizeSubscribers = new Dictionary <ITreeNodeView, ResizeSubscriber>();
 }
Esempio n. 11
0
        public Engine()
        {
            this.gameFactory     = new GameFactory();
            this.levelFactory    = new LevelFactory();
            this.questionFactory = new QuestionFactory();
            this.reader          = new Reader();

            SetCountsAndPrizes();

            this.Game = LoadGame();
        }
Esempio n. 12
0
		private async Task<IButton> loadButton(string id, IGameFactory factory, string folder, float x, string mode = null)
		{
			folder = _baseFolder + folder;
			IButton button = await factory.UI.GetButtonAsync(id, folder + "normal.bmp", folder + "hovered.bmp", folder + "pushed.bmp", x, 0f);
			button.TreeNode.SetParent(_panel.TreeNode);
			if (mode != null)
			{
				button.OnMouseClick(() => _scheme.CurrentMode = mode, _game);
			}
			return button;
		}
Esempio n. 13
0
 public GameSetUpFasade(IUserService userService, IUserSessionService userSessionService, IGameFactory gameFactory, IInterfaceService interfaceService, IWriterService writerService, IAsciiFactoriesFactory asciiFactoriesFactory, IFieldFactory fieldFactory, IButtonFactory buttonFactory)
 {
     this.userSessionService    = userSessionService;
     this.userService           = userService;
     this.gameFactory           = gameFactory;
     this.interfaceService      = interfaceService;
     this.writerService         = writerService;
     this.asciiFactoriesFactory = asciiFactoriesFactory;
     this.fieldFactory          = fieldFactory;
     this.buttonFactory         = buttonFactory;
 }
Esempio n. 14
0
 public AGSInspector(IGameFactory factory, IGameSettings gameSettings, IGameSettings editorSettings,
                     ActionManager actions, StateModel model, AGSEditor editor, IForm parentForm)
 {
     _cleanup        = new List <Action>(50);
     _actions        = actions;
     _model          = model;
     _props          = new Dictionary <InspectorCategory, List <IProperty> >();
     _factory        = factory;
     _font           = editorSettings.Defaults.TextFont;
     _editorProvider = new EditorProvider(factory, actions, model, gameSettings, editor, parentForm);
 }
Esempio n. 15
0
 public GameService(
     IComputerPlayerFactory computerPlayerFactory,
     IHumanPlayerFactory humanPlayerFactory,
     IPlayerInputValidator playerInputValidator,
     IGameFactory gameFactory)
 {
     _computerPlayerFactory = computerPlayerFactory;
     _humanPlayerFactory    = humanPlayerFactory;
     _playerInputValidator  = playerInputValidator;
     _gameFactory           = gameFactory;
 }
Esempio n. 16
0
 public AGSSaveLoad(Resolver resolver, IGameFactory factory,
                    ITextureCache textures, IGame game, IFileSystem fileSystem)
 {
     _game       = game;
     _resolver   = resolver;
     _factory    = factory;
     _textures   = textures;
     _state      = game.State;
     _events     = game.Events;
     _fileSystem = fileSystem;
 }
Esempio n. 17
0
        private async Task <IButton> loadButton(string id, IGameFactory factory, string folder, float x, string mode = null)
        {
            folder = _baseFolder + folder;
            IButton button = await factory.UI.GetButtonAsync(id, folder + "normal.bmp", folder + "hovered.bmp",
                                                             folder + "pushed.bmp", x, 0f, _panel);

            if (mode != null)
            {
                button.OnMouseClick(() => _scheme.CurrentMode = mode, _game);
            }
            return(button);
        }
Esempio n. 18
0
 public ApplicationViewModel(ILobbyFactory lobbyFactory,
                             IGameFactory gameFactory,
                             ILobbyService lobbyService,
                             IConsoleService consoleService,
                             IUserService userService)
 {
     _lobbyFactory   = lobbyFactory;
     _gameFactory    = gameFactory;
     _lobbyService   = lobbyService;
     _consoleService = consoleService;
     _userService    = userService;
 }
Esempio n. 19
0
        /// <summary>
        /// 注册一个游戏
        /// </summary>
        /// <param name="factory">用于创建游戏实例的工厂</param>
        public static void RegisterGame(IGameFactory factory)
        {
            lock ( _sync )
            {
                if (_collection.Contains(factory))
                {
                    return;
                }

                _collection.Add(factory);
            }
        }
Esempio n. 20
0
        public async Task LoadAsync(IGameFactory factory)
        {
            AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new AGS.API.Point(0, 0));

            Bottle = await factory.Inventory.GetInventoryItemAsync("Bottle", "../../Assets/Rooms/EmptyStreet/bottle.bmp", null, loadConfig);

            VoodooDoll = await factory.Inventory.GetInventoryItemAsync("Voodoo Doll", _baseFolder + "voodooDoll.bmp", null, loadConfig, true);

            Poster = await factory.Inventory.GetInventoryItemAsync("Poster", _baseFolder + "poster.bmp", playerStartsWithItem : true);

            Manual = await factory.Inventory.GetInventoryItemAsync("Manual", _baseFolder + "manual.bmp", null, loadConfig, true);
        }
Esempio n. 21
0
 public GameEngine(IGameFactory factory, IScreenPrinter printer, IHeroPrinter heroPrint,
                   IFightMode fightMode, ICollisionDetector detect, ICommandSelection commandSelection)
 {
     this.factory          = factory ?? throw new ArgumentNullException();
     this.printer          = printer ?? throw new ArgumentNullException();
     this.heroPrint        = heroPrint ?? throw new ArgumentNullException();
     this.fightMode        = fightMode ?? throw new ArgumentNullException();
     this.detect           = detect ?? throw new ArgumentNullException();
     this.commandSelection = commandSelection ?? throw new ArgumentNullException();
     this.Factory.HeroFactory();
     this.printer.Logger.SetSize();
 }
Esempio n. 22
0
        private async Task <IObject> loadCursor(string filename, IGameFactory factory)
        {
            IAnimation animation = await factory.Graphics.LoadAnimationFromFilesAsync(loadConfig : _loadConfig, files : new[] { _baseFolder + filename });

            var cursor = factory.Object.GetObject($"Cursor_{filename}");

            cursor.Pivot             = (0f, 1f);
            cursor.IgnoreScalingArea = true;
            cursor.IgnoreViewport    = true;
            cursor.StartAnimation(animation);
            return(cursor);
        }
Esempio n. 23
0
        public async Task <IPanel> LoadAsync(IGame game)
        {
            _game = game;
            _game.Events.OnSavedGameLoad.Subscribe(onSaveGameLoaded);
            IGameFactory factory = game.Factory;

            _player = game.State.Player;
            _panel  = await factory.UI.GetPanelAsync("Toolbar", "../../Assets/Gui/DialogBox/toolbar.bmp", 0f, 180f);

            _panel.Visible = false;

            await loadButton("Walk Button", factory, "walk/", 0f, RotatingCursorScheme.WALK_MODE);
            await loadButton("Interact Button", factory, "hand/", 20f, RotatingCursorScheme.INTERACT_MODE);
            await loadButton("Look Button", factory, "eye/", 40f, RotatingCursorScheme.LOOK_MODE);
            await loadButton("Talk Button", factory, "talk/", 60f, MouseCursors.TALK_MODE);

            InventoryButton = await loadButton("Inventory Button", factory, "inventory/", 80f);

            IButton activeInvButton = await loadButton("Active Inventory Button", factory, "activeInventory/", 100f, RotatingCursorScheme.INVENTORY_MODE);

            activeInvButton.Z = 1f;
            IButton helpButton = await loadButton("Help Button", factory, "help/", 280f);

            IButton optionsButton = await loadButton("Settings Button", factory, "settings/", 300f);

            InventoryButton.OnMouseClick(() => _invPanel.Show(), _game);
            optionsButton.OnMouseClick(() => _optionsPanel.Show(), _game);
            helpButton.OnMouseClick(() => _featuresPanel.Show(), _game);

            game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
            _inventoryItemIcon       = factory.Object.GetObject("Inventory Item Icon");
            _inventoryItemIcon.X     = 10f;
            _inventoryItemIcon.Y     = 10f;
            _inventoryItemIcon.Pivot = new AGS.API.PointF(0f, 0f);
            _inventoryItemIcon.TreeNode.SetParent(activeInvButton.TreeNode);
            _inventoryItemIcon.RenderLayer       = _panel.RenderLayer;
            _inventoryItemIcon.Enabled           = false;
            _inventoryItemIcon.IgnoreScalingArea = true;
            _inventoryItemIcon.IgnoreViewport    = true;
            game.State.UI.Add(_inventoryItemIcon);

            ILabel label = game.Factory.UI.GetLabel("Hotspot Label", "", 150f, 20f, 200f, 0f, _panel, new AGSTextConfig(brush: AGSGame.Device.BrushLoader.LoadSolidBrush(Colors.LightGreen),
                                                                                                                        alignment: Alignment.MiddleCenter, autoFit: AutoFit.TextShouldFitLabel, paddingBottom: 5f,
                                                                                                                        font: game.Factory.Fonts.LoadFont(AGSGameSettings.DefaultTextFont.FontFamily, 10f)));

            label.Pivot = new AGS.API.PointF(0.5f, 0f);
            VerbOnHotspotLabel hotspotLabel = new VerbOnHotspotLabel(() => _scheme.CurrentMode, game, label);

            hotspotLabel.Start();

            return(_panel);
        }
Esempio n. 24
0
 public LoadLevelState(
     GameStateMachine gameStateMachine,
     SceneLoader sceneLoader,
     IGameFactory gameFactory,
     IInputService inputService,
     IPersistentProgressService progressService)
 {
     _gameStateMachine = gameStateMachine;
     _sceneLoader      = sceneLoader;
     _gameFactory      = gameFactory;
     _progressService  = progressService;
     _inputService     = inputService;
 }
Esempio n. 25
0
        public BoardPlacementViewModel(IGameService gameService, IGameFactory gameFactory)
        {
            this.gameService = gameService;
            this.gameFactory = gameFactory;

            gameService.NewBoardStateAvailable += OnNewBoardStateAvailable;
            gameService.WinnerAvailable        += OnWinnerAvailable;

            BoardClick = new Command(HandleBoardClick);

            PossibleMoves       = new ObservableCollection <PlayerState>();
            PotentialPlacedWall = new ObservableCollection <Wall>();
        }
Esempio n. 26
0
 public LoadLevelState(
     GameStateMachine stateMachine,
     SceneLoader sceneLoader,
     LoadingCurtain curtain,
     IGameFactory gameFactory,
     ICardDealerService dealer)
 {
     _stateMachine = stateMachine;
     _sceneLoader  = sceneLoader;
     _curtain      = curtain;
     _gameFactory  = gameFactory;
     _dealer       = dealer;
 }
Esempio n. 27
0
        private IObject getIcon(string id, IGameFactory factory, float width, float height, IBorderStyle icon, IRenderLayer renderLayer)
        {
            var obj = factory.Object.GetObject(id);

            obj.Tint              = Colors.Transparent;
            obj.Image             = new EmptyImage(width, height);
            obj.RenderLayer       = renderLayer;
            obj.Pivot             = new PointF(0.5f, 0.5f);
            obj.IgnoreScalingArea = true;
            obj.IgnoreViewport    = true;
            obj.Border            = icon;
            return(obj);
        }
Esempio n. 28
0
        /****************************************************************************************************/
        /*  Constructor                                                                                     */
        /****************************************************************************************************/
        public Game(IGameFactory factory)
        {
            FaceupCharacters = new List<Character>();

            Players = factory.GetPlayers();
            PropertyChanged += factory.GetPropertyChanged();
            Characters = factory.GetCharacters();
            _characterPile = new List<Character>(Characters);
            _pile = factory.GetPile();
            _discardStrategy = factory.GetDiscardStrategy();

            OnStep();
            King = Players[0];
        }
Esempio n. 29
0
 public EntityDesigner(AGSEditor editor, ActionManager actions)
 {
     _actions = actions;
     _editor  = editor;
     _factory = editor.Editor.Factory;
     _state   = editor.Editor.State;
     _events  = editor.Editor.Events;
     _input   = editor.Editor.Input;
     _window  = editor.GameResolver.Container.Resolve <IWindowInfo>();
     _window.PropertyChanged += onWindowPropertyChanged;
     _resizeVisible           = true;
     _resizeHandles           = new List <ResizeHandle>(8);
     _rotateHandles           = new List <RotateHandle>(4);
 }
Esempio n. 30
0
        public PlayerController(
            PlayerOptions options,
            IGameFactory gameFactory)
        {
            Id           = options.Id;
            Color        = options.Color;
            _up          = options.Up;
            _right       = options.Right;
            _down        = options.Down;
            _left        = options.Left;
            _gameFactory = gameFactory;

            Reset();
        }
Esempio n. 31
0
        public async Task LoadAsync(IGameFactory factory)
        {
            AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new Point(0, 0));

            Bottle = await factory.Inventory.GetInventoryItemAsync("Bottle", "Rooms/EmptyStreet/bottle.bmp", null, loadConfig);

            VoodooDoll = await factory.Inventory.GetInventoryItemAsync("Voodoo Doll", _baseFolder + "voodooDoll.bmp", null, loadConfig, true);

            Poster = await factory.Inventory.GetInventoryItemAsync("Poster", _baseFolder + "poster.bmp", playerStartsWithItem : true);

            Manual = await factory.Inventory.GetInventoryItemAsync("Manual", _baseFolder + "manual.bmp", null, loadConfig, true);

            Poster.OnCombination(Manual).SubscribeToAsync(onPutPosterInManual);
        }
Esempio n. 32
0
        public async Task <ICharacter> LoadAsync(IGame game)
        {
            _game = game;
            IGameFactory       factory    = game.Factory;
            AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new Point(0, 0));

            IOutfit outfit = await factory.Outfit.LoadOutfitFromFoldersAsync(_baseFolder,
                                                                             walkLeftFolder : "Walk/left", walkDownFolder : "Walk/down", walkRightFolder : "Walk/right", walkUpFolder : "Walk/up",
                                                                             idleLeftFolder : "Idle/left", idleDownFolder : "Idle/down", idleRightFolder : "Idle/right", idleUpFolder : "Idle/up",
                                                                             speakLeftFolder : "Talk/left", speakDownFolder : "Talk/down", speakRightFolder : "Talk/right", speakUpFolder : "Talk/up",
                                                                             loadConfig : loadConfig);

            _character = factory.Object.GetCharacter("Beman", outfit).Remember(_game, character =>
            {
                _character = character;
                subscribeEvents();
            });
            _character.SpeechConfig.TextConfig = AGSTextConfig.ChangeColor(_character.SpeechConfig.TextConfig, Colors.CornflowerBlue, Colors.Black, 1f);
            _character.SpeechConfig.TextOffset = (0f, -10f);

            //Uncomment for portrait

            /*
             * var portrait = game.Factory.Object.GetObject("BemanPortrait");
             * portrait.StartAnimation(game.Factory.Graphics.LoadAnimationFromFolder(_baseFolder + "Talk/down"));
             * portrait.Border = game.Factory.Graphics.Borders.SolidColor(Colors.AliceBlue, 3f, true);
             * portrait.Visible = false;
             * portrait.RenderLayer = AGSLayers.Speech;
             * portrait.IgnoreViewport = true;
             * portrait.IgnoreScalingArea = true;
             * game.State.UI.Add(portrait);
             * _character.SpeechConfig.PortraitConfig = new AGSPortraitConfig { Portrait = portrait, Positioning = PortraitPositioning.Alternating };
             */

            var speakAnimation = _character.Outfit[AGSOutfit.Speak];

            Characters.RandomAnimationDelay(speakAnimation.Left);
            Characters.RandomAnimationDelay(speakAnimation.Right);
            Characters.RandomAnimationDelay(speakAnimation.Down);
            Characters.RandomAnimationDelay(speakAnimation.Up);

            _character.StartAnimation(_character.Outfit[AGSOutfit.Idle].Down);
            _character.DisplayName    = "Beman";
            _character.IsPixelPerfect = true;

            Characters.Beman = _character;

            _dialogs.Load(game);
            return(_character);
        }
Esempio n. 33
0
        private static FourInARowMove Common(String[] input, IGameAlgorithm algorithm, IGameFactory gameFactory)
        {
            FourInARowState state = PrepareState(input);

            IGameFactory factory = gameFactory;

            IGameLogic logic = factory.CreateLogic();

            IGameAlgorithm alg = algorithm;

            Int32 res = factory.CreateStateEvaluator().Evaluate(state, GamePlayer.PlayerMax);

            return((FourInARowMove)alg.FindBestMove(state, GamePlayer.PlayerMax));
        }
Esempio n. 34
0
 public AGSSayComponent(IGameState state, IGameFactory factory, IInput input, ISayLocationProvider location,
                        FastFingerChecker fastFingerChecker, ISayConfig sayConfig,
                        IBlockingEvent <BeforeSayEventArgs> onBeforeSay,
                        ISoundEmitter emitter, ISpeechCache speechCache)
 {
     _state             = state;
     _factory           = factory;
     _input             = input;
     _location          = location;
     _fastFingerChecker = fastFingerChecker;
     _emitter           = emitter;
     _speechCache       = speechCache;
     SpeechConfig       = sayConfig;
     OnBeforeSay        = onBeforeSay;
 }
Esempio n. 35
0
        public GameUtility(IRepository <Game> gameRepository,
                           IGameFactory gameFactory,
                           IDateTimeProvider dateTimeProvider,
                           IUnitOfWork unitOfWork)
        {
            Guard.WhenArgument(gameRepository, "GameRepository cannot be null").IsNull().Throw();
            Guard.WhenArgument(gameFactory, "gameFactory cannot be null").IsNull().Throw();
            Guard.WhenArgument(dateTimeProvider, "dateTimeProvider cannot be null").IsNull().Throw();
            Guard.WhenArgument(unitOfWork, "unitOfWork cannot be null").IsNull().Throw();

            this.gameRepository   = gameRepository;
            this.gameFactory      = gameFactory;
            this.dateTimeProvider = dateTimeProvider;
            this.unitOfWork       = unitOfWork;
        }
Esempio n. 36
0
 public Lobby(LobbyState state, IUserTopic topic, IGameFactory gameFactory)
 {
     if (state == null)
     {
         throw new ArgumentNullException(nameof(state));
     }
     if (string.IsNullOrEmpty(state.RoomId))
     {
         throw new ArgumentException("Room id should be initialized", nameof(state));
     }
     _state       = state;
     _topic       = topic ?? throw new ArgumentNullException(nameof(topic));
     _gameFactory = gameFactory ?? throw new ArgumentNullException(nameof(gameFactory));
     Initialize();
 }
Esempio n. 37
0
 public ScrabbleManager(
     IGameFactory gameFactory,
     Board board,
     ITileDrawer drawer,
     IGoHandler goHandler,
     IAiGoHandler aiGoHandler,
     IGameRepository gameRepo)
 {
     this.gameFactory = gameFactory;
     this.board       = board;
     this.drawer      = drawer;
     this.goHandler   = goHandler;
     this.aiGoHandler = aiGoHandler;
     this.gameRepo    = gameRepo;
 }
Esempio n. 38
0
        public void Init(IGameFactory factory, AGSEditor editor)
        {
            _pointer       = factory.UI.GetLabel("PointerCursor", "", 25f, 25f, 0f, 0f, config: FontIcons.IconConfig, addToUi: false);
            _pointer.Text  = FontIcons.Pointer;
            _pointer.Pivot = new PointF(0.29f, 0.83f);

            var toolbarHeight = _resolution.Height / 20f;

            _toolbar              = factory.UI.GetPanel("GameToolbar", _resolution.Width / 2f, toolbarHeight, _resolution.Width / 2f, _resolution.Height - toolbarHeight);
            _toolbar.Pivot        = new PointF(0.5f, 0f);
            _toolbar.Tint         = GameViewColors.SubPanel;
            _toolbar.RenderLayer  = new AGSRenderLayer(-99999, independentResolution: _resolution);
            _toolbar.ClickThrough = false;
            _toolbar.Border       = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 3f, true);

            var         idle         = new ButtonAnimation(null, FontIcons.ButtonConfig, GameViewColors.Button);
            var         hover        = new ButtonAnimation(null, AGSTextConfig.ChangeColor(FontIcons.ButtonConfig, Colors.Yellow, Colors.White, 0f), GameViewColors.HoveredButton);
            var         pushed       = new ButtonAnimation(null, FontIcons.ButtonConfig, GameViewColors.PushedButton);
            const float buttonWidth  = 50f;
            float       buttonHeight = _toolbar.Height * 3 / 4f;
            float       buttonY      = _toolbar.Height / 2f;
            float       buttonX      = _toolbar.Width / 2f;

            _playPauseButton             = factory.UI.GetButton("PlayPauseGameButton", idle, hover, pushed, buttonX, buttonY, _toolbar, width: buttonWidth, height: buttonHeight);
            _playPauseButton.Text        = FontIcons.Pause;
            _playPauseButton.Pivot       = new PointF(0.5f, 0.5f);
            _playPauseButton.RenderLayer = _toolbar.RenderLayer;
            _playPauseButton.MouseClicked.Subscribe(onPlayPauseClicked);

            _fpsLabel       = factory.UI.GetLabel("FPS Label (Editor)", "", 30f, 25f, 0f, _playPauseButton.Y, _toolbar, config: factory.Fonts.GetTextConfig(autoFit: AutoFit.LabelShouldFitText, font: _font));
            _fpsLabel.Pivot = new PointF(0f, 0.5f);
            _fpsLabel.TextBackgroundVisible = false;
            _fpsLabel.RenderLayer           = _toolbar.RenderLayer;
            _fpsLabel.Enabled = true;
            _fpsLabel.MouseEnter.Subscribe(_ => _fpsLabel.Tint = Colors.Indigo);
            _fpsLabel.MouseLeave.Subscribe(_ => _fpsLabel.Tint = Colors.IndianRed.WithAlpha(125));

            _mousePosLabel = factory.UI.GetLabel("Mouse Position Label (Editor)", "", 1f, 1f, 120f, _playPauseButton.Y, _toolbar, config: factory.Fonts.GetTextConfig(autoFit: AutoFit.LabelShouldFitText, font: _font));
            _mousePosLabel.TextBackgroundVisible = false;
            _mousePosLabel.Pivot       = new PointF(0f, 0.5f);
            _mousePosLabel.RenderLayer = _toolbar.RenderLayer;

            _hotspotLabel = factory.UI.GetLabel("Debug Hotspot Label (Editor)", "", 250f, _fpsLabel.Height, _toolbar.Width, _playPauseButton.Y, _toolbar, config: factory.Fonts.GetTextConfig(alignment: Alignment.TopRight,
                                                                                                                                                                                              autoFit: AutoFit.TextShouldFitLabel, font: _font));
            _hotspotLabel.TextBackgroundVisible = false;
            _hotspotLabel.Pivot       = new PointF(1f, 0.5f);
            _hotspotLabel.RenderLayer = _toolbar.RenderLayer;
        }
Esempio n. 39
0
		public void Init()
		{
			_mocks = Mocks.Init();
			Mock<IEngineConfigFile> config = new Mock<IEngineConfigFile> ();
			_resolver = new Resolver (config.Object);
			_resolver.Build();
			var updater = new ContainerBuilder ();
			updater.RegisterInstance(_mocks.Input().Object).As<IInput>();
			updater.RegisterInstance(_mocks.AudioSystem().Object).As<IAudioSystem>();
			updater.RegisterInstance(new Mock<IMessagePump>().Object);
			updater.Update(_resolver.Container);
            _textures = new Dictionary<string, ITexture> ();
			_state = _resolver.Container.Resolve<IGameState>();
			_factory = _resolver.Container.Resolve<IGameFactory>();
			_saveLoad = new AGSSaveLoad (_resolver, _factory, _textures, _resolver.Container.Resolve<IGame>());
			_state.Rooms.Add(_mocks.Room().Object);
		}
Esempio n. 40
0
		public AGSSayBehavior(IGameState state, IGameFactory factory, IInput input, ISayLocationProvider location,
			                  FastFingerChecker fastFingerChecker, ISayConfig sayConfig, IHasOutfit outfit, 
                              IFaceDirectionBehavior faceDirection, IBlockingEvent<BeforeSayEventArgs> onBeforeSay, 
                              ISoundEmitter emitter, ISpeechCache speechCache)
		{
			_state = state;
			_factory = factory;
			_input = input;
			_location = location;
			_fastFingerChecker = fastFingerChecker;
			_outfit = outfit;
			_faceDirection = faceDirection;
            _emitter = emitter;
            _speechCache = speechCache;
			SpeechConfig = sayConfig;
			OnBeforeSay = onBeforeSay;
		}
Esempio n. 41
0
		public TicTacToeRunner (IReader reader, IDisplayer displayer, IBoardFormatter formatter, IPlayerFactory player_factory, IRoundFactory round_factory, IGameFactory game_factory, IGameRepository game_repository)
		{
			_reader = reader;
			_displayer = displayer;
			_game_repository = game_repository;
			_game_factory = game_factory;
			_formatter = formatter;
			_round_factory = round_factory;
			_player_factory = player_factory;

			//on charge la partie dans le repo
			_game_model = _game_repository.Load();

			if(_game_model == null)
				_game_model = game_factory.Create (NUMBER_ROUND);
			
			_game = new TicTacToeGame (_reader, _displayer, formatter, player_factory, round_factory, _game_model, _game_repository);
		}
Esempio n. 42
0
        public static void PlayGame(IGameFactory factory)
        {
            IGame game = factory.GetGame();
            PlayerMoveDTO playerMoveDTO;

            while (true)
            {
                do
                {
                    // Избира фигура, която иска да премести. Връща новата позиция на избраната фигура заедно с фигурара
                    // или нейните координати.
                    playerMoveDTO = player1.Move(game.Board);
                }
                while (!game.isMoveValid(playerMoveDTO));

            // местим фигурата на дъската
                game.MoveFigure(playerMoveDTO);
                if (game.isEndGame())
                {
                    return;
                }

                do
                {
                    // Избира фигура, която иска да премести. Връща новата позиция на избраната фигура заедно с фигурара
                    // или нейните координати.
                    playerMoveDTO = player2.Move(game.Board);
                }
                while (!game.isMoveValid(playerMoveDTO));

                game.MoveFigure(playerMoveDTO);
                if (game.isEndGame())
                {
                    return;
                }
            }
        }
Esempio n. 43
0
		private IDialog createShadersDialog(IGameFactory factory)
		{
			IDialogOption option1 = factory.Dialog.GetDialogOption("Normal");
			IDialogOption option2 = factory.Dialog.GetDialogOption("Grayscale");
			IDialogOption option3 = factory.Dialog.GetDialogOption("Sepia");
			IDialogOption option4 = factory.Dialog.GetDialogOption("Soft Sepia");
			IDialogOption option5 = factory.Dialog.GetDialogOption("Vignette");
			IDialogOption option6 = factory.Dialog.GetDialogOption("Blur me!");
			IDialogOption option7 = factory.Dialog.GetDialogOption("Shake the screen!");
			IDialogOption option8 = factory.Dialog.GetDialogOption("Actually, I don't want a shader!");

			setShaderOption(option1, () => Shaders.SetStandardShader());
			setShaderOption(option2, () => Shaders.SetGrayscaleShader());
			setShaderOption(option3, () => Shaders.SetSepiaShader());
			setShaderOption(option4, () => Shaders.SetSoftSepiaShader());
			setShaderOption(option5, () => Shaders.SetVignetteShader());
			setShaderOption(option6, () => Shaders.SetBlurShader());
			setShaderOption(option7, () => Shaders.SetShakeShader());
			setShaderOption(option8, () => Shaders.TurnOffShader());

			IDialog dialog = factory.Dialog.GetDialog("Dialog: Beman- Shaders");
			dialog.AddOptions(option1, option2, option3, option4, option5, option6, option7, option8);

			return dialog;
		}
Esempio n. 44
0
		private IDialog createQuestionsDialog(IGameFactory factory)
		{
			IDialogOption option1 = factory.Dialog.GetDialogOption("Where are you from?");
			option1.AddText(Characters.Beman, "I'm from Sweden.");

			IDialogOption option2 = factory.Dialog.GetDialogOption("What do you do?");
			option2.AddText(Characters.Beman, "I'm a hobbyist game developer.");

			IDialogOption option3 = factory.Dialog.GetDialogOption("Can I start a scene?");
			option3.ExitDialogWhenFinished = true;
			option3.AddText(Characters.Beman, "Go for it, though remember that the user can skip the scene by pressing any key on the keyboard");
			option3.AddConditionalActions(startAScene);

			IDialogOption option4 = factory.Dialog.GetDialogOption("That's all I have...");
			option4.ChangeDialogWhenFinished = StartDialog;

			IDialog dialog = factory.Dialog.GetDialog("Dialog: Beman- Questions");
			dialog.AddOptions(option1, option2, option3, option4);

			return dialog;
		}
Esempio n. 45
0
		private async Task addLampPosts(IGameFactory factory)
		{
			PointF parallaxSpeed = new PointF (1.4f, 1f);
			AGSRenderLayer parallaxLayer = new AGSRenderLayer (-50, parallaxSpeed);
			var image = await factory.Graphics.LoadImageAsync(_baseFolder + "lampPost.png");
			var singleFrame = new AGSSingleFrameAnimation (image, factory.Graphics);
			const int numLampPosts = 3;

			for (int index = 0; index < numLampPosts; index++)
			{
				IObject lampPost = factory.Object.GetObject("Lamp Post " + index);
				lampPost.X = 200f * index + 30f;
				lampPost.Y = -130f;
				lampPost.RenderLayer = parallaxLayer;
				lampPost.StartAnimation(singleFrame);
				_room.Objects.Add(lampPost);
			}
		}
Esempio n. 46
0
		public IMask CreateMask(IGameFactory factory, string path, bool transparentMeansMasked = false, 
			AGS.API.Color? debugDrawColor = null, string saveMaskToFile = null, string id = null)
		{
			Bitmap debugMask = null;
			FastBitmap debugMaskFast = null;
			if (saveMaskToFile != null || debugDrawColor != null)
			{
				debugMask = Bitmap.CreateBitmap (Width, Height, Bitmap.Config.Argb8888);
				debugMaskFast = new FastBitmap (debugMask, true);
			}

			bool[][] mask = new bool[Width][];
			global::Android.Graphics.Color drawColor = debugDrawColor != null ? debugDrawColor.Value.Convert() : global::Android.Graphics.Color.Black;

			using (FastBitmap bitmapData = new FastBitmap (_bitmap))
			{
				for (int x = 0; x < Width; x++)
				{
					for (int y = 0; y < Height; y++)
					{
						var pixelColor = bitmapData.GetPixel(x, y);

						bool masked = pixelColor.A == 255;
						if (transparentMeansMasked)
							masked = !masked;

						if (mask[x] == null)
							mask[x] = new bool[Height];
						mask[x][Height - y - 1] = masked;

						if (debugMask != null)
						{
							debugMaskFast.SetPixel(x, y, masked ? drawColor : global::Android.Graphics.Color.Transparent);
						}
					}
				}
			}

			if (debugMask != null)
				debugMaskFast.Dispose();

			//Save the duplicate
			if (saveMaskToFile != null)
			{
				using (Stream stream = Hooks.FileSystem.Create(saveMaskToFile))
				{
					debugMask.Compress(global::Android.Graphics.Bitmap.CompressFormat.Png, 100, stream);
				}
			}	

			IObject debugDraw = null;
			if (debugDrawColor != null)
			{
				debugDraw = factory.Object.GetObject(id ?? path ?? "Mask Drawable");
                debugDraw.Image = factory.Graphics.LoadImage(new AndroidBitmap(debugMask, _graphics), null, path);
				debugDraw.Anchor = new AGS.API.PointF ();
			}

			return new AGSMask (mask, debugDraw);
		}
 public GameMoveAssigner(IGameFactory gameFactory)
 {
     _gameFactory = gameFactory;
 }
Esempio n. 48
0
 public IGame CreateGame(IGameFactory gameFactory, GameType type, IBoard board)
 {
     CurrentGame = gameFactory.CreateGame(type, board);
     return CurrentGame;
 }
Esempio n. 49
0
		public AGSWalkBehindsMap(IGameFactory factory)
		{
			_factory = factory;
			_images = new Dictionary<AreaKey, IImage> (100);
			_objects = new Dictionary<AreaKey, IObject> (100);
		}
Esempio n. 50
0
 private IObject getIcon(string id, IGameFactory factory, float width, float height, IBorderStyle icon)
 {
     var obj = factory.Object.GetObject(id);
     obj.Tint = Colors.Transparent;
     obj.Image = new EmptyImage(width, height);
     obj.RenderLayer = AGSLayers.UI;
     obj.Anchor = new PointF(0.5f, 0.5f);
     obj.IgnoreScalingArea = true;
     obj.IgnoreViewport = true;
     obj.Border = icon;
     return obj;
 }
Esempio n. 51
0
		public AGSMaskLoader(IGameFactory factory, IResourceLoader resourceLoader)
		{
			_factory = factory;
			_resourceLoader = resourceLoader;
		}
Esempio n. 52
0
 public GameController(ICurrentPlayerProvider currentPlayerProvider,
     IGameFactory gameFactory, IGameRepository gameRepository,
     IPlayerRepository playerRepository)
 {
     currentPlayer = currentPlayerProvider.GetUserPlayer();
     this.gameRepository = gameRepository;
     this.gameFactory = gameFactory;
     this.playerRepository = playerRepository;
 }
Esempio n. 53
0
 private static IObject clone(string id, IGameFactory factory, IObject obj)
 {
     IObject newObj = factory.Object.GetObject(id);
     newObj.Anchor = obj.Anchor;
     newObj.Location = obj.Location;
     newObj.Tint = obj.Tint;
     newObj.Hotspot = obj.Hotspot;
     newObj.RenderLayer = obj.RenderLayer;
     newObj.IgnoreViewport = obj.IgnoreViewport;
     newObj.IgnoreScalingArea = obj.IgnoreScalingArea;
     newObj.Border = obj.Border;
     if (obj.Animation != null) newObj.StartAnimation(obj.Animation.Clone());
     newObj.ResetBaseSize(obj.Width / obj.ScaleX, obj.Height / obj.ScaleY);
     newObj.ScaleBy(obj.ScaleX, obj.ScaleY);
     return newObj;
 }
Esempio n. 54
0
        void CreateEmbeddedServer(string gameDir, Guid save)
        {
            m_save = save;

            string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            var baseDir = System.IO.Path.GetDirectoryName(exePath);
            var serverPath = System.IO.Path.Combine(baseDir, "Dwarrowdelf.Server.exe");

            AppDomain appDomain;

            if (ClientConfig.EmbeddedServer == EmbeddedServerMode.SeparateAppDomain)
            {
                var di = AppDomain.CurrentDomain.SetupInformation;

                var domainSetup = new AppDomainSetup()
                {
                    ApplicationBase = di.ApplicationBase,
                    ConfigurationFile = di.ApplicationBase + "Dwarrowdelf.Server.exe.config",
                };

                m_serverDomain = AppDomain.CreateDomain("ServerDomain", null, domainSetup);

                appDomain = m_serverDomain;
            }
            else
            {
                appDomain = AppDomain.CurrentDomain;
            }

            m_gameFactory = (IGameFactory)appDomain.CreateInstanceFromAndUnwrap(serverPath, "Dwarrowdelf.Server.GameFactory");
        }