コード例 #1
0
        public Stop Convert(StopResource stopResource)
        {
            var existingStop = CreatedStops.Where(obj => obj.Id == stopResource.Id).FirstOrDefault();

            if (existingStop != null)
            {
                Assign(existingStop, stopResource);
                return(existingStop);
            }
            else
            {
                var newStop = new Stop();
                CreatedStops.Add(newStop);
                Assign(newStop, stopResource);
                return(newStop);
            }
        }
コード例 #2
0
        void Assign(Stop stop, StopResource StopResource)
        {
            stop.Id = StopResource.Id;

            if (StopResource.IsFinal != null)
            {
                stop.IsFinal = StopResource.IsFinal;
            }

            if (StopResource.IsInitial != null)
            {
                stop.IsInitial = StopResource.IsInitial;
            }

            if (StopResource.Name != null)
            {
                stop.Name = StopResource.Name;
            }

            if (StopResource.State1Requirement != null)
            {
                stop.State1Requirement = (short)StopResource.State1Requirement;
            }

            if (StopResource.State2Requirement != null)
            {
                stop.State2Requirement = (short)StopResource.State2Requirement;
            }

            if (StopResource.State3Requirement != null)
            {
                stop.State3Requirement = (short)StopResource.State3Requirement;
            }

            if (StopResource.State4Requirement != null)
            {
                stop.State4Requirement = (short)StopResource.State4Requirement;
            }

            if ((StopResource.Position != null) && stop.Position == null)
            {
                MapPosition newMapPosition = Convert(StopResource.Position);
                stop.Position = newMapPosition;
                newMapPosition.PositionOfStop = stop;
            }

            if ((StopResource.Passwords != null) && stop.Passwords == null)
            {
                stop.Passwords = new List <PasswordGameRequirement>();

                foreach (PasswordGameRequirementResource passwordResource in StopResource.Passwords)
                {
                    PasswordGameRequirement newPassword = Convert(passwordResource);
                    stop.Passwords.Add(newPassword);
                    newPassword.Stop = stop;
                }
            }

            if ((StopResource.Questions != null) && stop.Questions == null)
            {
                stop.Questions = new List <Question>();

                foreach (QuestionResource questionResource in StopResource.Questions)
                {
                    Question newQuestion = Convert(questionResource);
                    stop.Questions.Add(newQuestion);
                    if (newQuestion.StopsThatOpenThis == null)
                    {
                        newQuestion.StopsThatOpenThis = new List <Stop>();
                    }
                    newQuestion.StopsThatOpenThis.Add(stop);
                }
            }

            if ((StopResource.PositionsDisplayAfterDisplay != null) && stop.PositionsDisplayAfterDisplay == null)
            {
                stop.PositionsDisplayAfterDisplay = new List <MapPosition>();

                foreach (MapPositionResource positionResource in StopResource.PositionsDisplayAfterDisplay)
                {
                    MapPosition newPosition = Convert(positionResource);
                    stop.PositionsDisplayAfterDisplay.Add(newPosition);
                    if (newPosition.StopDisplayAfterDisplay == null)
                    {
                        newPosition.StopDisplayAfterDisplay = new List <Stop>();
                    }
                    newPosition.StopDisplayAfterDisplay.Add(stop);
                }
            }

            if ((StopResource.PositionsDisplayAfterUnlock != null) && stop.PositionsDisplayAfterUnlock == null)
            {
                stop.PositionsDisplayAfterUnlock = new List <MapPosition>();

                foreach (MapPositionResource positionResource in StopResource.PositionsDisplayAfterUnlock)
                {
                    MapPosition newPosition = Convert(positionResource);
                    stop.PositionsDisplayAfterUnlock.Add(newPosition);
                    if (newPosition.StopDisplayAfterUnlock == null)
                    {
                        newPosition.StopDisplayAfterUnlock = new List <Stop>();
                    }
                    newPosition.StopDisplayAfterUnlock.Add(stop);
                }
            }

            if ((StopResource.Opens != null) && stop.Opens == null)
            {
                stop.Opens = new List <StopStop>();

                foreach (StopStopResource stopStopResource in StopResource.Opens)
                {
                    StopStop newStopStop = Convert(stopStopResource);
                    stop.Opens.Add(newStopStop);
                    newStopStop.StopOpensThis = stop;
                }
            }

            if ((StopResource.ChoicesOpenThis != null) && stop.ChoicesOpenThis == null)
            {
                stop.ChoicesOpenThis = new List <ChoiceStop>();

                foreach (ChoiceStopResource choiceOpenThis in StopResource.ChoicesOpenThis)
                {
                    ChoiceStop newChoiceStop = Convert(choiceOpenThis);
                    stop.ChoicesOpenThis.Add(newChoiceStop);
                    newChoiceStop.Opens = stop;
                }
            }

            if ((StopResource.DisplayObjectsHints != null) && stop.DisplayObjectsHints == null)
            {
                stop.DisplayObjectsHints = new List <DisplayObjectStopDisplayAfterDisplay>();

                foreach (DisplayObjectStopDisplayAfterDisplayResource hint in StopResource.DisplayObjectsHints)
                {
                    DisplayObjectStopDisplayAfterDisplay newHint = Convert(hint);
                    stop.DisplayObjectsHints.Add(newHint);
                    newHint.Stop = stop;
                }
            }

            if ((StopResource.DisplayObjectsRewards != null) && stop.DisplayObjectsRewards == null)
            {
                stop.DisplayObjectsRewards = new List <DisplayObjectStopDisplayAfterUnlock>();

                foreach (DisplayObjectStopDisplayAfterUnlockResource reward in StopResource.DisplayObjectsRewards)
                {
                    DisplayObjectStopDisplayAfterUnlock newReward = Convert(reward);
                    stop.DisplayObjectsRewards.Add(newReward);
                    newReward.Stop = stop;
                }
            }
        }