예제 #1
0
        public BasePlayer(IPlayerSettings playerSettings, IPhysicsComponent physicsComponent, IBoundaryCollider boundaryCollider, IWeapons weapons, ITimer timer)
        {
            this.PlayerSettings = playerSettings;
            this.PlayerScore = new PlayerScore();

            if (physicsComponent == null)
                this.PhysicsComponent = new DummyPhysicsComponent();
            else
                this.PhysicsComponent = physicsComponent;

            this.PhysicsComponent.CollidedWithWorld += () => InContactWithLevel = true;
            this.PhysicsComponent.WasShot += Damage;

            this.Weapons = weapons;
            this.Weapons.DamagedAPlayer += (damage, physicsComp) => physicsComp.OnWasShot(this, damage);

            this.Timer = timer;
            this.BoundaryCollider = boundaryCollider;

            this.Health = BasePlayer.StartHealth;
            this.Status = PlayerStatus.Alive;
            this.Position = new Vector2(400, 100);

            this.PhysicsComponent.CollisionGroup = BasePlayer.CollisionGroup;
        }
예제 #2
0
 public void SetUp()
 {
     stubPlayerSettings = MockRepository.GenerateStub<IPlayerSettings>();
     stubPhysicsComponent = MockRepository.GenerateStub<IPhysicsComponent>();
     stubBoundaryCollider = MockRepository.GenerateStub<IBoundaryCollider>();
     stubWeapons = MockRepository.GenerateStub<IWeapons>();
     stubTimer = MockRepository.GenerateStub<ITimer>();
     player = new BasePlayer(stubPlayerSettings, stubPhysicsComponent, stubBoundaryCollider, stubWeapons, stubTimer);
 }
예제 #3
0
 public NavigatorPreferencesComposer(IPlayerSettings playerSettings)
     : base(Headers.NavigatorPreferencesMessageComposer)
 {
     WriteInt(playerSettings.NaviX);
     WriteInt(playerSettings.NaviY);
     WriteInt(playerSettings.NaviWidth);
     WriteInt(playerSettings.NaviHeight);
     WriteBoolean(playerSettings.NaviHideSearches);
     WriteInt(0); //No idea?
 }
예제 #4
0
 public PlayerMovement(
     IPlayer player,
     IPlayerSettings playerSettings,
     IInputManager inputManager,
     IMainCamera mainCamera)
 {
     this.player         = player;
     this.playerSettings = playerSettings;
     this.inputManager   = inputManager;
     this.mainCamera     = mainCamera;
 }
예제 #5
0
 public ThrowState(
     IPlayer player,
     IPillow pillow,
     IInputManager inputManager,
     IPlayerSettings playerSettings,
     PlayerMovement.Factory playerMovementFactory,
     WalkState.Factory walkStateFactory
     )
 {
     this.player           = player;
     this.pillow           = pillow;
     this.inputManager     = inputManager;
     this.playerSettings   = playerSettings;
     this.playerMovement   = playerMovementFactory.Create(player);
     this.walkStateFactory = walkStateFactory;
 }
예제 #6
0
        private static bool TryGetPlayerSettings(IDictionary<string, string> initParams, out IPlayerSettings playerSettings)
        {
            if (initParams.ContainsKeyIgnoreCase("InitialSettings"))
            {
                string xmlSettings = initParams.GetEntryIgnoreCase("InitialSettings");
                if (!String.IsNullOrWhiteSpace(xmlSettings))
                {
                    var serializer = new XmlSerializer(typeof(PlayerSettings));
                    playerSettings = (IPlayerSettings)serializer.Deserialize(xmlSettings.AsStream());
                    return true;
                }

            }
            playerSettings = null;
            return false;
        }
예제 #7
0
        internal async Task <IPlayerSettings> GetPlayerSettingsById(uint id)
        {
            IPlayerSettings playerSettings = null;

            await CreateTransaction(async transaction =>
            {
                await Select(transaction, async reader =>
                {
                    if (await reader.ReadAsync())
                    {
                        playerSettings = new PlayerSettings(reader);
                    }
                }, "SELECT navi_x, navi_y, navi_width, navi_height, navi_hide_searches FROM player_settings WHERE player_id = @0 LIMIT 1;", id);
            });

            return(playerSettings);
        }
예제 #8
0
        public async Task HandleAsync(
            ISession session,
            IClientPacket clientPacket)
        {
            string  ssoTicket = clientPacket.ReadString();
            IPlayer player    = await _playerController.GetPlayerBySsoAsync(ssoTicket);

            if (player != null)
            {
                session.Player = player;
                IPlayerSettings playerSettings =
                    await _playerController.GetPlayerSettingsByIdAsync(player.Id);

                if (playerSettings != null)
                {
                    session.PlayerSettings = playerSettings;
                }
                else
                {
                    await _playerController.AddPlayerSettingsAsync(player.Id);

                    session.PlayerSettings =
                        await _playerController.GetPlayerSettingsByIdAsync(player.Id);
                }

                await session.WriteAndFlushAsync(new AuthenticationOkComposer());

                await session.WriteAndFlushAsync(new HomeRoomComposer(1));

                await session.WriteAndFlushAsync(new FavouriteRoomsComposer());

                await session.WriteAndFlushAsync(new FigureSetIdsComposer());

                await session.WriteAndFlushAsync(new UserRightsComposer(session.Player.Rank));

                await session.WriteAndFlushAsync(new AvailabilityStatusComposer());

                await session.WriteAndFlushAsync(new BuildersClubMembershipComposer());

                await session.WriteAndFlushAsync(new CfhTopicsInitComposer());

                await session.WriteAndFlushAsync(new BadgeDefinitionsComposer());

                await session.WriteAndFlushAsync(new PlayerSettingsComposer());
            }
        }
예제 #9
0
        /// <summary>
        /// Generate the HTML code needed to deploy a silverlight media player in your view wrapped as a silverlight object.
        /// </summary>
        /// <param name="silverlightXapSource">Player's xap file location.</param>
        /// <param name="playerSettings">Player's settings.</param>
        /// <param name="divContainerHtmlAttributes">Anonymous object with silverlight's container div attributes.</param>
        /// <param name="onErrorJavaScriptHandlerFuntionName">JavaScript function name for error event handling.</param>
        /// <param name="onLoadJavaScriptHandlerFunctionName">JavaScript function name for load event handling.</param>
        /// <param name="objectWidthPercentage">Silverlight object width percentage.</param>
        /// <param name="objectHeightPercentage">Silverlight object width percentage.</param>
        /// <param name="minimumRuntimeVersion">Silverlight object minimum runtime version </param>
        /// <param name="iFrameStyle">Silverlight object iFrame style</param>
        /// <returns>HTML code for a silverlight media player with the requested settings.</returns>
        /// <exception cref="ArgumentNullException">Throws an ArgumentNullException exception if parameters <paramref name="playerSettings"/> or <paramref name="silverlightXapSource"/> weren't provided.</exception>
        public static HtmlString ControlHost(
            string silverlightXapSource, // URI Location of the Silverlight XAP file
            IPlayerSettings playerSettings,
            object divContainerHtmlAttributes = null,
            string onErrorJavaScriptHandlerFuntionName = "onSilverlightError",
            string onLoadJavaScriptHandlerFunctionName = "onSilverlightLoad",
            string objectWidthPercentage = "100",
            string objectHeightPercentage = "100",
            string minimumRuntimeVersion = "4.0.50826.0",
            string iFrameStyle = "visibility:hidden;height:0px;width:0px;border:0px")
        {
            if (playerSettings == null)
            {
                throw new ArgumentNullException("playerSettings");
            }

            if (silverlightXapSource == null)
            {
                throw new ArgumentNullException("silverlightXapSource");
            }

            //string silverlightObject = string.Format(
                                       
            //                                    "<object data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"{0}\" height=\"{1}\"> \n" +
            //                                      "<param name=\"source\" value=\"{2}\"/> \n" +
            //                                      "<param name=\"minRuntimeVersion\" value=\"{3}\" /> \n" +
            //                                      "<param name=\"onError\" value=\"{4}\" /> \n" +
            //                                      "<param name=\"onLoad\" value=\"{5}\" /> \n" +
            //                                      "<param name=\"background\" value=\"white\" /> \n" +
            //                                      "<param name=\"autoUpgrade\" value=\"true\" /> \n" +
            //                                      "<param name=\"InitParams\" value=\"PlayerSettings ={6}\" /> \n" +
            //                                      "<a href=\"http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0\" style=\"text-decoration:none\"> \n" +
            //                                          "<img src=\"http://go.microsoft.com/fwlink/?LinkId=161376\" alt=\"Get Microsoft Silverlight\" style=\"border-style:none\"/> \n" +
            //                                      "</a> \n" +
            //                                    "</object><iframe id=\"_sl_historyFrame\" style=\"{7}\"></iframe> \n",
            //                          objectWidth,
            //                          objectHeight,
            //                          silverlightXapSource,
            //                          minimumRuntimeVersion,
            //                          onErrorJavaScriptHandlerFuntionName,
            //                          onLoadJavaScriptHandlerFunctionName,
            //                          playerSettings.AsXmlSerializedString(),
            //                          iFrameStyle
            //                          );


            var imgBuilder = new TagBuilder("img");
            var imgAttributes = new Dictionary<string, string>()
                                       {
                                           {"src", "http://go.microsoft.com/fwlink/?LinkId=161376"},
                                           {"alt", "Get Microsoft Silverlight"},
                                           {"style", "border-style:none"},
                                       };
            imgBuilder.MergeAttributes(imgAttributes);

            var linkBuilder = new TagBuilder("a");
            var linkAttributes = new Dictionary<string, string>()
                                       {
                                           {"href", "http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0"},
                                           {"style", "text-decoration:none"},
                                       };
            linkBuilder.MergeAttributes(linkAttributes);
            linkBuilder.InnerHtml = imgBuilder.ToString(TagRenderMode.Normal);
            

            var objectBuilder = new TagBuilder("object");
            var objectAttributes = new Dictionary<string, string>()
                                       {
                                           {"data", "data:application/x-silverlight-2,"},
                                           {"type", "application/x-silverlight-2"},
                                           {"width", string.Format("{0}%",objectWidthPercentage)},
                                           {"height", string.Format("{0}%",objectHeightPercentage)},
                                       };
            objectBuilder.MergeAttributes(objectAttributes);
            
            objectBuilder.InnerHtml = new MvcHtmlString(
                CraftParamTagBuilder("source", silverlightXapSource).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("minRuntimeVersion", minimumRuntimeVersion).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("onError", onErrorJavaScriptHandlerFuntionName).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("onLoad", onLoadJavaScriptHandlerFunctionName).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("background", "white").ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("autoUpgrade", "true").ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("InitParams", "PlayerSettings = \n" + playerSettings.AsXmlSerializedString()).ToString(TagRenderMode.SelfClosing) +
                linkBuilder.ToString(TagRenderMode.Normal)
            ).ToHtmlString();

            var iframeBuilder = new TagBuilder("iframe");
            var iframeAttributes = new Dictionary<string, string>()
                                       {
                                           {"id", "_sl_historyFrame"},
                                           {"style", iFrameStyle},
                                       };
            iframeBuilder.MergeAttributes(iframeAttributes);

            var divBuilder = new TagBuilder("div");
            divBuilder.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(divContainerHtmlAttributes));
            //divBuilder.InnerHtml = new MvcHtmlString(silverlightObject).ToHtmlString();
            divBuilder.InnerHtml = new MvcHtmlString(
                objectBuilder.ToString(TagRenderMode.Normal) +
                iframeBuilder.ToString(TagRenderMode.Normal)
            ).ToHtmlString();

            return new MvcHtmlString(divBuilder.ToString(TagRenderMode.Normal));
        }
예제 #10
0
 public PillowCarrier(IPlayer player, IPlayerSettings playerSettings)
 {
     this.player         = player;
     this.playerSettings = playerSettings;
 }
예제 #11
0
        /// <summary>
        /// Generate the HTML code needed to deploy a silverlight media player in your view wrapped as a silverlight object.
        /// </summary>
        /// <param name="htmlHelper">The HTML helper instance that this method extends.</param>
        /// <param name="playerXapSource">Player's xap file location.</param>
        /// <param name="playerSettings">Player's settings.</param>
        /// <param name="containerHtmlAttributes">Anonymous object with silverlight's container div attributes.</param>
        /// <param name="xamlThemeSource">External Xaml Theme Uri. </param>
        /// /// <param name="scriptableName">object name used for the Javascript interface to the Player. </param>
        /// <param name="onErrorCallBack">JavaScript function name for silverlight error event handling.</param>
        /// <param name="onLoadedCallback">JavaScript function name for silverlight loaded event handling. </param>
        /// <param name="sidewiredXapSource">Sidewired's plugin xap file location. </param>
        /// <param name="objectWidthPercentage">Silverlight object width percentage.</param>
        /// <param name="objectHeightPercentage">Silverlight object width percentage.</param>
        /// <param name="windowLess"> Enables windowless behavior.</param>
        /// <param name="enableHtmlAccess"> Enables  html access.</param>
        /// <param name="enableGpuAcceleration">Allows GPU acceleration </param>
        /// <param name="autoUpgrade"> Allows autoupgrade behavior.</param>
        /// <param name="minimumRuntimeVersion">Silverlight object minimum runtime version </param>
        /// <param name="iFrameStyle">Silverlight object iFrame style</param>
        /// <returns>HTML code for a silverlight media player with the requested settings.</returns>
        /// <exception cref="ArgumentNullException">Throws an ArgumentNullException exception if parameters <paramref name="playerSettings"/> or <paramref name="playerXapSource"/> weren't provided.</exception>
        public static HtmlString SilverlightMediaPlayer(this HtmlHelper htmlHelper,
            string playerXapSource,
            IPlayerSettings playerSettings,
            object containerHtmlAttributes = null,            
            string xamlThemeSource = null,
            string scriptableName = "SMPlayer",
            string onErrorCallBack = "onSilverlightError",
            string onLoadedCallback = "onSilverlightLoaded",
            string sidewiredXapSource = @"/ClientBin/Sidewired.xap",
            string objectWidthPercentage = "100",
            string objectHeightPercentage = "100",
            bool enableHtmlAccess = true,
            bool enableGpuAcceleration = true,
            bool autoUpgrade = true,
            bool windowLess = true,
            string minimumRuntimeVersion = "4.0.50826.0",
            string iFrameStyle = "visibility:hidden;height:0px;width:0px;border:0px")
        {
            if (playerSettings == null)
            {
                throw new ArgumentNullException("playerSettings\xFEFF");
            }

            if (playerXapSource == null)
            {
                throw new ArgumentNullException("playerXapSource");
            }

            if (sidewiredXapSource == null)
            {
                throw new ArgumentNullException("sidewiredXapSource");
            }

            return CreatePlayerMarkup(playerSettings, playerXapSource, sidewiredXapSource, containerHtmlAttributes, 
                xamlThemeSource, scriptableName, onErrorCallBack, onLoadedCallback, objectWidthPercentage, objectHeightPercentage, 
                autoUpgrade, enableGpuAcceleration, windowLess, enableHtmlAccess,minimumRuntimeVersion, iFrameStyle);
        }
예제 #12
0
        private static HtmlString CreatePlayerMarkup(IPlayerSettings playerSettings, string playerXapSource,
                                                     string sidewiredXapSource, object containerHtmlAttributes, string xamlThemeSource,
                                                     string scriptableName,  string onErrorCallback, string onLoadedCallback,
                                                     string objectWidthPercentage, string objectHeightPercentage,
                                                     bool autoUpgrade, bool enableGpuAcceleration, bool windowless, bool enableHtmlAccess,
                                                     string minimumRuntimeVersion, string iFrameStyle)
        {
            var imgBuilder = new TagBuilder("img");
            var imgAttributes = new Dictionary<string, string>()
                                    {
                                        {"src", "http://go.microsoft.com/fwlink/?LinkId=161376"},
                                        {"alt", "Get Microsoft Silverlight"},
                                        {"style", "border-style:none"},
                                    };
            imgBuilder.MergeAttributes(imgAttributes);

            var linkBuilder = new TagBuilder("a");
            var linkAttributes = new Dictionary<string, string>()
                                     {
                                         {"href", "http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0"},
                                         {"style", "text-decoration:none"},
                                     };
            linkBuilder.MergeAttributes(linkAttributes);
            linkBuilder.InnerHtml = imgBuilder.ToString(TagRenderMode.Normal);


            var objectBuilder = new TagBuilder("object");
            var objectAttributes = new Dictionary<string, string>()
                                       {
                                           {"data", "data:application/x-silverlight-2,"},
                                           {"type", "application/x-silverlight-2"},
                                           {"width", string.Format("{0}%", objectWidthPercentage)},
                                           {"height", string.Format("{0}%", objectHeightPercentage)},
                                       };
            objectBuilder.MergeAttributes(objectAttributes);

            objectBuilder.InnerHtml = new MvcHtmlString(
                CraftParamTagBuilder("source", playerXapSource).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("minRuntimeVersion", minimumRuntimeVersion).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("onError", onErrorCallback).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("onLoad", onLoadedCallback).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("background", "white").ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("autoUpgrade", autoUpgrade.ToString()).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("EnableGPUAcceleration", enableGpuAcceleration.ToString()).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("Windowless", windowless.ToString()).ToString(TagRenderMode.SelfClosing) +
                CraftParamTagBuilder("EnableHtmlAccess", enableHtmlAccess.ToString()).ToString(TagRenderMode.SelfClosing) +
                (String.IsNullOrWhiteSpace(xamlThemeSource) ?
                CraftParamTagBuilder("InitParams", string.Format("pluginUrl = {0}, scriptableName = {1}, InitialSettings ={2}\n ", sidewiredXapSource, scriptableName , playerSettings.AsXmlSerializedString())) :
                CraftParamTagBuilder("InitParams", string.Format("pluginUrl = {0}, scriptableName = {1}, xamlThemeSource = {2}, InitialSettings ={3}\n ", sidewiredXapSource, scriptableName, xamlThemeSource, playerSettings.AsXmlSerializedString()))
                ).ToString(
                    TagRenderMode.SelfClosing) +
                linkBuilder.ToString(TagRenderMode.Normal)
                ).ToHtmlString();

            var iframeBuilder = new TagBuilder("iframe");
            var iframeAttributes = new Dictionary<string, string>()
                                       {
                                           {"id", "_sl_historyFrame"},
                                           {"style", iFrameStyle},
                                       };
            iframeBuilder.MergeAttributes(iframeAttributes);

            var divBuilder = new TagBuilder("div");
            divBuilder.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(containerHtmlAttributes));
            //divBuilder.InnerHtml = new MvcHtmlString(silverlightObject).ToHtmlString();
            divBuilder.InnerHtml = new MvcHtmlString(
                objectBuilder.ToString(TagRenderMode.Normal) +
                iframeBuilder.ToString(TagRenderMode.Normal)
                ).ToHtmlString();

            return new MvcHtmlString(divBuilder.ToString(TagRenderMode.Normal));
        }
예제 #13
0
 public const float SMOOTHING_FACTOR = 0.8f;     // 1f tries to catch up completely between each tick and is likely to be unstable
 public NetworkPlayer(IPlayerSettings playerSettings, IPhysicsComponent physicsComponent, IWeapons weapons, ITimer timer)
     : base(playerSettings, physicsComponent, null, weapons, timer)
 {
     LastReceivedPosition = this.Position;
 }
예제 #14
0
 // PLAYERSETTINGS:
 public static void Write(this NetBuffer netbuffer, IPlayerSettings settings)
 {
     netbuffer.Write(settings.Color.PackedValue);
     netbuffer.Write(settings.Name);
     netbuffer.Write((ushort)settings.Texture);
 }
예제 #15
0
 public LocalPlayer(IPlayerSettings playerSettings, IPhysicsComponent physicsComponent, IBoundaryCollider boundaryCollider, IWeapons weapons, ITimer timer)
     : base(playerSettings, physicsComponent, boundaryCollider, weapons, timer)
 {
     Console.Write("Creating Local Player");
 }