예제 #1
0
 void PoolThis()
 {
     // un-parent from tile gobj
     this.transform.SetParent(null);
     myExtractable = null;
     ObjectPool.instance.PoolObject(this.gameObject);
 }
예제 #2
0
 protected Extractable(Extractable b)
 {
     yield           = b.yield;
     capacity        = b.capacity;
     yieldRate       = b.yieldRate;
     extractableType = b.extractableType;
     weight          = b.weight;
 }
예제 #3
0
파일: Tile.cs 프로젝트: cesarrac/LDJam40
 public bool PlaceExtractable(Extractable newExtractable)
 {
     if (extractable != null)
     {
         return(false);
     }
     extractable = newExtractable;
     return(true);
 }
예제 #4
0
    public static Extractable PlaceInstance(Extractable prototype, Tile tileBase)
    {
        Extractable newExtractable = new Extractable(prototype.Clone());

        if (tileBase.PlaceExtractable(newExtractable) == false)
        {
            // placement failed
            return(null);
        }
        return(newExtractable);
    }
예제 #5
0
    public void PlaceExtractable(Tile tile)
    {
        if (tile == null)
        {
            return;
        }
        Extractable newExtractable = Extractable.PlaceInstance(GetPrototype(), tile);

        if (newExtractable == null)
        {
            return;
        }
    }
예제 #6
0
 public virtual bool RemoveItem(Extractable itemToRemove)
 {
     if (itemToRemove == null)
     {
         return(false);
     }
     Debug.Log(itemToRemove.extractableType + " removed from inventory.");
     itemsStored.Remove(itemToRemove);
     if (onInventoryChanged != null)
     {
         onInventoryChanged(itemsStored.Count);
     }
     return(true);
 }
예제 #7
0
    public int TotalInstancesOfItem(Extractable item)
    {
        if (itemsStored.Contains(item) == false)
        {
            return(0);
        }
        int count = 0;

        for (int i = 0; i < itemsStored.Count; i++)
        {
            if (itemsStored[i] == item)
            {
                count++;
            }
        }
        return(count);
    }
예제 #8
0
    public virtual bool AddItem(Extractable item, int count = 1)
    {
        if (currentWeight + item.weight > maxWeightCapacity)
        {
            Debug.Log("Carrying too much!");

            return(false);
        }
        for (int i = 0; i < count; i++)
        {
            itemsStored.Add(item);
        }
        Debug.Log(count + " " + item.extractableType + " added to inventory");
        if (onInventoryChanged != null)
        {
            onInventoryChanged(itemsStored.Count);
        }
        return(true);
    }
예제 #9
0
 public void InitExtractable(Extractable thisExtractable)
 {
     myExtractable = thisExtractable;
     if (myExtractable == null)
     {
         Debug.LogError("Extract_Controller is not receivin an extractor class!");
         return;
     }
     // Get sprite:
     if (myExtractable.spriteID != string.Empty)
     {
         sprite_renderer.sprite = SpriteManager.instance.GetSprite(myExtractable.spriteID);
     }
     else
     {
         sprite_renderer.sprite = SpriteManager.instance.GetOreSprite();
         myExtractable.spriteID = sprite_renderer.sprite.name;
     }
     curProgress = 0;
     yield       = myExtractable.yield;
     yieldRate   = myExtractable.yieldRate;
     capacity    = myExtractable.capacity;
     Init(transform.position);
 }
예제 #10
0
        public static T ExtractOrder <T>(IEnumerable <ArgType> what, Function fct, string str) where T : Extractable
        {
            Extractable element = null;

            foreach (ArgType argType in what)
            {
                if (argType == ArgType.Const)
                {
                    element = ExtractConst(str);
                }

                if (argType == ArgType.Variable)
                {
                    element = ExtractVar(fct, str);
                }

                if (element != null)
                {
                    return((T)element);
                }
            }

            return(null);
        }
예제 #11
0
 public ExtractPart(Extractable what, IPart from)
 {
     What = what;
     From = from;
 }
예제 #12
0
파일: Q.cs 프로젝트: susch19/querybuilder
 public static ExtractPart Extract(Extractable what, IPart from) => new ExtractPart(what, from);