Rev 1460 |
Rev 1477 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BauzoidNET.parser;
using BauzoidNET.graphics.sprite;
using BauzoidNET.graphics;
using BurutaruEditor.view;
namespace BurutaruEditor.file.enemies
{
public class BlobEnemySpawner : EnemySpawner
{
public const float BLOB_ENEMY_SIZE = 60;
public BlobEnemySpawner(Document doc, string name)
: base(doc, name)
{
}
public override void Render()
{
base.Render();
float triggerX = SpawnTrigger.x + Doc.View.CurrentPosition.x;
float triggerY = SpawnTrigger.y + Doc.View.CurrentPosition.y;
SpriteTransform t = DocumentView.Resources.BlobEnemySprite.getSpriteTransform();
t.x = triggerX + SpawnPosition.x;
t.y = triggerY + SpawnPosition.y;
t.w = BLOB_ENEMY_SIZE;
t.h = BLOB_ENEMY_SIZE;
t.centerPivot();
DocumentView.Resources.BlobEnemySprite.render();
float w = MainForm.App.getGraphics().getFont().getTextWidth(this.Name, Document.TEXT_SCALE);
MainForm.App.getGraphics().getFont().drawTextDirect(this.Name, t.x - w / 2, t.y + BLOB_ENEMY_SIZE/2,Document.TEXT_COLOR, Document.TEXT_SCALE);
RenderUtil.drawArrow(MainForm.App.getGraphics(), triggerX, triggerY, t.x, t.y, ARROW_COLOR);
}
public override void RenderSelected(int selectedPart, bool forHover = false)
{
if (selectedPart != PART_SPAWN_POSITION)
{
base.RenderSelected(selectedPart, forHover);
}
float posX = SpawnTrigger.x + SpawnPosition.x + Doc.View.CurrentPosition.x;
float posY = SpawnTrigger.y + SpawnPosition.y + Doc.View.CurrentPosition.y;
float halfSize = BLOB_ENEMY_SIZE / 2 + DocumentView.SELECTION_FRAME_OFFSET;
if (forHover)
Doc.View.RenderSelectionFrame(posX - halfSize, posY - halfSize, posX + halfSize, posY + halfSize, DocumentView.SELECTION_FRAME_HOVER_ALPHA);
else
Doc.View.RenderSelectionFrame(posX - halfSize, posY - halfSize, posX + halfSize, posY + halfSize);
}
public override bool IsInside(float x, float y, out int selectedPart)
{
if (base.IsInside(x, y, out selectedPart))
return true;
float px = SpawnTrigger.x + SpawnPosition.x + Doc.View.CurrentPosition.x;
float py = SpawnTrigger.y + SpawnPosition.y + Doc.View.CurrentPosition.y;
if ((Math.Abs(px - x) <= (BLOB_ENEMY_SIZE / 2)) && (Math.Abs(py - y) < (BLOB_ENEMY_SIZE / 2)))
{
selectedPart = PART_SPAWN_POSITION;
return true;
}
return false;
}
public override void MoveBy(float dx, float dy, int selectedPart)
{
if (selectedPart == PART_SPAWN_POSITION)
{
SpawnPosition.x += (dx / Doc.View.ZoomFactor);
SpawnPosition.y += (dy / Doc.View.ZoomFactor);
}
else
{
SpawnTrigger.x += (dx / Doc.View.ZoomFactor);
SpawnTrigger.y += (dy / Doc.View.ZoomFactor);
}
}
public override bool ReadParameter(Tokenizer t, String id)
{
return base.ReadParameter(t, id);
}
}
}