PageRenderTime 36ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/LevelDesigner/OtherStuff.cs

https://gitlab.com/seckmaster/LevelDesigner
C# | 162 lines | 126 code | 26 blank | 10 comment | 4 complexity | 55ef73426091338ebb63c2f93624dad0 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ComponentModel;
  6. using System.Drawing;
  7. using System.Windows.Forms;
  8. using System.Drawing.Drawing2D;
  9. namespace LevelDesigner
  10. {
  11. class myButton : Button, ICloneable
  12. {
  13. [Category("A_myStuff")]
  14. public GameData data { get; set; }
  15. [Category("A_myStuff")]
  16. public bool isSet { get; set; }
  17. public myButton()
  18. {
  19. BackgroundImageLayout = ImageLayout.Stretch;
  20. FlatAppearance.BorderSize = 0;
  21. FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  22. isSet = false;
  23. data = new GameData();
  24. Cursor = Cursors.Hand;
  25. data.image = "";
  26. }
  27. protected override void OnPaint(PaintEventArgs e)
  28. {
  29. //Graphics g = e.Graphics;
  30. //Brush _brush = new SolidBrush(data.c);
  31. //g.FillRectangle(_brush, 0, 0, ClientSize.Width, ClientSize.Height);
  32. base.OnPaint(e);
  33. }
  34. protected override bool ShowFocusCues
  35. {
  36. get
  37. {
  38. return false;
  39. }
  40. }
  41. public object Clone()
  42. {
  43. myButton x = new myButton();
  44. x.Size = Size;
  45. x.BackColor = BackColor;
  46. x.isSet = true;
  47. x.data = (GameData)data.Clone();
  48. x.BackgroundImage = BackgroundImage;
  49. return x;
  50. }
  51. }
  52. public enum E_BODY_TYPE
  53. {
  54. EBT_undefined,
  55. EBT_tossingBall,
  56. EBT_enemy,
  57. EBT_sceneObject,
  58. EBT_groundObject,
  59. EBT_obstacle,
  60. EBT_button
  61. };
  62. public enum E_SHAPE_TYPE
  63. {
  64. EST_rect,
  65. EST_circle,
  66. EST_triangle
  67. }
  68. [TypeConverter(typeof(ExpandableObjectConverter))]
  69. public class GameData : ICloneable
  70. {
  71. // basic data
  72. public int x { get; set; } // x position
  73. public int y { get; set; } // y position
  74. public int z { get; set; } // z position
  75. public int w { get; set; } // width
  76. public int h { get; set; } // height
  77. public int hp { get; set; } // hit points
  78. public int angle { get; set; } // angle in degrees
  79. // color
  80. public Color c { get; set; }
  81. // entity type
  82. public E_BODY_TYPE objectType { get; set; }
  83. // shape type
  84. public E_SHAPE_TYPE shapeType { get; set; }
  85. // texutres
  86. public string image { get; set; } // default texture
  87. public int numberOftextures { get; set; }
  88. // physics data
  89. public bool dynamic { get; set; }
  90. public bool gravity;
  91. // sounds
  92. public string onImpact { get; set; }
  93. public string onDamage { get; set; }
  94. public string onDestroy { get; set; }
  95. public int nImpact { get; set; }
  96. public int nDamage { get; set; }
  97. public int nDestroy { get; set; }
  98. public GameData()
  99. {
  100. image = "";
  101. numberOftextures = 0;
  102. hp = 100;
  103. }
  104. public override String ToString()
  105. {
  106. return "" + x + "|" + y + "|" + w + "|" + h + "|" + c.ToArgb() + "|" + (int)objectType + "|" + image + "|" + dynamic.ToString() + "|" + (int)shapeType;
  107. }
  108. public object Clone()
  109. {
  110. return this.MemberwiseClone();
  111. }
  112. }
  113. class Path
  114. {
  115. public Point a { get; set; }
  116. public Point b { get; set; }
  117. public myButton buttonRef { get; set; }
  118. public int velocity { get; set; }
  119. public Path()
  120. {
  121. a = new Point(-1, -1);
  122. b = new Point(-1, -1);
  123. buttonRef = null;
  124. velocity = 0;
  125. }
  126. public void Render(Graphics g)
  127. {
  128. if (a.X != -1 && b.X != -1)
  129. {
  130. {
  131. g.DrawLine(new Pen(Color.Black), a, b);
  132. }
  133. }
  134. }
  135. }
  136. }