コード例 #1
0
ファイル: Cycle2DDN.cs プロジェクト: baovien/bkb
 /// <summary>
 /// Removes a sprite renderer from the registry.
 /// </summary>
 /// <param name="render">The rsprite renderer to delete from the registry.</param>
 /// <param name="animated">Whether or not the sprite was animated.</param>
 public void DelRenderer(SpriteRenderer render, bool animated)
 {
     if (animated)
     {
         AnimatedSprites.Remove(render);
     }
     else
     {
         StaticSprites.Remove(render);
     }
 }
コード例 #2
0
ファイル: Cycle2DDN.cs プロジェクト: baovien/bkb
 /// <summary>
 /// Registers a sprite renderer to the day night system.
 /// </summary>
 /// <param name="render">The sprite renderer to register.</param>
 /// <param name="animated">Whether or not the sprite is animated.</param>
 public void RegRenderer(SpriteRenderer render, bool animated)
 {
     if (animated)
     {
         AnimatedSprites.Add(render);
     }
     else
     {
         StaticSprites.Add(render);
     }
 }
コード例 #3
0
ファイル: Inventory.cs プロジェクト: AnonK2/planet
        public int OnGuiInventory(int singleItemWithBorderGapDim, Rect r, StaticSprites sprites, int selectedSlot, bool showKeys, IInventoryButtonAccumulator accum)
        {
            GUIStyle invNumberGs = new GUIStyle();

            invNumberGs.fontSize = 8;
            float origX = r.x;

            for (int i = 0; i < m_Inventory.Count; i++)
            {
                if (i > 0 && i % 10 == 0)
                {
                    r.x  = origX;
                    r.y += singleItemWithBorderGapDim;
                }

                var entry = m_Inventory[i];
                OnGuiSingleEntry(r, sprites, selectedSlot == i, entry, i, showKeys, accum);

                r.x += singleItemWithBorderGapDim;
            }
            return((m_Inventory.Count + 9) / 10);
        }
コード例 #4
0
ファイル: Inventory.cs プロジェクト: AnonK2/planet
        public void OnGuiSingleEntry(Rect r, StaticSprites sprites, bool selected, InventoryEntry entry, int slot, bool showKeys, IInventoryButtonAccumulator accum)
        {
            GUIStyle invNumberGs = new GUIStyle();

            invNumberGs.fontSize = 8;

            if (sprites.m_LightBorder != null && sprites.m_Border != null)
            {
                Rect rborder = r.Expand(3, 3);
                var  btex    = sprites.m_Border.texture;
                if (!selected)
                {
                    btex = sprites.m_LightBorder.texture;
                }
                GUI.DrawTexture(rborder, btex);
                if (accum != null)
                {
                    accum.AddButton(rborder, this, slot);
                }
            }

            // show keynum
            if (showKeys && sprites.m_KeyIcon != null && slot < 10)
            {
                Rect rcorner = r;
                rcorner.x -= rcorner.width / 2;
                rcorner.y -= rcorner.height / 2;
                GUI.DrawTexture(rcorner, sprites.m_KeyIcon.texture);
                rcorner.x += 6;
                GuiExt.Label2(rcorner, "" + ((1 + slot) % 10));
            }

            if (entry != null)
            {
                var tex = ItemDatabase.GetIconStatic(entry.m_Name).texture;
                GUI.DrawTexture(r, tex);

                Sprite chargingTex = null;
                if (entry.HasProperty("energy"))
                {
                    var energy = entry.GetProperty("energy");
                    if (energy <= 1.0f)
                    {
                        chargingTex = sprites.m_PowerOff;
                    }
                    else if (energy < 20.0f)
                    {
                        chargingTex = sprites.m_LowBattery;
                    }

                    if (Time.time - entry.m_ChargingTime < 1.0f)
                    {
                        chargingTex = sprites.m_Charging;
                    }
                }

                if (chargingTex != null)
                {
                    if (Mathf.Sin(10.0f * Time.time) > 0.0f)
                    {
                        GUI.DrawTexture(r, chargingTex.texture);
                    }
                }

                //GUI.Button(r, new GUIContent(tex));
                // Count
                Rect r2 = new Rect(r.xMax - 5, r.yMax - 5, 200.0f, 30.0f);
                if (entry.m_Count > 1)
                {
                    invNumberGs.normal.textColor = Color.black;
                    TwoDee.GuiExt.Label2(r2, entry.m_Count + "", invNumberGs);
                    invNumberGs.normal.textColor = Color.white;
                    r2.x -= 1; r2.y -= 1;
                    TwoDee.GuiExt.Label2(r2, entry.m_Count + "", invNumberGs);
                }
            }
        }