示例#1
0
        // TODO
        // Refactor
        public override void Render(GBitmap screen)
        {
            int x = iX - 2;
            int y = iY - 2;

            int YAtlas = 9;

            if (BindingMaster || CurrentInvItemAKey != 1 || IsHolding())
            {
                YAtlas = 12;
            }

            screen.Blit(Art.Rotate(Art.GRAPHICS[0, YAtlas + TrackState], (int)Direction * 90), x, y);
            Art.GRAPHICS[1, 9].ChangeHue(UnitColors.GetUnitHue(Id));

            int ol = 10;
            int ot = 10;

            if (Direction == Directions.Right)
            {
                ot *= 0;
                ol *= -1;
            }
            else if (Direction == Directions.Down)
            {
                ol *= 0;
                ot *= -1;
            }
            else if (Direction == Directions.Left)
            {
                ot *= 0;
            }
            else if (Direction == Directions.Up)
            {
                ol *= 0;
            }

            screen.Blit(Art.Rotate(Art.GRAPHICS[1, 9], (int)Direction * 90), x + ol, y + ot);

            if (IsHolding())
            {
                HandedItem.Render(screen, Id, iX, iY, Direction);
            }
            else
            {
                if (BindingMaster)
                {
                    InvItem KeepingItem = InvItem.GetInvItem(GetSlaveEntityMoving().ToString());
                    if (!KeepingItem.ToString().Equals("inventory-item"))
                    {
                        KeepingItem.Render(screen, Id, iX, iY, Direction);
                        KeepingItem.RenderHologram(screen, Id, iX, iY);
                    }
                }
                else if (CurrentInvItemAKey != 1)
                {
                    InvItem HoldingItem = InvItem.GetInvItem(InvItem.GetNameByIndex(CurrentInvItemAKey - 1));
                    HoldingItem.Render(screen, Id, iX, iY, Direction);
                    HoldingItem.RenderHologram(screen, Id, iX, iY);
                }
            }

            if (!Controllable)
            {
                Color col = Color.Green;
                if (Health < MaxHealth * 1 / 3)
                {
                    col = Color.Red;
                }
                else if (Health < MaxHealth * 2 / 3)
                {
                    col = Color.Yellow;
                }
                screen.FillRect(col, x + 3, y + H, (int)((double)Health / MaxHealth * W), 4);
            }
        }