
using System;
using System.Drawing;
using System.Collections.Generic;

using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;

using Math2D;
using Math2D.Shapes;

namespace PlanetExpress.items {
	
	public class CustomGameObject {
				
		public CustomGameObject() {
			FShape = GetShape();
		}
		
		public virtual void Init() {
			
		}
		
		public virtual bool Action(double time) {
			FShape = GetShape();
			X += VecA.X * (float)time;
			Y += VecA.Y * (float)time;
			VecA.Length *= 1-(float)time;
			return false;
		}
		
		public virtual void Draw() {
			
		}
		
		public Vector2D VecA = new Vector2D();
		
		protected float FX;
		public virtual float X {
			get { return FX; }
			set { FX = value; }
		}
		
		protected float FY;
		public virtual float Y {
			get { return FY; }
			set { FY = value; }
		}
		
		public string ObjectClass = "";
		
		public bool CalcCollision = true;
		
		private Polygon2D[] FShape = new Polygon2D[0];
		protected virtual Polygon2D[] GetShape() {
			return new Polygon2D[0];
		}
		
		public Polygon2D[] Shape {
			get { return FShape; }
		}
		
		public virtual void OnCollision(CustomGameObject with) {
			
		}		
	
		private List<Polygon2D> FMap = new List<Polygon2D>();
		public void LoadMap(params PointF[] map) {
			FMap.Clear();		
		}
		
		public void DrawMap() {			
			return;
			GL.Disable(EnableCap.Texture2D);
			GL.Color4(new float[]{1f, 0f, 0f, 0.5f});
			GL.Begin(BeginMode.Triangles); {				
				foreach (Polygon2D p in FShape) {
					foreach (Vector2D v in p.P) {
						GL.Vertex2(v.X, v.Y);
					}
				}
			} GL.End();
			GL.Enable(EnableCap.Texture2D);
		}
		
		public static int COLLISION_CLASS_ENEMY = 0;
		public static int COLLISION_CLASS_PLAYER = 1;
		
		public int CollisionClass = COLLISION_CLASS_ENEMY;
		
		public virtual void Demage(int v) {
			
		}
		
		public virtual void Die() {
			
		}
	}
}
