public static void SpawnDecor(Decor decorPrefab, Vector3?spawnPos = null) { Decor decor = Instantiate <Decor>(decorPrefab, instance.transform); decor.spriteRenderer.flipX = Random.value > 0.5f; if (!spawnPos.HasValue) { Vector3 spawnOffset = Random.insideUnitSphere.normalized * 0.99f; float noise = Mathf.PerlinNoise( (spawnOffset.x + spawnOffset.z) * instance._noiseScale, (spawnOffset.y + spawnOffset.z) * instance._noiseScale); while (noise < decorPrefab.GetNoiseThreshold()) { spawnOffset = Random.insideUnitSphere.normalized * 0.99f; noise = Mathf.PerlinNoise( (spawnOffset.x + spawnOffset.z) * instance._noiseScale, (spawnOffset.y + spawnOffset.z) * instance._noiseScale); } spawnOffset *= instance._scaleMesh.localScale.x / 2f; spawnPos = instance.transform.position + spawnOffset; } decor.transform.position = spawnPos.Value; decor.initOffset = spawnPos.Value - instance.transform.position; }
/// <summary> /// Create and add <see cref="Decor"/> from supplied <see cref="HousingDecorInfoEntry"/> to your crate. /// </summary> public void DecorCreate(HousingDecorInfoEntry entry, uint quantity) { var residenceDecor = new ServerHousingResidenceDecor(); for (uint i = 0u; i < quantity; i++) { Decor decor = residence.DecorCreate(entry); decor.Type = DecorType.Crate; residenceDecor.DecorData.Add(new ServerHousingResidenceDecor.Decor { RealmId = WorldServer.RealmId, DecorId = decor.DecorId, ResidenceId = residence.Id, DecorType = decor.Type, PlotIndex = decor.PlotIndex, Scale = decor.Scale, Position = decor.Position, Rotation = decor.Rotation, DecorInfoId = decor.Entry.Id }); } EnqueueToAll(residenceDecor); }
public ActionResult Create([Bind(Include = "DecorCode,DecorName,CategoryId,Description,Price,Image,ImageType,IsActive")] Decor decor, HttpPostedFileBase image1) { if (image1 != null) { decor.Image = new byte[image1.ContentLength]; image1.InputStream.Read(decor.Image, 0, image1.ContentLength); } else { ModelState.AddModelError(string.Empty, "Please add image"); } if (ModelState.IsValid) { //foreach (HttpPostedFileBase Image in image1) //{ // //Checking file is available to save. // if (Image != null) // { // var InputFileName = Path.GetFileName(Image.FileName); // var ServerSavePath = Path.Combine(Server.MapPath("~/UploadedFiles/") + InputFileName); // //Save file to server folder // Image.SaveAs(ServerSavePath); // //assigning file uploaded status to ViewBag for showing message to user. // ViewBag.UploadStatus = Image.Count().ToString() + " files uploaded successfully."; // } //} db.Decors.Add(decor); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Category_Name", decor.CategoryId); return(View(decor)); }
private void SendResidenceDecor(Player player) { var residenceDecor = new ServerHousingResidenceDecor(); Decor[] decors = residence.GetDecor().ToArray(); for (uint i = 0u; i < decors.Length; i++) { // client freaks out if too much decor is sent in a single message, limit to 100 if (i != 0u && i % 100u == 0u) { player.Session.EnqueueMessageEncrypted(residenceDecor); residenceDecor = new ServerHousingResidenceDecor(); } Decor decor = decors[i]; residenceDecor.DecorData.Add(new ServerHousingResidenceDecor.Decor { RealmId = WorldServer.RealmId, DecorId = decor.DecorId, ResidenceId = residence.Id, DecorType = decor.Type, Scale = decor.Scale, Position = decor.Position, Rotation = decor.Rotation, DecorInfoId = decor.Entry.Id, ColourShift = decor.ColourShiftId }); if (i == decors.Length - 1) { player.Session.EnqueueMessageEncrypted(residenceDecor); } } }
public void StartGame() { decor = new Decor(Raylib.GetScreenWidth(), Raylib.GetScreenHeight()); rocks = new Rocks(Raylib.GetScreenWidth() - 50, Raylib.GetScreenHeight() - 50); astronaut = new Astronaut(350, 350, Raylib.GetScreenWidth(), Raylib.GetScreenHeight(), rocks); Continue(); }
private void DecorDelete(ClientHousingDecorUpdate.DecorUpdate update) { Decor decor = residence.GetDecor(update.DecorId); if (decor == null) { throw new InvalidPacketValueException(); } if (decor.Position != Vector3.Zero) { throw new InvalidOperationException(); } residence.DecorDelete(decor); // TODO: send packet to remove from decor list var residenceDecor = new ServerHousingResidenceDecor(); residenceDecor.DecorData.Add(new ServerHousingResidenceDecor.Decor { RealmId = WorldServer.RealmId, ResidenceId = residence.Id, DecorId = decor.DecorId, DecorInfoId = 0 }); EnqueueToAll(residenceDecor); }
void GenerateDecors() { float xMax = _worldSize.x / 2; float xMin = -xMax; float x = xMin; int currentGroupSize = 0; int targetGroupSize = 0; while (x < xMax) { if (currentGroupSize >= targetGroupSize) { float offsetBetweenGroups = _random.NextFloat(_offsetRangeBetweenGroups); x += offsetBetweenGroups; currentGroupSize = 0; targetGroupSize = _random.Next(_groupRange); } int decorIndex = _random.Next(_decorLibrary.Count); Decor decor = Instantiate(_decorLibrary[decorIndex], x); x += decor.collider.rect.size.x; currentGroupSize++; if (currentGroupSize < targetGroupSize) { x += _random.NextFloat(_offsetRangeInGroup); } } }
public void LoadDecor(Decor recoveredDecor) { decorParams = recoveredDecor; transform.position = decorParams.position; transform.rotation = Quaternion.Euler(decorParams.rotation); transform.parent = _Grid.instance.kuboGrid[decorParams.parent.nodeIndex - 1].cubeOnPosition.transform; }
public ActionResult DeleteConfirmed(int id) { Decor decor = db.Decors.Find(id); db.Decors.Remove(decor); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "DecorID,DecorColourOne,DecorPrice")] Decor decor) { if (ModelState.IsValid) { db.Entry(decor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(decor)); }
public async Task <IActionResult> OnGetAsync(int id) { Decor = await _db.Decors.FindAsync(id); if (Decor == null) { return(NotFound()); } return(Page()); }
Decor Instantiate(Decor decor, float x) { Decor d = GameObject.Instantiate(decor); d.transform.parent = transform; d.transform.position = new Vector3(x, _yBase, _decorDepth); d.Init(_random); return(d); }
public ActionResult Edit([Bind(Include = "DecorCode,DecorName,CategoryId,Description,Price,Image,ImageType,IsActive")] Decor decor) { if (ModelState.IsValid) { db.Entry(decor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Category_Name", decor.CategoryId); return(View(decor)); }
private void DecorMove(ClientHousingDecorUpdate.DecorUpdate update) { Decor decor = residence.GetDecor(update.DecorId); if (decor == null) { throw new InvalidPacketValueException(); } // TODO: research 0.835f if (decor.Type == DecorType.Crate) { if (decor.Entry.Creature2IdActiveProp != 0u) { // TODO: used for decor that have an associated entity } // crate->world var position = new Vector3(update.Position.X, update.Position.Y + 0.835f, update.Position.Z); decor.Move(update.DecorType, position, update.Rotation, update.Scale); } else { if (update.DecorType == DecorType.Crate) { decor.Crate(); } else { // world->world var position = new Vector3(update.Position.X, update.Position.Y + 0.835f, update.Position.Z); decor.Move(update.DecorType, position, update.Rotation, update.Scale); } } EnqueueToAll(new ServerHousingResidenceDecor { Operation = 0, DecorData = new List <ServerHousingResidenceDecor.Decor> { new ServerHousingResidenceDecor.Decor { RealmId = WorldServer.RealmId, DecorId = decor.DecorId, ResidenceId = residence.Id, DecorType = decor.Type, Scale = decor.Scale, Position = decor.Position, Rotation = decor.Rotation, DecorInfoId = decor.Entry.Id } } }); }
public ActionResult Create([Bind(Include = "DecorID,DecorColourOne,DecorPrice")] Decor decor) { if (ModelState.IsValid) { db.Decors.Add(decor); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(decor)); }
public void CreateNewDecor() { decorParams = new Decor(); //assign grid decorParams.parent = _Grid.instance.kuboGrid[transform.parent.gameObject.GetComponent <_CubeBase>().myIndex - 1]; decorParams.position = transform.position; decorParams.rotation = transform.rotation.eulerAngles; SaveAndLoad.instance.activeDecor.Add(decorParams); }
public bool Include(Decor elem) { try { elem.Render(this); } catch { return(false); } return(true); }
public bool Exclude(Decor elem) { try { elem.Remove(); } catch { return(false); } return(true); }
public bool Refresh(Decor elem) { try { elem.Redraw(); } catch { return(false); } return(true); }
// GET: Decors/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Decor decor = db.Decors.Find(id); if (decor == null) { return(HttpNotFound()); } return(View(decor)); }
// GET: Decors/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Decor decor = db.Decors.Find(id); if (decor == null) { return(HttpNotFound()); } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Category_Name", decor.CategoryId); return(View(decor)); }
protected override void LoadContent() { //Load Decors Decor = new Decor(); Decor.LoadDecors(Content, 2); //Load Game Over GameOverString = Content.Load <SpriteFont>("Sprites/GameOver/GameOverString"); GameOver.LoadContent(Content, "Sprites/GameOver/Game Over"); //Sound : //Song song = Content.Load<Song>("Kalimba"); //MediaPlayer.Play(song); //Load Joueurs et Enemis joueur.LoadContent(Content, "Sprites/Perso/mario", 4, 4, "h"); Enemis = new Sprite[1]; for (int i = 0; i < Enemis.Length; i++) { Enemis[i] = new Sprite(); Enemis[i].LoadContent(Content, "Sprites/Enemis/enemisD"); } for (int i = 0; i < Enemis.Length; i++) //On initialise ici car l'on a besoin de la taille du fond et des enemis donc il faut qu'il soit load { Enemis[i].Initialize(new Vector2(rand.Next(0, Decor.back.rectangle.Right - Enemis[i].Width), rand.Next(0, Decor.back.rectangle.Bottom - Enemis[i].Height))); } //Load vie et mana for (int i = 0; i < SLife.Length; i++) { SLife[i].LoadContent(Content, "Sprites/Life"); } for (int i = 0; i < SMana.Length; i++) { SMana[i].LoadContent(Content, "Sprites/Mana"); } SpriteBatch = new SpriteBatch(GraphicsDevice); //Load le menu TexturesMenu = new LoadM(); TexturesMenu.LoadMenu(Content); //Load la camera _camera = new Camera.Camera(Decor.backRectangle.Width, Decor.backRectangle.Height, GraphicsDevice); }
public override List <NomTexture> Name() { if (Decor == null) { return new List <NomTexture>() { NomTexture.CrossedCircle } } ; var textures = Decor.Name(); textures.Add(NomTexture.CrossedCircle); return(textures); } }
public override List <NomTexture> Name() { if (Decor == null) { return new List <NomTexture>() { NomTexture.Plane1 } } ; var textures = Decor.Name(); textures.Add(NomTexture.Plane1); return(textures); } }
private void DecorDelete(ClientHousingDecorUpdate.DecorUpdate update) { Decor decor = residence.GetDecor(update.DecorId); if (decor == null) { throw new InvalidPacketValueException(); } if (decor.Position != Vector3.Zero) { throw new InvalidOperationException(); } residence.DecorDelete(decor); // TODO: send packet to remove from decor list }
public ActionResult Create([Bind(Include = "DecorCode,DecorName,CategoryId,Description,Price,Image,ImageType,IsActive")] Decor decor, HttpPostedFileBase image1) { if (image1 != null) { decor.Image = new byte[image1.ContentLength]; image1.InputStream.Read(decor.Image, 0, image1.ContentLength); } else { ModelState.AddModelError(string.Empty, "Please add image"); } if (ModelState.IsValid) { db.Decors.Add(decor); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Category_Name", decor.CategoryId); return(View(decor)); }
private void DecorCreate(Player player, ClientHousingDecorUpdate.DecorUpdate update) { HousingDecorInfoEntry entry = GameTableManager.HousingDecorInfo.GetEntry(update.DecorInfoId); if (entry == null) { throw new InvalidPacketValueException(); } if (entry.CostCurrencyTypeId != 0u && entry.Cost != 0u) { /*if (!player.CurrencyManager.CanAfford((byte)entry.CostCurrencyTypeId, entry.Cost)) * { * // TODO: show error * return; * } * * player.CurrencyManager.CurrencySubtractAmount((byte)entry.CostCurrencyTypeId, entry.Cost);*/ } Decor decor = residence.DecorCreate(entry); decor.Type = update.DecorType; if (update.ColourShiftId != decor.ColourShiftId) { if (update.ColourShiftId != 0u) { ColorShiftEntry colourEntry = GameTableManager.ColorShift.GetEntry(update.ColourShiftId); if (colourEntry == null) { throw new InvalidPacketValueException(); } } decor.ColourShiftId = update.ColourShiftId; } if (update.DecorType != DecorType.Crate) { if (update.Scale < 0f) { throw new InvalidPacketValueException(); } // new decor is being placed directly in the world decor.Position = update.Position; decor.Rotation = update.Rotation; decor.Scale = update.Scale; } EnqueueToAll(new ServerHousingResidenceDecor { Operation = 0, DecorData = new List <ServerHousingResidenceDecor.Decor> { new ServerHousingResidenceDecor.Decor { RealmId = WorldServer.RealmId, DecorId = decor.DecorId, ResidenceId = residence.Id, DecorType = decor.Type, Scale = decor.Scale, Position = decor.Position, Rotation = decor.Rotation, DecorInfoId = decor.Entry.Id, ColourShift = decor.ColourShiftId } } }); }
//lit une image précedemment utilisée pour initialiser les salles pour remplir les salles d'objets public void fillRoom(Bitmap image) { int xStart; int yStart; int width; int height; Color clr; byte R; byte G; byte B; foreach (Salle room in floor) { //Console.WriteLine("Parcours de la salle n°" + room.getId_salle()); width = (int)room.getContour().GetLongueurRectangle(); height = (int)room.getContour().GetLargeurRectangle(); xStart = (int)room.getContour().getUsefulPoint().getAbscisse(); yStart = (int)room.getContour().getUsefulPoint().getOrdonnee(); for (int i = 1; i < height; i++) { for (int j = 1; j < width; j++) { clr = image.GetPixel(xStart + j, yStart + i); R = clr.R; G = clr.G; B = clr.B; CodeRGB idObject = new CodeRGB(R, G, B); if (index.ContainsKey(idObject) && index[idObject] != "vide de gimp") { //Console.WriteLine("x: " + (xStart + j) + " y: " + (yStart + i) + " l'objet est un : " + index[idObject]); float abscisse_rel = j; float ordonnee_rel = i; float abscisse_abs = xStart + j; float ordonnee_abs = yStart + i; int entity_type; int shape_type; string nom; short id; bool passThrough; Rectangle rec; string[] info = index[idObject].Split('|'); nom = info[0]; entity_type = Int32.Parse(info[1]); id = Int16.Parse(info[2]); shape_type = Int32.Parse(info[3]); int string_index = 3; rec = new Rectangle(); switch (shape_type) { case 0: rec.setPoint(new Point(abscisse_rel, ordonnee_rel)); rec.SetLongueurRectangle(Int32.Parse(info[++string_index])); rec.SetLargeurRectangle(Int32.Parse(info[++string_index])); break; } if (Int32.Parse(info[++string_index]) == 0) { passThrough = false; } else { passThrough = true; } switch (entity_type) { case 0: Decor bob = new Decor(nom, id, rec.GetPointRectangle(), rec.GetLongueurRectangle(), rec.GetLargeurRectangle(), new Point(), passThrough, 0); bob.AbsoluteCoordinate = new Point(abscisse_abs, ordonnee_abs); //bob.AfficherDecor(); room.Elements.Add(bob); break; } } } } room.AfficherContenueSalle(); } }
public static void DeregisterDecor(Decor decor) { instance._decor.Remove(decor); }
public override int GetHashCode() { return(Decor.GetHashCode()); }