//包含Flag public static bool Contains(this List <UnitFlagValue> list, UnitFlag flag) { foreach (var item in list) { if (item.flag == flag) { return(true); } } return(false); }
//设置标旗 public void SetFlag(UnitFlag flag, bool value) { //Debug.Log(string.Format("{0}标旗:{1}", value ? "添加" : "移除", flag.ToString())); int modiify = value ? 1 : -1; flagValueDic[flag] += modiify; //该单位是玩家,且刚恢复控制 if (GameManager.Player == this && flag == UnitFlag.Uncontrollable && !HasFlag(UnitFlag.Uncontrollable)) { //触发回调 PlayerController.OnBecomeControllable(); } }
//具有标旗 public bool HasFlag(UnitFlag flag) { return(flagValueDic[flag] > 0); }