Exemple #1
0
 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);
 }
Exemple #2
0
 protected virtual void OnInventoryMoneyChanged(Inventory inventory, long oldMoney)
 {
     if (inventory == Inventory)
     {
         NotifyCenter.PostNotify(InventoryMoneyChangedMsgKey, inventory, oldMoney);
     }
 }
Exemple #3
0
 protected virtual void OnInventoryWeightChanged(Inventory inventory, float oldWeightLimit)
 {
     if (inventory == Inventory)
     {
         NotifyCenter.PostNotify(InventoryMoneyChangedMsgKey, inventory, oldWeightLimit);
     }
 }
Exemple #4
0
 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);
         }
     });
Exemple #6
0
 /// <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);
     }
 }
Exemple #7
0
 /// <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);
        }
    }
Exemple #10
0
 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);
 }
Exemple #12
0
 protected override void RegisterNotify()
 {
     NotifyCenter.RemoveListener(this);
     if (SourceHandler != null)
     {
         NotifyCenter.AddListener(SourceHandler.ItemAmountChangedMsgKey, OnItemAmountChanged, this);
     }
 }
Exemple #13
0
 protected override void OnDestroy_()
 {
     if (handler != null)
     {
         NotifyCenter.RemoveListener(handler.ItemAmountChangedMsgKey, OnItemAmountChanged);
     }
     base.OnDestroy_();
 }
Exemple #14
0
 private void GatherCancel()
 {
     //PlayerManager.Instance.Controller.Animator.SetInteger(animaNameHash, -1);
     FinishInteraction();
     if (IsGathering)
     {
         NotifyCenter.PostNotify(NotifyCenter.CommonKeys.GatheringStateChanged, false);
     }
     IsGathering = false;
 }
Exemple #15
0
 private void GatherStart()
 {
     doneAgent = null;
     if (!IsGathering)
     {
         NotifyCenter.PostNotify(NotifyCenter.CommonKeys.GatheringStateChanged, true);
     }
     IsGathering = true;
     ProgressBar.Instance.New(Resource.ResourceInfo.GatherTime, GatherDone, GatherCancel, "采集中");
 }
Exemple #16
0
 public void Recycle()
 {
     NotifyCenter.RemoveListener(this);
     if (MapManager.Instance)
     {
         MapManager.Instance.RemoveMapIcon(mapIcon, true);
     }
     questHolder = null;
     mapIcon     = null;
     ObjectPool.Put(gameObject);
 }
Exemple #17
0
 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);
         }
     }
 }
Exemple #18
0
 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);
 }
Exemple #19
0
 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);
 }
Exemple #20
0
 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);
    }
Exemple #23
0
    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);
        }
    }
Exemple #24
0
 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);
 }
Exemple #25
0
 protected override void OnEnter()
 {
     base.OnEnter();
     NotifyCenter.AddListener(Window.WindowStateChanged, OnWindowStateChanged, this);
 }
Exemple #26
0
 protected override void OnExit()
 {
     NotifyCenter.RemoveListener(this);
 }
Exemple #27
0
 private void OnDestroy()
 {
     NotifyCenter.RemoveListener(this);
 }
Exemple #28
0
 private void Start()
 {
     NotifyCenter.AddListener(QuestManager.QuestStateChanged, OnQuestStateChanged, this);
     NotifyCenter.AddListener(QuestManager.ObjectiveUpdate, OnObjectiveUpdate, this);
     Defocus();
 }
Exemple #29
0
 protected override void RegisterNotify()
 {
     NotifyCenter.AddListener(QuestManager.QuestStateChanged, OnQuestStateChanged, this);
     NotifyCenter.AddListener(QuestManager.ObjectiveUpdate, OnObjectiveUpdate, this);
 }
Exemple #30
0
 /// <summary>
 /// 取消消息监听
 /// </summary>
 protected virtual void UnregisterNotify()
 {
     NotifyCenter.RemoveListener(this);
 }