public void Init(Talker questHolder) { this.questHolder = questHolder; if (MapManager.Instance) { if (mapIcon) { MapManager.Instance.RemoveMapIcon(mapIcon, true); } mapIcon = MapManager.Instance.CreateMapIcon(notAccepted, Vector2.one * 48, questHolder.GetData <TalkerData>().currentPosition, false, MapIconType.Quest, false); mapIcon.iconImage.raycastTarget = false; mapIcon.Hide(); } triggerNames.Clear(); foreach (var quest in questHolder.QuestInstances) { Condition find = quest.Model.AcceptCondition.Conditions.Find(x => x.Type == ConditionType.TriggerSet || x.Type == ConditionType.TriggerReset); if (find) { triggerNames.Add(find.TriggerName); } } UpdateUI(); Update(); NotifyCenter.RemoveListener(this); NotifyCenter.AddListener(QuestManager.QuestStateChanged, _ => UpdateUI(), this); NotifyCenter.AddListener(QuestManager.ObjectiveUpdate, _ => UpdateUI(), this); NotifyCenter.AddListener(NotifyCenter.CommonKeys.TriggerChanged, OnTriggerChange, this); }
protected virtual void OnInventoryMoneyChanged(Inventory inventory, long oldMoney) { if (inventory == Inventory) { NotifyCenter.PostNotify(InventoryMoneyChangedMsgKey, inventory, oldMoney); } }
protected virtual void OnInventoryWeightChanged(Inventory inventory, float oldWeightLimit) { if (inventory == Inventory) { NotifyCenter.PostNotify(InventoryMoneyChangedMsgKey, inventory, oldWeightLimit); } }
protected virtual void OnInventorySpaceChanged(Inventory inventory, int oldSpaceLimit) { if (inventory == Inventory) { NotifyCenter.PostNotify(InventoryMoneyChangedMsgKey, inventory, oldSpaceLimit); } }
public void DestroyStructure(StructureData structure) { if (!structure) { return; } ConfirmWindow.StartConfirm(string.Format("确定拆毁{0}{1}吗?", structure.Name, (Vector2)transform.position), delegate { if (structure) { if (this.structures.TryGetValue(structure.Info.ID, out var structures)) { structures.Remove(structure); if (structures.Count < 1) { this.structures.Remove(structure.Info.ID); } } if (structure.entity && structure.entity.gameObject) { UpdateAStar(structure.entity); structure.entity.Destroy(); } else if (structure.preview && structure.preview.gameObject) { UpdateAStar(structure.preview); structure.preview.Destroy(); } NotifyCenter.PostNotify(StructureDestroy, structure, structures); } });
/// <summary> /// 打开窗口 /// </summary> /// <param name="args">变长参数</param> /// <returns>是否成功打开</returns> public bool Open(params object[] args) { args ??= new object[0]; if (OnOpen(args)) { WindowsManager.Push(this); NotifyCenter.PostNotify(WindowStateChanged, GetType().Name, WindowStates.Open); IsOpen = true; closeBy = null; if (animated) { IFadeAble <Window> .FadeTo(this, 1, duration, () => content.blocksRaycasts = true); } else { content.alpha = 1; content.blocksRaycasts = true; } return(true); } else { return(false); } }
/// <summary> /// 关闭窗口 /// </summary> /// <param name="args">变长参数</param> /// <returns>是否成功关闭</returns> public bool Close(params object[] args) { args ??= new object[0]; if (OnClose(args)) { WindowsManager.Remove(this); NotifyCenter.PostNotify(WindowStateChanged, GetType().Name, WindowStates.Closed); IsOpen = false; onClose?.Invoke(); onClose = null; openBy = null; if (animated) { content.blocksRaycasts = false; IFadeAble <Window> .FadeTo(this, 0, duration); } else { content.alpha = 0; content.blocksRaycasts = false; } return(true); } else { return(false); } }
protected override void OnEnter() { base.OnEnter(); Character.SetSubState(CharacterBusyStates.UI); NotifyCenter.AddListener(MakingManager.MakingCanceled, OnMakingCanceled, this); making = WindowsManager.FindWindow <MakingWindow>(); }
public void UseItem(ItemData item) { if (!item.Model_old.Usable) { MessageManager.Instance.New("该物品不可使用"); return; } bool used = false; if (item.Model_old.IsBox) { used = UseBox(item); } else if (item.Model_old.IsEquipment) { used = UseEuipment(item); } else if (item.Model_old.IsBook) { used = UseBook(item); } else if (item.Model_old.IsBag) { used = UseBag(item); } else if (item.Model_old.IsForQuest) { used = UseQuest(item); } if (used) { NotifyCenter.PostNotify(BackpackUseItem, item); } }
private void OnDestroy() { if (MapManager.Instance) { MapManager.Instance.RemoveMapIcon(mapIcon); } NotifyCenter.RemoveListener(this); }
protected override void RegisterNotify() { NotifyCenter.AddListener(InventoryMoneyChangedMsgKey, OnInventoryMoneyChanged, this); NotifyCenter.AddListener(InventorySpaceChangedMsgKey, OnInventorySpaceChanged, this); NotifyCenter.AddListener(InventoryWeightChangedMsgKey, OnInventoryWeightChanged, this); NotifyCenter.AddListener(ItemAmountChangedMsgKey, OnItemAmountChanged, this); NotifyCenter.AddListener(SlotStateChangedMsgKey, OnSlotStateChanged, this); }
protected override void RegisterNotify() { NotifyCenter.RemoveListener(this); if (SourceHandler != null) { NotifyCenter.AddListener(SourceHandler.ItemAmountChangedMsgKey, OnItemAmountChanged, this); } }
protected override void OnDestroy_() { if (handler != null) { NotifyCenter.RemoveListener(handler.ItemAmountChangedMsgKey, OnItemAmountChanged); } base.OnDestroy_(); }
private void GatherCancel() { //PlayerManager.Instance.Controller.Animator.SetInteger(animaNameHash, -1); FinishInteraction(); if (IsGathering) { NotifyCenter.PostNotify(NotifyCenter.CommonKeys.GatheringStateChanged, false); } IsGathering = false; }
private void GatherStart() { doneAgent = null; if (!IsGathering) { NotifyCenter.PostNotify(NotifyCenter.CommonKeys.GatheringStateChanged, true); } IsGathering = true; ProgressBar.Instance.New(Resource.ResourceInfo.GatherTime, GatherDone, GatherCancel, "采集中"); }
public void Recycle() { NotifyCenter.RemoveListener(this); if (MapManager.Instance) { MapManager.Instance.RemoveMapIcon(mapIcon, true); } questHolder = null; mapIcon = null; ObjectPool.Put(gameObject); }
public void TimePass(float time) { if (Info.EmptyAble && Info.RefreshTime > 0) { leftRefreshTime -= time; if (leftRefreshTime <= 0) { leftRefreshTime = Info.RefreshTime; LeftAmount += Random.Range(Info.MinRefreshAmount, Info.MaxRefreshAmount); NotifyCenter.PostNotify(ShopManager.VendorGoodsRefresh, this); } } }
public void SetTrigger(string triggerName, bool value) { if (!triggers.ContainsKey(triggerName)) { triggers.Add(triggerName, value ? TriggerState.On : TriggerState.Off); } else { triggers[triggerName] = value ? TriggerState.On : TriggerState.Off; } OnTriggerSetEvent?.Invoke(triggerName, value); NotifyCenter.PostNotify(NotifyCenter.CommonKeys.TriggerChanged, triggerName, value); }
public void Init() { foreach (var quest in questsInProgress) { foreach (ObjectiveData o in quest.Objectives) { RemoveObjectiveMapIcon(o); } } questsInProgress.Clear(); questsFinished.Clear(); NotifyCenter.RemoveListener(this); NotifyCenter.AddListener(NotifyCenter.CommonKeys.TriggerChanged, OnTriggerChange); }
private void GatherDone() { //PlayerManager.Instance.Controller.Animator.SetInteger(animaNameHash, -1); if (!Resource) { return; } FinishInteraction(); Resource.GatherSuccess(); if (IsGathering) { NotifyCenter.PostNotify(NotifyCenter.CommonKeys.GatheringStateChanged, false); } IsGathering = false; doneAgent = Resource; StartCoroutine(UpdateDistance()); }
/// <summary> /// 扩展负重 /// </summary> /// <param name="weightLoad">扩展数量</param> /// <returns>是否成功扩展</returns> public bool ExpandLoad(float weightLoad) { if (weightLoad < 0.01f) { return(false); } if (maxWeightLimit > 0 && Inventory.WeightLimit >= maxWeightLimit) { MessageManager.Instance.New(Name + "已经达到最大扩展载重了"); return(false); } float finallyExpand = maxWeightLimit > 0 ? (Inventory.WeightLimit + weightLoad > maxWeightLimit ? maxWeightLimit - Inventory.WeightLimit : weightLoad) : weightLoad; Inventory.ExpandLoad(weightLoad); NotifyCenter.PostNotify(BackpackWeightChanged); MessageManager.Instance.New(Name + "载重增加了" + finallyExpand.ToString("F2")); return(true); }
/// <summary> /// 扩展容量 /// </summary> /// <param name="space">扩展数量</param> /// <returns>是否成功扩展</returns> public bool ExpandSpace(int space) { if (space < 1) { return(false); } if (maxSpaceLimit > 0 && Inventory.SpaceLimit >= maxSpaceLimit) { MessageManager.Instance.New(Name + "已经达到最大容量了"); return(false); } int finallyExpand = maxSpaceLimit > 0 ? (Inventory.SpaceLimit + space > maxSpaceLimit ? maxSpaceLimit - Inventory.SpaceLimit : space) : space; Inventory.ExpandSpace(finallyExpand); NotifyCenter.PostNotify(BackpackSpaceChanged); MessageManager.Instance.New(Name + "空间增加了" + finallyExpand); return(true); }
public void PlantCrop(CropInformation crop, Vector3 position) { if (!crop) { return; } if (FData.spaceOccup < crop.Size) { MessageManager.Instance.New("空间不足"); return; } CropData cropData = FData.PlantCrop(crop); if (cropData) { Crop entity = ObjectPool.Get(crop.Prefab, transform); entity.Init(cropData, this, position); NotifyCenter.PostNotify(FieldManager.FieldCropPlanted, this, cropData); } }
public bool Learn(ItemBase item) { if (!item) { return(false); } if (item.MakingMethod == MakingMethod.None || !item.Formulation || item.Formulation.Materials.Count < 1) { MessageManager.Instance.New("无法制作的道具"); return(false); } if (HadLearned(item)) { ConfirmWindow.StartConfirm("已经学会制作 [" + item.Name + "],无需再学习。"); return(false); } LearnedItems.Add(item); //MessageManager.Instance.NewMessage(string.Format("学会了 [{0}] 的制作方法!", item.name)); ConfirmWindow.StartConfirm(string.Format("学会了 [{0}] 的制作方法!", item.Name)); NotifyCenter.PostNotify(LearnedNewMakingItem, item); return(true); }
protected override void OnEnter() { base.OnEnter(); NotifyCenter.AddListener(Window.WindowStateChanged, OnWindowStateChanged, this); }
protected override void OnExit() { NotifyCenter.RemoveListener(this); }
private void OnDestroy() { NotifyCenter.RemoveListener(this); }
private void Start() { NotifyCenter.AddListener(QuestManager.QuestStateChanged, OnQuestStateChanged, this); NotifyCenter.AddListener(QuestManager.ObjectiveUpdate, OnObjectiveUpdate, this); Defocus(); }
protected override void RegisterNotify() { NotifyCenter.AddListener(QuestManager.QuestStateChanged, OnQuestStateChanged, this); NotifyCenter.AddListener(QuestManager.ObjectiveUpdate, OnObjectiveUpdate, this); }
/// <summary> /// 取消消息监听 /// </summary> protected virtual void UnregisterNotify() { NotifyCenter.RemoveListener(this); }