using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using DataStructures;

namespace Sentience
{
    /// <summary>
    /// IBlock implementors must implement these to be an IBlock.
    /// </summary>
    public interface IBlock : IName
    {
        // The label to be used in the block selector.
        String Label { get; }
        // The ID data that will be used to uniquely identify the block type.
        String ID { get; }
        // The bitmap image of the block (Defunct).
        Image Bitmap { get; set; }
        // The color of the block. *MUST* be unique.
        Color Color { get; }
        // If the block can be painted in the Designer.
        bool MultiSelect { get; }
        // If the block cannot be walked upon (e.g. a wall).
        bool Blocker { get; }
        // The action to be performed if stepped on.
        void Action(Entity entity);
    }

    /// <summary>
    /// Standard Floor tile, should do nothing.
    /// </summary>
    public class FloorBlock : IBlock
    {
        public FloorBlock(Map map)
        {
            Map = map;
        }

        private Map Map { get; set; }

        public String Label { get { return "Floor"; } }
        public String Name { get { return String.Format("{0}[{1}]", GetType().Name, ID); } }
        public String ID { get { return "f"; } }
        public Image Bitmap { get; set; }
        public Color Color { get { return Color.White; } }
        public bool MultiSelect { get { return true; } }
        public bool Blocker { get { return false; } }

        public void Action(Entity entity)
        {

        }
    }

    /// <summary>
    /// Wall tile, any nodes assigned as a wall block will be isolated from the graph.
    /// </summary>
    public class WallBlock : IBlock
    {
        public WallBlock(Map map)
        {
            Map = map;
        }

        private Map Map { get; set; }

        public String Label { get { return "Wall"; } }
        public String Name { get { return String.Format("{0}[{1}]", GetType().Name, ID); } }
        public String ID { get { return "w"; } }
        public Image Bitmap { get; set; }
        public Color Color { get { return Color.LightGray; } }
        public bool MultiSelect { get { return true; } }
        public bool Blocker { get { return true; } }

        public void Action(Entity entity)
        {

        }
    }

    /// <summary>
    /// Goal block will increase the score of any Goal-Seeker that steps on it.
    /// </summary>
    public class GoalBlock : IBlock
    {
        public GoalBlock(Map map)
        {
            Map = map;
        }

        private Map Map { get; set; }

        public String Label { get { return "Goal"; } }
        public String Name { get { return String.Format("{0}[{1}]", GetType().Name, ID); } }
        public String ID { get { return "g"; } }
        public Image Bitmap { get; set; }
        public Color Color { get { return Color.Green; } }
        public bool MultiSelect { get { return false; } }
        public bool Blocker { get { return false; } }

        public void Action(Entity entity)
        {
            if (entity.Team.Behavior is GoalSeeker)
            {
                entity.Team.Score++;
                //Map.Report(entity, "scored points from", this);
            }
        }
    }

    /// <summary>
    /// Teleporter block allows a free cost connection to any other teleporter block
    /// on the map, so entities can use them to quickly traverse large sections of get
    /// to inaccessible areas.
    /// </summary>
    public class TeleporterBlock : IBlock
    {
        public TeleporterBlock(Map map)
        {
            Map = map;
        }

        private Map Map { get; set; }

        public String Label { get { return "Teleporter"; } }
        public String Name { get { return String.Format("{0}[{1}]", GetType().Name, ID); } }
        public String ID { get { return "x"; } }
        public Image Bitmap { get; set; }
        public Color Color { get { return Color.DarkOrchid; } }
        public bool MultiSelect { get { return false; } }
        public bool Blocker { get { return false; } }

        public void Action(Entity entity)
        {
            Map.Report(this, "teleported", entity);
        }
    }

    /// <summary>
    /// Fire block will instantly kill any entity that walks upon it.
    /// </summary>
    public class FireBlock : IBlock
    {
        public FireBlock(Map map)
        {
            Map = map;
        }

        private Map Map { get; set; }

        public String Label { get { return "Fire"; } }
        public String Name { get { return String.Format("{0}[{1}]", GetType().Name, ID); } }
        public String ID { get { return "d"; } }
        public Image Bitmap { get; set; }
        public Color Color { get { return Color.Tomato; } }
        public bool MultiSelect { get { return true; } }
        public bool Blocker { get { return false; } }

        public void Action(Entity entity)
        {
            Map.Kill(entity, this);
        }
    }

    /// <summary>
    /// Spawn block allows an assigned team to spawn from it.
    /// </summary>
    public class SpawnBlock : IBlock
    {
        public SpawnBlock(Map map, Team team)
        {
            Map = map;
            Team = team;
        }

        private Map Map { get; set; }

        public String Label { get { return Team.Name + " Spawn"; } }
        public String Name { get { return String.Format("{0}[{1}]", GetType().Name, Team.Name); } }
        public String ID { get { return "t" + Team.ID; } }
        public Team Team;
        public Image Bitmap { get; set; }
        public Color Color { get { return Team.Color; } }
        public bool MultiSelect { get { return false; } }
        public bool Blocker { get { return false; } }

        public void Action(Entity entity)
        {
            //Map.Report(this, "spawned", entity);
        }
    }
}
