Example #1
0
        private void TakeMaterial(ref Dictionary <enumMaterialCategory, int> add_mat, ref Dictionary <enumMaterialCategory, int> summaryBase)
        {
            IEnumerable <IGrouping <int, Mem_tanker> > areaEnableTanker = Mem_tanker.GetAreaEnableTanker(Comm_UserDatas.Instance.User_tanker);

            if (areaEnableTanker.Count() != 0)
            {
                foreach (IGrouping <int, Mem_tanker> item in areaEnableTanker)
                {
                    Mst_maparea mst_maparea = Mst_DataManager.Instance.Mst_maparea[item.Key];
                    DeckShips   ship        = Comm_UserDatas.Instance.User_EscortDeck[item.Key].Ship;
                    mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, item.Count(), ref add_mat, randMaxFlag: false, ship);
                    mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, item.Count(), ref summaryBase, randMaxFlag: true, ship);
                }
                int materialMaxNum = Comm_UserDatas.Instance.User_basic.GetMaterialMaxNum();
                foreach (KeyValuePair <enumMaterialCategory, int> item2 in add_mat)
                {
                    int num  = 0;
                    int num2 = Comm_UserDatas.Instance.User_material[item2.Key].Value + item2.Value;
                    int num3 = materialMaxNum - num2;
                    if (num3 >= 0)
                    {
                        num = item2.Value;
                    }
                    else if (materialMaxNum > Comm_UserDatas.Instance.User_material[item2.Key].Value)
                    {
                        num = materialMaxNum - Comm_UserDatas.Instance.User_material[item2.Key].Value;
                    }
                    Comm_UserDatas.Instance.User_material[item2.Key].Add_Material(num);
                }
            }
        }
        private void TakeMaterial(ref Dictionary <enumMaterialCategory, int> add_mat, ref Dictionary <enumMaterialCategory, int> summaryBase)
        {
            IEnumerable <IGrouping <int, Mem_tanker> > areaEnableTanker = Mem_tanker.GetAreaEnableTanker(Comm_UserDatas.Instance.User_tanker);

            if (Enumerable.Count <IGrouping <int, Mem_tanker> >(areaEnableTanker) == 0)
            {
                return;
            }
            using (IEnumerator <IGrouping <int, Mem_tanker> > enumerator = areaEnableTanker.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    IGrouping <int, Mem_tanker> current = enumerator.get_Current();
                    Mst_maparea mst_maparea             = Mst_DataManager.Instance.Mst_maparea.get_Item(current.get_Key());
                    DeckShips   ship = Comm_UserDatas.Instance.User_EscortDeck.get_Item(current.get_Key()).Ship;
                    mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, Enumerable.Count <Mem_tanker>(current), ref add_mat, false, ship);
                    mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, Enumerable.Count <Mem_tanker>(current), ref summaryBase, true, ship);
                }
            }
            int materialMaxNum = Comm_UserDatas.Instance.User_basic.GetMaterialMaxNum();

            using (Dictionary <enumMaterialCategory, int> .Enumerator enumerator2 = add_mat.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    KeyValuePair <enumMaterialCategory, int> current2 = enumerator2.get_Current();
                    int num  = 0;
                    int num2 = Comm_UserDatas.Instance.User_material.get_Item(current2.get_Key()).Value + current2.get_Value();
                    int num3 = materialMaxNum - num2;
                    if (num3 >= 0)
                    {
                        num = current2.get_Value();
                    }
                    else if (materialMaxNum > Comm_UserDatas.Instance.User_material.get_Item(current2.get_Key()).Value)
                    {
                        num = materialMaxNum - Comm_UserDatas.Instance.User_material.get_Item(current2.get_Key()).Value;
                    }
                    Comm_UserDatas.Instance.User_material.get_Item(current2.get_Key()).Add_Material(num);
                }
            }
        }
Example #3
0
        public Dictionary <enumMaterialCategory, int> GetMaterialNum(int area_id, int tankerNum, DeckShips deckShip)
        {
            Dictionary <enumMaterialCategory, int> addValues = new Dictionary <enumMaterialCategory, int>();

            foreach (object value2 in Enum.GetValues(typeof(enumMaterialCategory)))
            {
                addValues.Add((enumMaterialCategory)(int)value2, 0);
            }
            Mst_maparea value = null;

            if (!Mst_DataManager.Instance.Mst_maparea.TryGetValue(area_id, out value))
            {
                return(addValues);
            }
            DeckShips deckShip2 = (deckShip != null) ? deckShip : Comm_UserDatas.Instance.User_EscortDeck[area_id].Ship;

            value.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, tankerNum, ref addValues, randMaxFlag: true, deckShip2);
            return(addValues);
        }
Example #4
0
        public Dictionary <enumMaterialCategory, int> GetMaterialNum(int area_id, int tankerNum, DeckShips deckShip)
        {
            Dictionary <enumMaterialCategory, int> dictionary = new Dictionary <enumMaterialCategory, int>();

            using (IEnumerator enumerator = Enum.GetValues(typeof(enumMaterialCategory)).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    object current = enumerator.get_Current();
                    dictionary.Add((enumMaterialCategory)((int)current), 0);
                }
            }
            Mst_maparea mst_maparea = null;

            if (!Mst_DataManager.Instance.Mst_maparea.TryGetValue(area_id, ref mst_maparea))
            {
                return(dictionary);
            }
            DeckShips deckShip2 = (deckShip != null) ? deckShip : Comm_UserDatas.Instance.User_EscortDeck.get_Item(area_id).Ship;

            mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, tankerNum, ref dictionary, true, deckShip2);
            return(dictionary);
        }