Esempio n. 1
0
 public void DestroyCrop()
 {
     ConfirmWindow.StartConfirm("销毁作物不会有任何产物,确定销毁吗?", delegate
     {
         window.Remove(Data);
     });
 }
Esempio n. 2
0
    public void Confirm()
    {
        if (copySlots.Count < 1)
        {
            MessageManager.Instance.New("未选择任何物品");
            return;
        }
        List <ItemWithAmount> items = new List <ItemWithAmount>();

        foreach (var kvp in copySlots)
        {
            items.Add(new ItemWithAmount(kvp.Value.Item, kvp.Value.Data.amount));
        }
        confirm = true;
        if (string.IsNullOrEmpty(dialog))
        {
            onConfirm?.Invoke(items);
            Close();
        }
        else
        {
            ConfirmWindow.StartConfirm(dialog, delegate
            {
                onConfirm?.Invoke(items);
                Close();
            });
        }
    }
Esempio n. 3
0
 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);
         }
     });
Esempio n. 4
0
 /// <summary>
 /// 放弃当前展示的任务
 /// </summary>
 public void AbandonSelectedQuest()
 {
     if (!selectedQuest)
     {
         return;
     }
     ConfirmWindow.StartConfirm("已消耗的道具不会退回,确定放弃此任务吗?", delegate
     {
         if (QuestManager.Instance.AbandonQuest(selectedQuest))
         {
             ShowOrHideDescription(false);
         }
     });
 }
Esempio n. 5
0
 public bool Learn(StructureInformation structureInfo)
 {
     if (!structureInfo)
     {
         return(false);
     }
     if (HadLearned(structureInfo))
     {
         ConfirmWindow.StartConfirm("这种设施已经学会建造。");
         return(false);
     }
     StructuresLearned.Add(structureInfo);
     ConfirmWindow.StartConfirm(string.Format("学会了 [{0}] 的建造方法!", structureInfo.Name));
     return(true);
 }
Esempio n. 6
0
    /// <summary>
    /// 向玩家卖出道具
    /// </summary>
    /// <param name="goods">商品信息</param>
    public void SellItem(GoodsData goods)
    {
        if (MShop == null || goods == null || !goods.Info.IsValid)
        {
            return;
        }
        if (!MShop.Commodities.Contains(goods))
        {
            return;
        }
        long maxAmount = goods.Info.EmptyAble ? goods.LeftAmount : (goods.Info.SellPrice > 0 ? BackpackManager.Instance.Inventory.Money / goods.Info.SellPrice : 999);

        if (goods.LeftAmount == 1 && goods.Info.EmptyAble)
        {
            ConfirmWindow.StartConfirm(string.Format("确定购买1个 [{0}] 吗?", goods.Item.Name), delegate
            {
                if (OnSell(goods))
                {
                    MessageManager.Instance.New(string.Format("购买了1个 [{0}]", goods.Item.Name));
                }
            });
        }
        else if (goods.IsEmpty)
        {
            ConfirmWindow.StartConfirm("该商品暂时缺货");
        }
        else
        {
            AmountWindow.StartInput(delegate(long amount)
            {
                ConfirmWindow.StartConfirm(string.Format("确定购买{0}个 [{1}] 吗?", (int)amount, goods.Item.Name), delegate
                {
                    if (OnSell(goods, (int)amount))
                    {
                        MessageManager.Instance.New(string.Format("购买了{0}个 [{1}]", (int)amount, goods.Item.Name));
                    }
                });
            }, maxAmount, "购买数量", ZetanUtility.ScreenCenter, Vector2.zero);
        }
    }
Esempio n. 7
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);
 }
Esempio n. 8
0
    /// <summary>
    /// 从玩家那里购入道具
    /// </summary>
    /// <param name="data">商品信息</param>
    public void PurchaseItem(GoodsData data)
    {
        if (MShop == null || data == null || !data.IsValid)
        {
            return;
        }
        if (!MShop.Acquisitions.Contains(data))
        {
            return;
        }
        int backpackAmount = BackpackManager.Instance.GetAmount(data.Item);
        int maxAmount      = data.Info.EmptyAble ? (data.LeftAmount > backpackAmount ? backpackAmount : data.LeftAmount) : backpackAmount;

        if (data.LeftAmount == 1 && data.Info.EmptyAble)
        {
            ConfirmWindow.StartConfirm(string.Format("确定出售1个 [{0}] 吗?", data.Item.Name), delegate
            {
                if (OnPurchase(data, 1))
                {
                    MessageManager.Instance.New(string.Format("出售了1个 [{1}]", 1, data.Item.Name));
                }
            });
        }
        else if (data.IsEmpty)
        {
            ConfirmWindow.StartConfirm("这种物品暂无特价收购需求,确定按原价出售吗?", delegate
            {
                if (BackpackManager.Instance.GetItemData(data.Item, out var item, out var amount))
                {
                    PurchaseItem(item, amount, true);
                }
                else
                {
                    MessageManager.Instance.New($"{BackpackManager.Instance.Name}中没有{data.Item.Name}");
                }
            });
Esempio n. 9
0
 private void Exit()
 {
     ConfirmWindow.StartConfirm("确定退出" + Application.productName + "吗?", Application.Quit);
 }
Esempio n. 10
0
    /// <summary>
    /// 放弃任务
    /// </summary>
    /// <param name="quest">要放弃的任务</param>
    public bool AbandonQuest(QuestData quest)
    {
        if (!quest.Model.Abandonable)
        {
            ConfirmWindow.StartConfirm("该任务无法放弃。");
        }
        else if (HasOngoingQuest(quest) && quest && quest.Model.Abandonable)
        {
            if (HasQuestNeedAsCondition(quest.Model, out var findQuest))
            {
                //MessageManager.Instance.New($"由于任务[{bindQuest.Title}]正在进行,无法放弃该任务。");
                ConfirmWindow.StartConfirm($"由于任务[{findQuest.Model.Title}]正在进行,无法放弃该任务。");
            }
            else
            {
                bool isCmplt = quest.IsComplete;
                quest.InProgress = false;
                questsInProgress.Remove(quest);
                foreach (ObjectiveData o in quest.Objectives)
                {
                    o.OnStateChangeEvent -= OnObjectiveStateChange;
                    if (o is CollectObjectiveData)
                    {
                        CollectObjectiveData co = o as CollectObjectiveData;
                        co.CurrentAmount   = 0;
                        co.amountWhenStart = 0;
                        BackpackManager.Instance.Inventory.OnItemAmountChanged -= co.UpdateCollectAmount;
                    }
                    if (o is KillObjectiveData ko)
                    {
                        ko.CurrentAmount = 0;
                        switch (ko.Model.KillType)
                        {
                        case KillObjectiveType.Specific:
                            GameManager.Enemies[ko.Model.Enemy.ID].ForEach(e => e.OnDeathEvent -= ko.UpdateKillAmount);
                            break;

                        case KillObjectiveType.Race:
                            foreach (List <Enemy> enemies in GameManager.Enemies.Values.Where(x => x.Count > 0 && x[0].Info.Race && x[0].Info.Race == ko.Model.Race))
                            {
                                enemies.ForEach(e => e.OnDeathEvent -= ko.UpdateKillAmount);
                            }
                            break;

                        case KillObjectiveType.Group:
                            foreach (List <Enemy> enemies in GameManager.Enemies.Values.Where(x => x.Count > 0 && ko.Model.Group.Contains(x[0].Info.ID)))
                            {
                                enemies.ForEach(e => e.OnDeathEvent -= ko.UpdateKillAmount);
                            }
                            break;

                        case KillObjectiveType.Any:
                            foreach (List <Enemy> enemies in GameManager.Enemies.Select(x => x.Value))
                            {
                                enemies.ForEach(e => e.OnDeathEvent -= ko.UpdateKillAmount);
                            }
                            break;
                        }
                    }
                    if (o is TalkObjectiveData to)
                    {
                        to.CurrentAmount = 0;
                        DialogueManager.Instance.Talkers[to.Model.NPCToTalk.ID].objectivesTalkToThis.RemoveAll(x => x == to);
                        DialogueManager.Instance.RemoveDialogueData(to.Model.Dialogue);
                    }
                    if (o is MoveObjectiveData mo)
                    {
                        mo.CurrentAmount = 0;
                        mo.targetPoint   = null;
                        CheckPointManager.Instance.RemoveCheckPointListener(mo.Model.AuxiliaryPos, mo.UpdateMoveState);
                    }
                    if (o is SubmitObjectiveData so)
                    {
                        so.CurrentAmount = 0;
                        DialogueManager.Instance.Talkers[so.Model.NPCToSubmit.ID].objectivesSubmitToThis.RemoveAll(x => x == so);
                    }
                    if (o is TriggerObjectiveData cuo)
                    {
                        cuo.CurrentAmount = 0;
                        TriggerManager.Instance.DeleteTriggerListner(cuo.UpdateTriggerState);
                    }
                    RemoveObjectiveMapIcon(o);
                }
                if (quest.Model.NPCToSubmit)
                {
                    quest.originalQuestHolder.TransferQuestToThis(quest);
                }
                quest.latestHandleDays = TimeManager.Instance.Days;
                NotifyCenter.PostNotify(QuestStateChanged, quest, true);
                return(true);
            }
        }
        MessageManager.Instance.New("该任务未在进行");
        return(false);
    }