using Core.Utilities;
using UnityEngine;
using KTGMGemClient;
namespace TowerDefense.Towers.Placement
{
///
/// An interface for a placement area that can contain a tower
///
public interface IPlacementArea
{
///
/// Gets this object's transform
///
Transform transform { get; }
///
/// 获取当前PlaceMentArea的Size.
///
IntVector2 getdimsize();
///
/// 获取一个可以放置塔防的位置.
///
///
IntVector2 getFreePos(int xdim, int ydim, bool forceGet = false);
///
/// 获取对应位置的充能子弹界面指针.
///
///
///
///
BulletUICtl GetBulletUICtl(int x, int y);
///
/// 获取对应位置的能量条界面指针.
///
///
///
EnergyUICtl GetEnergyUICtl(int x, int y);
///
/// 获取对应位置的水精灵充能条
///
///
///
///
FreezeBreath GetFreezeBreath(int x, int y);
///
/// 是否空置的攻击位
///
///
///
///
bool isFreeAtackPos(int x, int y);
///
/// 是否有已开启的可放置攻击位置。
///
///
bool hasFreeAttackPos();
///
/// 是否是等待购买的攻击塔位.
///
///
///
///
bool isWaitBuyGrid(int x, int y);
void startCoinGenMode();
///
/// 购买对应的待购攻击塔位.
///
///
///
///
bool buyWaitBuyGrid(int x, int y);
///
/// 设置某一个格子为已破坏塔位。
///
///
///
///
bool SetDestroyedGrid(int x, int y);
///
/// 设置格子为合成状态。
///
///
///
///
bool SetComboGrid(int x, int y);
///
/// 设置塔位的血条血量数据
///
///
///
void setTowerPosHealth(int ix, float health);
///
/// Calculates the grid position from a given world position, offset to center for a specific size object
///
IntVector2 WorldToGrid(Vector3 worldPosition, IntVector2 sizeOffset);
///
/// Calculates the snapped world position from a given grid position
///
Vector3 GridToWorld(IntVector2 gridPosition, IntVector2 sizeOffset);
///
/// 当前是否是反方的TowerPlacementGrid.
///
bool isOpponent();
///
/// Gets whether an object of a given size would fit on this grid at the given location
///
/// The grid location
/// The size of the item
/// True if the item would fit at
TowerFitStatus Fits(IntVector2 gridPos, IntVector2 size);
///
/// Occupy the given space on this placement area
///
/// The grid location
/// The size of the item
void Occupy(IntVector2 gridPos, IntVector2 size);
///
/// Clear the given space on this placement area
///
/// The grid location
/// The size of the item
void Clear(IntVector2 gridPos, IntVector2 size);
}
public static class PlacementAreaExtensions
{
///
/// Snaps a given world positionn to this grid
///
public static Vector3 Snap(this IPlacementArea placementArea, Vector3 worldPosition, IntVector2 sizeOffset)
{
// Calculate the nearest grid location and then change that back to world space
return placementArea.GridToWorld(placementArea.WorldToGrid(worldPosition, sizeOffset), sizeOffset);
}
}
}