using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public abstract class TileType {
    public static TileType FireTrap = new FireTrap();
    public static TileType WaterTrap = new WaterTrap();
    public static TileType ObjectiveTile = new ObjectiveTile();   
    public static TileType EmptyTileType = new EmptyTileType();
    public static TileType WallTurnRight = new WallTurnRight(null, null, "WallTurnRight");
    public static TileType WallTurnLeft = new WallTurnLeft(null, null, "WallTurnLeft");
    public static TileType WaterWallRight = new WallTurnRight(new ForceType[] { ForceType.Water }, new ForceType[] { ForceType.Fire }, "WaterWallRight");
    public static TileType WaterWallLeft = new WallTurnLeft(new ForceType[] { ForceType.Water }, new ForceType[] { ForceType.Fire }, "WaterWallLeft");
    //public static TileType FireWallRight = new WallTurnRight(null, null);
    //public static TileType FireWallLeft = new WallTurnLeft(null, null);
    public static TileType WaterTile = new DecorationTile("WaterPrefab");
    public static TileType WallTile = new DecorationTile("WallPrefab");
    public static TileType RoadTile = new DecorationTile("RoadPrefab");

    protected Dictionary<ForceType, bool> forceEffects;

    protected TileType() {
        forceEffects = new Dictionary<ForceType, bool>();
    }

    public abstract string Prefab { get; }
    public abstract void PawnEnters(PawnScript pawn);
    public abstract void PawnStartsTowards(PawnScript pawn);

    public bool DoesForceAffect(ForceType force) {
        return forceEffects.ContainsKey(force);
    }

    public bool GetForceEffect(ForceType force) {
        return forceEffects[force];
    }

    protected void SetForces(IEnumerable<ForceType> forceOn, IEnumerable<ForceType> forceOff) {
        forceEffects = new Dictionary<ForceType, bool>();
        if (forceOn != null) {
            foreach (ForceType force in forceOn) {
                forceEffects[force] = true;
            }
        }

        if (forceOff != null) {
            foreach (ForceType force in forceOff) {
                forceEffects[force] = false;
            }
        }
    }
}
