Exemplo n.º 1
0
    private Template LoadHouse(Tilemap tilemap, string name, Character character)
    {
        Template template = LoadTemplate(tilemap, out RectInt usedSpace);
        House    house    = House.AddTo(gameObject, name, character, usedSpace);

        house.onHouseClick = onHouseClick;
        house.defenses     = giveEachHouse.Select(defense => Instantiate(defense)).ToList();
        usedSpaces.Add(usedSpace, house);
        return(template);
    }
Exemplo n.º 2
0
        public void Add_WhenSomeTilesAreInInvalidRegion_ShouldIgnoreRegions(
            ISimpleGameObject simpleGameObject,
            [Frozen] IRegionLocator regionLocator,
            IRegion region0,
            [Frozen] ITileLocator tileLocator,
            RegionManager regionManager)
        {
            simpleGameObject.PrimaryPosition.Returns(new Position(1, 1));
            regionLocator.GetRegionIndex(0, 0).ReturnsForAnyArgs <ushort>(2);

            regionLocator.GetRegionIndex(1, 1).Returns <ushort>(0);
            regionLocator.GetRegionIndex(2, 1).Returns <ushort>(1);

            tileLocator.ForeachMultitile(simpleGameObject).Returns(new[]
            {
                new Position(1, 1),
                new Position(2, 1),
            });

            regionManager.AddRegion(region0);

            regionManager.Add(simpleGameObject);

            region0.Received(1).AddObjectToTile(simpleGameObject, 1, 1);
        }
Exemplo n.º 3
0
        public void Add_ShouldAddObjectToAllTiles(
            ISimpleGameObject simpleGameObject,
            [Frozen] IRegionLocator regionLocator,
            IRegion region0,
            IRegion region1,
            IRegion region2,
            [Frozen] ITileLocator tileLocator,
            RegionManager regionManager)
        {
            simpleGameObject.PrimaryPosition.Returns(new Position(1, 2));
            regionLocator.GetRegionIndex(0, 0).ReturnsForAnyArgs <ushort>(2);

            regionLocator.GetRegionIndex(1, 1).Returns <ushort>(0);
            regionLocator.GetRegionIndex(1, 2).Returns <ushort>(0);
            regionLocator.GetRegionIndex(2, 1).Returns <ushort>(1);

            tileLocator.ForeachMultitile(simpleGameObject).Returns(new[]
            {
                new Position(1, 1),
                new Position(1, 2),
                new Position(2, 1),
            });

            regionManager.AddRegion(region0);
            regionManager.AddRegion(region1);
            regionManager.AddRegion(region2);

            regionManager.Add(simpleGameObject);

            region0.Received(1).AddObjectToTile(simpleGameObject, 1, 1);
            region0.Received(1).AddObjectToTile(simpleGameObject, 1, 2);
            region1.Received(1).AddObjectToTile(simpleGameObject, 2, 1);
            region2.DidNotReceive().AddObjectToTile(Arg.Any <ISimpleGameObject>(), Arg.Any <uint>(), Arg.Any <uint>());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new region
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Region CreateRegion(string name)
        {
            var region = new Region(name);

            RegionManager.Add(region);
            return(region);
        }
        private static void CreateRegion(Entity entity)
        {
            var target = PositionClone()[entity];

            if (target.RegionGuid != Guid.Empty)
            {
                RegionManager.Remove(target.RegionGuid);
            }

            if (target.Pos1 != default(Vector3D) && target.Pos2 == default(Vector3D))
            {
                target.RegionGuid = RegionManager.Add(target.Pos1.From3Dto3I(), Tiles.GetTiles());
            }
            else if (target.Pos2 != default(Vector3D) && target.Pos1 == default(Vector3D))
            {
                target.RegionGuid = RegionManager.Add(target.Pos2.From3Dto3I(), Tiles.GetTiles());
            }
            else
            {
                target.RegionGuid = RegionManager.AddCube(target.Pos1.From3Dto3I(), target.Pos2.From3Dto3I(), Tiles.GetTiles());
            }
        }
Exemplo n.º 6
0
        public void Add_ShouldAddObjectToPrimaryRegion(
            ISimpleGameObject simpleGameObject,
            [Frozen] IRegionLocator regionLocator,
            IRegion region0,
            IRegion region1,
            RegionManager regionManager)
        {
            simpleGameObject.PrimaryPosition.Returns(new Position(1, 2));
            regionLocator.GetRegionIndex(simpleGameObject.PrimaryPosition.X, simpleGameObject.PrimaryPosition.Y).Returns <ushort>(1);

            regionManager.AddRegion(region0);
            regionManager.AddRegion(region1);

            regionManager.Add(simpleGameObject);

            region0.DidNotReceive().Add(simpleGameObject);
            region1.Received(1).Add(simpleGameObject);
        }
Exemplo n.º 7
0
        public ActionResult RegionRegister(Region region)
        {
            if (ModelState.IsValid)
            {
                BusinnessLayerResult <Region> reg = regionManager.RegisterRegion(region);
                if (reg.Errors.Count > 0)
                {
                    reg.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                    return(View(region));
                }
                OkViewModel okViewModel = new OkViewModel()
                                          //VİEW MODALLERDE PUPOP OLACAK
                {
                    Title  = "Kayıt Başarılı",
                    Header = "Kayıt Başarılı",
                };
                okViewModel.Items.Add("Bölge Başarılı Bir Şekilde Kaydedilmiştir.");
                return(View("OK", okViewModel));
            }



            if (region.Id == 0)
            {
                regionManager.Add(region);
            }
            else
            {
                var kontrol = regionManager.Find(x => x.Id == region.Id);
                if (kontrol != null)
                {
                    regionManager.Update(region);
                }
                else
                {
                    //HATA SAYFASİNA GİDECEK
                }
            }
            Listeler();
            return(View("RegionRegister", region));
        }