Пример #1
0
        public void HandleActionUseOnTarget(Player player, WorldObject target)
        {
            ActionChain chain = new ActionChain();

            var keyCode = GetProperty(PropertyString.KeyCode);

            chain.AddAction(player, () =>
            {
                if (target.WeenieType == WeenieType.Door)
                {
                    var door = (Door)target;

                    Door.UnlockDoorResults results = door.UnlockDoor(keyCode);

                    switch (results)
                    {
                    case Door.UnlockDoorResults.UnlockSuccess:
                        Structure--;
                        if (Structure < 1)
                        {
                            player.TryRemoveItemFromInventoryWithNetworking(this, 1);
                        }

                        player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session));
                        player.Session.Network.EnqueueSend(new GameMessagePublicUpdatePropertyInt(this, PropertyInt.Structure, (int)Structure));
                        break;

                    case Door.UnlockDoorResults.DoorOpen:
                        player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session, WeenieError.YouCannotLockWhatIsOpen));
                        break;

                    case Door.UnlockDoorResults.AlreadyUnlocked:
                        player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session, WeenieError.LockAlreadyUnlocked));
                        break;

                    default:
                        player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session, WeenieError.KeyDoesntFitThisLock));
                        break;
                    }
                }
                else if (target.WeenieType == WeenieType.Chest)
                {
                    var message = new GameMessageSystemChat($"Unlocking {target.Name} has not been implemented, yet!", ChatMessageType.System);
                    player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session), message);
                }
                else
                {
                    player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session, WeenieError.YouCannotLockOrUnlockThat));
                }
            });

            chain.EnqueueChain();
        }
Пример #2
0
Файл: Key.cs Проект: dworkin/ACE
        public void HandleActionUseOnTarget(Player player, WorldObject target)
        {
            ActionChain chain = new ActionChain();

            chain.AddAction(player, () =>
            {
                if (player == null)
                {
                    return;
                }

                if (!player.IsWithinUseRadiusOf(target))
                {
                    player.DoMoveTo(target);
                }
                else
                {
                    var sendUseDoneEvent = new GameEventUseDone(player.Session);
                    if (target.WeenieType == WeenieType.Door)
                    {
                        Door door = target as Door;
                        Door.UnlockDoorResults results = door.UnlockDoor(KeyCode);
                        switch (results)
                        {
                        case Entity.Door.UnlockDoorResults.UnlockSuccess:
                            Structure--;
                            if (Structure < 1)
                            {
                                // Remove item from players
                                player.DestroyInventoryItem(this);
                                // Clean up the shard database.
                                DatabaseManager.Shard.DeleteObject(SnapShotOfAceObject(), null);
                            }
                            player.Session.Network.EnqueueSend(sendUseDoneEvent);
                            player.Session.Network.EnqueueSend(new GameMessagePublicUpdatePropertyInt(this.Sequences, Guid, PropertyInt.Structure, (uint)Structure));
                            break;

                        case Entity.Door.UnlockDoorResults.DoorOpen:
                            var messageDoorOpen = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_0481);     // TODO: Messages are not quiet right. Need to find right one.
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageDoorOpen);
                            break;

                        case Entity.Door.UnlockDoorResults.AlreadyUnlocked:
                            var messageAlreadyUnlocked = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04B2);     // TODO: Messages are not quiet right. Need to find right one.
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageAlreadyUnlocked);
                            break;

                        default:
                            var messageIncorrectKey = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04B2);
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageIncorrectKey);
                            break;
                        }
                    }
                    else if (target.WeenieType == WeenieType.Chest)
                    {
                        var message = new GameMessageSystemChat($"Unlocking {target.Name} has not been implemented, yet!", ChatMessageType.System);
                        player.Session.Network.EnqueueSend(sendUseDoneEvent, message);
                    }
                    else
                    {
                        var message = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_0480);
                        player.Session.Network.EnqueueSend(sendUseDoneEvent, message);
                    }
                }
            });
            chain.EnqueueChain();
        }
Пример #3
0
        public void HandleActionUseOnTarget(Player player, WorldObject target)
        {
            ActionChain chain = new ActionChain();

            var keyCode = GetProperty(PropertyString.KeyCode);

            chain.AddAction(player, () =>
            {
                if (player == null)
                {
                    return;
                }

                if (!player.IsWithinUseRadiusOf(target))
                {
                    player.DoMoveTo(target);
                }
                else
                {
                    var sendUseDoneEvent = new GameEventUseDone(player.Session);

                    if (target.WeenieType == WeenieType.Door)
                    {
                        Door door = target as Door;

                        Door.UnlockDoorResults results = door.UnlockDoor(keyCode);

                        switch (results)
                        {
                        case WorldObjects.Door.UnlockDoorResults.UnlockSuccess:
                            Structure--;
                            if (Structure < 1)
                            {
                                player.RemoveItemFromInventory(Guid.Full, player.Guid.Full, 1);
                            }

                            player.Session.Network.EnqueueSend(sendUseDoneEvent);
                            player.Session.Network.EnqueueSend(new GameMessagePublicUpdatePropertyInt(Sequences, Guid, PropertyInt.Structure, (int)Structure));
                            break;

                        case WorldObjects.Door.UnlockDoorResults.DoorOpen:
                            var messageDoorOpen = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.YouCannotLockWhatIsOpen);     // TODO: Messages are not quiet right. Need to find right one.
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageDoorOpen);
                            break;

                        case WorldObjects.Door.UnlockDoorResults.AlreadyUnlocked:
                            var messageAlreadyUnlocked = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.KeyDoesntFitThisLock);     // TODO: Messages are not quiet right. Need to find right one.
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageAlreadyUnlocked);
                            break;

                        default:
                            var messageIncorrectKey = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.KeyDoesntFitThisLock);
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageIncorrectKey);
                            break;
                        }
                    }
                    else if (target.WeenieType == WeenieType.Chest)
                    {
                        var message = new GameMessageSystemChat($"Unlocking {target.Name} has not been implemented, yet!", ChatMessageType.System);
                        player.Session.Network.EnqueueSend(sendUseDoneEvent, message);
                    }
                    else
                    {
                        var message = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.YouCannotLockOrUnlockThat);
                        player.Session.Network.EnqueueSend(sendUseDoneEvent, message);
                    }
                }
            });

            chain.EnqueueChain();
        }
Пример #4
0
        public void HandleActionUseOnTarget(Player player, WorldObject target)
        {
            ActionChain chain = new ActionChain();


            chain.AddAction(player, () =>
            {
                if (target.WeenieType == WeenieType.Door)
                {
                    var door = (Door)target;

                    if (player.Skills[Skill.Lockpick].Status != SkillStatus.Trained && player.Skills[Skill.Lockpick].Status != SkillStatus.Specialized)
                    {
                        player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session, WeenieError.YouArentTrainedInLockpicking));
                        return;
                    }

                    void consume(Player plr, Lockpick lp)
                    {
                        lp.Structure--;
                        if (lp.Structure < 1)
                        {
                            plr.TryRemoveItemFromInventoryWithNetworking(this, 1);
                        }
                        plr.Session.Network.EnqueueSend(new GameEventUseDone(plr.Session));
                        plr.Session.Network.EnqueueSend(new GameMessagePublicUpdatePropertyInt(lp, PropertyInt.Structure, (int)lp.Structure));
                        plr.Session.Network.EnqueueSend(new GameMessageSystemChat($"Uses reamaining: {Structure}", ChatMessageType.System));
                    }

                    Door.UnlockDoorResults results = door.UnlockDoor(player.Skills[Skill.Lockpick].Current);
                    switch (results)
                    {
                    case Door.UnlockDoorResults.UnlockSuccess:
                        consume(player, this);
                        break;

                    case Door.UnlockDoorResults.DoorOpen:
                        player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session, WeenieError.YouCannotLockWhatIsOpen));
                        break;

                    case Door.UnlockDoorResults.AlreadyUnlocked:
                        player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session, WeenieError.LockAlreadyUnlocked));
                        break;

                    case Door.UnlockDoorResults.PickLockFailed:
                        consume(player, this);
                        break;

                    default:
                        player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session, WeenieError.KeyDoesntFitThisLock));
                        break;
                    }
                }
                else if (target.WeenieType == WeenieType.Chest)
                {
                    var message = new GameMessageSystemChat($"Unlocking {target.Name} has not been implemented, yet!", ChatMessageType.System);
                    player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session), message);
                }
                else
                {
                    player.Session.Network.EnqueueSend(new GameEventUseDone(player.Session, WeenieError.YouCannotLockOrUnlockThat));
                }
            });

            chain.EnqueueChain();
        }