Exemplo n.º 1
0
        public bool Change_TempDeck(int deck_targetIdx, int ship_rid, ref DeckShips deckShip)
        {
            DeckShips deckShips = deckShip;

            if (ship_rid == -2)
            {
                deckShips.RemoveRange(1, deckShips.Count() - 1);
                return(true);
            }
            int num  = deckShips.Find(ship_rid);
            int num2 = deckShips[deck_targetIdx];

            deckShips[deck_targetIdx] = ship_rid;
            if (ship_rid == -1 || num == -1)
            {
                return(true);
            }
            if (num2 != ship_rid)
            {
                deckShips[num] = num2;
            }
            else
            {
                deckShips[num] = -1;
            }
            return(true);
        }
Exemplo n.º 2
0
 private bool validEscortStypeCheck(DeckShips deckship, int deck_targetIdx)
 {
     if (deckship.Count() == 0)
     {
         return(true);
     }
     return((DeckUtils.IsValidChangeEscort(deckship.getMemShip(), mst_escort_group, deck_targetIdx) == EscortCheckKinds.OK) ? true : false);
 }
Exemplo n.º 3
0
        protected void _Update(DeckShips deck_ships, Dictionary <int, ShipModel> ships)
        {
            List <int> list = new List <int>();

            for (int i = 0; i < deck_ships.Count(); i++)
            {
                list.Add(deck_ships[i]);
            }
            _ships = new List <ShipModel>();
            for (int j = 0; j < list.Count; j++)
            {
                ShipModel item = ships[list[j]];
                _ships.Add(item);
            }
        }
Exemplo n.º 4
0
        public bool UnsetAllOrganize()
        {
            DeckShips deckShip = _edit_deck.DeckShips;

            if (deckShip.Count() <= 1)
            {
                return(false);
            }
            if (_api.Change_TempDeck(0, -2, ref deckShip))
            {
                base.UserInfo.__UpdateTemporaryEscortDeck__(_edit_deck);
                return(true);
            }
            return(false);
        }
        protected void _Update(DeckShips deck_ships, Dictionary <int, ShipModel> ships)
        {
            List <int> list = new List <int>();

            for (int i = 0; i < deck_ships.Count(); i++)
            {
                list.Add(deck_ships[i]);
            }
            this._ships = new List <ShipModel>();
            for (int j = 0; j < list.get_Count(); j++)
            {
                ShipModel shipModel = ships.get_Item(list.get_Item(j));
                this._ships.Add(shipModel);
            }
        }
Exemplo n.º 6
0
        public bool UnsetAllOrganize()
        {
            DeckShips deckShips = this._edit_deck.DeckShips;

            if (deckShips.Count() <= 1)
            {
                return(false);
            }
            bool flag = this._api.Change_TempDeck(0, -2, ref deckShips);

            if (flag)
            {
                base.UserInfo.__UpdateTemporaryEscortDeck__(this._edit_deck);
                return(true);
            }
            return(false);
        }
        public bool IsValidChange(int deck_rid, int deck_targetIdx, int ship_rid)
        {
            Mem_deck deck = null;

            if (!Comm_UserDatas.Instance.User_deck.TryGetValue(deck_rid, ref deck))
            {
                return(false);
            }
            if (deck.MissionState != MissionStates.NONE || deck.IsActionEnd)
            {
                return(false);
            }
            List <int> list = new List <int>();

            if (ship_rid == -2)
            {
                if (deck.Ship.Count() == 0)
                {
                    return(false);
                }
                deck.Ship.Clone(out list);
                list.RemoveAt(0);
            }
            else if (ship_rid == -1)
            {
                list.Add(deck.Ship[deck_targetIdx]);
            }
            else
            {
                list.Add(ship_rid);
                list.Add(deck.Ship[deck_targetIdx]);
                bool flag = Enumerable.Any <Mem_ndock>(Comm_UserDatas.Instance.User_ndock.get_Values(), (Mem_ndock x) => x.Ship_id == ship_rid && x.Area_id != deck.Area_id);
                if (flag)
                {
                    return(false);
                }
            }
            if (Enumerable.Any <Mem_esccort_deck>(Comm_UserDatas.Instance.User_EscortDeck.get_Values(), (Mem_esccort_deck escort) => escort.Ship.Find(ship_rid) != -1))
            {
                return(false);
            }
            if (ship_rid == -2 || (ship_rid == -1 && deck_targetIdx == 0 && deck.Rid == 1))
            {
                return(deck.Ship.Count() > 1);
            }
            if (ship_rid == -1)
            {
                return(deck.Area_id == 1 || deck.Ship.Count() != 1);
            }
            Mem_ship mem_ship = null;

            if (!Comm_UserDatas.Instance.User_ship.TryGetValue(ship_rid, ref mem_ship))
            {
                return(false);
            }
            if (mem_ship.IsBlingShip())
            {
                return(false);
            }
            if (mem_ship.BlingType == Mem_ship.BlingKind.WaitEscort)
            {
                return(false);
            }
            if (mem_ship.BlingType == Mem_ship.BlingKind.WaitDeck && mem_ship.BlingWaitArea != deck.Area_id)
            {
                return(false);
            }
            DeckShips deckShips = null;

            deck.Ship.Clone(out deckShips);
            int[] array = deck.Search_ShipIdx(ship_rid);
            Func <DeckShips, bool> func = delegate(DeckShips x)
            {
                int           num   = x.Count();
                List <string> list2 = new List <string>();
                for (int i = 0; i < num; i++)
                {
                    int ship_id = Comm_UserDatas.Instance.User_ship.get_Item(x[i]).Ship_id;
                    list2.Add(Mst_DataManager.Instance.Mst_ship.get_Item(ship_id).Yomi);
                }
                IEnumerable <IGrouping <string, string> > enumerable = Enumerable.GroupBy <string, string>(list2, (string y) => y);
                return(Enumerable.Count <IGrouping <string, string> >(enumerable) == Enumerable.Count <string>(list2));
            };

            if (array[0] == deck_rid)
            {
                deckShips[array[1]] = deckShips[deck_targetIdx];
            }
            else if (array[0] != -1)
            {
                Mem_deck mem_deck = Comm_UserDatas.Instance.User_deck.get_Item(array[0]);
                if (mem_deck.MissionState != MissionStates.NONE || mem_deck.IsActionEnd)
                {
                    return(false);
                }
                if (mem_deck.Area_id != deck.Area_id)
                {
                    return(false);
                }
                DeckShips deckShips2 = null;
                mem_deck.Ship.Clone(out deckShips2);
                deckShips2[array[1]] = deckShips[deck_targetIdx];
                if (mem_deck.Rid == 1 && deckShips2.Count() == 0)
                {
                    return(false);
                }
                if (deckShips2.Count() == 0 && mem_deck.Area_id != 1)
                {
                    return(false);
                }
                if (!func.Invoke(deckShips2))
                {
                    return(false);
                }
            }
            deckShips[deck_targetIdx] = ship_rid;
            return(func.Invoke(deckShips) && !deckShips.Equals(deck.Ship));
        }
Exemplo n.º 8
0
        public bool IsValidChange(int deck_rid, int deck_targetIdx, int ship_rid, DeckShips deckShip)
        {
            initEscortGroup();
            Mem_esccort_deck value = null;

            if (!Comm_UserDatas.Instance.User_EscortDeck.TryGetValue(deck_rid, out value))
            {
                return(false);
            }
            List <int> unsetShips = null;

            if (ship_rid == -2)
            {
                if (deckShip.Count() <= 1)
                {
                    return(false);
                }
                deckShip.Clone(out unsetShips);
                unsetShips.RemoveAt(0);
            }
            else if (ship_rid == -1)
            {
                unsetShips = new List <int>
                {
                    deckShip[deck_targetIdx]
                };
            }
            else
            {
                if (ship_rid == deckShip[deck_targetIdx])
                {
                    return(false);
                }
                int stype = Comm_UserDatas.Instance.User_ship[ship_rid].Stype;
                if (Mst_DataManager.Instance.Mst_stype[stype].IsSubmarine())
                {
                    return(false);
                }
                unsetShips = new List <int>
                {
                    ship_rid
                };
            }
            DeckShips out_ships = null;

            deckShip.Clone(out out_ships);
            Change_TempDeck(deck_targetIdx, ship_rid, ref out_ships);
            if (!validEscortStypeCheck(out_ships, -1))
            {
                return(false);
            }
            Mem_ndock mem_ndock = Comm_UserDatas.Instance.User_ndock.Values.FirstOrDefault((Mem_ndock x) => unsetShips.Contains(x.Ship_id) ? true : false);

            if (mem_ndock != null)
            {
                return(false);
            }
            if (unsetShips.Any(delegate(int bling_rid)
            {
                Mem_ship value3 = null;
                return(Comm_UserDatas.Instance.User_ship.TryGetValue(bling_rid, out value3) && value3.IsBlingShip());
            }))
            {
                return(false);
            }
            if (ship_rid < 0)
            {
                return(true);
            }
            if (Comm_UserDatas.Instance.User_deck.Values.Any((Mem_deck x) => x.Ship.Find(ship_rid) != -1))
            {
                return(false);
            }
            if (Comm_UserDatas.Instance.User_EscortDeck.Values.Any((Mem_esccort_deck x) => x.Rid != deck_rid && x.Ship.Find(ship_rid) != -1))
            {
                return(false);
            }
            Func <DeckShips, bool> func = delegate(DeckShips x)
            {
                int           num  = x.Count();
                List <string> list = new List <string>();
                for (int i = 0; i < num; i++)
                {
                    int ship_id = Comm_UserDatas.Instance.User_ship[x[i]].Ship_id;
                    list.Add(Mst_DataManager.Instance.Mst_ship[ship_id].Yomi);
                }
                IEnumerable <IGrouping <string, string> > source = from y in list
                                                                   group y by y;
                return((source.Count() == list.Count()) ? true : false);
            };
            Mem_ship value2 = null;

            if (!Comm_UserDatas.Instance.User_ship.TryGetValue(ship_rid, out value2))
            {
                return(false);
            }
            if (value2.IsBlingShip())
            {
                return(false);
            }
            if (value2.BlingType == Mem_ship.BlingKind.WaitDeck)
            {
                return(false);
            }
            if (value2.BlingType == Mem_ship.BlingKind.WaitEscort && value2.BlingWaitArea != value.Maparea_id)
            {
                return(false);
            }
            if (deckShip.Equals(out_ships))
            {
                return(false);
            }
            if (!func(out_ships))
            {
                return(false);
            }
            return(true);
        }