当前位置: 首页>>代码示例>>C#>>正文


C# Screen.Draw方法代码示例

本文整理汇总了C#中Screen.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# Screen.Draw方法的具体用法?C# Screen.Draw怎么用?C# Screen.Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Screen的用法示例。


在下文中一共展示了Screen.Draw方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawParty

    /*public void LoadTextures()
    {
        //Texture = M.game.Content.Load<Texture2D>("other/player");
        Texture = NamedTexture.Get("other/player");
    }*/
    public void DrawParty(ZPoint position)
    {
        Screen screen = new Screen(position, new ZPoint(1, 1));
        int vOffset = 0, iOffset = 0, hiOffset = 40, vStep = 40;
        MouseTrigger.Clear<MouseTriggerObject<LocalObject>>();

        foreach (var c in party)
        {
            Screen icon = new Screen(position + new ZPoint(0, vOffset), new ZPoint(32, 32));
            icon.Fill(Stuff.MyColor("Very Dark Grey"));
            icon.Draw(c.GetTexture, ZPoint.Zero);
            if (c.xp != null) icon.DrawRectangle(new ZPoint(-2, 32), new ZPoint(2, (int)(-32 * ((float)(c.xp.value % c.xp.Max)/c.xp.Max))), Color.Yellow);
            MouseTriggerObject<LocalObject>.Set(c, icon.position, icon.size);

            float hpMissing = 1 - (float)c.hp.value / c.hp.Max;
            float staminaMissing = 1 - (float)c.hp.stamina / c.hp.Max;

            icon.DrawRectangle(new ZPoint(0, 32), new ZPoint(32, -(int)(staminaMissing * 32)), new Color(0.2f, 0.0f, 0.0f, 0.2f));
            icon.DrawRectangle(new ZPoint(0, 32), new ZPoint(32, -(int)(hpMissing * 32)), new Color(0.2f, 0.0f, 0.0f, 0.2f));

            if (c.inventory != null) c.inventory.Draw(position + new ZPoint(hiOffset, iOffset));

            vOffset += vStep;
            if (c.inventory != null) iOffset += vStep;
        }

        var mtc = MouseTrigger.GetUnderMouse<MouseTriggerObject<LocalObject>>();
        if (mtc != null)
        {
            LocalObject c = mtc.t;
            Screen icon = new Screen(position + new ZPoint(0, vStep * party.IndexOf(c)), new ZPoint(32, 32));
            icon.DrawString(M.fonts.verySmall, c.hp.stamina.ToString() + "/" + c.hp.value + "/" + c.hp.Max, 27, Color.White);
            c.DrawInfo(position + new ZPoint(6 * 32 + 48, 40));
        }

        Action<Inventory> draw = i =>
        {
            i.Draw(position + new ZPoint(hiOffset, iOffset));
            iOffset += i.Height * 32 + 8;
        };

        draw(inventory);
        if (!crafting.IsEmpty) DrawCrafting(screen.position + new ZPoint(240, iOffset));
        draw(crafting);
        if (!ground.IsEmpty) draw(ground);
        if (barter != null) DrawBarter(new ZPoint(hiOffset + 6 * 32 + 16, 8));
    }
开发者ID:mxgmn,项目名称:GENW,代码行数:52,代码来源:GlobalDraw.cs

示例2: DrawInfo

    public void DrawInfo(ZPoint position)
    {
        int length = 288, height = 124 + 48;
        Screen screen = new Screen(position, new ZPoint(length, height));
        screen.Fill(Color.Black);

        if (t.hp != null)
        {
            float hpFraction = (float)t.hp.value / t.hp.Max;
            float staminaFraction = (float)t.hp.stamina / t.hp.Max;

            screen.DrawRectangle(new ZPoint(0, 0), new ZPoint((int)(hpFraction * length), 20), new Color(0.2f, 0, 0));
            screen.DrawRectangle(new ZPoint(0, 0), new ZPoint((int)(staminaFraction * length), 20), new Color(0.4f, 0, 0));
            for (int i = 1; i <= t.hp.Max; i++) screen.DrawRectangle(new ZPoint((int)(i * (float)length / t.hp.Max), 0),
                new ZPoint(1, 20), Color.Black);
        }

        SpriteFont font = M.fonts.verdanaBold;
        screen.DrawString(font, t.FullName, 23, Color.White);

        if (t.attack != null)
        {
            screen.Draw(NamedTexture.Get("other/damage"), new ZPoint(0, 40));
            screen.DrawString(font, t.attack.Damage.ToString(), new ZPoint(22, 43), Color.White);
            screen.DrawString(font, t.attack.Value.ToString() + "/" + t.defence.Value, 43, Color.White);
        }

        if (t.hp != null)
        {
            screen.DrawString(font, t.hp.Armor.ToString(), new ZPoint(length - 32, 43), Color.White);
            screen.Draw(NamedTexture.Get("other/armor"), new ZPoint(length - 20, 40));
        }

        if (t.effects != null) t.effects.Draw(screen.position + new ZPoint(0, 60), screen.position + new ZPoint(24, 180));
        if (t.inventory != null) t.inventory.Draw(screen.position + new ZPoint(0, 92));
        if (t.abilities != null) t.abilities.Draw(screen, new ZPoint(0, 124));
        Ground.Draw(screen.position + new ZPoint(192, 92));
    }
开发者ID:mxgmn,项目名称:GENW,代码行数:38,代码来源:LocalPosition.cs

示例3: Draw

    public void Draw(ZPoint position)
    {
        Screen screen = new Screen(position, new ZPoint(width * 32, height * 32));

        if (G.battle) MouseTrigger.Clear<MouseTriggerInventory>();
        for (int i = 0; i < Size; i++) MouseTriggerInventory.Set(this, i, screen.position + CellPosition(i), new ZPoint(32, 32));
        var mti = MouseTrigger.GetUnderMouse<MouseTriggerInventory>();

        if (((mti != null && mti.inventory == this) || !IsEmpty) && name != "" && !G.battle) screen.DrawString(M.fonts.superSmall, name, Color.White);
        screen.Fill(name == "ground" ? Stuff.MyColor("Very Dark Blue") : Stuff.MyColor("Very Dark Grey"));
        if (globalOwner == World.Instance.player) screen.DrawRectangle(ZPoint.Zero, new ZPoint(screen.size.x,
            (int)(Weight * screen.size.y / globalOwner.WeightLimit)), new Color(0.2f, 0.2f, 0.2f, 0.5f));

        for (int i = 0; i < Size; i++)
        {
            ZPoint p = CellPosition(i);
            if (data[i] != null)
            {
                screen.Draw(data[i].data.texture, p);
                if (data[i].numberOfStacks > 1)
                    screen.DrawStringWithShading(M.fonts.small, data[i].numberOfStacks.ToString(), p + new ZPoint(24, 18), Color.White);
                if (G.battle && localOwner == B.current && name == "" && data[i].data.ability != null)
                    screen.DrawStringWithShading(M.fonts.small, data[i].cooldown > 0 ? "(" + (int)data[i].cooldown + ")"
                        : Stuff.ItemHotkeys[i].ToString(), p, Color.White);
            }
        }

        if (mti != null && mti.inventory == this)
        {
            screen.Draw(NamedTexture.Get("other/zSelection"), CellPosition(mti.cell));
            Item item = mti.GetItem();
            if (item != null)
            {
                item.data.DrawDescription(G.battle ? name == "ground" ? position + new ZPoint(-168, 88) : position +
                    new ZPoint(24, 88) : new ZPoint(248, 48));

                if (G.battle && G.RightMouseButtonClicked && B.current.inventory != null)
                {
                    Inventory inventory = B.current.inventory;
                    if (this == inventory)
                    {
                        B.Add(new LocalObject(item), B.current.p.value);
                        Remove(mti.cell);
                    }
                    else if (name == "ground" && inventory.CanAdd(item))
                    {
                        inventory.Add(item);
                        B.RemoveItem(item);
                    }
                }
            }
        }
    }
开发者ID:mxgmn,项目名称:GENW,代码行数:53,代码来源:Inventory.cs

示例4: DrawScale

    private void DrawScale(bool horizontal)
    {
        ZPoint position = horizontal ? new ZPoint(128, M.size.y - 68) : new ZPoint(16 + 32, 8 + 16 + 32);
        int length = horizontal ? 736 : 720 - 16 - 64 - 32, height = horizontal ? 20 : 16;
        Screen screen = new Screen(position, new ZPoint(height, length).Transpose(horizontal));

        screen.Fill(Stuff.MyColor("Dark Grey"));

        var query = ActiveObjects.OrderBy(lc => lc.initiative.r.x);
        float zeroInitiative = -query.Last().initiative.r.x;

        Func<float, int> func = f => (int)(100.0f * (-f - zeroInitiative)) + 1;
        Func<LocalObject, ZPoint> yz = lc => horizontal == lc.team.isInParty ? new ZPoint(height, 0) : new ZPoint(-32, -32);
        Func<LocalObject, ZPoint> iconPosition = lc => new ZPoint(yz(lc).x, func(lc.initiative.r.x) + 1).Transpose(horizontal);

        foreach (LocalObject lc in query) MouseTriggerObject<LocalObject>.Set(lc, screen.position + iconPosition(lc), new ZPoint(32, 32));
        var trigger = MouseTrigger.GetUnderMouse<MouseTriggerObject<LocalObject>>();

        foreach (LocalObject lc in query)
        {
            Color color = lc.p.TheSameAs(Mouse) || (trigger != null && trigger.t == lc) ? lc.RelationshipColor : Color.White;

            if (scaleAnimations.CurrentTarget != lc.initiative.r)
                screen.DrawRectangle(new ZPoint(yz(lc).y, func(lc.initiative.r.x)).Transpose(horizontal),
                new ZPoint(height + 32, 1).Transpose(horizontal), color);

            screen.Draw(lc.GetTexture, iconPosition(lc));
        }

        if (expectedInitiative < 0)
            screen.DrawRectangle(new ZPoint(0, func(expectedInitiative)).Transpose(horizontal),
            new ZPoint(height + 32, 1).Transpose(horizontal), Color.DodgerBlue);

        expectedInitiative = 0.0f;

        if (trigger != null) Draw(NamedTexture.Get("other/zSelection"), trigger.t.p.value);
        MouseTrigger.Clear<MouseTriggerObject<LocalObject>>();
    }
开发者ID:mxgmn,项目名称:GENW,代码行数:38,代码来源:BattlefieldDraw.cs

示例5: Draw

    public void Draw(ZPoint p, ZPoint descriptionP)
    {
        Screen screen = new Screen(p, new ZPoint(1, 32));
        MouseTriggerKeyword.Clear("effect");

        int i = 0;
        foreach (Effect e in data)
        {
            screen.Draw(e.data.texture, new ZPoint(32 * i, 0), e.data.SgnColor);
            screen.DrawStringWithShading(M.fonts.small, ((int)e.timeLeft).ToString(), new ZPoint(32 * i + 26, 20), Color.White);

            MouseTriggerKeyword.Set("effect", i.ToString(), p + new ZPoint(32 * i, 0), new ZPoint(32, 32));
            i++;
        }

        var mtk = MouseTriggerKeyword.GetUnderMouse("effect");
        if (mtk != null) data[int.Parse(mtk.parameter)].data.DrawDescription(descriptionP);
    }
开发者ID:mxgmn,项目名称:GENW,代码行数:18,代码来源:Effect.cs


注:本文中的Screen.Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。