Beispiel #1
0
        /// <summary>
        /// Get the surrounding locations based on a strength radius
        /// </summary>
        /// <param name="strength">number of places to go out</param>
        /// <returns>list of valid surrounding locations</returns>
        public IEnumerable <ILocation> GetSurroundings(int strength)
        {
            var radiusLocations = new List <ILocation>();

            //If we don't have any paths out what can we even do
            if (Pathways.Count() == 0)
            {
                return(radiusLocations);
            }

            var currentRadius   = 0;
            var currentPathsSet = Pathways.EntitiesContained();

            while (currentRadius <= strength && currentPathsSet.Count() > 0)
            {
                var currentLocsSet = currentPathsSet.Select(path => path.ToLocation);

                if (currentLocsSet.Count() == 0)
                {
                    break;
                }

                radiusLocations.AddRange(currentLocsSet);
                currentPathsSet = currentLocsSet.SelectMany(ro => ro.Pathways.EntitiesContained());

                currentRadius++;
            }

            return(radiusLocations);
        }
Beispiel #2
0
        public IActionResult Create(Pathways pathway)
        {
            try
            {
                var claimsIdentity = (ClaimsIdentity)User.Identity;

                var      claim   = claimsIdentity.Claims.ToArray();
                var      email   = claim[1].Value;
                var      userid  = User.Claims.FirstOrDefault(c => c.Type == AppUtility.UserId).Value;      //claim[3].Value;
                DateTime today   = DateTime.Now;
                var      user    = _users.FindById(userid.ToString());
                var      issuers = _issuer.AsQueryable().ToList();
                var      issuer  = issuers.Where(e => e.UserId == new ObjectId(userid)).FirstOrDefault();
                pathway.CreatedAt = today;
                pathway.IssuersId = issuer.Id;
                pathway.CreatedBy = issuer.Name;
                _path.InsertOne(pathway);
            }
            catch (Exception)
            {
                ModelState.AddModelError(string.Empty, "Please try again later.");
                return(View());
            }
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public async void GetAllPathways_returns_all_pathways()
        {
            MockPathwaysConfigurationManager.Setup(m => m.UseLivePathways).Returns(false);
            _pathwayRepository = new PathwayRepository(GraphRepository, MockPathwaysConfigurationManager.Object);

            var res = await _pathwayRepository.GetAllPathways();

            Assert.AreEqual(res.Count(), Pathways.Count());
        }
Beispiel #4
0
        public async void GetGroupedPathways_returns_grouped_pathways()
        {
            MockPathwaysConfigurationManager.Setup(m => m.UseLivePathways).Returns(false);
            _pathwayRepository = new PathwayRepository(GraphRepository, MockPathwaysConfigurationManager.Object);

            var allDistinctPathways = Pathways.Where(p => p.Module == "1").Select(p => p.Title).Distinct();

            var res = await _pathwayRepository.GetGroupedPathways();

            Assert.AreEqual(res.Count(), allDistinctPathways.Count());
        }
Beispiel #5
0
        public async void GetAllPathways_when_only_using_live_returns_only_live_pathways()
        {
            MockPathwaysConfigurationManager.Setup(m => m.UseLivePathways).Returns(true);
            _pathwayRepository = new PathwayRepository(GraphRepository, MockPathwaysConfigurationManager.Object);

            var liveOnlyPathways = PathwaysConfigurationManager.GetLivePathwaysElements().Select(e => e.Title);

            var res = await _pathwayRepository.GetAllPathways();

            Assert.AreEqual(res.Count(), Pathways.Count(p => liveOnlyPathways.Contains(p.Title)));
        }
Beispiel #6
0
        public async void GetGroupedPathways_when_only_using_live_returns_grouped_pathways()
        {
            MockPathwaysConfigurationManager.Setup(m => m.UseLivePathways).Returns(true);
            _pathwayRepository = new PathwayRepository(GraphRepository, MockPathwaysConfigurationManager.Object);

            var liveOnlyPathways         = PathwaysConfigurationManager.GetLivePathwaysElements().Select(e => e.Title);
            var liveOnlyDistinctPathways = Pathways.Where(p => p.Module == "1" && liveOnlyPathways.Contains(p.Title)).Select(p => p.Title).Distinct();

            var res = await _pathwayRepository.GetGroupedPathways();

            Assert.AreEqual(res.Count(), liveOnlyDistinctPathways.Count());
        }
Beispiel #7
0
        /// <summary>
        /// Move an entity out of this' named container
        /// </summary>
        /// <typeparam name="T">the type of entity to remove</typeparam>
        /// <param name="thing">the entity</param>
        /// <param name="containerName">the name of the container</param>
        /// <returns>errors</returns>
        public string MoveFrom <T>(T thing, string containerName)
        {
            var implimentedTypes = DataUtility.GetAllImplimentingedTypes(typeof(T));

            if (implimentedTypes.Contains(typeof(IInanimate)))
            {
                var obj = (IInanimate)thing;

                if (!Contents.Contains(obj, containerName))
                {
                    return("That is not in the container");
                }

                Contents.Remove(obj, containerName);
                obj.CurrentLocation = null;
                this.UpsertToLiveWorldCache();
                return(string.Empty);
            }


            if (implimentedTypes.Contains(typeof(IMobile)))
            {
                var obj = (IMobile)thing;

                if (!MobilesInside.Contains(obj, containerName))
                {
                    return("That is not in the container");
                }

                MobilesInside.Remove(obj, containerName);
                obj.CurrentLocation = null;
                this.UpsertToLiveWorldCache();
                return(string.Empty);
            }

            if (implimentedTypes.Contains(typeof(IPathway)))
            {
                var obj = (IPathway)thing;

                if (!Pathways.Contains(obj, containerName))
                {
                    return("That is not in the container");
                }

                Pathways.Remove(obj, containerName);
                obj.CurrentLocation = null;
                this.UpsertToLiveWorldCache();
                return(string.Empty);
            }

            return("Invalid type to move from container.");
        }
Beispiel #8
0
        /// <summary>
        /// Move an entity into a named container in this
        /// </summary>
        /// <typeparam name="T">the type of the entity to add</typeparam>
        /// <param name="thing">the entity to add</param>
        /// <param name="containerName">the name of the container</param>
        /// <returns>errors</returns>
        public string MoveInto <T>(T thing, string containerName)
        {
            var implimentedTypes = DataUtility.GetAllImplimentingedTypes(typeof(T));

            if (implimentedTypes.Contains(typeof(IInanimate)))
            {
                var obj = (IInanimate)thing;

                if (Contents.Contains(obj, containerName))
                {
                    return("That is already in the container");
                }

                Contents.Add(obj, containerName);
                obj.CurrentLocation = this;
                this.UpsertToLiveWorldCache();
                return(string.Empty);
            }

            if (implimentedTypes.Contains(typeof(IMobile)))
            {
                var obj = (IMobile)thing;

                if (MobilesInside.Contains(obj, containerName))
                {
                    return("That is already in the container");
                }

                MobilesInside.Add(obj, containerName);
                obj.CurrentLocation = this;
                this.UpsertToLiveWorldCache();
                return(string.Empty);
            }

            if (implimentedTypes.Contains(typeof(IPathway)))
            {
                var obj = (IPathway)thing;

                if (Pathways.Contains(obj, containerName))
                {
                    return("That is already in the container");
                }

                Pathways.Add(obj, containerName);
                obj.CurrentLocation = this;
                this.UpsertToLiveWorldCache();
                return(string.Empty);
            }

            return("Invalid type to move to container.");
        }
Beispiel #9
0
        public IActionResult PathwayEditPost(string id, Pathways p)
        {
            var claimsIdentity = (ClaimsIdentity)User.Identity;
            /*var claim = claimsIdentity.FindFirst(ClaimTypes.Email);*/
            var claim  = claimsIdentity.Claims.ToArray();
            var email  = claim[1].Value;
            var userid = User.Claims.FirstOrDefault(c => c.Type == AppUtility.UserId).Value;//  claim[3].Value;

            var user    = _users.FindById(userid.ToString());
            var issuers = _issuer.AsQueryable().ToList();
            var issuer  = issuers.Where(e => e.UserId == new ObjectId(userid)).FirstOrDefault();

            p.Id        = new ObjectId(id);
            p.IssuersId = issuer.Id;
            p.CreatedBy = issuer.Name;
            _path.ReplaceOne(p);
            return(RedirectToAction("Index"));
        }
Beispiel #10
0
        /// <summary>
        /// Get all of the entities matching a type inside this in a named container
        /// </summary>
        /// <typeparam name="T">the type</typeparam>
        /// <returns>the contained entities</returns>
        /// <param name="containerName">the name of the container</param>
        public IEnumerable <T> GetContents <T>(string containerName)
        {
            var implimentedTypes = DataUtility.GetAllImplimentingedTypes(typeof(T));

            var contents = new List <T>();

            if (implimentedTypes.Contains(typeof(IMobile)))
            {
                contents.AddRange(MobilesInside.EntitiesContained(containerName).Select(ent => (T)ent));
            }

            if (implimentedTypes.Contains(typeof(IInanimate)))
            {
                contents.AddRange(Contents.EntitiesContained(containerName).Select(ent => (T)ent));
            }

            if (implimentedTypes.Contains(typeof(IPathway)))
            {
                contents.AddRange(Pathways.EntitiesContained(containerName).Select(ent => (T)ent));
            }

            return(contents);
        }
Beispiel #11
0
 public void AddPathway(Direction direction, Locale locale)
 {
     Pathways.Add(direction, locale);
 }
    void BoardSetup()
    {
        boardHolder = new GameObject("Board").transform;
        //Room 1
        for (int x = -1; x < innerColumns + 1; x++)
        {
            for (int y = -1; y < innerRows + 1; y++)
            {
                if (x == 8 && y == 3)
                {
                    continue;
                }
                GameObject toInstantiate = innerTiles;
                GameObject instance      =
                    Instantiate(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
                if (x == -1 || x == innerColumns || y == -1 || y == innerRows)
                {
                    GameObject toInstantiateW = innerWalls;
                    GameObject instanceW      =
                        Instantiate(toInstantiateW, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
                }
            }
        }
        //Room 2
        for (int x = 9; x < outerColumns + 1; x++)
        {
            for (int y = -20; y < outerRows + 1; y++)
            {
                if (x == 9 && y == 3)
                {
                    continue;
                }
                if (x == 9 && y == 23)
                {
                    continue;
                }
                GameObject toInstantiate = outerTiles [Random.Range(0, outerTiles.Length)];
                if (x == 9 || x == outerColumns || y == -20 || y == outerRows)
                {
                    toInstantiate = outerWalls;
                }
                GameObject instance =
                    Instantiate(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
            }
        }
        //boss 1
        for (int x = -10; x < bossColumns + 1; x++)
        {
            for (int y = 0; y < bossRows + 1; y++)
            {
                if (x == 15 && y == 1)
                {
                    continue;
                }
                GameObject toInstantiate = bossTiles;
                if (x == -10 || x == bossColumns || y == 0 || y == bossRows)
                {
                    toInstantiate = bossWalls;
                }
                GameObject instance =
                    Instantiate(toInstantiate, new Vector3(x - 7, y + 22, 0f), Quaternion.identity) as GameObject;
                instance.transform.SetParent(boardHolder);
            }
        }
        //Player
        GameObject playerI =
            Instantiate(player, new Vector3(3, 3, 0f), Quaternion.identity) as GameObject;

        //Nurse
        Instantiate(nurse, new Vector3(18, 14, 0f), Quaternion.identity);
        //Flower
        Instantiate(flower, new Vector3(18, -13, 0f), Quaternion.identity);
        //Owl
        Instantiate(owl, new Vector3(3, 7, 0f), Quaternion.identity);
        //BoyTwin
        Instantiate(boyTwin, new Vector3(16, -15, 0f), Quaternion.identity);
        //GirlTwin
        Instantiate(girlTwin, new Vector3(17, -15, 0f), Quaternion.identity);
        //Librarian
        Instantiate(librarian, new Vector3(11, -3, 0f), Quaternion.identity);
        //Boss
        Instantiate(boss, new Vector3(-5, 28, 0f), Quaternion.identity);
        //Music
        Instantiate(music, new Vector3(22, -4, 0f), Quaternion.identity);
        // Darkness
        GameObject dark =
            Instantiate(darkI, new Vector3(3, 3, 0f), Quaternion.identity) as GameObject;
        GameObject dark1 =
            Instantiate(darkO, new Vector3(18, 2, 0f), Quaternion.identity) as GameObject;
        GameObject dark2 =
            Instantiate(darkB, new Vector3(-5, 22, 0f), Quaternion.identity) as GameObject;
        //Add darkness to countdown for reset
        GameObject timer     = GameObject.Find("Timer");
        CountDown  countDown = timer.GetComponent <CountDown> ();

        countDown.darkI = dark;
        countDown.darkO = dark1;
        countDown.darkB = dark2;
        //CoverWalls
        GameObject coverWall1 =
            Instantiate(coverWallO, new Vector3(8, 3, 0f), Quaternion.identity) as GameObject;
        GameObject coverWall2 =
            Instantiate(coverWallT, new Vector3(9, 23, 0f), Quaternion.identity) as GameObject;

        //Path
        Instantiate(path, new Vector3(7, 3, 0f), Quaternion.identity);
        Instantiate(path, new Vector3(8, 3, 0f), Quaternion.identity);
        GameObject gPath =
            Instantiate(pathT, new Vector3(9, 3, 0f), Quaternion.identity) as GameObject;

        Pathways pathScript = gPath.GetComponent <Pathways> ();

        pathScript.player    = playerI;
        pathScript.darkI     = dark;
        pathScript.darkO     = dark1;
        pathScript.coverWall = coverWall1;

        Instantiate(path, new Vector3(10, 3, 0f), Quaternion.identity);
        Instantiate(path, new Vector3(6, 3, 0f), Quaternion.identity);

        dark.SetActive(false);
        //Special Tiles
        Instantiate(floorT, new Vector3(2, 7, 0f), Quaternion.identity);
        Instantiate(floorH, new Vector3(0, 2, 0f), Quaternion.identity);
        Instantiate(floorB, new Vector3(3, 0, 0f), Quaternion.identity);
        Instantiate(floorG, new Vector3(4, 0, 0f), Quaternion.identity);
        Instantiate(floorM, new Vector3(5, 7, 0f), Quaternion.identity);
        Instantiate(floorL, new Vector3(0, 5, 0f), Quaternion.identity);
        //Path to Boss
        for (int x = 3; x < 3 + 1; x++)
        {
            for (int y = 3; y < 23 + 1; y++)
            {
                GameObject toInstantiate = path;
                GameObject instance      =
                    Instantiate(toInstantiate, new Vector3(x + 8, y, 0f), Quaternion.identity) as GameObject;
            }
        }
        GameObject qPath =
            Instantiate(pathE, new Vector3(10, 23, 0f), Quaternion.identity) as GameObject;
        PathToBoss pathScript2 = qPath.GetComponent <PathToBoss> ();

        pathScript2.player    = playerI;
        pathScript2.dark      = dark1;
        pathScript2.darkB     = dark2;
        pathScript2.coverWall = coverWall2;

        Instantiate(path, new Vector3(9, 23, 0f), Quaternion.identity);
        //Bush
        Instantiate(plantA, new Vector3(10, 20, 0f), Quaternion.identity);
        Instantiate(plantB, new Vector3(22, -15, 0f), Quaternion.identity);
        Instantiate(plantA, new Vector3(14, -3, 0f), Quaternion.identity);
        Instantiate(plantB, new Vector3(20, 3, 0f), Quaternion.identity);

        // Tree Set Up
        Instantiate(tree1, new Vector3(14, -13, 0f), Quaternion.identity);
        Instantiate(tree2, new Vector3(16, 16, 0f), Quaternion.identity);
        Instantiate(ctree1, new Vector3(14, -13, 0f), Quaternion.identity);
        Instantiate(ctree2, new Vector3(16, 16, 0f), Quaternion.identity);
    }