public override void OnUserLeave(RoomInstance Instance, RoomActor Actor) { if (mSelfActor == null || Actor.Type == RoomActorType.AiBot) { return; } }
/// <summary> /// 刷新用户显示信息 /// </summary> private void ReflashRoomInfo() { int memberNum = 0; // for (int i = 0; i < allMemberShow.Count; i++) { RoomActor info = null; if (DataController.instance.ActorList.ContainsKey(i)) { info = DataController.instance.ActorList[i]; } if (info == null || info.Register == null) { allMemberShow[i].all.SetActive(false); } else { //Debug.LogError(info.GetSendInfo()); memberNum++; allMemberShow[i].all.SetActive(true); allMemberShow[i].txName.text = "" + info.Register.name; //allMemberShow[i].txKill.Show(info.KillCount + ""); } } // txRoomLimet.text = memberNum + "/" + DataController.instance.MyRoomInfo.Limit; }
//private void ShowModelUIName() //{ // foreach (var item in DataController.instance.ActorList) // { // if (item.Key != DataController.instance.MyLocateIndex) // { // memberGroup[item.Value.UniqueID].ShowMyName(item.Value.Register.name); // } // } //} /// <summary> /// 刷新3D模型的显示 /// </summary> private void UpdateRoomActor() { GameObject obj = null; for (int i = 0; i < DataController.instance.MyRoomInfo.Limit; i++) { RoomActor info = DataController.instance.ActorList[i]; if (!memberGroup.ContainsKey(i)) { Debug.Log("初始化其他玩家模型站位:" + i); memberGroup.Add(i, null); } CharacterCommon mControl = memberGroup[i]; if (mControl == null)//初始化生成 { obj = PoolManager.instance.GetPoolObjByType(PreLoadType.Member, transActor); mControl = obj.GetComponent <CharacterCommon>(); memberGroup[i] = mControl; } if (DataController.instance.ActorList[i] == null)//该位置玩家退出或不存在 { mControl.gameObject.SetActive(false); } else { mControl.gameObject.SetActive(true); mControl.Init(info.UniqueID); mControl.ShowTeam(DataController.instance.ActorList[i].MyTeam); } } }
private static bool HandleSwitch(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode) { if (Event != ItemEventType.Interact) { return(true); } RoomActor actor = Instance.GetActor(Session.CharacterId); if (actor == null) { return(true); } foreach (Item item in Instance.GetFloorItems()) { if (item.Definition.Behavior != ItemBehavior.WiredTrigger || WiredTypesUtil.TriggerFromInt(item.Definition.BehaviorData) != WiredTriggerTypes.state_changed) { continue; } String[] Selected = item.WiredData.Data1.Split('|'); if (Selected.Contains(Item.Id.ToString())) { Instance.WiredManager.ExecuteActions(item, actor); } } return(true); }
private static void SubmitAnswer(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId); if (Actor == null) { return; } int AnswerId = Message.PopWiredInt32(); lock (mInfobusQuestions) { if (mInfobusQuestions.ContainsKey(Instance.RoomId)) { mInfobusQuestions[Instance.RoomId].SubmitAnswer(Actor.Id, AnswerId); } } }
public void Run(Client client, MessageEvent msg) { int x = msg.ReadVL64(); int y = msg.ReadVL64(); if (client.CurrentRoomId == 0) { return; } if (!Engine.Locator.RoomController.Rooms.TryGetValue(client.CurrentRoomId, out Room room)) { return; } RoomActor actor = client.UserActor; if (x == room.Map.DoorX && y == room.Map.DoorY) { actor.QuitRoom = true; } if (actor.Position.X == x && actor.Position.Y == y) { return; } actor.TargetPoint.X = x; actor.TargetPoint.Y = y; actor.CalcPath = true; }
public override void OnUserChat(RoomInstance Instance, RoomActor Actor, string MessageText, bool Shout) { if (mSelfActor == null || Actor.Type == RoomActorType.AiBot || mServingItemId > 0 || (Distance.Calculate(Actor.Position.GetVector2(), mSelfActor.Position.GetVector2()) > mSelfBot.ResponseDistance)) { return; } BotResponse Response = mSelfBot.GetResponseForMessage(MessageText); if (Response != null) { mSelfActor.Chat(Response.GetResponse(), false); if (Response.ResponseServeId > 0) { mMovingToServePos = true; mServingItemId = Response.ResponseServeId; mServingActorId = Actor.Id; mActorServePos = new Vector2(mSelfActor.Position.X, mSelfActor.Position.Y); mSelfActor.MoveTo(mSelfBot.ServePosition); if (mNextMovementAttempt < 50) { mNextMovementAttempt = 50; } } if (mNextSpeechAttempt < 50) { mNextSpeechAttempt += 10; } } }
public void SendInfoUpdate() { if (!Authenticated) { return; } SendData(UserInfoUpdateComposer.Compose(0, mCharacterInfo.Figure, mCharacterInfo.Gender, mCharacterInfo.Motto, mCharacterInfo.Score)); if (InRoom) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(CurrentRoomId); if (Instance == null) { return; } RoomActor Actor = Instance.GetActorByReferenceId(CharacterId); if (Actor == null) { return; } Instance.BroadcastMessage(UserInfoUpdateComposer.Compose(Actor.Id, mCharacterInfo.Figure, mCharacterInfo.Gender, mCharacterInfo.Motto, mCharacterInfo.Score)); } }
public int GetHolderId(RoomActor roomData) { //确定庄家位置 var grabSeats = roomData.GetGrabSeatDatas(); var seats = roomData.GetInGameSeatDatas(); int holderId = 0; int random = 0; if (grabSeats.Count == 0) { if (seats.Count == 0) { return(10000); } random = RandomUtils.GetRandom(0, seats.Count); holderId = seats[random].UserId; } else { random = RandomUtils.GetRandom(0, grabSeats.Count); holderId = grabSeats[random].UserId; } return(holderId); }
private static void ApplyEffect(Session Session, ClientMessage Message) { int EffectSpriteId = Message.PopWiredInt32(); if (EffectSpriteId < 0) { EffectSpriteId = 0; } RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId); if (Actor == null || (EffectSpriteId != 0 && !Session.AvatarEffectCache.HasEffect(EffectSpriteId, true))) { return; } Actor.ApplyEffect(EffectSpriteId); Session.CurrentEffect = EffectSpriteId; }
public void ClearOffLine(RoomActor actor) { lock (OffLineRooms) { int removeCount = 0; OffLineRooms.TryRemove(actor.Register.userID, out removeCount); } }
private async Task SendCurrentOppoThrow(RoomActor roomActor, ThrowResult throwResult) { foreach (var otherAU in roomActor.Room.RoomUsers .Where(ru => ru != roomActor).Select(ru => ru.ActiveUser)) { await _masterHub.SendOrderedAsync(otherAU, "CurrentOppoThrow", throwResult); } }
public override void OnSelfLeaveRoom(RoomInstance Instance) { if (mSelfActor == null) { return; } mSelfActor = null; }
private static bool HandleScoreboard(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode) { switch (Event) { case ItemEventType.Interact: if (!Instance.CheckUserRights(Session)) { break; } RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId); if (Actor == null) { break; } if (!Distance.TilesTouching(Actor.Position.GetVector2(), Item.RoomPosition.GetVector2())) { Actor.MoveToItemAndInteract(Item, RequestData, Opcode); break; } int Val = 0; int.TryParse(Item.DisplayFlags, out Val); if (RequestData == 1) { Val--; if (Val < 0) { Val = 99; } } else if (RequestData == 2) { Val++; if (Val > 99) { Val = 0; } } else { Val = (Val == -1 ? 0 : -1); } Item.DisplayFlags = Val.ToString(); Item.BroadcastStateUpdate(Instance); break; } return(true); }
public override void OnSelfLeaveRoom(RoomInstance Instance) { if (mSelfActor == null) { return; } //mSelfActor.Chat("*leaves*", false); mSelfActor = null; }
/// <summary> /// This should be called whenever a new room in our game is loaded /// </summary> /// <param name="RoomThatWasLoaded"></param> public void OnRoomLoaded(RoomActor RoomThatWasLoaded) { RoomActor CurrentRoom = BaseGameOverseer.Instance.CurrentlyLoadedRoom; if (CurrentRoom) { CachedRoomBounds.MaxBounds = BaseGameOverseer.Instance.CurrentlyLoadedRoom.GetMaxRoomBounds(); CachedRoomBounds.MinBounds = BaseGameOverseer.Instance.CurrentlyLoadedRoom.GetMinRoomBounds(); bHasCachedRoomBounds = true; } }
private static void TradeComplete(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } Trade Trade = Instance.TradeManager.GetTradeForUser(Session.CharacterId); if (Trade == null) { return; } Session TargetSession = SessionManager.GetSessionByCharacterId(Trade.UserOne == Session.CharacterId ? Trade.UserTwo : Trade.UserOne); if (TargetSession == null || !Trade.AcceptTrade(Trade.UserOne == Session.CharacterId)) { return; } if (Trade.TradeStage == TradeStage.Finalized) { Session User1 = (TargetSession.CharacterId == Trade.UserOne ? TargetSession : Session); Session User2 = (TargetSession.CharacterId == Trade.UserTwo ? TargetSession : Session); Trade.DeliverItems(User1, User2); Session.SendData(TradeFinalizedComposer.Compose()); TargetSession.SendData(TradeFinalizedComposer.Compose()); Instance.TradeManager.StopTradeForUser(Session.CharacterId); Instance.TradeManager.StopTradeForUser(TargetSession.CharacterId); RoomActor Actor1 = Instance.GetActorByReferenceId(Session.CharacterId); RoomActor Actor2 = Instance.GetActorByReferenceId(TargetSession.CharacterId); if (Actor1 != null) { Actor1.RemoveStatus("trd"); Actor1.UpdateNeeded = true; } if (Actor2 != null) { Actor2.RemoveStatus("trd"); Actor2.UpdateNeeded = true; } } }
private void Generate(RoomActor actor) { TeamType team = actor.MyTeam; GameObject obj = Common.Generate(loadPrefab, team == TeamType.Blue ? transTeamBlue : transTeamRed); PrefabLoad info = obj.GetComponent <PrefabLoad>(); info.Init(actor); if (!allLoad.ContainsKey(actor.UniqueID)) { allLoad.Add(actor.UniqueID, info); } }
public override void OnUserEnter(RoomInstance Instance, RoomActor Actor) { if (mSelfActor == null || Actor.Type == RoomActorType.AiBot) { return; } if (mSelfBot.Effect > 0) { mSelfActor.ApplyEffect(mSelfBot.Effect); } }
/// <summary> /// Function should be called from the awake function of room's actor /// </summary> /// <param name="RoomThatWasLoaded"></param> public void OnRoomWasLoaded(RoomActor RoomThatWasLoaded) { if (CurrentlyLoadedRoom == RoomThatWasLoaded) { return; } CurrentlyLoadedRoom = RoomThatWasLoaded; if (MainGameCamera) { MainGameCamera.OnRoomLoaded(CurrentlyLoadedRoom); } }
public override void OnUserEnter(RoomInstance Instance, RoomActor Actor) { if (mSelfActor == null || Actor.ReferenceId != mSelfBot.PetData.OwnerId || Actor.Type != RoomActorType.UserCharacter || (mCurrentAction != PetBotAction.Idle && mCurrentAction != PetBotAction.Roaming)) { return; } if (RandomGenerator.GetNext(0, 1) == 1) { RespondToEvent("SEE_OWNER"); } }
public override void OnSelfEnterRoom(RoomInstance Instance) { mSelfActor = Instance.GetActorByReferenceId(mSelfBot.Id, RoomActorType.AiBot); if (mSelfActor == null) { return; } mCurrentAction = PetBotAction.Idle; mActionStartedTimestamp = UnixTimestamp.GetCurrent(); mGstTimestamp = UnixTimestamp.GetCurrent(); RespondToEvent("SEE_OWNER"); }
private void UpdateUserStatus(RoomActor actor, List <Item> items) { if (items.Count > 0) { Item highestItem = items[items.Count - 1]; highestItem.ActorOnItem = actor; if (highestItem.Definition.ItemType == "seat") { if (!actor.Statusses.ContainsKey("sit")) { actor.Statusses.Add("sit", "1.00"); } actor.Rotation = highestItem.Rotation; } } }
public int GetHolderId(RoomActor roomData) { //确定庄家位置 var cardDatas = roomData.Seats.Where(m => m.InGame).Select(m => new { UserId = m.UserId, CardSize = PokerManager.GetCardSize(m.CardDataBefore, roomData) }).ToList(); cardDatas = cardDatas.Where(m => m.CardSize / 1000 >= 10 && m.CardSize / 1000 <= 12).ToList(); if (cardDatas.Count > 0) { cardDatas.Sort((x, y) => y.CardSize - x.CardSize); return(cardDatas[0].UserId); } return(roomData.HolderId); }
public static List <Point2D> GetPath(Room room, Point2D start, Point2D end, RoomActor actor) { List <Point2D> steps = new List <Point2D>(); var path = FindReversePath(room, start, end, actor); Node current = path; while (current != null) { steps.Add(new Point2D(current.X, current.Y)); current = current.Next; } return(steps); }
public void HandleExpiration(Session Session) { lock (mSyncRoot) { mQuantity--; mActivated = false; mTimestampActivated = 0; using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("id", mId); if (mQuantity < 1) { MySqlClient.ExecuteNonQuery("DELETE FROM avatar_effects WHERE id = @id LIMIT 1"); } else { MySqlClient.SetParameter("quantity", mQuantity); MySqlClient.ExecuteNonQuery("UPDATE avatar_effects SET quantity = @quantity, activated = '0', timestamp_activated = 0 WHERE id = @id LIMIT 1"); } } Session.SendData(UserEffectRemovedComposer.Compose(this)); RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId); if (Actor == null) { return; } if (Actor.AvatarEffectId == mSpriteId) { Actor.ApplyEffect(0); Session.CurrentEffect = 0; } } }
protected override void OnPersist(IEvent persistedEvent) { switch (persistedEvent) { case CreatedRoom room: { var rm = room.Room; if (Context.Child(rm.Tag).IsNobody()) { var roomActor = Context.ActorOf(RoomActor.Prop(new RoomHandler(), new RoomState(rm.RoomId, rm.Tag), rm.Tag, _connectionString), rm.Tag); //roomActor.Tell(new InstallSensor()); } } break; } base.OnPersist(persistedEvent); }
private void SerializeActor(RoomActor actor) { AppendVL64(actor.Client.Player.Id); AppendString(actor.Client.Player.Username); AppendString(actor.Client.Player.Motto); AppendString(actor.Client.Player.Figure); AppendVL64(actor.VirtualId); AppendVL64(actor.Position.X); AppendVL64(actor.Position.Y); AppendString(actor.Position.Z.ToString()); AppendVL64(actor.Rotation); AppendVL64(1); // TODO: BOTs, PETs etc. AppendString(actor.Client.Player.Gender); AppendVL64(5); AppendVL64(-1); AppendVL64(-1); AppendString(""); // pool figure }
public int GetHolderId(RoomActor roomData) { var user = roomData.GetUser(roomData.CreateUserId); if (user == null) { throw new Exception("GameStaticHolder-GetHolderId用户信息为空"); } var holderSeat = roomData.GetSeatData(user.UserId); if (holderSeat == null) { throw new Exception("GameStaticHolder-GetHolderId房主没有玩游戏"); } return(roomData.CreateUserId); }
public override void OnUserChat(RoomInstance Instance, RoomActor Actor, string MessageText, bool Shout) { string Message = MessageText.ToLower().Trim(); string PetName = mSelfBot.PetData.Name.ToLower(); if (mSelfActor == null || mSelfBot.PetData.OwnerId != Actor.ReferenceId || Actor.Type != RoomActorType.UserCharacter || !Message.StartsWith(PetName + " ") || Message.Length <= PetName.Length) { return; } if (mSelfBot.PetData.Energy < 20) { mSelfActor.SetStatus("gst", "hng"); RespondToEvent("TIRED"); return; } if (mSelfBot.PetData.Happiness < 20) { mSelfActor.SetStatus("gst", "sad"); RespondToEvent("UNHAPPY"); return; } int SkipLength = PetName.Length + 1; string Command = MessageText.Substring(SkipLength, MessageText.Length - SkipLength).ToLower().Trim(); switch (Command) { case "free": mSelfActor.ClearStatusses(); mSelfActor.Chat("All statusses cleared"); break; default: mSelfActor.SetStatus(Command.ToLower()); mSelfActor.Chat("Effect applied: " + Command.ToLower()); mSelfActor.UpdateNeeded = true; break; } }