Ejemplo n.º 1
0
        public void AddItem(CanBePickedUp pickable)
        {
            var Items = EntityManager.GetBuffer <InventoryItem>(inventoryEntity);

            Items.Add(new InventoryItem()
            {
                name = pickable.name, description = pickable.description, appearance = pickable.appearance
            });
        }
Ejemplo n.º 2
0
        public void CreateCollectible(EntityCommandBuffer ecb, int2 xy, float3 pos)
        {
            Entity entity = ecb.CreateEntity(Collectible);

            Sprite2DRenderer s  = new Sprite2DRenderer();
            Translation      t  = new Translation();
            WorldCoord       c  = new WorldCoord();
            LayerSorting     l  = new LayerSorting();
            CanBePickedUp    p  = new CanBePickedUp();
            HealthBonus      hb = new HealthBonus();

            t.Value = pos;

            c.x = xy.x;
            c.y = xy.y;

            // Only tint sprites if ascii
            s.color = GlobalGraphicsSettings.ascii
                ? new Unity.Tiny.Core2D.Color(1, 1, 1)
                : Color.Default;
            if (GlobalGraphicsSettings.ascii)
            {
                s.color.a = 0;
            }

            l.layer = 1;

            p.appearance.color  = s.color;
            p.appearance.sprite = SpriteSystem.IndexSprites[SpriteSystem.ConvertToGraphics('S')];   //defaults

            p.name        = new NativeString64("unknown pickup");
            p.description = new NativeString64("Check collectible gen");

            var collectibleGenSystem = World.Active.GetOrCreateSystem <CollectibleGenSystem>();

            collectibleGenSystem.GetRandomCollectible(ecb, entity, p, hb);
            s.sprite = p.appearance.sprite;

            ecb.SetComponent(entity, s);
            ecb.SetComponent(entity, t);
            ecb.SetComponent(entity, c);
            ecb.SetComponent(entity, l);
            ecb.SetComponent(entity, p);
        }