예제 #1
0
 public SynchronizingItem(ItemInterface item, TaskState task, SyncState state = SyncState.None)
 {
     this.Drive = item.GDrive;
     this.ID    = item.ID;
     this.Task  = task;
     this.State = state;
 }
예제 #2
0
        private void button10_Click(object sender, EventArgs e)
        {
            ItemInterface palind = Notepad.GetInterface("palindrome");

            String[] withSpilt = palind.getSpesItem(richTextBox1.Text);

            int s_start = richTextBox1.SelectionStart, startIndex = 0, index;

            richTextBox1.Select(0, richTextBox1.Text.Length);
            richTextBox1.SelectionBackColor = Color.White;

            int count = 0;

            foreach (String s in withSpilt)
            {
                if (s != null)
                {
                    count++;
                    while ((index = richTextBox1.Text.IndexOf(s, startIndex)) != -1)
                    {
                        richTextBox1.Select(index, s.Length);
                        richTextBox1.SelectionBackColor = Color.Yellow;

                        startIndex = index + s.Length;
                    }
                }
            }
            label5.Text = count.ToString();
        }
예제 #3
0
    //when an equipment slot button is clicked, equip the selected item
    //type: 0 = armor, 1 = weapon, 2 = artifact
    public void EquipButtonClick(int type)
    {
        if (selectedItem == null)
        {
            return;
        }

        if ((int)selectedItem.GetComponent <InventoryItem>().itemReference.GetComponent <ItemInterface>().itemType != type)
        {
            return;
        }

        //set equipbuttons image to equipped item
        ItemInterface item = selectedItem.GetComponent <InventoryItem>().itemReference.GetComponent <ItemInterface>();

        equippedButtons[(int)item.itemType].GetComponent <Image>().sprite = item.image;
        //unequip previous item
        GameObject unequippedItem = selectedPlayer.GetComponent <PlayerItems>().EquipItem(selectedItem);

        if (unequippedItem != null)
        {
            int _type = (int)unequippedItem.GetComponent <ItemInterface>().itemType;
            unequippedItem.GetComponent <ItemInterface>().inventoryItem.GetComponent <InventoryItem>().equippedBy = null;
            unequippedItem.GetComponent <ItemInterface>().equippedBy = null;
            if (unequippedItem.GetComponent <ItemInterface>().itemName == item.itemName)
            {
                //not swapping, just unequipping
                equippedButtons[_type].GetComponent <Image>().sprite = defaultEquipIcons[_type];
                selectedPlayer.GetComponent <PlayerItems>().UnequipItem(_type);
            }
        }
        //update display stats with new items
        GetComponentInChildren <DisplayStats>().SetStats(selectedPlayer);
    }
    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.gameObject.layer == LayerMask.NameToLayer("Item"))
        {
            ItemInterface item = (ItemInterface)hit.gameObject.GetComponent(typeof(ItemInterface));
            item.get();
            return;
        }

        Rigidbody body = hit.collider.attachedRigidbody;

        if (hit.gameObject.layer == LayerMask.NameToLayer("Enemy"))
        {
            Debug.Log("Enemy");
            EnemyInterface enemy = (EnemyInterface)hit.gameObject.GetComponent(typeof(EnemyInterface));
            int            dmg   = enemy.getEnemyDamage();
            gameManager.plusPower(-dmg);
        }

        if (body == null || body.isKinematic)
        {
            return;
        }


        if (hit.gameObject.layer == LayerMask.NameToLayer("Pushable"))
        {
            body.AddForceAtPosition(Vector3.down * pushPower, hit.point);
        }
    }
예제 #5
0
    public void createBuyUtilits(ItemInterface _itemInformation)
    {
        GameObject _obj = InstanceController.createObject(BuyUtilits, BuyUtilits.transform.position, BuyUtilits.transform.rotation) as GameObject;

        _obj.GetComponent <BuyInterface>().ItemsInformation = _itemInformation;

        TouchController.layerMask = LayerMask.NameToLayer("Layer2");
    }
예제 #6
0
 public ItemSlot(ItemInterface iface, Vector2 position, Item[] items, int index, Fits fits = null) : base(iface)
 {
     this.Items     = items;
     this.Index     = index;
     this.Interface = iface;
     this.Position  = position;
     this.fits      = fits;
 }
예제 #7
0
    // Start is called before the first frame update
    void Start()
    {
        audioSource = GetComponent <AudioSource>();
        objItemInt  = GetComponent <ItemInterface>();

        uniqueAudioClip = objItemInt.getUniqueAudio();
        collisionClip   = objItemInt.getCollisionAudio();
    }
예제 #8
0
        public ItemInterface GetItem()
        {
            if (_item != null)
            {
                return(_item);
            }

            _item = Drive.GetFileById(ID);
            return(_item);
        }
예제 #9
0
 public Inventory(UnitInterface unit, ItemInterface[] items)
 {
     //testing
     this.items = new Item[limit];
     for (int f = 0; f < items.Length; f++)
         this.items[f] = items[f];
     this.unit = unit;
     //Just for testing
     for (int i = items.Length; i < limit; i++)
     {
         this.items[i] = new Item("nothing", null);
     }
 }
예제 #10
0
        /// <summary>
        /// Check if the file should be downloaded or uploaded (FILE ONLY)
        /// </summary>
        /// <param name="item">The item to check</param>
        /// <returns>DownloadOrUpload</returns>
        private DownloadOrUpload CheckDownloadOrUpload(string basePath, ItemInterface item)
        {
            string finalPath = PathNormalizer.Normalize(
                Path.Combine(basePath, item.GetFullName())
                );

            if (item == null)
            {
                return(DownloadOrUpload.Upload);
            }

            if (item.IsFolder())
            {
                throw new Exception("Item should be a file, not folder!");
            }

            // If reached here, is a file
            if (File.Exists(finalPath))
            {
                var itemHash  = item.MD5();
                var localHash = HashMD5(finalPath);

                if (itemHash == localHash)
                {
                    return(DownloadOrUpload.Nothing);
                }

                else
                {
                    var driveMod = item.LastMod;
                    var localMod = File.GetLastWriteTime(finalPath);

                    if (driveMod > localMod)
                    {
                        // Drive's item is more recent, let's download it
                        return(DownloadOrUpload.Download);
                    }
                    else if (driveMod < localMod)
                    {
                        // Local item is more recent, let's upload it
                        return(DownloadOrUpload.Update);
                    }
                }
            }
            bool exists = File.Exists(finalPath);

            // File does not exists, let's download
            return(DownloadOrUpload.Download);
        }
예제 #11
0
        public void SyncWithState(ItemInterface item, SynchronizingItem.SyncState state)
        {
            while (tempSyncItems_locked) /* wait */; {
            }


            var localItem = localStack.GetItem(item.ID);

            if (localItem != null && (localItem.State == state &&
                                      localItem.Task != SynchronizingItem.TaskState.Done))
            {
                return;
            }

            var syncItem = new SynchronizingItem(item, SynchronizingItem.TaskState.NotStarted, state);

            int  index = 0;
            bool shouldBeUpdatedAtIndex = false;

            foreach (var sItem in tempSyncItems)
            {
                if (sItem.ID == syncItem.ID)
                {
                    shouldBeUpdatedAtIndex = true;
                    break;
                }

                index++;
            }

            tempSyncItems_locked = true;

            if (shouldBeUpdatedAtIndex)
            {
                tempSyncItems[index] = syncItem;
            }
            else
            {
                tempSyncItems.Add(syncItem);
            }

            tempSyncItems_locked = false;
        }
예제 #12
0
	public  void LoadItem() {
		int id = Attributes.selectedItem;

		switch(id) {
		case 1:
			item = CarController.instance;
			break;
		case 2: //binh tuoi
			item = Bottle.instance;
			break;
		case 3://luoi hai
			item = Scythe.instance;
			break;
		case 4: //bu nhin rom
			item = Scaresrow.instance;
			break;
		default:
			item = null;
			break;
		}
	}
예제 #13
0
 void SetItem(ItemInterface item)
 {
     if (item.isConsumable())
     {
         currentItemAmountText.gameObject.SetActive(true);
         item.UseHandlerAddListener(() => { currentItemAmountText.SetText((item.itemAmount).ToString()); });
     }
     if (item.getType() == ItemCategories.ItensTypes.healthPotion)
     {
         input.Player.UseItem.performed += a => {
             item.UseItem(() =>
             {
                 if (PlayerHealth.currentHealth < PlayerHealth.maxHealth)
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             });
         };
     }
 }
예제 #14
0
파일: Axe.cs 프로젝트: kimbokChi/pSandBox
 public override bool IsUsing(ItemInterface itemInterface)
 {
     return(itemInterface == ItemInterface.Equip);
 }
예제 #15
0
 public ItemPresenter(ItemInterface view)
 {
     itemInterface = view;
 }
예제 #16
0
 public virtual bool IsUsing(ItemInterface itemInterface)
 {
     return(false);
 }
예제 #17
0
        /// <summary>
        /// IAnalyzeItemインスタンス作成
        /// </summary>
        /// <param name="node">対象Node</param>
        /// <param name="semanticModel">対象ソースのsemanticModel</param>
        /// <param name="container">イベントコンテナ</param>
        /// <param name="parent">親IAnalyzeItemインスタンス(デフォルトはnull)</param>
        /// <returns>IAnalyzeItemインスタンス</returns>
        public static IAnalyzeItem Create(SyntaxNode node, SemanticModel semanticModel, EventContainer container, IAnalyzeItem parent = null)
        {
            IAnalyzeItem result = null;

            // nodeの種類によって取得メソッドを実行
            switch (node)
            {
            // クラス定義
            case ClassDeclarationSyntax targetNode:
                result = new ItemClass(targetNode, semanticModel, parent, container);
                break;

            // インターフェース
            case InterfaceDeclarationSyntax targetNode:
                result = new ItemInterface(targetNode, semanticModel, parent, container);
                break;

            // クラス要素定義
            case PropertyDeclarationSyntax targetNode:
                result = new ItemProperty(targetNode, semanticModel, parent, container);
                break;

            case FieldDeclarationSyntax targetNode:
                result = new ItemField(targetNode, semanticModel, parent, container);
                break;

            case MethodDeclarationSyntax targetNode:
                result = new ItemMethod(targetNode, semanticModel, parent, container);
                break;

            case ConstructorDeclarationSyntax targetNode:
                result = new ItemConstructor(targetNode, semanticModel, parent, container);
                break;

            case EnumDeclarationSyntax targetNode:
                result = new ItemEnum(targetNode, semanticModel, parent, container);
                break;

            // ラムダ式
            case ArrowExpressionClauseSyntax targetNode:
                if (parent is ItemProperty)
                {
                    result = new ItemAccessor(targetNode, semanticModel, parent, container);
                }
                else
                {
                    var op = semanticModel.GetOperation(targetNode).Children.First();
                    switch (op)
                    {
                    case Microsoft.CodeAnalysis.Operations.IReturnOperation operation:
                        result = new ItemReturn(op.Syntax, semanticModel, parent, container);
                        break;

                    case Microsoft.CodeAnalysis.Operations.IExpressionStatementOperation operation:
                        result = new ItemStatementExpression(op.Syntax, semanticModel, parent, container);
                        break;
                    }
                }
                break;

            // ローカル定義
            case LocalFunctionStatementSyntax targetNode:
                result = new ItemLocalFunction(targetNode, semanticModel, parent, container);
                break;

            case LocalDeclarationStatementSyntax targetNode:
                result = new ItemStatementLocalDeclaration(targetNode, semanticModel, parent, container);
                break;

            case ExpressionStatementSyntax targetNode:
                result = new ItemStatementExpression(targetNode, semanticModel, parent, container);
                break;

            case AccessorDeclarationSyntax targetNode:
                result = new ItemAccessor(targetNode, semanticModel, parent, container);
                break;

            // 分岐処理
            case IfStatementSyntax targetNode:
                result = new ItemIf(targetNode, semanticModel, parent, container);
                break;

            case ElseClauseSyntax targetNode:
                result = new ItemElseClause(targetNode, semanticModel, parent, container);
                break;

            case SwitchStatementSyntax targetNode:
                result = new ItemSwitch(targetNode, semanticModel, parent, container);
                break;

            case SwitchSectionSyntax targetNode:
                result = new ItemSwitchCase(targetNode, semanticModel, parent, container);
                break;

            // ループ処理
            case WhileStatementSyntax targetNode:
                result = new ItemWhile(targetNode, semanticModel, parent, container);
                break;

            case DoStatementSyntax targetNode:
                result = new ItemDo(targetNode, semanticModel, parent, container);
                break;

            case ForEachStatementSyntax targetNode:
                result = new ItemForEach(targetNode, semanticModel, parent, container);
                break;

            case ForStatementSyntax targetNode:
                result = new ItemFor(targetNode, semanticModel, parent, container);
                break;

            // その他
            case ReturnStatementSyntax targetNode:
                result = new ItemReturn(targetNode, semanticModel, parent, container);
                break;

            case BreakStatementSyntax targetNode:
                result = new ItemBreak(targetNode, semanticModel, parent, container);
                break;

            case ContinueStatementSyntax targetNode:
                result = new ItemContinue(targetNode, semanticModel, parent, container);
                break;
            }

            return(result);
        }
예제 #18
0
 public void add(ItemInterface item)
 {
     for (int i = 0; i < items.Length; i++)
         if (items[i].matches("nothing"))
             items[i] = item;
 }
예제 #19
0
        //private List<ItemInterface> items = new List<ItemInterface>();

        public void addItems(ItemInterface iteminterface)
        {
            items.Add(iteminterface);
        }