summaryrefslogtreecommitdiff
path: root/Penguloon/Objects/ObjectBase.cs
diff options
context:
space:
mode:
authoraldrikboy <aldrikboy@gmail.com>2018-01-17 21:11:18 +0100
committeraldrikboy <aldrikboy@gmail.com>2018-01-17 21:11:18 +0100
commitaa6972a5d052d1f57dfda3dadb79fcd5d8ded30b (patch)
tree551c536bcce4bbee415fe20c48a911e152019983 /Penguloon/Objects/ObjectBase.cs
parent2185c2d45506c8b0d4e95000b82bc50859c663b7 (diff)
optimization
Diffstat (limited to 'Penguloon/Objects/ObjectBase.cs')
-rw-r--r--Penguloon/Objects/ObjectBase.cs37
1 files changed, 5 insertions, 32 deletions
diff --git a/Penguloon/Objects/ObjectBase.cs b/Penguloon/Objects/ObjectBase.cs
index d1ed0d4..19a222c 100644
--- a/Penguloon/Objects/ObjectBase.cs
+++ b/Penguloon/Objects/ObjectBase.cs
@@ -56,11 +56,15 @@ namespace Penguloon.Objects
this.Position = position;
CreateUpgrades();
+
+ RangeCircle = ContentManager.GetTexture("UI/circle");
}
public ObjectBase(Map map)
{
this.Map = map;
+
+ RangeCircle = ContentManager.GetTexture("UI/circle");
}
public virtual void CreateUpgrades()
@@ -151,9 +155,6 @@ namespace Penguloon.Objects
public void Draw(float deltaTime)
{
- if(RangeCircle == null)
- RangeCircle = CreateCircle((int)Range * 2);
-
float rot = (float)Rotation + (float)MathHelper.PiOver2;
if (!ShouldRotate)
@@ -199,35 +200,7 @@ namespace Penguloon.Objects
public abstract void DrawUnique(float deltaTime);
- public Texture2D CreateCircle(int radius)
- {
- Texture2D texture = new Texture2D(Map.ParentScene.Main.GraphicsDevice, radius, radius);
- Color[] colorData = new Color[radius * radius];
-
- float diam = radius / 2f;
- float diamsq = diam * diam;
-
- for (int x = 0; x < radius; x++)
- {
- for (int y = 0; y < radius; y++)
- {
- int index = x * radius + y;
- Vector2 pos = new Vector2(x - diam, y - diam);
- if (pos.LengthSquared() <= diamsq)
- {
- colorData[index] = Color.FromNonPremultiplied(200, 0, 0, 50);
- }
- else
- {
- colorData[index] = Color.Transparent;
- }
- }
- }
-
- texture.SetData(colorData);
- return texture;
- }
-
+
private double GetRotation(Vector2 enemyPos)
{
double radians = Math.Atan2(enemyPos.Y - Center.Y, enemyPos.X - Center.X);