using System; using GameCore; using Newtonsoft.Json; using UnityEngine; namespace EventMowForTreasure { public class EventMowForTreasureObstacleData : IComparable { public int IsBrokeInt = 0; public EEventMowForTreasureObstacleType Type; public void SetData(EventMowForTreasureObstacleData data) { IsBrokeInt = data.IsBrokeInt; Type = data.Type; } [JsonIgnore] public bool IsBroke { get=>IsBrokeInt == 1; set => IsBrokeInt = value ? 1 : 0; } [JsonIgnore] public Vector2Int Coordinate; [JsonIgnore] public ItemData ItemData; [JsonIgnore] public bool IsCollectionReward=> Type is EEventMowForTreasureObstacleType.CommonReward or EEventMowForTreasureObstacleType.ModerateReward or EEventMowForTreasureObstacleType.HeightReward; [JsonIgnore] public bool IsObstacleCell=>Type is EEventMowForTreasureObstacleType.CommonObstacle or EEventMowForTreasureObstacleType.HeightObstacle; [JsonIgnore] public bool IsSpecialReward=>Type is EEventMowForTreasureObstacleType.SpecialReward; #region A* [JsonIgnore] public float GCost; // 从起点到当前节点的代价 [JsonIgnore] public float HCost; // 从当前节点到终点的启发式代价 [JsonIgnore] public float FCost => GCost + HCost; [JsonIgnore] public EventMowForTreasureObstacleData Parent; public int CompareTo(EventMowForTreasureObstacleData other) { var compare = FCost.CompareTo(other.FCost); if (compare == 0) compare = HCost.CompareTo(other.HCost); return compare; } public void Reset() { GCost = 0; HCost = 0; Parent = null; } #endregion } }