Example #1
0
    void RemoveGoods(GameObject go, object parameter)
    {
        Parameter.Box p = (Parameter.Box)parameter;
        //CharBag.Goods goods = (CharBag.Goods)p.obj;

        //如果货架上有商品,则添加道具到背包
        if (goodslist[p.ID - 1].Name != null && goodslist[p.ID - 1].ID != 0)
        {
            CharBag.AddGoods(goodslist[p.ID - 1]);
            goodslist[p.ID - 1] = new CharBag.Goods();
        }

        string path = p.ID.ToString() + "/itemIcon";

        transform.Find(path).GetComponent <SpriteRenderer>().sprite = null;

        //取消显示价格
        string priceiconpath = p.ID.ToString() + "/price/icon";
        string pricepath     = p.ID.ToString() + "/price/text";

        transform.Find(priceiconpath).gameObject.SetActive(false);
        transform.Find(pricepath).gameObject.SetActive(false);

        _bagInstance.CloseBagMenu(gameObject);
        ChangeRecipeUiState();

        PlayerData.ShopGoodsData.SaveShopGoods(goodslist);
    }
Example #2
0
        static public void LoadData(string name)
        {
            try
            {
                IFormatter serializer = new BinaryFormatter();
                string     path       = PathKit.GetResourcesPath() + name;
                if (File.Exists(path))
                {
                    FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);

                    datas = serializer.Deserialize(fs) as ArrayList;
                    fs.Close();

                    CharBag.UpdateGoods(datas);

                    Debug.Log("loaded bag");
                }
                else
                {
                    Debug.Log("找不到背包存档!");
                }
            }
            catch (IOException e)
            {
                Debug.Log(e.ToString());
                return;
            }
        }
Example #3
0
    CharBag.Goods CreateGoods()
    {
        CharBag.Goods goods = new CharBag.Goods();
        goods.Property = new int[4];

        for (int i = 0; i < PropertyBox.Count; i++)
        {
            //如果大于最大个数则忽略
            if (i >= 4)
            {
                break;
            }
            PropertyElementBase p = (PropertyElementBase)PropertyBox[i];
            goods.Property[i] = p.Property.ID;
        }

        goods.Quality = Quality;
        goods.Number  = 1;
        goods.Name    = recipe.Name;

        string target = recipe.Target;

        if (target[0] == char.Parse("0"))
        {
            string mat_str = target.Substring(target.IndexOf(",") + 1);
            goods.MateriralType = 0;
            goods.ID            = int.Parse(mat_str);
        }
        else if (target[0] == char.Parse("1"))
        {
            string mat_str = target.Substring(target.IndexOf(",") + 1);
            goods.MateriralType = 1;
            goods.ID            = int.Parse(mat_str);
        }

        goods.Type          = Materiral.GetTypeByMaterialID(goods.MateriralType, goods.ID);
        goods.MaterialEffet = QualityEffectID;

        //计算价格
        goods.Price = Materiral.GetMaterialPrice(goods.MateriralType, goods.ID);
        goods       = CharBag.SetPrice(goods);

        //添加道具
        goods.UID = CharBag.AddGoods(goods);

        questManager.CheckQuestListWithGoods(QuestManager.QuestTypeList.ComposeGoods, goods, 0);
        //更新物品信息
        PlayerInfo.AddGoodsInfo(goods.MateriralType, goods.ID, PlayerInfo.GoodsInfoType.RecipeCount);

        //删除道具
        foreach (SlotBox slot in SlotList.Values)
        {
            CharBag.RemoveGoods(slot.slot.UID);
        }

        return(goods);
    }
Example #4
0
    //上架商品
    void ClickInBag(GameObject go, object parameter)
    {
        Parameter.Box p     = (Parameter.Box)parameter;
        CharBag.Goods goods = (CharBag.Goods)p.obj;

        //如果货架上有商品,则添加道具到背包
        if (goodslist[p.ID - 1].Name != null && goodslist[p.ID - 1].ID != 0)
        {
            CharBag.AddGoods(goodslist[p.ID - 1]);
        }

        //添加选中的商品到商品列
        goodslist[p.ID - 1] = goods;
        string path = p.ID.ToString() + "/itemIcon";

        transform.Find(path).GetComponent <SpriteRenderer>().sprite = Materiral.GetMaterialIcon(goods.MateriralType, goods.ID);

        //显示商品价格
        string priceiconpath = p.ID.ToString() + "/price/icon";
        string pricepath     = p.ID.ToString() + "/price/text";

        transform.Find(priceiconpath).gameObject.SetActive(true);
        transform.Find(pricepath).gameObject.SetActive(true);
        transform.Find(pricepath).GetComponent <TextMesh>().text = goods.Price.ToString();


        //移除背包中的商品
        CharBag.RemoveGoods(goods.UID);

        _bagInstance.CloseBagMenu(gameObject);
        ChangeRecipeUiState();

        PlayerData.ShopGoodsData.SaveShopGoods(goodslist);
        CharBag.SaveBagGoods();

        questManager.CheckQuestListWithGoods(QuestManager.QuestTypeList.PutGoods, goods, 0);

        //更新物品信息
        PlayerInfo.AddGoodsInfo(goods.MateriralType, goods.ID, PlayerInfo.GoodsInfoType.PutCount);
    }
Example #5
0
    // Use this for initialization
    public void Initialize(int type)
    {
        scrollList = BagMenuUI.transform.Find("ScrollList/BagList").gameObject;
        _fitter    = scrollList.transform.Find("GridLayoutPanel").GetComponent <ContentSizeFitter>();
        iteminfo   = Resources.Load <GameObject>("Prefab/ItemInfoUI");
        shopGoods  = transform.Find("ShopGoods").gameObject;

        //获取背包数据
        _bagList  = CharBag.GetGoodsList();
        f_BagList = new ArrayList();
        //设置关闭按钮
        if (type == 1)
        {
            EventTriggerListener.Get(msk_Close).onClick = CloseBagMenu;
        }
        else
        {
            EventTriggerListener.Get(msk_Close).onClick = CloseBagMenuInShop;
            shopGoods.SetActive(true);
        }

        this.transform.SetParent(GameObject.Find("Canvas").transform, false);
        this.transform.SetAsLastSibling();
    }
Example #6
0
    //预检查事件 ,用于显示可以触发的任务
    /// <summary>
    /// 预检查事件 ,用于显示可以触发的任务
    /// sceneID 0;shop;1:map
    /// </summary>
    /// <param name="sceneID"></param>
    /// <returns></returns>
    public void PreCheckEventList(int sceneID)
    {
        ArrayList preCheckEvent = new ArrayList();

        PlayerInfo.Info playerInfo = PlayerInfo.GetPlayerInfo();

        //筛选需要判断的事件
        ArrayList CheckList = new ArrayList();

        foreach (ChatEvent _event in ChatEventsList)
        {
            if (_event.EventType == ChatEvent.EventTypeList.Arrive ||
                _event.EventType == ChatEvent.EventTypeList.InMap ||
                _event.EventType == ChatEvent.EventTypeList.InShop)
            {
                CheckList.Add(_event);
            }
        }

        //事件判断
        foreach (ChatEvent _event in CheckList)
        {
            switch (_event.EventType)
            {
            case ChatEvent.EventTypeList.InShop:
                if (sceneID == 0)
                {
                    break;
                }

                PlayerInfo.SenceInfo shop_senceinfo = (PlayerInfo.SenceInfo)playerInfo.SenceInfoList[0];
                if (_event.Num <= shop_senceinfo.InCount + 1 && !PlayerInfo.CheckEvents(_event.ID))
                {
                    if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                        (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                    {
                        Debug.Log("prehit event: " + _event.ID);
                        preCheckEvent.Add(_event);
                    }
                }
                break;

            case ChatEvent.EventTypeList.InMap:
                if (sceneID == 1)
                {
                    break;
                }

                PlayerInfo.SenceInfo map_senceinfo = (PlayerInfo.SenceInfo)playerInfo.SenceInfoList[1];
                if (_event.Num <= map_senceinfo.InCount + 1 && !PlayerInfo.CheckEvents(_event.ID))
                {
                    if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                        (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                    {
                        Debug.Log("prehit event: " + _event.ID);
                        preCheckEvent.Add(_event);
                    }
                }
                break;

            case ChatEvent.EventTypeList.Arrive:
                foreach (PlayerInfo.MapInfo mapinfo in playerInfo.MapInfoList)
                {
                    if (mapinfo.ID == _event.Parameter[0] && _event.Num <= mapinfo.InCount + 1 && !PlayerInfo.CheckEvents(_event.ID))
                    {
                        if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                            (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                        {
                            Debug.Log("prehit event: " + _event.ID);
                            preCheckEvent.Add(_event);
                        }
                        break;
                    }
                }
                break;

            default:
                Debug.LogWarning("Can't Check EventType:" + _event.EventType + "!");
                break;
            }
        }
        if (preCheckEvent.Count > 0)
        {
            ShowEventHint(sceneID, preCheckEvent);
        }
    }
Example #7
0
    /// <summary>
    /// 用于检查是否触发事件,物品判断的条件不管使用哪个EventType都一样
    /// </summary>
    /// <param name="EventType"></param>
    /// <returns></returns>
    public bool CheckEventList(ChatEvent.EventTypeList EventType, bool ClearStoryList)
    {
        bool ishit = false;

        if (ClearStoryList)
        {
            StoryList = new ArrayList();
        }
        PlayerInfo.Info playerInfo = PlayerInfo.GetPlayerInfo();

        //筛选需要判断的事件
        ArrayList CheckList = new ArrayList();

        foreach (ChatEvent _event in ChatEventsList)
        {
            if (CompareEventType(_event.EventType, EventType))
            {
                CheckList.Add(_event);
            }
        }

        //事件判断
        foreach (ChatEvent _event in CheckList)
        {
            switch (_event.EventType)
            {
            //给物品相关的判断,统一处理
            case ChatEvent.EventTypeList.PutGoods:
            case ChatEvent.EventTypeList.SellGoods:
            case ChatEvent.EventTypeList.ComposeGoods:
            case ChatEvent.EventTypeList.CollectGoods:
            case ChatEvent.EventTypeList.ComposeProperty:
                if (_event.EventType == ChatEvent.EventTypeList.ComposeProperty)
                {
                    foreach (PlayerInfo.PropertysInfo pinfo in playerInfo.MaterialInfoList.Propertys)
                    {
                        if (pinfo.ID == _event.Parameter[0] && _event.Num <= pinfo.RecipeCount && !PlayerInfo.CheckEvents(_event.ID))
                        {
                            if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                            {
                                ishit = true;
                                PlayerInfo.AddEvents(_event.ID);
                                Debug.Log("hit event: " + _event.ID);
                                AddStroyName(_event);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    if (_event.Parameter == null || _event.Parameter.Length <= 0)
                    {
                        Debug.LogWarning("事件配置表Parameter出错! eventID:" + _event.ID);
                    }
                    if (_event.Parameter[0] == 0)
                    {
                        foreach (PlayerInfo.ItemsInfo items in playerInfo.MaterialInfoList.Items)
                        {
                            if (items.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.PutGoods && _event.Num <= items.PutCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                            else if (items.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.SellGoods && _event.Num <= items.SellCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                            else if (items.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.ComposeGoods && _event.Num <= items.RecipeCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                            else if (items.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.CollectGoods && _event.Num <= items.CollectCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                        }
                    }       //item
                    else if (_event.Parameter[0] == 1)
                    {
                        foreach (PlayerInfo.MindsInfo minds in playerInfo.MaterialInfoList.Minds)
                        {
                            if (minds.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.PutGoods && _event.Num <= minds.PutCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                            else if (minds.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.SellGoods && _event.Num <= minds.SellCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                            else if (minds.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.ComposeGoods && _event.Num <= minds.RecipeCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                            else if (minds.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.CollectGoods && _event.Num <= minds.CollectCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                        }
                    }       //mind
                    else if (_event.Parameter[0] == 2)
                    {
                        foreach (PlayerInfo.SpecialItemsInfo spitems in playerInfo.MaterialInfoList.SpecialItems)
                        {
                            if (spitems.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.PutGoods && _event.Num <= spitems.PutCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                            else if (spitems.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.SellGoods && _event.Num <= spitems.SellCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                            else if (spitems.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.ComposeGoods && _event.Num <= spitems.RecipeCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                            else if (spitems.ID == _event.Parameter[1] && _event.EventType == ChatEvent.EventTypeList.CollectGoods && _event.Num <= spitems.CollectCount && !PlayerInfo.CheckEvents(_event.ID))
                            {
                                if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                                    (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                                {
                                    ishit = true;
                                    PlayerInfo.AddEvents(_event.ID);
                                    Debug.Log("hit event: " + _event.ID);
                                    AddStroyName(_event);
                                    break;
                                }
                            }
                        }
                    }       //specail
                }
                break;

            case ChatEvent.EventTypeList.InShop:
                PlayerInfo.SenceInfo shop_senceinfo = (PlayerInfo.SenceInfo)playerInfo.SenceInfoList[0];
                if (_event.Num <= shop_senceinfo.InCount && !PlayerInfo.CheckEvents(_event.ID))
                {
                    if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                        (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                    {
                        ishit = true;
                        PlayerInfo.AddEvents(_event.ID);
                        Debug.Log("hit event: " + _event.ID);
                        AddStroyName(_event);
                    }
                }
                break;

            case ChatEvent.EventTypeList.InMap:
                PlayerInfo.SenceInfo map_senceinfo = (PlayerInfo.SenceInfo)playerInfo.SenceInfoList[1];
                if (_event.Num <= map_senceinfo.InCount && !PlayerInfo.CheckEvents(_event.ID))
                {
                    if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                        (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                    {
                        ishit = true;
                        PlayerInfo.AddEvents(_event.ID);
                        Debug.Log("hit event: " + _event.ID);
                        AddStroyName(_event);
                    }
                }
                break;

            case ChatEvent.EventTypeList.Arrive:
                foreach (PlayerInfo.MapInfo mapinfo in playerInfo.MapInfoList)
                {
                    if (mapinfo.ID == _event.Parameter[0] && _event.Num <= mapinfo.InCount && !PlayerInfo.CheckEvents(_event.ID))
                    {
                        if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                            (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                        {
                            ishit = true;
                            PlayerInfo.AddEvents(_event.ID);
                            Debug.Log("hit event: " + _event.ID);
                            AddStroyName(_event);
                        }
                        break;
                    }
                }
                break;

            case ChatEvent.EventTypeList.Mines:
                if (_event.Num <= playerInfo.MineCount && !PlayerInfo.CheckEvents(_event.ID))
                {
                    if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                        (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                    {
                        ishit = true;
                        PlayerInfo.AddEvents(_event.ID);
                        Debug.Log("hit event: " + _event.ID);
                        AddStroyName(_event);
                    }
                }
                break;

            case ChatEvent.EventTypeList.Golds:
                if (_event.Num <= playerInfo.Money && !PlayerInfo.CheckEvents(_event.ID))
                {
                    if (((_event.EventItem == null) || (_event.EventItem != null && CharBag.ContainsGoods(_event.EventItem[0], _event.EventItem[1]))) &&
                        (_event.NeedQuest == 0 || (_event.NeedQuest != 0 && PlayerInfo.CheckCompleteQuest(_event.NeedQuest))))
                    {
                        ishit = true;
                        PlayerInfo.AddEvents(_event.ID);
                        Debug.Log("hit event: " + _event.ID);
                        AddStroyName(_event);
                    }
                }
                break;

            default:
                Debug.LogWarning("Can't Check EventType:" + EventType + "!");
                ishit = false;
                break;
            }
        }
        return(ishit);
    }
Example #8
0
    void GetQuestAward(GameObject go)
    {
        Transform Board      = go.transform.parent.parent;
        Transform root       = Board.parent;
        Transform MoneyBoard = transform.Find("/ToolsKit/Canvas/PlayerInfo/glodBoard");
        Transform mineBoard  = transform.Find("/ToolsKit/Canvas/PlayerInfo/mineBoard");
        //Award
        Transform awardGold  = Board.transform.Find("QuestBoard/award/Gold");
        Transform awardExp   = Board.transform.Find("QuestBoard/award/Exp");
        Transform AwardGoods = Board.transform.Find("QuestBoard/award/Goods");

        QuestManager.QuestBase info = questManager.GetQuestInfoByID(int.Parse(Board.name));

        //增加奖励
        PlayerInfo.ChangeMoney(info.Award.Gold);
        for (int i = 0; i < info.Award.GoodsNum; i++)
        {
            CharBag.AddGoodsByID(info.Award.Goods[0], info.Award.Goods[1]);
        }

        //完成任务
        PlayerInfo.AddCompleteQuest(info.ID);
        questManager.RemoveQuestToList(info.ID);
        //销毁任务面板的任务
        Transform questbutton = QuestListUI.transform.Find(info.ID.ToString());

        if (questbutton != null)
        {
            Destroy(questbutton.gameObject);
        }

        //生成金币
        for (int i = 0; i < info.Award.Gold; i = i + 50)
        {
            Transform gold = Instantiate(awardGold, root);
            gold.position = awardGold.position;
            float randomrange = 100f;
            float time        = 0.5f;
            LeanTween.moveY(gold.gameObject, gold.position.y + Random.Range(-randomrange, randomrange), time).setEase(LeanTweenType.easeOutSine);
            LeanTween.moveX(gold.gameObject, gold.position.x + Random.Range(-randomrange, randomrange), time).setEase(LeanTweenType.easeOutSine);

            LeanTween.moveX(gold.gameObject, MoneyBoard.position.x, time).setDelay(time * Random.Range(1.5f, 2f));
            LeanTween.moveY(gold.gameObject, MoneyBoard.position.y, time).setDelay(time * Random.Range(1.5f, 2f)).setOnComplete(
                () =>
            {
                Destroy(gold.gameObject);
            });
            if (i > 500)
            {
                break;
            }
        }

        //生成经验
        for (int i = 0; i < info.Award.Exp; i = i + 50)
        {
            Transform exp = Instantiate(awardExp, root);
            exp.position = awardExp.position;
            float randomrange = 100f;
            float time        = 0.5f;
            LeanTween.moveY(exp.gameObject, exp.position.y + Random.Range(-randomrange, randomrange), time).setEase(LeanTweenType.easeOutSine);
            LeanTween.moveX(exp.gameObject, exp.position.x + Random.Range(-randomrange, randomrange), time).setEase(LeanTweenType.easeOutSine);

            LeanTween.moveX(exp.gameObject, mineBoard.position.x, time).setDelay(time * Random.Range(1.5f, 2f));
            LeanTween.moveY(exp.gameObject, mineBoard.position.y, time).setDelay(time * Random.Range(1.5f, 2f)).setOnComplete(
                () =>
            {
                Destroy(exp.gameObject);
            });

            if (i > 500)
            {
                break;
            }
        }

        //生成物品
        for (int i = 0; i < info.Award.GoodsNum; i++)
        {
            Transform goods = Instantiate(AwardGoods, root);
            goods.position = AwardGoods.position;
            float randomrange = 100f;
            float time        = 0.5f;
            LeanTween.moveY(goods.gameObject, AwardGoods.position.y + Random.Range(-randomrange, randomrange), time).setEase(LeanTweenType.easeOutSine);
            LeanTween.moveX(goods.gameObject, AwardGoods.position.x + Random.Range(-randomrange, randomrange), time).setEase(LeanTweenType.easeOutSine);

            LeanTween.moveX(goods.gameObject, mineBoard.position.x + 100, time).setDelay(time * Random.Range(1.5f, 2f));
            LeanTween.moveY(goods.gameObject, mineBoard.position.y, time).setDelay(time * Random.Range(1.5f, 2f)).setOnComplete(
                () =>
            {
                Destroy(goods.gameObject);
            });

            if (i > 10)
            {
                break;
            }
        }

        LeanTween.moveLocalY(go.transform.parent.gameObject, Screen.height / 2 + 200, 0.3f).setEaseInBack().setOnComplete(() =>
        {
            Destroy(Board.gameObject);

            //添加完成的事件
            if (info.Award.Event != 0)
            {
                eventmanager.AddStroyWithEventID(info.Award.Event);
            }

            if (!questManager.IsArriveWaitingCheckPoint(0))
            {
                eventmanager.StartStory();
            }
        });

        //延迟更新显示
        LeanTween.delayedCall(0.5f * 2f, () => {
            PlayerInfo.Info playerInfo = PlayerInfo.GetPlayerInfo();
            MoneyBoard.Find("Text").GetComponent <Text>().text = playerInfo.Money.ToString();
        });
    }
Example #9
0
    //通过进入地图的id筛选出道具,然后通过权重选出拾取的东西。
    //如果以后会有专门进入地图的设定的话,则可以吧判断地图id筛选道具列表的方法单独移出。
    public void CollectionAction(int ap, RectTransform rect)
    {
        Debug.Log("mine:" + ap);

        //筛选出可以掉落的道具
        int       mapid = ap;
        ArrayList List  = new ArrayList();

        int max = 0;

        foreach (CollectionMap materiral in CollectionList)
        {
            if (materiral.Map == mapid)
            {
                List.Add(materiral);
                //获取随机范围
                max += materiral.Weight;
            }
        }

        //随机权重,选出拾取哪个道具
        CharBag.Goods dropMa = new CharBag.Goods();
        dropMa.Property = new int[4];

        int point = Random.Range(1, max);
        int check = 0;

        foreach (CollectionMap materiral in List)
        {
            check += materiral.Weight;

            if (check >= point)
            {
                //指定掉落的材料
                dropMa.MateriralType = materiral.MateriralType;

                dropMa.ID = materiral.ID;
                //指定数量,后期会修改为需要指定数量
                dropMa.Number = 1;

                //随机品质
                dropMa.Quality = Random.Range(materiral.RandomQuality[0], materiral.RandomQuality[1]);

                //随机属性;随机4个属性
                int random_max = 0;
                int propcount  = 0;
                for (int i = 0; i < materiral.RandomProperty.Length / 2; i++)
                {
                    random_max += materiral.RandomProperty[i, 1];
                }

                for (int index = 0; index < 4; index++)
                {
                    if (materiral.PropertyProbability < Random.Range(1, 100))
                    {
                        continue;
                    }

                    int _point = Random.Range(1, random_max);
                    int _check = 0;
                    //指定随机属性
                    for (int i = 0; i < materiral.RandomProperty.Length / 2; i++)
                    {
                        _check += materiral.RandomProperty[i, 1];
                        if (_check >= _point)
                        {
                            dropMa.Property[propcount] = materiral.RandomProperty[i, 0];
                            propcount++;
                            break;
                        }
                    }
                }
                break;
            } //endif
        }     //endforech

        //获取名称
        if (dropMa.MateriralType == 0)
        {
            Materiral.Items dorp_item = Materiral.FindItemByID(dropMa.ID);
            dropMa.Name = dorp_item.Name;
            //设定基础价格,之后还需要计算
            dropMa.Price = dorp_item.Price;

            //获取type
            dropMa.Type = Materiral.GetTypeByMaterialID(dropMa.MateriralType, dropMa.ID);
        }   //item
        else if (dropMa.MateriralType == 1)
        {
            Materiral.Minds drop_mind = Materiral.FindMindByID(dropMa.ID);
            dropMa.Name = drop_mind.Name;
            //设定基础价格,之后还需要计算
            dropMa.Price = drop_mind.Price;

            //获取type
            dropMa.Type = Materiral.GetTypeByMaterialID(dropMa.MateriralType, dropMa.ID);
        }   //mind

        //计算价格
        dropMa = CharBag.SetPrice(dropMa);
        //添加物品
        dropMa.UID = CharBag.AddGoods(dropMa);

        questManager.CheckQuestListWithGoods(QuestManager.QuestTypeList.CollectGoods, dropMa, ap);
        //更新物品信息
        PlayerInfo.AddGoodsInfo(dropMa.MateriralType, dropMa.ID, PlayerInfo.GoodsInfoType.CollectCount);
        eventmanager.PreCheckEventList(1);
        ShowMaterialIcon(dropMa, rect);
    }