Inheritance: MonoBehaviour
Esempio n. 1
0
        public static Photo ProcessPhoto(int buildingId, byte[] imageBytes, ImageFormat format, string extension,
                                         BuildingFacade buildingFacade, PhotoFacade photoFacade)
        {
            var photoId = Guid.NewGuid();

            //resolutions
            var vectors = new List <Vector2>();

            vectors.Add(new Vector2(800, 600));
            vectors.Add(new Vector2(600, 395));
            vectors.Add(new Vector2(280, 190));
            vectors.Add(new Vector2(200, 150));
            vectors.Add(new Vector2(115, 85));
            vectors.Add(new Vector2(50, 50));

            //load image
            using (var stream = new MemoryStream(imageBytes))
            {
                stream.Position = 0;
                using (Image image = Image.FromStream(stream))
                {
                    foreach (var v in vectors)
                    {
                        using (Image resized = ImageScaler.Crop(image, v.X, v.Y,
                                                                ImageScaler.AnchorPosition.Center))
                        {
                            string fileName = string.Format("{0}-{1}x{2}{3}",
                                                            photoId, v.X, v.Y, extension);

                            //UploadPhoto would go here
                            SavePhoto(buildingId, resized, fileName, format);
                        }
                    }
                }
            }

            //create the db reference for the images.
            var photo = new Photo();

            photo.PhotoId    = photoId;
            photo.BuildingId = buildingId;
            photo.Extension  = extension.Replace(".", string.Empty);

            if (photoFacade.GetPhotos(buildingId).Count(p => p.IsPrimary) == 0)
            {
                photo.IsPrimary = true;
            }

            if (photo.IsPrimary)
            {
                var building = buildingFacade.GetBuilding(buildingId);
                building.PrimaryPhotoId        = photo.PhotoId;
                building.PrimaryPhotoExtension = photo.Extension;
                buildingFacade.Save();
            }

            photoFacade.AddPhoto(buildingId, photo);
            photoFacade.Save();
            return(photo);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var building = new BuildingFacade();

            Console.WriteLine(building.InspectBuilding());

            Console.ReadLine();
        }
Esempio n. 3
0
 public static BuildingFacade getInstance()
 {
     if (Inst == null)
     {
         Inst = new BuildingFacade();
     }
     return(Inst);
 }
Esempio n. 4
0
        public static Photo ProcessPhoto(int buildingId, byte[] imageBytes, ImageFormat format, string extension,
			BuildingFacade buildingFacade, PhotoFacade photoFacade)
        {
            var photoId = Guid.NewGuid();

            //resolutions
            var vectors = new List<Vector2>();
            vectors.Add(new Vector2(800, 600));
            vectors.Add(new Vector2(600, 395));
            vectors.Add(new Vector2(280, 190));
            vectors.Add(new Vector2(200, 150));
            vectors.Add(new Vector2(115, 85));
            vectors.Add(new Vector2(50, 50));

            //load image
            using(var stream = new MemoryStream(imageBytes))
            {
                stream.Position = 0;
                using(Image image = Image.FromStream(stream))
                {
                    foreach(var v in vectors)
                    {
                        using(Image resized = ImageScaler.Crop(image, v.X, v.Y,
                                  ImageScaler.AnchorPosition.Center))
                        {
                            string fileName = string.Format("{0}-{1}x{2}{3}",
                                                photoId, v.X, v.Y, extension);

                            //UploadPhoto would go here
                            SavePhoto(buildingId, resized, fileName, format);
                        }
                    }
                }
            }

            //create the db reference for the images.
            var photo = new Photo();
            photo.PhotoId = photoId;
            photo.BuildingId = buildingId;
            photo.Extension = extension.Replace(".", string.Empty);

            if(photoFacade.GetPhotos(buildingId).Count(p => p.IsPrimary) == 0)
                photo.IsPrimary = true;

            if(photo.IsPrimary)
            {
                var building = buildingFacade.GetBuilding(buildingId);
                building.PrimaryPhotoId = photo.PhotoId;
                building.PrimaryPhotoExtension = photo.Extension;
                buildingFacade.Save();
            }

            photoFacade.AddPhoto(buildingId, photo);
            photoFacade.Save();
            return photo;
        }
        // GET: Adventures
        public ActionResult Index(int id)
        {
            if (!BuildingFacade.GetBuildingByNameAndVillageId("Tavern", id).Built)
            {
                return(RedirectToAction("VisitVillage", "Villages", new { id = id }));
            }

            var result1 = new List <AdventureDTO>(AdventureFacade.ListAdventures(id));
            var result2 = new List <UnitDTO>(UnitFacade.ListUnitsByVillage(id));
            var model   = new AdventureListViewModel()
            {
                Adventures = result1, Units = result2, VillageID = id
            };

            return(View("AdventureListView", model));
        }
Esempio n. 6
0
 private void OnClickUnlock(EventContext context)
 {
     BuildingFacade.getInstance().BuildingUnlock(m_BuildingId);
     Hide();
 }
 void OnEnable()
 {
     facade = (BuildingFacade)target;
 }
Esempio n. 8
0
 void OnEnable()
 {
     facade = (BuildingFacade)target;
 }
Esempio n. 9
0
 private void OnClickLevelUp(EventContext context)
 {
     BuildingFacade.getInstance().BuildingLevelUp(m_BuildingId);
 }
Esempio n. 10
0
    void BuildFromToNode(Node from, Node to)
    {
        Vector3 dirFromTo = (to.Position - from.Position).normalized;

        float space = Vector3.Distance(from.Position, to.Position);

        cursor = transform.TransformPoint(from.Position);

        GameObject facadeSide = new GameObject("FacadeSide");

        facadeSide.transform.SetParent(facadeParent.transform);
        facadeSide.transform.localScale    = Vector3.one;
        facadeSide.transform.localPosition = Vector3.zero;

        int currentIndex = int.MinValue;

        for (int i = 0; i < 100f; i++)
        {
            currentIndex = GetRandomFacadeIndex(space);
            // Place facade
            GameObject     facadeObj = null;
            BuildingFacade facade    = null;
            if (currentIndex == -1)
            {
                facadeObj = Instantiate(facadeStretchPrefab);
                facadeObj.transform.SetParent(facadeSide.transform);
                facadeObj.transform.localPosition = Vector3.zero;
                facadeObj.transform.localScale    = new Vector3(space, 1f, 1f);
            }
            else
            {
                facadeObj = Instantiate(facadePrefabs[currentIndex]);
                facadeObj.transform.SetParent(facadeSide.transform);
                facadeObj.transform.localPosition = Vector3.zero;
                facadeObj.transform.localScale    = Vector3.one;
            }

            facade = facadeObj.GetComponentInChildren <BuildingFacade>();

            if (currentIndex == -1)
            {
                float width = Vector3.Distance(facade.nodes[0].Position, facade.nodes[1].Position);
                facadeObj.transform.localScale = new Vector3(space / width, 1f, 1f);
            }

            if (i == 0)
            {
                facade.isFirst = true;
                facade.nodes[0].dirToInside = from.dirToInside;
            }
            if (facade.isStretchable)
            {
                facade.nodes[1].dirToInside = to.dirToInside;
            }
            facade.ID = facadeCounter++;
            facades.Add(facade);

            facadeObj.transform.rotation = Quaternion.LookRotation(UtilityTools.MathHelper.LeftSideNormal(dirFromTo));
            // Set position in regards to the first node
            //facade.transform.position = cursor - footPrint.nodes[0].Position;
            Vector3 toCursor = cursor - facadeObj.transform.TransformPoint(facade.nodes[0].Position);
            facadeObj.transform.position += toCursor;

            if (currentIndex != -1)
            {
                float facadeWidth = Vector3.Distance(facade.nodes[0].Position, facade.nodes[1].Position);
                cursor += dirFromTo * facadeWidth;
                space  -= facadeWidth;
            }
            else
            {
                break;
            }
        }
    }