Ejemplo n.º 1
0
        public bool Pickup(GameComponent item, RestockType restockType)
        {
            if (item == null || item.IsDead)
            {
                return(false);
            }

            if (item is ResourceEntity)
            {
                var entity = item as ResourceEntity;
                Resources.Add(new InventoryItem()
                {
                    MarkedForRestock = restockType == RestockType.RestockResource,
                    MarkedForUse     = restockType != RestockType.RestockResource,
                    Resource         = entity.Resource
                });
            }
            else
            {
                throw new InvalidOperationException();
            }

            item.SetFlag(Flag.Active, false);
            var toss = new BodyTossMotion(0.5f + MathFunctions.Rand(0.05f, 0.08f), 1.0f, item.GlobalTransform, Parent);

            item.AnimationQueue.Add(toss);
            toss.OnComplete += () => item.GetRoot().Delete();

            return(true);
        }
Ejemplo n.º 2
0
        public bool Pickup(GameComponent item, RestockType restockType)
        {
            if (item == null || item.IsDead)
            {
                return(false);
            }

            if (item is ResourceEntity)
            {
                ResourceEntity entity = item as ResourceEntity;
                for (int i = 0; i < entity.Resource.Count; i++)
                {
                    Resources.Add(new InventoryItem()
                    {
                        MarkedForRestock = restockType == RestockType.RestockResource,
                        MarkedForUse     = restockType != RestockType.RestockResource,
                        Resource         = entity.Resource.Type
                    });
                }
            }
            else
            {
                Resources.Add(new InventoryItem()
                {
                    MarkedForRestock = restockType == RestockType.RestockResource,
                    MarkedForUse     = restockType != RestockType.RestockResource,
                    Resource         = item.Tags[0]
                });
            }

            item.SetFlag(Flag.Active, false);
            BodyTossMotion toss = new BodyTossMotion(0.5f + MathFunctions.Rand(0.05f, 0.08f),
                                                     1.0f, item.GlobalTransform, Parent as GameComponent);

            item.AnimationQueue.Add(toss);
            toss.OnComplete += () => item.GetRoot().Delete();

            return(true);
        }