示例#1
0
    public bool CanOpenDoor(int ID, bool noKey)
    {
        bool result = false;

        if (!noKey)
        {
            foreach (Item item in Inventory)
            {
                if (item is AccessItem)
                {
                    AccessItem i = ((AccessItem)item);

                    if (i.OpensDoor(ID))
                    {
                        result = true;
                    }
                }
            }
        }
        else if (noKey)
        {
            result = true;
        }

        return(result);
    }
示例#2
0
        void OnLootEntity(BasePlayer player, BaseEntity targetEntity)
        {
            if (player == null || targetEntity == null)
            {
                return;
            }

            StorageContainer storage = targetEntity as StorageContainer;

            if (storage == null)
            {
                return;
            }

            uint        storageId = storage.net.ID;
            StorageItem storageItem;

            if (m_storagesLogs.AliveStorages.ContainsKey(storageId))
            {
                storageItem = m_storagesLogs.AliveStorages[storageId];
            }
            else
            {
                storageItem          = new StorageItem();
                storageItem.Position = new Point(storage.transform.position);
                m_storagesLogs.AliveStorages[storageId] = storageItem;
            }

            AccessItem accessItem = new AccessItem();

            accessItem.dateTime = dateTimeToString(DateTime.Now);
            storageItem.AccessItems[player.userID] = accessItem;
        }
    private void TestInventoryFunctionality()
    {
        print("========== Testing Inventory Functionality ==========");

        Item i = new AccessItem("Key of Doom", 10, 1);
        Item j = new BonusItem("Potato of the Gods", 50, 100);
        Item k = new BonusItem("Potato of Death", 50, 50);

        AddItemToInventory(i);
        AddItemToInventory(j);
        AddItemToInventory(k);

        inventory.DebugInventory();

        if (inventory.CanOpenDoor(1))
        {
            print($"Opened the door of Doom aka 1");
        }
        else
        {
            print("Door of Doom not opened");
        }

        if (inventory.CanOpenDoor(2))
        {
            print($"Opened the door of Death aka 2");
        }
        else
        {
            print("Door of Death not opened");
        }
    }
示例#4
0
        void OnSignUpdated(Signage sign, BasePlayer player, string text)
        {
            uint signId = sign.net.ID;

            SignItem signItem;

            if (m_signsLogs.SignItems.ContainsKey(signId))
            {
                signItem = m_signsLogs.SignItems[signId];
            }
            else
            {
                signItem = new SignItem();
                m_signsLogs.SignItems[signId] = signItem;
            }

            AccessItem accessItem;

            if (signItem.AccessItems.ContainsKey(player.userID))
            {
                accessItem = signItem.AccessItems[player.userID];
            }
            else
            {
                accessItem = new AccessItem();
                signItem.AccessItems[player.userID] = accessItem;
            }

            accessItem.dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
示例#5
0
    private void TestCreateItem()
    {
        Debug.Log("============== Testing creation of items =============");
        Item i = new AccessItem("Key of doom", 10, 1);

        DebugItem(i);

        Item j = new BonusItem("Potato of the gods", 2, 100);

        DebugItem(j);
    }
    private void TestCreateItem()
    {
        print("========== Testing Item Creation ==========");
        Item i = new AccessItem("Key of Death", 10, 1);

        DebugItem(i);

        Item j = new BonusItem("Potato of the Gods", 2, 100);

        DebugItem(j);
    }
示例#7
0
    public void TestCreateItem()
    {
        print("========== Testing creation of items ==========");
        Item i = new AccessItem("Key of Doom", 10, 1);

        DebugItem(i);

        Item j = new BonusItem("Patato of the gods", 2, 100);

        DebugItem(j);
    }
示例#8
0
    public void TestCreateItem()
    {
        Debug.Log("-=-=-=-=-=-=-=-=- TESTING ITEM CREATION -=-=-=-=-=-=-=-=-");
        //this is how you make a new item
        Item i = new AccessItem(name: "small key", weight: 10.0f, door: 1);

        DebugItem(i);

        Item j = new BonusItem(name: "Bathduck", weight: 3, points: 69);

        DebugItem(j);
    }
 public AsyncEntryBlockUC Enter()
 {
     using (SpinLock.Enter())
     {
         if (LockStatus == Status.Opened)
         {
             LockStatus = Status.Locked;
             return(new AsyncEntryBlockUC(ExclusiveEntry));
         }
         AccessItem access;
         Queue.Enqueue(access = AccessItem.NewTCS());
         return(new AsyncEntryBlockUC(null, access.TCS));
     }
 }
示例#10
0
 public bool HasKey(int id)
 {
     for (int i = 0; i < items.Count; i++)
     {
         if (items[i] is AccessItem)
         {
             AccessItem it = (AccessItem)items[i];
             if (it.door == id)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public AsyncEntryBlockUC TryEnter(int milliseconds)
        {
            AccessItem access;

            using (SpinLock.Enter())
            {
                if (LockStatus == Status.Opened)
                {
                    LockStatus = Status.Locked;
                    return(new AsyncEntryBlockUC(ExclusiveEntry));
                }
                Queue.Enqueue(access = AccessItem.NewTimeLimitedTCS(milliseconds));
            }
            return(new AsyncEntryBlockUC(null, access.TCS));
        }
示例#12
0
        public EntryBlockUC Enter()
        {
            AccessItem access;

            using (SpinLock.Enter())
            {
                if (LockStatus == Status.Opened)
                {
                    LockStatus = Status.Locked;
                    return(ExclusiveEntry);
                }
                Queue.Enqueue(access = AccessItem.NewTCS());
            }
            return(access.WaitForResult());           //waiting synchronously for completion
        }
示例#13
0
    private Item createItem()
    {
        Item it = null;

        switch (itemType)
        {
        case ItemType.accessItem:
            it = new AccessItem(name, weight, doorId);
            break;

        case ItemType.bonusItem:
            it = new BonusItem(name, weight, bonusPoints);
            break;
        }

        return(it);
    }
示例#14
0
    private void DebugItem(Item i)
    {
        string itemInfo  = "The item: " + i.GetName() + " weighs " + i.GetWeight() + "Kg";
        string extraInfo = "";

        if (i is AccessItem)
        {
            AccessItem ai = (AccessItem)i;
            extraInfo = " and opens door: " + ai.GetDoorId();
        }
        else if (i is BonusItem)
        {
            BonusItem bi = (BonusItem)i;
            extraInfo = " and give you: " + bi.GetPoints() + " points";
        }

        Debug.Log(itemInfo + extraInfo);
    }
示例#15
0
    private void TestCreateItem()
    {
        Item i = new AccessItem("Key for dwum", 10, 1);

        DebugItem(i);

        AccessItem ai = new AccessItem("Key for aiaiai", 10, 2);

        DebugItem(ai);

        Item j = new BonusItem("Potatoe", 2, 100);

        DebugItem(j);

        BonusItem bj = new BonusItem("Pota2", 2, 100);

        DebugItem(bj);
    }
示例#16
0
    public void DebugItem(Item i)
    {
        string ItemInfo  = "The item name is: " + i.GetName() + " and it weighs " + i.GetWeight() + " kg";
        string ExtraInfo = "";

        if (i is AccessItem)
        {
            AccessItem ai = (AccessItem)i;
            ExtraInfo = " and open's door: " + ai.GetDoorId();
        }
        else if (i is BonusItem)
        {
            BonusItem bi = (BonusItem)i;
            ExtraInfo = "and gives you: " + bi.GetPoints() + " points";
        }

        Debug.Log(ItemInfo + ExtraInfo);
    }
示例#17
0
        object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
        {
            if (hitInfo == null || entity == null)
            {
                return(null);
            }

            BasePlayer player = hitInfo.Initiator as BasePlayer;
            Signage    sign   = entity as Signage;

            if (player && sign && m_signsShowInfo.Contains(player.userID))
            {
                if (player.net.connection.authLevel == 0 && !permission.UserHasPermission(player.userID.ToString(), "SSNSigns.signs"))
                {
                    return(null);
                }

                uint signId = sign.net.ID;

                player.ChatMessage("Sign: <color=cyan>" + signId + "</color>");

                if (m_signsLogs.SignItems.ContainsKey(signId))
                {
                    List <ulong> contextPlayers = new List <ulong>();
                    SignItem     signItem       = m_signsLogs.SignItems[signId];
                    int          i = 0;
                    foreach (ulong userID in sortedByDatetime(signItem.AccessItems))
                    {
                        contextPlayers.Add(userID);

                        AccessItem accessItem = m_signsLogs.SignItems[signId].AccessItems[userID];

                        string message = m_configData.Messages["player_access"];
                        message = message.Replace("%player_steamid", userID.ToString());
                        message = message.Replace("%player_name", SSNNotifier.Call <string>("PlayerName", userID));
                        message = message.Replace("%timestamp", accessItem.dateTime);
                        player.ChatMessage((++i).ToString() + ") " + message);
                    }
                    SSNNotifier.Call("SetContextPlayers", player.userID, contextPlayers);
                }
                return("handled");
            }
            return(null);
        }
示例#18
0
    private void DebugItem(Item i)
    {
        string defaultInfo = "ITEM CREATED: " + i.GetName() + " // " + i.GetWeight() + "KG";
        string extraInfo   = "";

        //Interspection
        if (i is AccessItem)
        {
            AccessItem ai = (AccessItem)i;
            extraInfo = "and opens door: " + ai.GetDoorId();
        }
        else if (i is BonusItem)
        {
            BonusItem ai = (BonusItem)i;
            extraInfo = "and opens door: " + ai.GetPoints();
        }

        Debug.Log(defaultInfo + extraInfo);
    }
示例#19
0
 public async Task ExecuteLoadItemsCommand()
 {
     IsBusy = true;
     try
     {
         Items.Clear();
         var items = new AccessItem().SelectAll();
         foreach (var item in items)
         {
             Items.Add(item);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
     finally
     {
         IsBusy = false;
     }
 }
示例#20
0
    public void DebugItem(Item i)
    {
        string itemInfo  = "The item's name is " + i.GetName() + " and weighs " + i.GetWeight() + " Kg";
        string extraInfo = "";

        if (i is AccessItem)
        {
            //casting
            //Transforming item 'i' in an AccessItem to access more variables
            AccessItem ai = (AccessItem)i;
            extraInfo = " and opens door: " + ai.GetDoorId();
        }
        else if (i is BonusItem)
        {
            //casting
            //Transforming item 'i' in an BonusItem to access more variables
            BonusItem bi = (BonusItem)i;
            extraInfo = " and gives you: " + bi.GetPoints();
        }

        print(itemInfo + extraInfo);
    }
示例#21
0
    void TestInventory()
    {
        BonusItem  bonus = new BonusItem("Bonus1", 2f, 100);
        AccessItem key   = new AccessItem("Key1", 2f, 1);
        BonusItem  anvil = new BonusItem("anvil", 9f, 900);


        Debug.Log("Adding bonus success: " + Inventory.instance.AddItem(bonus));
        Debug.Log("Adding key success: " + Inventory.instance.AddItem(key));
        Debug.Log("Adding Anvil success: " + Inventory.instance.AddItem(anvil));
        Debug.Log("");
        Debug.Log("INVENTORY:");
        Inventory.instance.printToConsole();

        Inventory.instance.removeItem(bonus);
        Debug.Log("INVENTORY (after removing):");
        Inventory.instance.printToConsole();

        Inventory.instance.removeItem(anvil);
        Debug.Log("INVENTORY (after FAKE removing):");
        Inventory.instance.printToConsole();
    }
示例#22
0
 private async void Icon_Click(object sender, ItemClickEventArgs e)
 {
     AccessItem accessItem = e.ClickedItem as AccessItem;
     await Launcher.LaunchUriAsync(accessItem.UriStr);
 }
示例#23
0
    private void TestInventoryFunctionality()
    {
        Debug.Log("============== Testing inventory functionality =============");
        Item i = new AccessItem("Key of doom", 10, 1);
        Item j = new BonusItem("Potato of the gods", 50, 50);
        Item k = new BonusItem("Globe of eternal sunshine", 50, 100);

        if (inventory.AddItem(i))
        {
            Debug.Log("Added " + i.GetName() + " to the inventory");
        }
        else
        {
            Debug.Log("Failed to add " + i.GetName() + " to the inventory");
        }

        if (inventory.AddItem(j))
        {
            Debug.Log("Added " + j.GetName() + " to the inventory");
        }
        else
        {
            Debug.Log("Failed to add " + j.GetName() + " to the inventory");
        }

        if (inventory.AddItem(k))
        {
            Debug.Log("Added " + k.GetName() + " to the inventory");
        }
        else
        {
            Debug.Log("Failed to add " + k.GetName() + " to the inventory");
        }

        inventory.DebugInventory();

        if (inventory.CanOpenDoor(1))
        {
            Debug.Log("Door 1 can be opened.");
        }
        else
        {
            Debug.Log("Door 1 can NOT be opened.");
        }

        if (inventory.CanOpenDoor(2))
        {
            Debug.Log("Door 2 can be opened.");
        }
        else
        {
            Debug.Log("Door 2 can NOT be opened.");
        }

        if (inventory.HasItem(i))
        {
            Debug.Log("Inventory has Key of doom");
        }
        else
        {
            Debug.Log("Key of doom not in inventory");
        }

        if (inventory.RemoveItem(i))
        {
            Debug.Log("Key Removed");
        }
        else
        {
            Debug.Log("Key was not removed");
        }

        if (inventory.CanOpenDoor(1))
        {
            Debug.Log("Door 1 can be opened.");
        }
        else
        {
            Debug.Log("Door 1 can NOT be opened.");
        }

        if (inventory.HasItem(i))
        {
            Debug.Log("Inventory has Key of doom");
        }
        else
        {
            Debug.Log("Key of doom not in inventory");
        }
    }
示例#24
0
    private void TestInventoryFunctioanlity()
    {
        print("========== Testing inventory functionalities ==========");
        Item i = new AccessItem("Key of Doom", 10, 1);
        Item j = new BonusItem("Patato of the gods", 50, 50);
        Item k = new BonusItem("Globe of eternal sunshine", 50, 100);
        Item l = new PuzzelItem("Riddle01", 10, "What is an lama of islam?", "Islama");

        //added item
        if (inventory.AddItem(i))
        {
            print("Added " + i.GetName() + " to the inventory");
        }
        else
        {
            print("Failed to add " + i.GetName() + " to the inventory");
        }

        //added item
        if (inventory.AddItem(j))
        {
            print("Added " + j.GetName() + " to the inventory");
        }
        else
        {
            print("Failed to add " + j.GetName() + " to the inventory");
        }

        //added item
        if (inventory.AddItem(k))
        {
            print("Added " + k.GetName() + " to the inventory");
        }
        else
        {
            print("Failed to add " + k.GetName() + " to the inventory");
        }

        //added riddle
        if (inventory.AddItem(l))
        {
            print("Added " + l.GetName() + " to the inventory");
        }
        else
        {
            print("Failed to add " + l.GetName() + " to the inventory");
        }

        inventory.DebugInventory();

        if (inventory.CanOpenDoor(1))
        {
            print("Door 1 can be opened.");
        }
        else
        {
            print("Door 1 can NOT be opened");
        }

        if (inventory.CanOpenDoor(2))
        {
            print("Door 2 can be opened.");
        }
        else
        {
            print("Door 2 can NOT be opened");
        }

        if (inventory.HasItem(i))
        {
            print("Inventory has key of doom");
        }
        else
        {
            print("Inventory doenst have key of doom");
        }

        if (inventory.RemoveItem(i))
        {
            print("Key removed");
        }
        else
        {
            print("Key was nont removed");
        }

        if (inventory.CanOpenDoor(1))
        {
            print("Door 1 can be opened.");
        }
        else
        {
            print("Door 1 can NOT be opened");
        }

        if (inventory.HasItem(i))
        {
            print("Inventory has key of doom");
        }
        else
        {
            print("Inventory doenst have key of doom");
        }

        TestPuzzelItemFunctionallities(l);
    }
示例#25
0
    public void TestInventory()
    {
        Debug.Log("-=-=-=-=-=-=-=-=- TESTING INVENTORY -=-=-=-=-=-=-=-=-");
        Item i = new AccessItem(name: "small key", weight: 10, door: 1);
        Item j = new BonusItem(name: "Bathduck", weight: 50, points: 69);
        Item k = new BonusItem(name: "Triforce", weight: 50, points: 180);

        if (inventory.AddItem(i))
        {
            Debug.Log("Added " + i.GetName() + " to the inventory");
        }
        else
        {
            Debug.Log("Failed to add " + i.GetName() + " to the inventory");
        }

        if (inventory.AddItem(j))
        {
            Debug.Log("Added " + j.GetName() + " to the inventory");
        }
        else
        {
            Debug.Log("Failed to add " + j.GetName() + " to the inventory");
        }

        if (inventory.AddItem(k))
        {
            Debug.Log("Added " + k.GetName() + " to the inventory");
        }
        else
        {
            Debug.Log("Failed to add " + k.GetName() + " to the inventory");
        }

        inventory.DebugInventory();

        if (inventory.CanOpenDoor(1))
        {
            Debug.Log("Door 1 Can be opened");
        }
        else
        {
            Debug.Log("Door 1 Can not be opened");
        }

        if (inventory.CanOpenDoor(2))
        {
            Debug.Log("Door 2 Can be opened");
        }
        else
        {
            Debug.Log("Door 2 Can not be opened");
        }

        if (inventory.HasItem(i))
        {
            Debug.Log("Inventory has key");
        }
        else
        {
            Debug.Log("Inventory does not have the key");
        }

        if (inventory.RemoveItem(i))
        {
            Debug.Log("The key is removed");
        }
        else
        {
            Debug.Log("The key is not removed");
        }

        if (inventory.CanOpenDoor(1))
        {
            Debug.Log("Door 1 Can be opened");
        }
        else
        {
            Debug.Log("Door 1 Can not be opened");
        }

        if (inventory.HasItem(i))
        {
            Debug.Log("Inventory has key");
        }
        else
        {
            Debug.Log("Inventory does not have the key");
        }
    }
示例#26
0
    private void TestInv()
    {
        //Creating the items
        Debug.Log("INV SHIT HERE YEEET");
        AccessItem i  = new AccessItem("Key for dwum", 10, 1);
        AccessItem ai = new AccessItem("Key for aiaiai", 20, 3);
        BonusItem  j  = new BonusItem("Potatoe", 65, 100);
        BonusItem  bj = new BonusItem("Pota2", 10, 100);

        //Adding
        if (inventory.AddItem(i))
        {
            Debug.Log("Added " + i.GetName() + " To the inventory");
        }

        if (inventory.AddItem(ai))
        {
            Debug.Log("Added " + ai.GetName() + " To the inventory");
        }

        if (inventory.AddItem(j))
        {
            Debug.Log("Added " + j.GetName() + " To the inventory");
        }

        if (inventory.AddItem(bj))
        {
            Debug.Log("Added " + bj.GetName() + " To the inventory");
        }

        //inventory.DebugInv();

        //Can open door
        if (inventory.CanOpenDoor(1))
        {
            Debug.Log("Can open door 1");
        }
        else
        {
            Debug.Log("Can't open door 1");
        }

        if (inventory.CanOpenDoor(2))
        {
            Debug.Log("Can open door 2");
        }
        else
        {
            Debug.Log("Can't open door 2");
        }

        //Has and Remove
        if (inventory.HasItem(i))
        {
            Debug.Log("Has item " + i.GetName());
        }
        else
        {
            Debug.Log("Doesn't have " + i.GetName());
        }

        if (inventory.RemoveItem(i))
        {
            Debug.Log("Removed item");
        }
        else
        {
            Debug.Log("Couldn't remove item");
        }

        if (inventory.HasItem(i))
        {
            Debug.Log("Has item " + i.GetName());
        }
        else
        {
            Debug.Log("Doesn't have " + i.GetName());
        }
    }