protected void Page_Load(object sender, EventArgs e)
    {
        // Register chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Insert script references
        ChatHelper.RegisterChatManager(Page);
        ChatHelper.RegisterChatNotificationManager(Page);
        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatNotification_files/ChatNotification.js");

        btnRemoveAllNotifications.OnClientClick = "ChatManager.RemoveAllNotifications(); return false;";
        btnShow.Text  = ResHelper.GetString("chat.notification.bubble.show");
        btnClose.Text = ResHelper.GetString("chat.notification.bubble.close");

        // Prepare and run startup script
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatNotification_" + ClientID, BuildStartupScript(), true);

        imgChatRoomsPrompt.ImageUrl = GetImageUrl("CMSModules/CMS_Chat/message_information24.png");
    }
Пример #2
0
 private void Instance_UserListReceived(object sender, ServerEventArgs e)
 {
     if (e.Message != null)
     {
         messagingControl.UpdateUsers(ChatHelper.Split(e.Message));
     }
 }
Пример #3
0
        public override bool Shoot(Player player, ProjectileSource_Item_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            Vector2 pos = new Vector2((int)player.position.X + Main.rand.Next(-800, 800), (int)player.position.Y + Main.rand.Next(-1000, -250));

            if (!Main.dayTime)
            {
                if (!NPC.downedMechBoss1)
                {
                    Main.dayTime = false;
                    Main.time    = 0;

                    if (Main.netMode == NetmodeID.Server) //sync time
                    {
                        NetMessage.SendData(MessageID.WorldData, -1, -1, null, 0, 0f, 0f, 0f, 0, 0, 0);
                    }
                }

                Projectile.NewProjectile(player.GetProjectileSource_Item(source.Item), pos, Vector2.Zero, ModContent.ProjectileType <SpawnProj>(), 0, 0, Main.myPlayer, NPCID.TheDestroyer);

                if (Main.netMode == NetmodeID.Server)
                {
                    ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("The Destroyer has awoken!"), new Color(175, 75, 255));
                }
                else
                {
                    Main.NewText("The Destroyer has awoken!", new Color(175, 75, 255));
                }
            }

            SoundEngine.PlaySound(SoundID.Roar, player.position, 0);

            return(false);
        }
Пример #4
0
        public override object ExecuteCommand(InCourseRequest inCourseRequest)
        {
            int IdChat = ChatHelper.CrearChat(Nombre, EsGrupo);

            ChatEntity chat = this.context.Chats.Find(IdChat);


            if (chat != null)
            {
                foreach (string idUsuario in Usuarios.Split(','))
                {
                    ChatUsuarioEntity request = new ChatUsuarioEntity()
                    {
                        IdUsuario = short.Parse(idUsuario),
                        Fecha     = DateTime.Now,
                        EsOwner   = false,
                        IdChat    = IdChat
                    };
                    this.AgregarAlContextoParaAlta(request);
                }
                ChatUsuarioEntity owner = new ChatUsuarioEntity()
                {
                    IdUsuario = IdUsuario,
                    Fecha     = DateTime.Now,
                    EsOwner   = EsGrupo,//Si es grupo es el owner, sino, no, por ser chat individual.
                    IdChat    = IdChat
                };
                this.AgregarAlContextoParaAlta(owner);
            }
            ChatHelper.InformarNuevoGrupo(chat, Usuarios, IdUsuario);
            return(null);
        }
Пример #5
0
        public override ActionResponse Handle()
        {
            if (!Main.eclipse)
            {
                Main.SkipToTime(0, true);
                Main.eclipse = true;
                switch (Main.netMode)
                {
                case 0:
                    Main.NewText(Language.GetText("LegacyMisc." + 20).Value, 50, byte.MaxValue, 130);
                    break;

                case 2:
                    ChatHelper.BroadcastChatMessage(Language.GetText("LegacyMisc." + 20).ToNetworkText(), new Color(50, byte.MaxValue, 130));
                    break;
                }
                if (Main.netMode == 2)
                {
                    NetMessage.SendData(7);
                }

                return(ActionResponse.Done);
            }

            TryLater(TimeSpan.FromSeconds(20));
            return(ActionResponse.Retry);
        }
Пример #6
0
    void EditForm_OnBeforeSave(object sender, EventArgs e)
    {
        int chatUserID;

        if (IsEditing)
        {
            chatUserID = TypedEditedObject.ChatRoomUserChatUserID;
        }
        else
        {
            int userID = ValidationHelper.GetInteger(fUserSelector.Value, 0);

            chatUserID = ChatUserHelper.GetChatUserFromCMSUser(UserInfoProvider.GetUserInfo(userID)).ChatUserID;
        }

        AdminLevelEnum adminLevel = ChatHelper.GetEnum(Convert.ToInt32(fdrpAdminLevel.SelectedValue), AdminLevelEnum.None);

        ChatRoomUserHelper.SetChatAdminLevel(ChatRoomID, chatUserID, adminLevel);


        URLHelper.Redirect(string.Format("List.aspx?roomid={0}&saved=1", ChatRoomID));

        // Stop processing, because save was handled manually
        UIFormControl.StopProcessing = true;
    }
Пример #7
0
        /// <summary>
        /// When new client is added
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ClientAdded(object sender, EventArgs e)
        {
            var socket    = ((CustomEventArgs)e).ClientSocket;
            var bytes     = new byte[1024];
            var bytesRead = socket.Receive(bytes);

            var newUserName = Encoding.Unicode.GetString(bytes, 0, bytesRead);

            if (clients.Any(client => client.UserName == newUserName))
            {
                SendNameAlreadyExist(socket, newUserName);
                return;
            }

            var newClient = new ConnectedClient(newUserName, socket);

            clients.Add(newClient);

            OnClientConnected(socket, newUserName);

            foreach (var client in clients)
            {
                SendUsersList(client.Connection, client.UserName, newUserName, ChatHelper.CONNECTED);
            }

            var state = new ChatHelper.StateObject
            {
                WorkSocket = socket
            };

            socket.BeginReceive(state.Buffer, 0, ChatHelper.StateObject.BUFFER_SIZE, 0,
                                OnReceive, state);

            ChatHelper.WriteToEventLog(Log.ClientConnected, EventLogEntryType.Information);
        }
Пример #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Registration to chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Script references insertion
        ChatHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatRoomName_files/ChatRoomName.js");

        // Run script
        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            roomNameTemplate    = ChatHelper.GetWebpartTransformation(ChatRoomNameTransformationName, "chat.error.transformation.namewp.error"),
            contentClientID     = "#" + pnlChatRoomName.ClientID,
            clientID            = ClientID,
            conversationTitle   = ResHelper.GetString("chat.title.privateconversation"),
            groupID             = GroupID,
            displayInitialTitle = DisplayInitialTitle,
            noRoomTitle         = InitialTitle,
            loadingDiv          = ChatHelper.GetWebpartLoadingDiv("ChatRoomNameWPLoading", "chat.wploading.roomname"),
            envelopeID          = "#envelope_" + ClientID
        }
            );
        string startupScript = String.Format("InitChatRoomNameWebpart({0});", json);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatRoomName_" + ClientID, startupScript, true);
    }
Пример #9
0
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            roomID = RoomID,
            chatMessageTemplate = ChatHelper.GetWebpartTransformation(ChatMessageTransformationName, "chat.error.transformation.messages.message"),
            count                = (Count >= 0) ? Count : ChatHelper.FirstLoadMessagesCountSetting,
            contentClientID      = "#" + pnlChatRoomMessages.ClientID,
            displayInline        = DisplayInline,
            groupID              = GroupID,
            clientID             = ClientID,
            direction            = (int)Direction,
            enableBBCode         = (ChatHelper.EnableBBCodeSetting && EnableBBCode),
            loadingDiv           = ChatHelper.GetWebpartLoadingDiv("ChatMessagesWPLoading", "chat.wploading.messages"),
            envelopeID           = "#envelope_" + ClientID,
            pnlInformDialog      = "#" + pnlChatRoomMessagesInfoDialog.ClientID,
            btnInformDialogClose = "#" + btnChatMessageInformDialogClose.ClientID,
            container            = "#" + pnlChatRoomWebpart.ClientID
        }
            );

        return(String.Format("InitChatMessagesWebpart({0});", json));
    }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Insert script references
        ChatHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatLeaveRoom_files/ChatLeaveRoom.js");

        string redirectURL = RedirectURL.Length > 0 ? RedirectURL : ChatHelper.RedirectURLLeaveSetting;

        // Prepare and run startup script
        string startupScript = String.Format("InitChatLeaveRoom({{groupID:{0}, clientID:'{1}', btnChatLeaveRoom:{2},pnlContent:{3}, redirectURL:{4}, envelopeID: '#envelope_{1}' }});",
                                             ScriptHelper.GetString(GroupID),
                                             ClientID,
                                             ScriptHelper.GetString("#" + btnChatLeaveRoom.ClientID),
                                             ScriptHelper.GetString('#' + pnlChatLeaveRoom.ClientID),
                                             redirectURL.Length > 0 ? ScriptHelper.GetString(DocumentURLProvider.GetUrl(redirectURL)) : "\"\""
                                             );

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatLeaveRoom_" + ClientID, startupScript, true);
    }
Пример #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Registration to chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Script references insertion
        ChatHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterJQueryUI(Page);
        ScriptHelper.RegisterScriptFile(Page, "jquery/jquery-a-tools.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/BBCodeParser.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatMessageSend_files/ChatMessageSend.js");

        imgInformationDialog.ImageUrl = GetImageUrl("General/Labels/Information.png");

        RoomID = ChatHelper.GetRoomIdFromQuery(RoomID, GroupID);

        // Register startup script
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatMessageSend_" + ClientID, BuildStartupScript(), true);

        // Set link to documentation and tooltip for canned responses
        lnkCannedRespHelp.NavigateUrl = DocumentationHelper.GetDocumentationTopicUrl(CANNED_RESPONSES_HELP_TOPIC);
        lnkCannedRespHelp.ToolTip     = ResHelper.GetString("chat.cannedresponses.helplabel");
    }
Пример #12
0
        // condition is so that display text is hidden if the kill is done early, BUT the kill is still counted
        // e.g. kill an enemy early, whose spawner is sold in hm, then get into hm, then spawner is unlocked
        // however, text is hidden on that first kill so people don't think it's sold right away
        public static void TryDowned(NPC npc, string seller, Color color, bool conditions, params string[] names)
        {
            bool update = false;

            foreach (string name in names)
            {
                if (!FargoWorld.DownedBools[name])
                {
                    FargoWorld.DownedBools[name] = true;
                    update = true;
                }
            }

            if (update)
            {
                string text = $"A new item has been unlocked in {seller}'s shop!";
                if (Main.netMode == NetmodeID.SinglePlayer)
                {
                    if (conditions)
                    {
                        Main.NewText(text, color);
                    }
                }
                else if (Main.netMode == NetmodeID.Server)
                {
                    if (conditions)
                    {
                        ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(text), color);
                    }
                    NetMessage.SendData(MessageID.WorldData); //sync world
                }
            }
        }
Пример #13
0
        /// <summary>
        /// Menu closing sends "CharacterChanged (SelectedModelHash)" to server
        /// </summary>
        /// <param name="sender"></param>
        protected override void MainMenu_OnMenuClose(UIMenu sender)
        {
            //Destroy cameras, set this _camera to inactive
            Cam.RenderScriptCams(false, true, 0, false, false, 0);
            Cam.SetCamActive(_camera, false);
            Cam.DestroyCam(_camera, false);

            //Enable the players controls again
            RAGE.Elements.Player.LocalPlayer.SetGravity(true);
            Pad.EnableAllControlActions(0);

            //Let server know menu is closed to change if selected a ped to sync.
            RAGE.Events.CallRemote("ClientMenuClosed", SelectedModelHash.ToString(), selectedOutfit);

            PlayerHelper.FreezePlayer(false, false);

            ChatHelper.EnableChat(true);
            UiHelper.EnableHuds();

            _instructionLayer = ScaleformHelper.InstructionalButtons(KeyValuePairs);
            if (_debug)
            {
                Chat.Output("Skin selector Menu closed");
            }
        }
Пример #14
0
        private async Task OnSpawnVehicle(string modelName)
        {
            //TODO: Check if the model is actually a valid model.
            Model vehModel    = new Model(modelName);
            bool  modelLoaded = await vehModel.Request(1000);

            if (!modelLoaded)
            {
                ChatHelper.SendMessage("DevToolbox", $"Failed to load model {modelName}", 255, 0, 0);
                return;
            }

            Player player = new Player(PlayerId());

            Vector3 vehPosition = player.Character.Position;
            float   vehHeading  = player.Character.Heading;

            Vehicle vehToSpawn = await World.CreateVehicle(vehModel, vehPosition, vehHeading);

            Debug.WriteLine(vehToSpawn.Handle.ToString());
            player.Character.SetIntoVehicle(vehToSpawn, VehicleSeat.Driver);

            ChatHelper.SendMessage("DevToolbox", "Successfully spawned vehicle", 0, 255, 0);

            DevToolboxState state = RaceClient.Instance.States.GetState <DevToolboxState>();

            state.CarModel.Unset();
        }
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        int id = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            onlineUserTemplate = ChatHelper.GetWebpartTransformation(OnlineUserTransformationName, "chat.error.transformation.users.onlineuser"),
            chatRoomWindowUrl  = ChatHelper.GetChatRoomWindowURL(Page),
            clientID           = ClientID,
            GUID            = id,
            contentClientID = pnlChatSearchOnlineUsers.ClientID,
            textbox         = txtChatSearchOnlineUsers.ClientID,
            button          = btnChatSearchOnlineUsers.ClientID,
            pnlPaging       = pnlChatSearchOnlineUsersPaging.ClientID,
            pagingEnabled   = PagingEnabled,
            pagingItems     = PagingItems > 0 ? PagingItems : ChatHelper.WPPagingItems,
            groupPagesBy    = GroupPagesBy >= 0 ? GroupPagesBy : ChatHelper.WPGroupPagesBy,
            maxUsers        = ResponseMaxUsers,
            inviteMode      = InviteMode,
            loadingDiv      = ChatHelper.GetWebpartLoadingDiv("ChatSearchOnlineUsersWPLoading", "chat.wploading.searchonlineusers"),
            resStrMoreFound = (ResponseMaxUsers > 0) ? String.Format(ResHelper.GetString("chat.searchonlineusers.morefound"), ResponseMaxUsers) : "",
            resStrNotFound  = ResHelper.GetString("chat.searchonlineusers.notfound"),
            pnlInfo         = pnlChatSearchOnlineUsersInfo.ClientID,
            resStrFound     = ResHelper.GetString("chat.searchonlineusers.results"),
            envelopeID      = "envelope_" + ClientID,
            groupID         = GroupName,
            invitePanel     = pnlChatSearchOnlineUsersInvite.ClientID
        }
            );

        return(String.Format("InitChatSearchOnlineUsersWebpart({0});", json));
    }
Пример #16
0
        public override bool Shoot(Player player, ProjectileSource_Item_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            Vector2 pos = new Vector2((int)player.position.X + Main.rand.Next(-800, 800), (int)player.position.Y + Main.rand.Next(-1000, -250));

            // Vanilla
            Projectile.NewProjectile(player.GetProjectileSource_Item(source.Item), pos, Vector2.Zero, ModContent.ProjectileType <SpawnProj>(), 0, 0, Main.myPlayer, 1, 3);

            // Modded
            for (int i = Main.maxNPCTypes; i < NPCLoader.NPCCount; i++)
            {
                NPC npc = new NPC();
                npc.SetDefaults(i);

                if (npc.boss)
                {
                    SpawnBoss(player, i, npc.TypeName);
                }
            }

            if (Main.netMode == NetmodeID.Server)
            {
                ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral("Every boss has awoken!"), new Color(175, 75, 255));
            }
            else
            {
                Main.NewText("Every boss has awoken!", new Color(175, 75, 255));
            }

            SoundEngine.PlaySound(SoundID.Roar, player.position, 0);

            return(false);
        }
Пример #17
0
 private void HandleChatMessage(ChatMessagePacket packet)
 {
     Player.Level.RelayBroadcast(new ChatMessagePacket()
     {
         Message = ChatHelper.EncodeChatMessage($"<{Player.Username}> {packet.Message}")
     });
 }
Пример #18
0
 protected void Page_Prerender(object sender, EventArgs e)
 {
     if (!StopProcessing)
     {
         ChatHelper.RegisterStylesheet(Page, false);
     }
 }
Пример #19
0
        public static async Task SendChatbotMessage(string name, string sender, string message)
        {
            try
            {
                var hub = GlobalHost.ConnectionManager.GetHubContext <ChatHub>();
                if (hub != null)
                {
                    var botMessage = ChatHelper.FilterTextBot(message);
                    var chatItem   = new ChatMessageData
                    {
                        UserId     = Constant.SYSTEM_USER_CHATBOT.ToString(),
                        Message    = HttpUtility.HtmlEncode($"{name}:{sender}:{botMessage}"),
                        IsEnabled  = true,
                        Timestamp  = DateTime.UtcNow,
                        UserName   = name,
                        ChatHandle = sender,
                        IsBot      = true,
                    };
                    await _cache.AddMessage(chatItem);

                    chatItem.Message = botMessage;
                    await BroadcastMessage(hub, chatItem);
                }
            }
            catch (Exception)
            {
            }
        }
Пример #20
0
    public void Parse_Message_Into_Command_And_Argument(string?message, string botUsername, string?expectedCommand, string?expectedArgument)
    {
        var(command, argument) = ChatHelper.ParseMessageIntoCommandAndArgument(message, botUsername);

        Assert.Equal(expectedCommand, command);
        Assert.Equal(expectedArgument, argument);
    }
Пример #21
0
        public void OnReceive(IAsyncResult ar)
        {
            var state = ar.AsyncState as ChatHelper.StateObject;

            if (state == null)
            {
                return;
            }
            var handler = state.WorkSocket;

            if (!handler.Connected)
            {
                return;
            }
            try
            {
                var bytesRead = handler.EndReceive(ar);
                if (bytesRead <= 0)
                {
                    return;
                }

                ParseRequest(state, handler);
            }

            catch (Exception)
            {
                ChatHelper.WriteToEventLog(Log.TcpClientUnexpected, EventLogEntryType.Error);
                DisconnectClient(handler);
            }
        }
Пример #22
0
            public static void PutBallInCup_Actual(
                Point hitLocation,
                int plr,
                int numberOfHits,
                int projid)
            {
                if (numberOfHits == 0)
                {
                    return;
                }
                Wiring.HitSwitch(hitLocation.X, hitLocation.Y);
                NetMessage.SendData(59, -1, -1, (NetworkText)null, hitLocation.X, (float)hitLocation.Y, 0.0f, 0.0f, 0, 0, 0);
                GolfHelper.ContactListener.EmitGolfballExplosion(hitLocation.ToWorldCoordinates(8f, 0.0f));
                string key = "Game.BallBounceResultGolf_Single";

                if (numberOfHits != 1)
                {
                    key = "Game.BallBounceResultGolf_Plural";
                }
                NetworkText text = NetworkText.FromKey(key, (object)Main.player[plr].name, (object)NetworkText.FromKey(Lang.GetProjectileName(projid).Key), (object)numberOfHits);

                switch (Main.netMode)
                {
                case 0:
                case 1:
                    Main.NewText(text.ToString(), byte.MaxValue, (byte)240, (byte)20);
                    break;

                case 2:
                    ChatHelper.BroadcastChatMessage(text, new Color((int)byte.MaxValue, 240, 20), -1);
                    break;
                }
            }
Пример #23
0
        public JsonResult GetWelcomeText(string enterID)
        {
            List <string> result = new List <string>();

            if (!IsUserAgent())
            {
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            try
            {
                string appServerDb = ConfigurationManager.AppSettings["appServerDb"];
                Uri    uri         = new Uri(string.Format("{0}Db/GetWelcomeWords?enterID={1}&ss={2}&jsoncallback?"
                                                           , appServerDb, enterID, DateTime.Now.Millisecond));

                result = ChatHelper.RemoteRequest <List <string> >(uri);
                List <string> realResult = new List <string>();
                if (result != null && result.Count > 0)
                {
                    result.FindAll(item => !string.IsNullOrEmpty(item))
                    .ForEach(item => { realResult.Add(item.Replace("\r\n", "<br />")); });
                    result = realResult;
                }
                else
                {
                    ChatLog.GetInstance().FormatMessage("Error02:获取欢迎话术未渠道值,方法:ChatController:GetWelcomeText,enterID:{0}", enterID);
                }
            }
            catch (Exception ex)
            {
                ChatLog.GetInstance().LogException(ex);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #24
0
        public ActionResult FileUpload2()
        {
            try
            {
                UploadModel model  = new UploadModel();
                var         result = new { Flag = false, Message = "上传文件失败。" };
                if (this.Request.Files.Count > 0)
                {
                    var file = this.Request.Files[0];

                    if (file.ContentLength > 1024 * 1024 * 2)
                    {
                        model.ReturnFlag = false;
                        model.Message    = "文件不能大于2M!";
                    }
                    else
                    {
                        model = ChatHelper.UploadFile(file, UNCConfig.GetCfg());
                    }
                }
                else
                {
                    model.ReturnFlag = false;
                    model.Message    = "找不到可以上传的文件!";
                }
                string jsonData = JsonConvert.SerializeObject(model);
                ViewData["r"] = jsonData;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(PartialView());
        }
Пример #25
0
        public override bool Shoot(Player player, ProjectileSource_Item_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            Vector2 pos = new Vector2((int)player.position.X + Main.rand.Next(-800, 800), (int)player.position.Y + Main.rand.Next(-800, -250));

            if (NPCType == NPCID.Golem)
            {
                pos = player.Center;
                for (int i = 0; i < 30; i++)
                {
                    pos.Y -= 16;

                    if (pos.Y <= 0 || WorldGen.SolidTile((int)pos.X / 16, (int)pos.Y / 16))
                    {
                        pos.Y += 16;
                        break;
                    }
                }
            }

            Projectile.NewProjectile(player.GetProjectileSource_Item(source.Item), pos, Vector2.Zero, ModContent.ProjectileType <SpawnProj>(), 0, 0, Main.myPlayer, NPCType);

            if (Main.netMode == NetmodeID.Server)
            {
                ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral($"{NPCName} has awoken!"), new Color(175, 75, 255));
            }
            else if (NPCType != NPCID.KingSlime)
            {
                Main.NewText($"{NPCName} has awoken!", new Color(175, 75, 255));
            }

            SoundEngine.PlaySound(SoundID.Roar, player.position, 0);

            return(false);
        }
Пример #26
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (args.Length > 0)
            {
                if (!CommandManager.GetCommand(caller, args[0], out ModCommand mc))
                {
                    throw new UsageException("Unknown command: " + args[0], Color.Red);
                }
                if (mc != null)
                {
                    caller.Reply(mc.Usage);
                    if (!string.IsNullOrEmpty(mc.Description))
                    {
                        caller.Reply(mc.Description);
                    }
                }
                return;
            }

            var help = CommandManager.GetHelp(caller.CommandType);

            caller.Reply(caller.CommandType + " Commands:", Color.Yellow);

            foreach (var entry in help)
            {
                caller.Reply(entry.Item1 + "   " + entry.Item2);
            }

            if (Main.netMode == 1)
            {
                //send the command to the server
                ChatHelper.SendChatMessageFromClient(new ChatMessage(input));
            }
        }
Пример #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Insert script references
        ChatHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterScriptFile(Page, "jquery/jquery-tmpl.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatRooms_files/ChatRooms.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/ListPaging.js");

        if (EnableFiltering)
        {
            pnlChatRoomsFiltering.Visible = true;
        }
        // Prepare and run startup script
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatRooms_" + ClientID, BuildStartupScript(), true);

        imgChatRoomsPrompt.ImageUrl        = GetImageUrl("CMSModules/CMS_Chat/lock24.png");
        imgChatRoomsCreatePrompt.ImageUrl  = GetImageUrl("CMSModules/CMS_Chat/message_add24.png");
        imgChatRoomsCreateError.ImageUrl   = GetImageUrl("CMSModules/CMS_Chat/error16.png");
        imgChatRoomsDeletePrompt.ImageUrl  = GetImageUrl("CMSModules/CMS_Chat/sign_forbidden24.png");
        imgChatRoomsAbandonPrompt.ImageUrl = GetImageUrl("CMSModules/CMS_Chat/sign_forbidden24.png");
        imgChatRoomsEditPrompt.ImageUrl    = GetImageUrl("CMSModules/CMS_Chat/message_edit24.png");
        imgChatRoomsEditError.ImageUrl     = GetImageUrl("CMSModules/CMS_Chat/error16.png");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsVisible)
        {
            pnlChatSearchOnlineUsersWP.Visible = false;
            return;
        }

        // Registration to chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Script references insertion
        ChatHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatSearchOnlineUsers_files/ChatSearchOnlineUsers.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/ListPaging.js");

        if (!PagingEnabled)
        {
            pnlChatSearchOnlineUsersPaging.Visible = false;
        }
        if (InviteMode)
        {
            pnlChatSearchOnlineUsersInvite.Visible = true;
        }

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "SearchOnlineUsers_" + ClientID, BuildStartupScript(), true);
    }
Пример #29
0
        private bool DeserializeAsClient(BinaryReader reader, int senderPlayerId)
        {
            byte messageAuthor = reader.ReadByte();

            ChatHelper.DisplayMessage(NetworkText.Deserialize(reader), reader.ReadRGB(), messageAuthor);
            return(true);
        }
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        int id = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            onlineUserTemplate = ChatHelper.GetWebpartTransformation(OnlineUserTransformationName, "chat.error.transformation.users.onlineuser"),
            chatRoomWindowUrl  = ChatHelper.GetChatRoomWindowURL(),
            clientID           = ClientID,
            GUID                  = id,
            contentClientID       = pnlChatOnlineUsers.ClientID,
            inviteMode            = InviteMode,
            pnlFilterClientID     = pnlChatOnlineUsersFiltering.ClientID,
            pnlPagingClientID     = pnlChatOnlineUsersPaging.ClientID,
            pagingItems           = PagingItems > 0 ? PagingItems : ChatHelper.WPPagingItems,
            pagingEnabled         = EnablePaging,
            btnFilter             = btnChatOnlineUsersFilter.ClientID,
            txtFilter             = txtChatOnlineUsersFilter.ClientID,
            filterEnabled         = EnableFiltering,
            pnlInfo               = pnlChatOnlineUsersInfo.ClientID,
            resStrNoFound         = ResHelper.GetString("chat.onlineusers.notfound"),
            resStrResults         = ResHelper.GetString("chat.onlineusers.results"),
            loadingDiv            = ChatHelper.GetWebpartLoadingDiv("ChatOnlineUsersWPLoading", "chat.wploading.onlineusers"),
            filterCount           = ShowFilterItems >= 0 ? ShowFilterItems : ChatHelper.WPShowFilterLimit,
            envelopeID            = "envelope_" + ClientID,
            resStrNoOneInviteMode = ResHelper.GetString("chat.onlineusers.invitemodenousers"),
            groupID               = GroupName,
            invitePanel           = pnlChatOnlineUsersInvite.ClientID
        }
            );

        return(String.Format("InitChatOnlineUsersWebpart({0});", json));
    }