Exemplo n.º 1
0
        internal static void HandleSave(uint itemID, Room room, ClientMessage clientMessage)
        {
            RoomItem item = room.GetRoomItemHandler().GetItem(itemID);
            if (item == null)
                return;

            if (item.wiredHandler != null)
            {
                item.wiredHandler.Dispose();
                item.wiredHandler = null;
            }

            InteractionType type = item.GetBaseItem().InteractionType;
            switch (type)
            {
                case InteractionType.actiongivescore:
                    {
                        clientMessage.ReadInt();

                        int points = clientMessage.ReadInt();
                        int games = clientMessage.ReadInt();

                        IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), item, room.GetWiredHandler());
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.actionmoverotate:
                    {
                        //clientMessage.AdvancePointer(1);
                        clientMessage.ReadInt();
                        MovementState movement = (MovementState)clientMessage.ReadInt();
                        RotationState rotation = (RotationState)clientMessage.ReadInt();

                        clientMessage.ReadString();
                        //clientMessage.ReadInt();
                        //clientMessage.ReadInt();
                        //clientMessage.AdvancePointer(2);

                        List<RoomItem> items = GetItems(clientMessage, room);
                        int delay = clientMessage.ReadInt();

                        IWiredTrigger action = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.actionposreset:
                    {

                        clientMessage.ReadInt();
                        clientMessage.ReadString();

                        List<RoomItem> items = GetItems(clientMessage, room);
                        int delay = clientMessage.ReadInt();

                        IWiredTrigger action = new PositionReset(items, delay, room.GetRoomItemHandler(), room.GetWiredHandler(), item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.actionresettimer:
                    {
                        clientMessage.ReadInt();
                        clientMessage.ReadString();

                        List<RoomItem> items = GetItems(clientMessage, room);
                        int delay = clientMessage.ReadInt();


                        IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), items, delay, item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.actionshowmessage:
                    {
                        clientMessage.ReadInt();
                        string message = clientMessage.ReadString();

                        IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.actionkick:
                    {
                        clientMessage.ReadInt();
                        string message = clientMessage.ReadString();

                        IWiredTrigger action = new Kick(message, room.GetWiredHandler(), item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.actionteleportto:
                    {
                        clientMessage.ReadInt();
                        clientMessage.ReadString();
                        List<RoomItem> items = GetItems(clientMessage, room);
                        int delay = clientMessage.ReadInt();

                        IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.actiontogglestate:
                    {
                        clientMessage.ReadInt();
                        clientMessage.ReadString();

                        List<RoomItem> items = GetItems(clientMessage, room);
                        int delay = clientMessage.ReadInt();

                        IWiredTrigger action = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), items, delay, item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.specialrandom:
                    {

                        break;
                    }

                case InteractionType.specialunseen:
                    {

                        break;
                    }

                case InteractionType.triggergameend:
                    {
                        IWiredTrigger handler = new GameEnds(item, room.GetWiredHandler(), room.GetGameManager());
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggergamestart:
                    {
                        IWiredTrigger handler = new GameStarts(item, room.GetWiredHandler(), room.GetGameManager());
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggeronusersay:
                    {
                        clientMessage.ReadInt();
                        bool isOnlyOwner = clientMessage.ReadInt() == 1;
                        //clientMessage.AdvancePointer(0);
                        string message = clientMessage.ReadString();
                        //string stuff = clientMessage.ToString();

                        IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), isOnlyOwner, message, room);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.triggerrepeater:
                    {
                        clientMessage.ReadInt();
                        int cycleTimes = clientMessage.ReadInt();

                        IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.triggerroomenter:
                    {
                        clientMessage.ReadInt();
                        string users = clientMessage.ReadString();

                        IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(users), users);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggerscoreachieved:
                    {
                        clientMessage.ReadInt();
                        int score = clientMessage.ReadInt();

                        IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.triggertimer:
                    {
                        clientMessage.ReadInt();
                        int cycles = clientMessage.ReadInt();

                        IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager());
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.triggerstatechanged:
                    {
                        clientMessage.ReadInt();
                        clientMessage.ReadString();

                        List<RoomItem> items = GetItems(clientMessage, room);
                        int delay = clientMessage.ReadInt();

                        IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, items, delay);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.triggerwalkofffurni:
                    {
                        clientMessage.ReadInt();
                        clientMessage.ReadString();

                        List<RoomItem> items = GetItems(clientMessage, room);

                        int delay = clientMessage.ReadInt();

                        IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), items, delay);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggerwalkonfurni:
                    {
                        clientMessage.ReadInt();
                        clientMessage.ReadString();

                        List<RoomItem> items = GetItems(clientMessage, room);

                        int delay = clientMessage.ReadInt();

                        IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items, delay);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                        break;
                    }
            }
        }
Exemplo n.º 2
0
        internal static void LoadWiredItem(RoomItem item, Room room, IQueryAdapter dbClient)
        {
            InteractionType type = item.GetBaseItem().InteractionType;
            WiredLoaderObject wiredData = WiredLoaderObject.LoadItem(item, room, dbClient);
            
            switch (type)
            {
                case InteractionType.actiongivescore:
                    {
                        IWiredTrigger action = new GiveScore(0, 0, room.GetGameManager(), item, room.GetWiredHandler());
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionmoverotate:
                    {
                        IWiredTrigger action = new MoveRotate(MovementState.none, RotationState.none,new List<RoomItem>(), 0, room, room.GetWiredHandler(), item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionposreset:
                    {
                        IWiredTrigger action = new PositionReset(new List<RoomItem>(), 0, room.GetRoomItemHandler(), room.GetWiredHandler(), item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionresettimer:
                    {
                        IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), new List<RoomItem>(), 0, item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionshowmessage:
                    {
                        IWiredTrigger action = new ShowMessage(string.Empty, room.GetWiredHandler(), item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionteleportto:
                    {
                        IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), new List<RoomItem>(), 0, item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actiontogglestate:
                    {
                        IWiredTrigger action = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), new List<RoomItem>(), 0, item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionkick:
                    {
                        IWiredTrigger action = new Kick(string.Empty, room.GetWiredHandler(), item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.conditionfurnishaveusers:
                    {
                        IWiredCondition furniHasUsers = new FurniHasUser(item, new List<RoomItem>(), room.GetWiredHandler());
                        furniHasUsers.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(furniHasUsers, item);
                        break;
                    }

                case InteractionType.conditionhasfurnionfurni:
                    {
                        IWiredCondition furniHasUsers = new FurniHasFurni(item, new List<RoomItem>(), room.GetWiredHandler(), false);
                        furniHasUsers.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(furniHasUsers, item);
                        break;
                    }
                case InteractionType.conditionstatepos:
                    {
                        IWiredCondition furnistatepos = new FurniStatePosMatch(item, new List<RoomItem>(), room.GetWiredHandler(),false,false,false);
                        furnistatepos.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(furnistatepos, item);
                        break;
                    }

                case InteractionType.conditiontimelessthan:
                    {
                        IWiredCondition timeLessThan = new LessThanTimer(0, room, item, room.GetWiredHandler());
                        timeLessThan.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(timeLessThan, item);
                        break;
                    }

                case InteractionType.conditiontimemorethan:
                    {
                        IWiredCondition timeMoreThan = new MoreThanTimer(0, room, item, room.GetWiredHandler());
                        timeMoreThan.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(timeMoreThan, item);
                        break;
                    }

                case InteractionType.conditiontriggeronfurni:
                    {
                        IWiredCondition triggerOnFurni = new TriggerUserIsOnFurni(item, new List<RoomItem>(), room.GetWiredHandler());
                        triggerOnFurni.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(triggerOnFurni, item);
                        break;
                    }

                case InteractionType.specialrandom:
                    {

                        break;
                    }

                case InteractionType.specialunseen:
                    {

                        break;
                    }

                case InteractionType.triggergameend:
                    {
                        IWiredTrigger handler = new GameEnds(item, room.GetWiredHandler(), room.GetGameManager());
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggergamestart:
                    {
                        IWiredTrigger handler = new GameStarts(item, room.GetWiredHandler(), room.GetGameManager());
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggeronusersay:
                    {
                        IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), false, string.Empty, room);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerrepeater:
                    {
                        IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, 0);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerroomenter:
                    {
                        IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), false, string.Empty);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerscoreachieved:
                    {
                        IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), 0, room.GetGameManager());
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggertimer:
                    {
                        IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), 0, room.GetGameManager());
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerstatechanged:
                    {
                        IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, new List<RoomItem>(), 0);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerwalkofffurni:
                    {
                        IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), new List<RoomItem>(), 0);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerwalkonfurni:
                    {
                        IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), new List<RoomItem>(), 0);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }
            }

        }
Exemplo n.º 3
0
        internal static void HandleDefaultSave(uint itemID, Room room)
        {
            RoomItem item = room.GetRoomItemHandler().GetItem(itemID);
            if (item == null)
                return;

            InteractionType type = item.GetBaseItem().InteractionType;
            switch (type)
            {
                case InteractionType.actiongivescore:
                    {
                        int points = 0;
                        int games = 0;

                        IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), item, room.GetWiredHandler());
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.actionmoverotate:
                    {
                        MovementState movement = MovementState.none;
                        RotationState rotation = RotationState.none;

                        List<RoomItem> items = new List<RoomItem>();
                        int delay = 0;

                        IWiredTrigger action = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.actionposreset:
                    {
                        List<RoomItem> items = new List<RoomItem>();
                        int delay = 0;

                        IWiredTrigger action = new PositionReset(items, delay, room.GetRoomItemHandler(), room.GetWiredHandler(), item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.actionresettimer:
                    {
                        List<RoomItem> items = new List<RoomItem>();
                        int delay = 0;

                        IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), items, delay, item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.actionshowmessage:
                    {
                        string message = string.Empty;

                        IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.actionteleportto:
                    {
                        List<RoomItem> items = new List<RoomItem>();
                        int delay = 0;

                        IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.actiontogglestate:
                    {
                        List<RoomItem> items = new List<RoomItem>();
                        int delay = 0;

                        IWiredTrigger action = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), items, delay, item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.actionkick:
                    {
                        string message = string.Empty;

                        IWiredTrigger action = new Kick(message, room.GetWiredHandler(), item);
                        HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.conditionfurnishaveusers:
                    {

                        break;
                    }

                case InteractionType.conditionstatepos:
                    {

                        break;
                    }

                case InteractionType.conditiontimelessthan:
                    {

                        break;
                    }

                case InteractionType.conditiontimemorethan:
                    {

                        break;
                    }

                case InteractionType.conditiontriggeronfurni:
                    {

                        break;
                    }

                case InteractionType.specialrandom:
                    {

                        break;
                    }

                case InteractionType.specialunseen:
                    {

                        break;
                    }

                case InteractionType.triggergameend:
                    {
                        IWiredTrigger handler = new GameEnds(item, room.GetWiredHandler(), room.GetGameManager());
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggergamestart:
                    {
                        IWiredTrigger handler = new GameStarts(item, room.GetWiredHandler(), room.GetGameManager());
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggeronusersay:
                    {
                        bool isOnlyOwner = false;
                        string message = string.Empty;

                        IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), !isOnlyOwner, message, room);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggerrepeater:
                    {
                        int cycleTimes = 0;

                        IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggerroomenter:
                    {
                        string users = string.Empty;

                        IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(users), users);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggerscoreachieved:
                    {
                        int score = 0;

                        IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggertimer:
                    {
                        int cycles = 0;

                        IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager());
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                        break;
                    }

                case InteractionType.triggerstatechanged:
                    {
                        List<RoomItem> items = new List<RoomItem>();
                        int delay = 0;

                        IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, items, delay);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.triggerwalkofffurni:
                    {
                        List<RoomItem> items = new List<RoomItem>();

                        int delay = 0;

                        IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), items, delay);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                        break;
                    }

                case InteractionType.triggerwalkonfurni:
                    {
                        List<RoomItem> items = new List<RoomItem>();

                        int delay = 0;

                        IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items, delay);
                        HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                        break;
                    }
            }
        }