コード例 #1
0
    public void TakeIcon()
    {
        if (_icon != null)
        {
            return;
        }
        if (_characterClass < 0 && _actionCtrl != null)
        {
            string charID = _actionCtrl.Data.characterId;
            if (charID.StartsWith("mage"))
            {
                _characterClass = 0;
            }
            else if (charID.StartsWith("warrior"))
            {
                _characterClass = 1;
            }
            else if (charID.StartsWith("monk"))
            {
                _characterClass = 2;
            }
        }
        if (_characterClass < 0)
        {
            return;
        }
        _icon = RenderTexture.GetTemporary(128, 128, 32, RenderTextureFormat.ARGB32);
        string[] cameraPaths = new string[] { "Assets/Characters/Common/IconCamera_mage.prefab",
                                              "Assets/Characters/Common/IconCamera_warrior.prefab",
                                              "Assets/Characters/Common/IconCamera_monk.prefab" };
        GameObject go = InJoy.AssetBundles.AssetBundles.Load(cameraPaths[_characterClass], typeof(GameObject)) as GameObject;

        go = GameObject.Instantiate(go) as GameObject;
        go.transform.parent        = transform;
        go.transform.localPosition = Vector3.zero;
        go.transform.localRotation = Quaternion.identity;
        go.transform.localScale    = Vector3.one;

        Renderer[] renderers = gameObject.GetComponentsInChildren <Renderer>();
        int[]      layers    = new int[renderers.Length];
        for (int i = 0; i < renderers.Length; ++i)
        {
            layers[i] = renderers[i].gameObject.layer;
            if (renderers[i].gameObject.layer == LayerMask.NameToLayer("CHARACTER") ||
                renderers[i].gameObject.layer == LayerMask.NameToLayer("Default"))
            {
                renderers[i].gameObject.layer = LayerMask.NameToLayer("SCRIPT");
            }
        }

        IconRenderer iRenderer = go.GetComponent <IconRenderer>();

        iRenderer.Render(_icon);
        Destroy(go);

        for (int i = 0; i < renderers.Length; ++i)
        {
            renderers[i].gameObject.layer = layers[i];
        }
    }
コード例 #2
0
        public override void Draw()
        {
            for (int i = 0; i < m_Parent.TilesWidth * m_Parent.TilesHeight; i++)
            {
                Tuple <byte, Texture2D, bool, bool> tuple = m_Parent.GetTile(i);

                bool          h = tuple.Item3, v = tuple.Item4;
                SpriteEffects effect = (h ? SpriteEffects.FlipHorizontally : 0) | (v ? SpriteEffects.FlipVertically : 0);

                if (tuple == null || tuple.Item2 == null)
                {
                    break;
                }
                int x_tile = tuple.Item1 % 16 * 8;
                int y_tile = (tuple.Item1 / 16) * 8;
                RenderManager.SpriteBatch.GUIDrawSprite(tuple.Item2,
                                                        new Rectangle(
                                                            Area.X + (i % m_Parent.TilesWidth) * (Area.Width / m_Parent.TilesWidth),
                                                            Area.Y + (i / m_Parent.TilesWidth) * (Area.Height / m_Parent.TilesHeight),
                                                            Area.Width / m_Parent.TilesWidth,
                                                            Area.Height / m_Parent.TilesHeight),
                                                        new Rectangle(x_tile, y_tile, 8, 8), effects: effect, Palettized: true, Palette: m_Parent.Attribute);
            }

            if (m_Parent.DrawFlags)
            {
                for (int i = 0; i < 8; i++)
                {
                    if ((m_Parent.Flags & (0x01 << i)) != 0)
                    {
                        _checkbox_checked.Render(RenderManager.SpriteBatch, new Rectangle(
                                                     Area.X + (i % 3) * 16, Area.Y + (i / 3) * 16, 16, 16));
                    }
                    else
                    {
                        _checkbox.Render(RenderManager.SpriteBatch, new Rectangle(
                                             Area.X + (i % 3) * 16, Area.Y + (i / 3) * 16, 16, 16));
                    }
                }
            }

            Color border = Color.Black;

            RenderManager.SpriteBatch.DrawRectangle(
                new Vector3(Area.X - 1, Area.Y - 1, 0),
                new Vector2(Area.Width + 2, Area.Height + 2),
                border);
        }
コード例 #3
0
        public override void Draw()
        {
            switch (Mode)
            {
            case RenderMode.Default:
            {
                _default.Render(RenderManager.SpriteBatch, Area);
                break;
            }

            case RenderMode.Hover:
            {
                _hover.Render(RenderManager.SpriteBatch, Area);
                break;
            }

            case RenderMode.Pressed:
            {
                _pressed.Render(RenderManager.SpriteBatch, Area);
                break;
            }
            }
        }