public void ServantByIdSuccess()
        {
            var mockRepo      = new Mock <IServantRepository>();
            var mockDbContext = new Mock <IDbContext>();

            var servant = new Servant()
            {
                Id    = 1,
                Name  = "MockedServant",
                Title = "MockServantTitle",
                FirstAscensionImage = "MockFirstAscImage",
                FinalAscensionImage = "MockFinalAscImage",
                Dialogue            = "MockDialogue",
                Audio = "MockAudio"
            };

            mockRepo.Setup(repo => repo.GetServantByIdAsync(1)).ReturnsAsync(servant);
            mockDbContext.Setup(db => db.Servants).Returns(mockRepo.Object);

            var sut    = new ServantController(mockDbContext.Object);
            var result = sut.ServantById(1).Result.Value;

            Assert.AreEqual(servant.Id, result.Id);
            Assert.AreEqual(servant.Title, result.Title);
            Assert.AreEqual(servant.FinalAscensionImage, result.FinalAscensionImage);
        }
Example #2
0
    public void StartBattle(ServantParty servantParty, Servant wildServant)
    {
        this.servantParty = servantParty;
        this.wildServant  = wildServant;

        StartCoroutine(SetupBattle());
    }
Example #3
0
 public void Poison(Servant servant)
 {
     poisoned       = true;
     poisonDamage   = UnityEngine.Random.Range(10, 20);
     poisonMurderer = servant;
     speed          = speed * 0.2f;
 }
        public async Task <ActionResult <Servant> > SaveServant(Servant servant)
        {
            var servantModel = servant;
            await _iServant.Save(servantModel);

            return(CreatedAtRoute(nameof(GetServantById), new { Id = servantModel.Id }, servantModel));
        }
Example #5
0
 protected override void OnPoisonHit(int hitCount, Servant poisonMurderer)
 {
     if (hitCount == 2 || hitCount == 4)
     {
         OrderToKillSpecificServant(poisonMurderer);
     }
 }
 private void DistributeCards()
 {
     Servant.Shuffle(_cards);
     Servant.DistributeCards(_cards, _bankerView);
     _views.Each(v => v.Value.RepresentDistributeCards());
     _views.Each(v => v.Value.ArrangeActLandlordsActionPrelude(_views.Current.Value.Player));
 }
Example #7
0
    void MakeServantfunc()
    {
        Servant NewServant = new Servant();

        NewServant.SetServant_Basic(setName, setBasicHP, setBasicAtk, setServantClass, setFivecardtype, setActiveSkill, setFaceSprite, setCardSprite, setIllustSprite, setSelectFriendSprite, setFormationSprite, ingameImg, m_materialCard);
        Player.MainPlayer.addNewServant(NewServant);
    }
Example #8
0
 public void SaveServant(Servant servant)
 {
     using (var session = DocumentStoreHolder.Store.OpenSession())
     {
         session.Store(servant);
         session.SaveChanges();
     }
 }
Example #9
0
    public void SetData(Servant servantInfo)
    {
        _servant = servantInfo;

        nameText.text  = servantInfo.servantBase.Name;
        levelText.text = "Lvl " + servantInfo.Level;
        hpBar.SetHP((float)servantInfo.HP / servantInfo.MaxHP);
    }
Example #10
0
        private void writeButton_Click(object sender, EventArgs e)//将读取的从者写入文件
        {
            Servant writeServant = readServantFromTable();

            formMain.memory.addServant(writeServant);

            formMain.memory.refreshComboBox(servantComboBox);
            formMain.memory.showComboBox(servantComboBox, writeServant.ID);
            MessageBox.Show("更新成功");
        }
        public async Task <ActionResult <Servant> > ServantById(int id)
        {
            Servant servant = await servantRepository.GetServantByIdAsync(id);

            if (servant == null)
            {
                return(NotFound());
            }
            return(servant);
        }
Example #12
0
        public Servant GetServantById(int id)
        {
            var servant = new Servant();

            using (var session = DocumentStoreHolder.Store.OpenSession())
            {
                servant = session.Load <Servant>($"servants/{id}");
            }
            return(servant);
        }
        public async Task Save(Servant servant)
        {
            var request = new RestRequest("", Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddJsonBody(servant);
            var            response          = _restClient.Execute(request);
            HttpStatusCode statusCode        = response.StatusCode;
            int            numericStatusCode = (int)statusCode;
        }
Example #14
0
	void Setup()  
	{  
		servant = GetComponent<Servant>();
		//得到模型原始高度
		float mHight=servant.transform.GetComponentInChildren<SkinnedMeshRenderer>().bounds.size.y;
		float mScale=servant.transform.localScale.y;
		npcHeight=mHight * mScale;
		maxHealth = servant.m_Hp;
		camera = GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<Camera>();
	}  
Example #15
0
        public void SaveServant_ShouldReturnOkResult_WhenTheServantIsValid()
        {
            var servant = new Servant();

            MockRepo.Setup(repo => repo.SaveServant(servant)).Verifiable();
            MockServantCreationValidator.Setup(mscv => mscv.Validate(It.IsAny <CreationCandidate <Servant> >())).Returns(new ValidationResult());

            var controller = new ServantController(MockRepo.Object, MockServantCreationValidator.Object);

            Assert.IsInstanceOf <OkObjectResult>(controller.SaveServant(servant));
        }
        public async Task Remove(int id)
        {
            Servant servantToDelete = await Get(id);

            if (servantToDelete != null)
            {
                await _dbSet.Remove(servantToDelete.Id);

                await _dbSet.Save();
            }
        }
Example #17
0
        static void Main(string[] args)
        {
            Servant servant = new Servant(6756); // invoke localhost/Close to stop app

            servant.register(new Test());
            servant.register(new Test2());
            while (servant.Running)
            {
                Thread.Sleep(100);
            }
        }
Example #18
0
    public void OrderToKillSpecificServant(Servant servant)
    {
        // find closest guard
        GameObject[] guards       = GameObject.FindGameObjectsWithTag(Tags.GUARD);
        GameObject   closestGuard = FindClosest(guards);

        if (servant != null && closestGuard != null)
        {
            Guard guard = closestGuard.GetComponent <Guard>();
            guard.PleaseKill(servant);
        }
    }
Example #19
0
        public void SaveServant_ShouldReturnErrors_WhenTheServantIsInvalid()
        {
            var servant = new Servant();

            servant.Strength = 1000;

            MockRepo.Setup(repo => repo.SaveServant(servant)).Verifiable();
            var realServantCreationValidator = new ServantCreationValidator();

            var controller = new ServantController(MockRepo.Object, realServantCreationValidator);

            Assert.IsInstanceOf <IList <ValidationFailure> >(controller.SaveServant(servant));
        }
Example #20
0
    public static GameObject createWindow(Servant servant, GameObject mod)
    {
        GameObject re = servant.create
                        (
            mod,
            Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height * 1.5f, 600)),
            new Vector3(0, 0, 0),
            false,
            Program.ui_main_2d
                        );

        UIHelper.InterGameObject(re);
        return(re);
    }
        public void ServantByIdFail()
        {
            var mockRepo      = new Mock <IServantRepository>();
            var mockDbContext = new Mock <IDbContext>();

            Servant servant = null;

            mockRepo.Setup(repo => repo.GetServantByIdAsync(-1)).ReturnsAsync(servant);
            mockDbContext.Setup(db => db.Servants).Returns(mockRepo.Object);

            var sut    = new ServantController(mockDbContext.Object);
            var result = sut.ServantById(-1).Result.Value;

            Assert.IsNull(result);
        }
        public dynamic SaveServant([FromBody] Servant servant)
        {
            var cc = new CreationCandidate <Servant>(servant);
            var validationResults = ServantCreationValidator.Validate(cc);

            if (validationResults.IsValid)
            {
                ServantRepository.SaveServant(servant);
                return(Ok("Servant Created"));
            }
            else
            {
                return(validationResults.Errors);
            }
        }
Example #23
0
        public ActionResult Edit(int id)
        {
            var servant = new Servant();


            servant = _context.Servants.SingleOrDefault(c => c.Id == id);

            if (servant == null)
            {
                return(HttpNotFound());
            }



            return(View("New", servant));
        }
Example #24
0
        protected override void InitBadPixels()
        {
            base.InitBadPixels();

            // boss
            boss = new Boss();
            Add(boss);

            for (int i = 0; i < 412; i++)
            {
                RedGuard bp = RedGuard.Create(); // Cloaky();
                bp.PositionAndTarget = new Vector2(RandomMath.RandomBetween(123f, 720f), RandomMath.RandomBetween(9f, 290f));
                //bp.TargetSpeed = 18.0f; // TODO
                Add(bp);
                AllEnemies.Add(bp);
                FindWalkableGround(bp);
            }

            for (int i = 0; i < 36; i++)
            {
                Servant s = Servant.Create();
                s.PositionAndTarget = new Vector2(RandomMath.RandomBetween(140f, 720f), RandomMath.RandomBetween(9f, 290f));
                Add(s);
                FindWalkableGround(s);
            }

            // servants at local hero's castle
            for (int i = 0; i < 3; i++)
            {
                Servant s = Servant.Create();
                s.AvoidingKnights.ChaseRange = 4f;
                s.AvoidingHero.ChaseRange    = 4f;
                s.PositionAndTarget          = new Vector2(RandomMath.RandomBetween(0f, 20f), RandomMath.RandomBetween(32f, 90f));
                Add(s);
                FindWalkableGround(s);
            }

            for (int i = 0; i < 14; i++) // XIV companions!
            {
                Knight cp = Knight.Create();
                cp.PositionAndTarget = new Vector2(KnightsStartingPositions[2 * i] + DEBUG_SHIFT_POS_RIGHT, KnightsStartingPositions[2 * i + 1]);
                //bp.TargetSpeed = 18.0f; // TODO
                Add(cp);
                hero.Knights.Add(cp);
                FindWalkableGround(cp);
            }
        }
Example #25
0
        public void Setup()
        {
            GlobalReference.GlobalValues = new GlobalValues();

            npc            = new Mock <INonPlayerCharacter>();
            room           = new Mock <IRoom>();
            findObjects    = new Mock <IFindObjects>();
            defaultValues  = new Mock <IDefaultValues>();
            dice           = new Mock <IDice>();
            random         = new Mock <IRandom>();
            settings       = new Mock <ISettings>();
            moneyToCoins   = new Mock <IMoneyToCoins>();
            tagWrapper     = new Mock <ITagWrapper>();
            notify         = new Mock <INotify>();
            inGameDateTime = new Mock <IInGameDateTime>();
            gameDateTime   = new Mock <IGameDateTime>();

            npc.Setup(e => e.Room).Returns(room.Object);
            room.Setup(e => e.Zone).Returns(24);
            room.Setup(e => e.Id).Returns(22);
            findObjects.Setup(e => e.FindNpcInRoom(room.Object, "queens guard")).Returns(new List <INonPlayerCharacter>()
            {
                npc.Object
            });
            findObjects.Setup(e => e.FindNpcInRoom(room.Object, "King")).Returns(new List <INonPlayerCharacter>()
            {
                npc.Object
            });
            defaultValues.Setup(e => e.DiceForArmorLevel(45)).Returns(dice.Object);
            random.Setup(e => e.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(10);
            settings.Setup(e => e.BaseStatValue).Returns(5);
            moneyToCoins.Setup(e => e.FormatedAsCoins(It.IsAny <ulong>())).Returns("some");
            tagWrapper.Setup(e => e.WrapInTag(It.IsAny <string>(), TagType.Info)).Returns((string x, TagType y) => (x));
            inGameDateTime.Setup(e => e.GameDateTime).Returns(gameDateTime.Object);

            GlobalReference.GlobalValues.FindObjects   = findObjects.Object;
            GlobalReference.GlobalValues.DefaultValues = defaultValues.Object;
            GlobalReference.GlobalValues.Random        = random.Object;
            GlobalReference.GlobalValues.Settings      = settings.Object;
            GlobalReference.GlobalValues.MoneyToCoins  = moneyToCoins.Object;
            GlobalReference.GlobalValues.TagWrapper    = tagWrapper.Object;
            GlobalReference.GlobalValues.Notify        = notify.Object;
            GlobalReference.GlobalValues.GameDateTime  = inGameDateTime.Object;

            servant = new Servant();
        }
Example #26
0
    public void OnShow()
    {
        //data
        ServantData data = ServantManager.getInstace().getData();

        UIList list = transform.Find("Group_ServantSelect/ScrollView/Viewport/Content").GetComponent <UIList>();

        list.DrawList(data.nameToServant.Count, (index, listItem) =>
        {
            Servant servant = data.nameToServant[index];
            listItem.transform.Find("UIButton").GetComponent <Button>().onClick.AddListener(() =>
            {
                GameObject uiDialogShop = UIManager.getInstace().ShowDialog("DlgShop");
                uiDialogShop.GetComponent <DlgShop>().OnShow(servant.servantEName);
            });
            listItem.transform.Find("UIText").GetComponent <Text>().text = servant.servantEName;
        });
    }
Example #27
0
    public void OrderToKillClosestServant()
    {
        // find closest guard
        GameObject[] guards       = GameObject.FindGameObjectsWithTag(Tags.GUARD);
        GameObject   closestGuard = FindClosest(guards);

        // find closest servant
        GameObject[] servants       = GameObject.FindGameObjectsWithTag(Tags.SERVANT);
        GameObject   closestServant = FindClosest(servants);

        // ask guard to kill servant
        if (closestServant != null && closestGuard != null)
        {
            Guard   guard   = closestGuard.GetComponent <Guard>();
            Servant servant = closestServant.GetComponent <Servant>();
            guard.PleaseKill(servant);
        }
    }
Example #28
0
    public void placementSetUp(Servant servant)
    {
        servantInfo = servant;
        if (isPlayerUnit)
        {
            image.sprite = servantInfo.servantBase.BackSprite;
        }
        else
        {
            image.sprite = servantInfo.servantBase.FrontSprite;
        }

        hud.SetData(servant);

        image.color = originalColor;

        PlayEnterAnimation();
    }
Example #29
0
        public void ServiceStart(string[] args)
        {
            if (!IsAnAdministrator())
            {
                MessageHandler.LogException("Administrator access required.");
                return;
            }

            try
            {
                SetRecoveryOptions(ServiceConfig.ServiceName);
                Servant.Start();
            }
            catch (Exception ex)
            {
                MessageHandler.LogException(ex.Message);
                throw;
            }
        }
Example #30
0
    IEnumerator SwitchServant(Servant newServant)
    {
        if (playerUnit.servantInfo.HP > 0)
        {
            yield return(dialogBox.TypeDialog($"Retreat {playerUnit.servantInfo.servantBase.Name}"));

            playerUnit.PlayFaintAnimation();

            // To be reworked.
            // playerUnit.PlayReturnAnimation();
            yield return(new WaitForSeconds(2f));
        }
        playerUnit.placementSetUp(newServant);

        dialogBox.SetMoveNames(newServant.Moves);

        yield return(dialogBox.TypeDialog($"Go {newServant.servantBase.Name}!"));

        StartCoroutine(EnemyMove());
    }
Example #31
0
        public ActionResult Delete(int id)
        {
            var servant = new Servant();


            servant = _context.Servants.SingleOrDefault(c => c.Id == id);

            var User        = _context.Users.SingleOrDefault(u => u.Email == servant.Email);
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(_context));

            UserManager.RemoveFromRole(User.Id, "Admins");

            if (servant == null)
            {
                return(HttpNotFound());
            }
            _context.Servants.Remove(servant);
            _context.SaveChanges();


            return(RedirectToAction("Index"));
        }
        public void MultiServantQueueSumulator_Test()
        {
            var enterDiffRandomNumbers = new[]
            {
                0, .26, .98, .90, .26, .42, .74, .80, .68, .22,
                .48, .34, .45, .24, .34, .63, .38, .80, .42, .56,
                .89, .18, .51, .71, .16, .92
            }.AsEnumerable();

            var serviceRandomNumbers = new[]
            {
                .95, .21, .51, .92, .89, .38, .13, .61, .50, .49,
                .39, .53, .88, .01, .81, .54, .81, .64, .01, .67,
                .01, .47, .75, .57, .87, .48
            }.AsEnumerable();

            var habil = new Servant { Name = "Habil" };
            var khabbaz = new Servant { Name = "Khabbaz" };
            var simulator = new MultiServantQueueSimulator(new[] { habil, khabbaz }, enterDiffRandomNumbers, serviceRandomNumbers);

            simulator
                .AddEnteringDifferencePossibility(1, .25)
                .AddEnteringDifferencePossibility(2, .40)
                .AddEnteringDifferencePossibility(3, .20)
                .AddEnteringDifferencePossibility(4, .15)

                .AddServiceTimePossibility(habil, 2, .30)
                .AddServiceTimePossibility(habil, 3, .28)
                .AddServiceTimePossibility(habil, 4, .25)
                .AddServiceTimePossibility(habil, 5, .15)

                .AddServiceTimePossibility(khabbaz, 3, .35)
                .AddServiceTimePossibility(khabbaz, 4, .25)
                .AddServiceTimePossibility(khabbaz, 5, .20)
                .AddServiceTimePossibility(khabbaz, 6, .20);

            var expectedCustomersResult = new[]
            {
                new MultiServantQueueCustomer(1, 0, 0, habil, 0, 5, 5, 0),
                new MultiServantQueueCustomer(2, 2, 2, khabbaz, 2, 3, 5, 0),
                new MultiServantQueueCustomer(3, 4, 6, habil, 6, 3, 9, 0),
                new MultiServantQueueCustomer(4, 4, 10, habil, 10, 5, 15, 0),
                new MultiServantQueueCustomer(5, 2, 12, khabbaz, 12, 6, 18, 0),
                new MultiServantQueueCustomer(6, 2, 14, habil, 15, 3, 18, 1),
                new MultiServantQueueCustomer(7, 3, 17, habil, 18, 2, 20, 1),
                new MultiServantQueueCustomer(8, 3, 20, habil, 20, 4, 24, 0),
                new MultiServantQueueCustomer(9, 3, 23, khabbaz, 23, 4, 27, 0),
                new MultiServantQueueCustomer(10, 1, 24, habil, 24, 3, 27, 0),
                new MultiServantQueueCustomer(11, 2, 26, habil, 27, 3, 30, 1),
                new MultiServantQueueCustomer(12, 2, 28, khabbaz, 28, 4, 32, 0),
                new MultiServantQueueCustomer(13, 2, 30, habil, 30, 5, 35, 0),
                new MultiServantQueueCustomer(14, 1, 31, khabbaz, 32, 3, 35, 1),
                new MultiServantQueueCustomer(15, 2, 33, habil, 35, 4, 39, 2),
                new MultiServantQueueCustomer(16, 2, 35, khabbaz, 35, 4, 39, 0),
                new MultiServantQueueCustomer(17, 2, 37, habil, 39, 4, 43, 2),
                new MultiServantQueueCustomer(18, 3, 40, khabbaz, 40, 5, 45, 0),
                new MultiServantQueueCustomer(19, 2, 42, habil, 43, 2, 45, 1),
                new MultiServantQueueCustomer(20, 2, 44, habil, 45, 4, 49, 1),
                new MultiServantQueueCustomer(21, 4, 48, khabbaz, 48, 3, 51, 0),
                new MultiServantQueueCustomer(22, 1, 49, habil, 49, 3, 52, 0),
                new MultiServantQueueCustomer(23, 2, 51, khabbaz, 51, /*4*/5, 56, 0),
                new MultiServantQueueCustomer(24, 3, 54, habil, 54, 3, 57, 0),
                new MultiServantQueueCustomer(25, 1, 55, khabbaz, 56, 6, 62, 1),
                new MultiServantQueueCustomer(26, 4, 59, habil, 59, 3, 62, 0)
            };

            var simulatorEnumerator = simulator.GetEnumerator();
            var customers = new List<MultiServantQueueCustomer>();
            foreach (var expectedResult in expectedCustomersResult)
            {
                simulatorEnumerator.MoveNext();
                Assert.AreEqual(expectedResult, simulatorEnumerator.Current);
                customers.Add(simulatorEnumerator.Current);
            }

            Assert.AreEqual(.90, Math.Round(customers.ServantBusyAverage(habil), 2));
            Assert.AreEqual(.69, Math.Round(customers.ServantBusyAverage(khabbaz), 2));
            Assert.AreEqual(.35, Math.Round(customers.WaitedCustomersRatio(), 2));
            Assert.AreEqual(.42, Math.Round(customers.WaitingTimeAverage(), 2));
            Assert.AreEqual(1.22, Math.Round(customers.WaitedCustomersWaitingTimeAverage(), 2));
        }
	// Use this for initialization
	void Start () {
        servant = GetComponent<Servant>();	
	}
Example #34
0
        public static void StopSite(Servant.Business.Objects.Site site)
        {
            using (var manager = new ServerManager())
            {
                var iisSite = manager.Sites.SingleOrDefault(x => x.Id == site.IisId);
                if (iisSite == null)
                    throw new SiteNotFoundException("Site " + site.Name + " was not found on IIS");

                iisSite.Stop();    
            }
        }
Example #35
0
        public static Servant.Business.Objects.Enums.SiteStartResult StartSite(Servant.Business.Objects.Site site)
        {
            using (var manager = new ServerManager())
            {
                var iisSite = manager.Sites.SingleOrDefault(x => x.Id == site.IisId);
                if (iisSite == null)
                    throw new SiteNotFoundException("Site " + site.Name + " was not found on IIS");

                try
                {
                    iisSite.Start();
                    return SiteStartResult.Started;
                }
                catch (Microsoft.Web.Administration.ServerManagerException)
                {
                    return SiteStartResult.BindingIsAlreadyInUse;
                }
                catch (FileLoadException)
                {
                    return SiteStartResult.CannotAccessSitePath;
                }
            }
        }
Example #36
0
        public static void UpdateSite(Servant.Business.Objects.Site site)
        {
            using (var manager = new ServerManager())
            {
                var iisSite = manager.Sites.SingleOrDefault(x => x.Id == site.IisId);
                var mainApplication = iisSite.Applications.First();

                mainApplication.VirtualDirectories[0].PhysicalPath = site.SitePath;

                // In some scenarios Microsoft.Web.Administation fails to save site if property-set is detected with same name. 
                //I believe it deletes and insert sites on updates and this makes a name conflict. Fixed by the hack below:
                if(site.Name != iisSite.Name) 
                    iisSite.Name = site.Name;

                // If the application pool does not exists on the server, create it
                if (manager.ApplicationPools.SingleOrDefault(x => x.Name == site.ApplicationPool) == null)
                {
                    manager.ApplicationPools.Add(site.ApplicationPool);
                }

                mainApplication.ApplicationPoolName = site.ApplicationPool;

                // Commits bindings
                iisSite.Bindings.Clear();
                foreach (var binding in site.Bindings)
                {
                    if (binding.Protocol == Protocol.https)
                    {
                        var certificate = GetCertificates().Single(x => x.Thumbprint == binding.CertificateThumbprint);
                        iisSite.Bindings.Add(binding.ToIisBindingInformation(), certificate.Hash, "My");
                    }
                    else
                        iisSite.Bindings.Add(binding.ToIisBindingInformation(), binding.Protocol.ToString());
                }

                //Intelligently updates virtual applications
                foreach (var application in site.Applications)
                {
                    var iisApp = iisSite.Applications.SingleOrDefault(x => x.Path == application.Path);

                    if (iisApp == null)
                    {
                        if (!application.Path.StartsWith("/"))
                            application.Path = "/" + application.Path;

                        iisSite.Applications.Add(application.Path, application.DiskPath);
                        iisApp = iisSite.Applications.Single(x => x.Path == application.Path);

                    }

                    iisApp.VirtualDirectories[0].PhysicalPath = application.DiskPath;
                    iisApp.ApplicationPoolName = application.ApplicationPool;
                }

                var applicationsToDelete = iisSite.Applications.Skip(1).Where(x => !site.Applications.Select(a => a.Path).Contains(x.Path));
                foreach (var application in applicationsToDelete)
                {
                    application.Delete();
                }
                
                manager.CommitChanges();
            }
        }
Example #37
0
 public static string GetSitename(Servant.Business.Objects.Site site) {
     if(site == null)
         return "Unknown";
     
     return site.Name;
 }
        public List<Title> CreateTitlesFromPathArray(int? parentid, string[] path, string Tag)
        {
            // Create a list of all newly added titles
            List<Title> NewTitles = new List<Title>();
            bool titleCreated = false;
            Title folderTitle;
            foreach (string file in path)
            {
                try
                {
                    if (Directory.Exists(file))
                    {
                        // Folder passed in. This is where St Sana kicks in
                        Servant stsana = new Servant();
                        stsana.Log += new Servant.SSEventHandler(StSana_Log);
                        stsana.BasePaths.Add(file);
                        stsana.Scan();

                        int? a_parent;

                        if (OMLEngine.Settings.OMLSettings.StSanaCreateTLFolder)
                        {
                            titleCreated = false;
                            folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(parentid, Path.GetFileName(file), TitleTypes.Collection, null, out titleCreated);
                            a_parent = folderTitle.Id;
                            if (titleCreated) NewTitles.Add(folderTitle);
                        }
                        else
                        {
                            a_parent = parentid;
                        }

                        if (stsana.Entities != null)
                        {
                            foreach (Entity e in stsana.Entities)
                            {
                                int? e_parent = a_parent;
                                if (e.Name != file)
                                {
                                    switch (e.EntityType)
                                    {
                                        case Serf.EntityType.COLLECTION:
                                        case Serf.EntityType.MOVIE:
                                            if ((e.Series.Count() > 1) || (OMLEngine.Settings.OMLSettings.StSanaAlwaysCreateMovieFolder))
                                            {
                                                titleCreated = false;
                                                folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(a_parent, e.Name, TitleTypes.Collection, null, out titleCreated);
                                                e_parent = folderTitle.Id;
                                                if (titleCreated) NewTitles.Add(folderTitle);
                                            }
                                            else
                                            {
                                                e_parent = a_parent;
                                            }
                                            break;
                                        case Serf.EntityType.TV_SHOW:
                                            titleCreated = false;
                                            folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(a_parent, e.Name, TitleTypes.TVShow, null, out titleCreated);
                                            e_parent = folderTitle.Id;
                                            if (titleCreated) NewTitles.Add(folderTitle);
                                            break;
                                    }
                                }

                                foreach (Series s in e.Series)
                                {
                                    int? s_parent = e_parent;
                                    // if the s.name and e.name are the same, its a movie, to be sure though lets check s.number, it should be
                                    // -1 for non tv shows.
                                    if (s.Name.ToUpperInvariant().CompareTo(e.Name.ToUpperInvariant()) != 0 || s.Number > -1)
                                    {
                                        //s_parent = CreateFolderNonDuplicate(e_parent, s.Name, TitleTypes.Collection, false);
                                        if (s.Name != e.Name)
                                        {
                                            switch (e.EntityType)
                                            {
                                                case Serf.EntityType.COLLECTION:
                                                case Serf.EntityType.MOVIE:
                                                    if ((e_parent == a_parent) || (OMLEngine.Settings.OMLSettings.StSanaAlwaysCreateMovieFolder))
                                                    {
                                                        titleCreated = false;
                                                        folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(e_parent, s.Name, TitleTypes.Collection, null, out titleCreated);
                                                        s_parent = folderTitle.Id;
                                                        if (titleCreated) NewTitles.Add(folderTitle);
                                                    }
                                                    else
                                                    {
                                                        s_parent = e_parent;
                                                    }
                                                    break;
                                                case Serf.EntityType.TV_SHOW:
                                                    titleCreated = false;
                                                    folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(e_parent, s.Name, TitleTypes.Season, (short)s.Number, out titleCreated);
                                                    s_parent = folderTitle.Id;
                                                    if (titleCreated) NewTitles.Add(folderTitle);
                                                    break;
                                            }
                                        }
                                        else
                                        {
                                            s_parent = e_parent;
                                        }
                                    }

                                    foreach (Video v in s.Videos)
                                    {
                                        StSana_Log("Processing " + v.Name);
                                        //int v_parent = CreateFolder(s_parent, Path.GetFileNameWithoutExtension(v.Name), TitleTypes.Collection, false);

                                        List<Disk> disks = new List<Disk>();

                                        if ((e.EntityType == Serf.EntityType.COLLECTION) ||
                                            (e.EntityType == Serf.EntityType.MOVIE))
                                        {
                                            // Collection or movie mode. Create one title per folder with multiple disks
                                            foreach (string f in v.Files)
                                            {
                                                if (!TitleCollectionManager.ContainsDisks(OMLEngine.FileSystem.NetworkScanner.FixPath(f)))
                                                {
                                                    Disk disk = new Disk();
                                                    disk.Path = f;
                                                    disk.Format = disk.GetFormatFromPath(f); // (VideoFormat)Enum.Parse(typeof(VideoFormat), fileExtension.ToUpperInvariant());
                                                    disk.Name = string.Format("Disk {0}", 0);
                                                    if (disk.Format != VideoFormat.UNKNOWN)
                                                    {
                                                        disks.Add(disk);
                                                    }
                                                }
                                            }
                                            if (disks.Count != 0)
                                            {
                                                Title newTitle = TitleCollectionManager.CreateTitle(s_parent,
                                                    Path.GetFileNameWithoutExtension(v.Name),
                                                    TitleTypes.Unknown,
                                                    Tag,
                                                    disks.ToArray());

                                                CheckDiskPathForImages(newTitle, disks[0]);
                                                NewTitles.Add(newTitle);
                                                TitleCollectionManager.SaveTitleUpdates();
                                            }
                                        }
                                        else
                                        {
                                            // TV mode. Create one title per file, each with single disks
                                            foreach (string f in v.Files)
                                            {
                                                if (!TitleCollectionManager.ContainsDisks(OMLEngine.FileSystem.NetworkScanner.FixPath(f)))
                                                {
                                                    Disk disk = new Disk();
                                                    disk.Path = f;
                                                    disk.Format = disk.GetFormatFromPath(f); //(VideoFormat)Enum.Parse(typeof(VideoFormat), fileExtension.ToUpperInvariant());
                                                    disk.Name = string.Format("Disk {0}", 0);
                                                    if (disk.Format != VideoFormat.UNKNOWN)
                                                    {
                                                        disks.Add(disk);
                                                    }
                                                }
                                                if (disks.Count != 0)
                                                {
                                                    short episodeno = 0;
                                                    if (v.EpisodeNumbers.Count > 0) episodeno = (short)v.EpisodeNumbers[0];

                                                    Title newTitle = TitleCollectionManager.CreateTitle(s_parent,
                                                        Path.GetFileNameWithoutExtension(f),
                                                        TitleTypes.Episode,
                                                        Tag,
                                                        (short)s.Number,
                                                        episodeno,
                                                        disks.ToArray());

                                                    CheckDiskPathForImages(newTitle, disks[0]);
                                                    NewTitles.Add(newTitle);
                                                    TitleCollectionManager.SaveTitleUpdates();

                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (File.Exists(file))
                    {
                        StSana_Log("Processing " + file);
                        string extension = Path.GetExtension(file).ToUpper().Replace(".", "");
                        extension = extension.Replace("-", "");

                        Disk disk = new Disk();
                        disk.Path = file;
                        disk.Format = disk.GetFormatFromPath(file); // (VideoFormat)Enum.Parse(typeof(VideoFormat), extension.ToUpperInvariant());
                        disk.Name = string.Format("Disk {0}", 0);

                        if (disk.Format != VideoFormat.UNKNOWN)
                        {
                            Title newTitle = TitleCollectionManager.CreateTitle(parentid,
                                Path.GetFileNameWithoutExtension(file),
                                TitleTypes.Unknown,
                                Tag,
                                new Disk[1] { disk });

                            CheckDiskPathForImages(newTitle, disk);
                            NewTitles.Add(newTitle);
                            TitleCollectionManager.SaveTitleUpdates();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utilities.DebugLine("[OMLEngine] CreateTitlesFromPathArray exception" + ex.Message);
                }
            }
            return NewTitles;
        }