Beispiel #1
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            PlanetDetails planetDetails = await db.Planets.FindAsync(id);

            db.Planets.Remove(planetDetails);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
 public ActionResult Edit([Bind(Include = "Id,Name,DistanceToSun,Comment")] PlanetDetails planetDetails)
 {
     if (ModelState.IsValid)
     {
         repository.InsertOrUpdate(planetDetails);
         repository.Save();
         return(RedirectToAction("Index"));
     }
     return(View(planetDetails));
 }
Beispiel #3
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,AstronomicalSymbol,DistanceToSun,EquatorialRadius,EquatorialGravity,Comment")] PlanetDetails planetDetails)
        {
            if (ModelState.IsValid)
            {
                db.Entry(planetDetails).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(planetDetails));
        }
        public void PlanetDetailsShouldDeserialize()
        {
            var original = new PlanetDetails()
            {
                Environment = new Core.Environment(1, 2, 3),
                Minerals    = new Minerals(4, 5, 6),
            };

            var restored = SerializeAndDeserialize(original);

            restored.Should().BeEquivalentTo(original);
        }
Beispiel #5
0
        // GET: Planets/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PlanetDetails planetDetails = repository.GetPlanet(id);

            if (planetDetails == null)
            {
                return(HttpNotFound());
            }
            return(View(planetDetails));
        }
Beispiel #6
0
        // GET: Planet/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PlanetDetails planetDetails = await db.Planets.FindAsync(id);

            if (planetDetails == null)
            {
                return(HttpNotFound());
            }
            return(View(planetDetails));
        }
	public static List <PlanetDetails> LoadLevel (string fileName) {
		//Name|Description|Tags|Stats|Actions|Special
		List<PlanetDetails> items = new List<PlanetDetails> ();
		
		string[] text = new string[0];
		try{
			//text = System.IO.File.ReadAllLines(Application.dataPath + "/Resources/" + fileName);//does not work with building
			TextAsset ta = Resources.Load (fileName) as TextAsset;
			text = ta.text.Split ('\n');
		} catch (System.Exception e) {
			Debug.Log ("Unable to read file: " + fileName);
			throw e;
		}
		if (text.Length < 1) {
			Debug.Log ("Could not read: " + fileName);
			return items;
		}
		
		List<string> categories = new List<string> ( text [0].Trim().Split (','));
		
		for (int i = 1; i < text.Length; i++) {
			try{
				if(text[i].Trim() == "")
					continue;//some lines may be blank, I guess
				
				string[] values = text[i].Trim().Split(',');
				string x = values[categories.IndexOf("x")];
				string y = values[categories.IndexOf("y")];
				string type = values[categories.IndexOf("type")];
				
				PlanetDetails item = new PlanetDetails ();
				item.position = new Vector3 (float.Parse (x), float.Parse (y), 0f);
				item.type = type;

				items.Add (item);
			} catch (System.Exception e) {
				Debug.Log ("Failure to read planet: " + text[i] + " from level " + fileName);
				Debug.Log (e.Message);
				//throw e;
			}
		}
		
		return items;
	}
        private static Game CreateGame()
        {
            var game = new Game()
            {
                Rules = new GameRules(),

                Players = new EntityStore <Player>
                {
                    new Player()
                    {
                        Id   = 1,
                        Name = "Player One",
                    },
                },

                Galaxy = new Galaxy()
                {
                    Bounds = new GalaxyBounds(800),

                    Planets = new EntityStore <Planet>
                    {
                        new Planet()
                        {
                            Id       = 1,
                            Name     = "Planet One",
                            Position = new Position(100, 100),
                            Details  = new PlanetDetails()
                            {
                                Environment = new Environment(10, 50, 20),
                                Minerals    = new Minerals(20, 30, 50),
                            },
                            Settlement = new Settlement()
                            {
                                OwnerId       = 1,
                                Population    = new Population(10_000),
                                Installations = new Installations
                                {
                                    Scanner = 100,
                                },
                            },
                        },
                    },
                },
Beispiel #9
0
        private PlanetDetails CreateDetails()
        {
            var details = new PlanetDetails()
            {
                Environment = new Environment()
                {
                    Gravity     = rnd.Norm(0, 100, 3),
                    Radiation   = rnd.Norm(0, 100, 3),
                    Temperature = rnd.Norm(0, 100, 3),
                },

                Minerals = new Minerals()
                {
                    Boranium  = rnd.Norm(0, 100, 3),
                    Germanium = rnd.Norm(0, 100, 3),
                    Ironium   = rnd.Norm(0, 100, 3),
                },
            };

            return(details);
        }