internal void SetSelectedObject(GraphicLink graphicLink, ModelLink modelLink, State state) { Clear(); this.graphicLink = graphicLink; this.state = state; id = 0; linkGraphic = AppendRootCategory(id++, "Graphic"); //linkGraphicGuid = AppendProperty(linkGraphic, id++, "Guid", graphicLink, "Guid", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicOrigin = AppendProperty(linkGraphic, id++, "Origin", graphicLink, "Origin", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicDestination = AppendProperty(linkGraphic, id++, "Destination", graphicLink, "Destination", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicOriginPortID = AppendProperty(linkGraphic, id++, "Origin Port ID", graphicLink, "OriginPortID", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicDestinationPortID = AppendProperty(linkGraphic, id++, "Destination Port ID", graphicLink, "DestinationPortID", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicTag = AppendProperty(linkGraphic, id++, "Tag", graphicLink, "Tag", ""); linkModel = AppendRootCategory(id++, "Model"); //linkModelClass = AppendProperty(linkModel, id++, "Class", modelLink, "LinkClass", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkModelOrigin = AppendProperty(linkModel, id++, "Origin", modelLink, "Origin", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkModelDestination = AppendProperty(linkModel, id++, "Destination", modelLink, "Destination", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkModelOriginPort = AppendProperty(linkModel, id++, "Origin Port", modelLink, "OriginPort", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkModelDestinationPort = AppendProperty(linkModel, id++, "Destination Port", modelLink, "DestinationPort", "", new System.ComponentModel.ReadOnlyAttribute(true)); }
protected PirateAiModel(PirateModel.PirateType pirateType, MapModel map, ModelLink modelLink, GameController gameController) { this.pirateType = pirateType; this.map = map; this.modelLink = modelLink; this.gameController = gameController; }
// Use this for initialization. Starting method for our code. public void Start() { //Get the path of the Game data folder string m_Path = Application.dataPath; tradeGUIController = dockUI.GetComponent <TradeGUIController>(); stationModel = new StationModel(tradeGUIController); //Creates the sound view and sound controller. this.soundView = UnityEngine.Object.Instantiate(this.soundView); // Gets the controller from the musicView GameObject. this.soundController = this.soundView.GetComponent <SoundController>(); // Lets the Controller access the GameObject this.soundController.SetSoundView(this.soundView); this.soundController.SetSliders(this.musicSlider, this.sfxSlider); //Output the Game data path to the console this.modelLink = new ModelLink(this, mapGameObject, stationModel); // Creates the map. this.MapControllerField = new MapController(125, 250, modelLink, this, stationModel); // Gets a starting space for the player, based on coordinates. Moving away from coordinates, but they are fine for setup SpaceModel playerSpace = MapControllerField.Map.GetSpace(63, 125); // Create a player, and set up MVC connections this.playerModel = new PlayerModel(playerSpace, MapControllerField.Map, this, stationModel); modelLink.CreatePlayerView(playerModel, playerMovementText, currency, metal, organics, gas, water, fuel, fuelMax, totalSpace); MapControllerField.Map.CreateHunterKiller(playerModel, this); }
public TestModelEnvironment() { var printComponents = new HashSet <ModelComponent>(); var print = new ModelBlock(new Vector3(10, 10, 10), printComponents, "print"); var printAccessor = new ModelComponent(ComponentType.Accessor, new Vector3(10, 10, 15), print); var printReturn = new ModelComponent(ComponentType.Return, new Vector3(10, 10, 5), print); printComponents.Add(printAccessor); printComponents.Add(printReturn); me.AddBlock(print); var originComponents = new HashSet <ModelComponent>(); var originBlock = new ModelBlock(new Vector3(0, 0, 0), originComponents, "origin", isOrigin: true); var originParameter = new ModelComponent(ComponentType.Parameter, new Vector3(0, 0, 5), originBlock); var originReturn = new ModelComponent(ComponentType.Return, new Vector3(0, 0, -5), originBlock); originComponents.Add(originParameter); originComponents.Add(originReturn); me.AddBlock(originBlock); // LINKS ARE WIP // This might not make sense. var link = new ModelLink(new Vector3(10, 10, 5), new Vector3(0, 0, -5)); me.AddLink(link); }
private static void BuildMeterCreate(int PID, List <VM_Branch> branches, List <BranchMeter> branchMeters) { //清空BuildMeter表 BuildMeterDAL.DeleteByPID(PID); var buildMeters = ModelLink.BuildMeterLink(branches, branchMeters); CommonDAL.CreateMultiple(buildMeters); }
public ActionResult DeleteConfirmed(int id) { ModelLink modelLink = db.Links.Find(id); db.Links.Remove(modelLink); db.SaveChanges(); return(RedirectToAction("Index")); }
public static HashSet <ModelLink> GetSampleModelLinks() { var link = new ModelLink(new Vector3(5, 5, 0), new Vector3(8, 5, 0)); return(new HashSet <ModelLink> { link }); }
private static void EnergyItemMeterCreate(int PID, List <VM_Branch> branches, List <BranchMeter> branchMeters) { //清空EnergyItemMeter表 EnergyItemMeterDAL.DeleteByPID(PID); var item_meters = ModelLink.EnergyItemMeterLink(branches, branchMeters); CommonDAL.CreateMultiple(item_meters); }
/// <summary> /// Method to invoke when the ImportModel command is executed. /// </summary> private void ImportModel(ModelLink ml) { if (SelectedProduct != null && ml != null && ml.Link != null) { SelectedModelLink = ml; DialogResult = true; CloseViewModelAsync(true); } }
private static (List <VM_Branch> branches, List <BranchMeter> branchMeters) getBranchesAndBranchMeter(int PID) { //读取所有仪表 var meters = MeterDAL.GetViewListByPID(PID); //读取所有支路 var branches = BranchDAL.GetViewListByPID(PID); var branchMeters = ModelLink.BranchMeterLink(branches, meters); return(branches, branchMeters); }
public static void BuildMeterCreate(int PID) { var result = getBranchesAndBranchMeter(PID); //清空BuildMeter表 BuildMeterDAL.DeleteByPID(PID); var buildMeters = ModelLink.BuildMeterLink(result.branches, result.branchMeters); CommonDAL.CreateMultiple(buildMeters); }
public ActionResult Edit([Bind(Include = "Id,Name,Slug,Type,TableId")] ModelLink modelLink) { if (ModelState.IsValid) { db.Entry(modelLink).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(modelLink)); }
public ActionResult Create([Bind(Include = "Id,Name,Slug,Type,TableId")] ModelLink modelLink) { if (ModelState.IsValid) { db.Links.Add(modelLink); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(modelLink)); }
//private System.IO.StreamWriter debugLog; public EditorLink(State state, GraphicLink graphicLink, ModelLink modelLink) { this.state = state; this.graphicLink = graphicLink; this.modelLink = modelLink; opacityTimer.Interval = 100; opacityTimer.Elapsed += new ElapsedEventHandler(opacityTimer_Elapsed); //debugLog = new System.IO.StreamWriter("c:\\" + guid.ToString() + " - " + tag + ".log"); }
public void CreateStation(SpaceModel stationLocation, StationType stationType, ModelLink link) { //int reset = 999; GenerateStationResources(StationType.Reset); GenerateStationResources(stationType); // IF THE LOADING TIME TAKES TOO LONG, THIS NEEDS TO BE DONE ONLY WHEN A STATION IS DOCKED AT Station newStation = new Station(stationLocation, stationType, metalAvailable, metalPrice, organicAvailable, organicPrice, fuelAvailable, fuelPrice, gasAvailable, gasPrice, waterAvailable, waterPrice, this); link.CreateStationView(newStation); allStations.Add(stationLocation, newStation); }
public GameObject ConstructAndBindViewLink(Vector3 to, Vector3 from) { var gameObjectLink = Instantiate(linkPrefab, new Vector3(0, 0, 0), Quaternion.identity); var viewLink = gameObjectLink.GetComponent <ViewLink>(); var modelLink = new ModelLink(to, from); var linkBinding = new LinkBinding(viewLink, modelLink, environmentChanged); linkBindings.Add(linkBinding); me.AddLink(modelLink); viewLink.Initialize(to, from, linkBinding); return(gameObjectLink); }
// GET: Admin/Links/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ModelLink modelLink = db.Links.Find(id); if (modelLink == null) { return(HttpNotFound()); } return(View(modelLink)); }
public ActionResult Index(string slug = null) { if (slug == null) { //trang chu return(this.Home()); } else { ModelLink rowlink = db.Links.Where(m => m.Slug == slug).FirstOrDefault(); if (rowlink != null) { //co slug trong link string typeslug = rowlink.Type; switch (typeslug) { case "category": return(this.ProductCategory(slug, page)); case "topic": return(this.PostTopic(slug, page)); case "page": return(this.PostPage(slug)); default: return(this.Error404(slug)); } } else { //khoong co int countproduct = db.Product.Where(m => m.Slug == slug && m.Status == 1).Count(); if (countproduct != 0) { return(this.ProductDetail(slug)); } else { int countpost = db.Post.Where(m => m.Slug == slug && m.Status == 1 && m.Type == "post").Count(); if (countpost != 0) { return(this.PostDetail(slug)); } else { return(this.Error404(slug)); } } } } }
public ActionResult Create(ModelCategories modelCategories) { ViewBag.ListCat = new SelectList(db.Categories.Where(m => m.Status != 0).ToList(), "Id", "Name", 0); ViewBag.ListOrder = new SelectList(db.Categories.Where(m => m.Status != 0).ToList(), "Orders", "Name", 0); String baoloi = ""; if (ModelState.IsValid) { try { if (modelCategories.ParentId == null) { modelCategories.ParentId = 0; } string slug = Mystring.str_slug(modelCategories.Name); modelCategories.Orders += 1; modelCategories.Slug = slug; modelCategories.Created_By = (int?)Session["UserIdAdmin"]; modelCategories.Created_At = DateTime.Now; modelCategories.Update_By = 1; modelCategories.Update_At = DateTime.Now; db.Categories.Add(modelCategories); //them du lieu bang link ModelLink modelLink = new ModelLink(); modelLink.Name = modelCategories.Name; modelLink.Slug = modelCategories.Slug; modelLink.TableId = modelCategories.Id; modelLink.Type = "category"; db.Links.Add(modelLink); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { baoloi = "thêm không thành công"; } } ViewBag.Error = baoloi; return(View(modelCategories)); }
public ActionResult Create(ModelTopic modelTopic) { ViewBag.listParent = new SelectList(db.Topic.Where(m => m.Status != 0 && m.ParentId == 0).ToList(), "Id", "Name", 0); String baoloi = ""; if (ModelState.IsValid) { try { if (modelTopic.ParentId == null) { modelTopic.ParentId = 0; } string slug = Mystring.str_slug(modelTopic.Name); modelTopic.Slug = slug; modelTopic.Created_At = DateTime.Now; modelTopic.Created_By = (int?)Session["UserIdAdmin"]; db.Topic.Add(modelTopic); //them du lieu bang link ModelLink modelLink = new ModelLink(); modelLink.Name = modelTopic.Name; modelLink.Slug = modelTopic.Slug; modelLink.TableId = modelTopic.Id; modelLink.Type = "topic"; db.Links.Add(modelLink); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { baoloi += "Thêm Không Thành Công"; } } ViewBag.Error = baoloi; return(View(modelTopic)); }
//private MapModel map; public PatrolAI(PirateModel.PirateType pirateType, MapModel map, ModelLink modelLink, List <SpaceModel> patrolPoints, GameController gameController) : base(pirateType, map, modelLink, gameController) { // Oisín Notes: This constructor takes in a list of patrol points, which we can use to set up the patrol patrolPath = new List <SpaceModel>(); // Oisín Notes: Should be using a for loop, but for now assume that the patrol points have three points. //var thread = new Thread(() => //{ // path between point 0 and 1 patrolPath.AddRange(AStarPathfinding.GetPathToDestination(patrolPoints[0], patrolPoints[1])); // path between point 1 and 2 patrolPath.AddRange(AStarPathfinding.GetPathToDestination(patrolPoints[1], patrolPoints[2])); // path between point 2 and 0 patrolPath.AddRange(AStarPathfinding.GetPathToDestination(patrolPoints[2], patrolPoints[0])); // patrolPath should now be one continuous line of spaces. If AStar has bugs, it might break around the edges // What space of the path we're on. currentSpaceOnPath = 0; base.SpawnPirate(patrolPath[0]); //}); //thread.Start(); }
public ActionResult Create(ModelMenu modelMenu) { String baoloi = ""; if (ModelState.IsValid) { try { if (modelMenu.ParentId == null) { modelMenu.ParentId = 0; } string link = Mystring.str_slug(modelMenu.Name); modelMenu.Orders += 1; modelMenu.Link = link; modelMenu.Created_By = (int?)Session["UserIdAdmin"]; modelMenu.Created_At = DateTime.Now; db.Menu.Add(modelMenu); //them du lieu bang link ModelLink modelLink = new ModelLink(); modelLink.Name = modelMenu.Name; modelLink.Slug = link; modelLink.TableId = modelMenu.Id; modelLink.Type = modelMenu.Type; db.Links.Add(modelLink); db.SaveChanges(); return(RedirectToAction("Index")); }catch (Exception ex) { baoloi += "khong thanh cong"; } } ViewBag.ListParent = new SelectList(db.Menu.Where(m => m.Status != 0 && m.ParentId == 0 && m.Type == "category").ToList(), "Id", "Name", 0); ViewBag.Error = baoloi; return(View(modelMenu)); }
public void CreateModelTest() { //test model's level number Model model = new Model(); model.CreateModel(); string model_str1 = ""; Queue <ModelNode> node_queue = new Queue <ModelNode>(); node_queue.Enqueue(model.root_node); while (node_queue.Count > 0) { ModelNode now_node = node_queue.Dequeue(); foreach (ModelNode node in now_node.nextlevel) { node_queue.Enqueue(node); } model_str1 += now_node.NodeLevel; } Assert.AreEqual("1" + "2222" + "3333333333333" + "4444444444444444444444444444444", model_str1); //test model's level name string model_str2 = ""; node_queue.Clear(); node_queue.Enqueue(model.root_node); while (node_queue.Count > 0) { ModelNode now_node = node_queue.Dequeue(); foreach (ModelNode node in now_node.nextlevel) { node_queue.Enqueue(node); } model_str2 += now_node.NodeLevelName; } Assert.AreEqual("Quality Attribute" + "AttributeAttributeAttributeAttribute" + "PropertyPropertyPropertyPropertyPropertyPropertyPropertyPropertyPropertyPropertyPropertyPropertyProperty" + "MetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetricMetric" , model_str2); //test model's node name string model_str3 = ""; node_queue.Clear(); node_queue.Enqueue(model.root_node); while (node_queue.Count > 0) { ModelNode now_node = node_queue.Dequeue(); foreach (ModelNode node in now_node.nextlevel) { node_queue.Enqueue(node); } model_str3 += now_node.NodeName; } Assert.AreEqual("Maintainability" + "AnalyzabilityChangeabilityStabilityModularity" + "CouplingCohesionDesign ComplexitySystem SizeCouplingCohesionService GranularityParameter GranularityService LoopbackParameter GranularityService LoopbackCohesionService Granularity" + "NSNDCS()NSNMNSNIS()NSNPI()NII()NSNDCS()NSNMNSNMNPI()NMNMP()NPI()NSWISL()NMNMP()NPI()NSWISL()NSNMNSNMNPI()" , model_str3); //test level1_nodes,level2_nodes,level3_nodes,level4_nodes string level1_nodes_str = ""; string level2_nodes_str = ""; string level3_nodes_str = ""; string level4_nodes_str = ""; foreach (ModelNode node in model.level1_nodes) { level1_nodes_str += node.NodeName; } foreach (ModelNode node in model.level2_nodes) { level2_nodes_str += node.NodeName; } foreach (ModelNode node in model.level3_nodes) { level3_nodes_str += node.NodeName; } foreach (ModelNode node in model.level4_nodes) { level4_nodes_str += node.NodeName; } Assert.AreEqual("Maintainability", level1_nodes_str); Assert.AreEqual("AnalyzabilityChangeabilityStabilityModularity", level2_nodes_str); Assert.AreEqual("CouplingCohesionDesign ComplexitySystem SizeCouplingCohesionService GranularityParameter GranularityService LoopbackParameter GranularityService LoopbackCohesionService Granularity", level3_nodes_str); Assert.AreEqual("NSNDCS()NSNMNSNIS()NSNPI()NII()NSNDCS()NSNMNSNMNPI()NMNMP()NPI()NSWISL()NMNMP()NPI()NSWISL()NSNMNSNMNPI()", level4_nodes_str); //test node's upper nodes foreach (ModelNode node1 in model.level1_nodes) { foreach (ModelNode node2 in node1.nextlevel) { foreach (ModelNode node3 in node2.nextlevel) { foreach (ModelNode node4 in node3.nextlevel) { Assert.AreEqual(node3, node4.prelevel); } Assert.AreEqual(node2, node3.prelevel); } Assert.AreEqual(node1, node2.prelevel); } Assert.AreEqual(null, node1.prelevel); } //test node's upper nodes - Method 2 ModelLink ml = new ModelLink(); for (int i = 0; i < ml.LEVEL1_LINK_1_NUM; i++) { Assert.AreEqual(model.root_node.prelevel, model.level1_nodes[i].prelevel); } for (int i = 0; i < ml.LEVEL1_LINK_2_NUM; i++) { Assert.AreEqual(model.level1_nodes[ml.LEVEL1_LINK_1_NUM - 1], model.level2_nodes[i].prelevel); } for (int i = 0; i < ml.LEVEL2_LINK_3_NUM[0]; i++) { Assert.AreEqual(model.level2_nodes[0], model.level3_nodes[i].prelevel); } for (int i = ml.LEVEL2_LINK_3_NUM[0]; i < ml.LEVEL2_LINK_3_NUM[0] + ml.LEVEL2_LINK_3_NUM[1]; i++) { Assert.AreEqual(model.level2_nodes[1], model.level3_nodes[i].prelevel); } for (int i = ml.LEVEL2_LINK_3_NUM[0] + ml.LEVEL2_LINK_3_NUM[1]; i < ml.LEVEL2_LINK_3_NUM[0] + ml.LEVEL2_LINK_3_NUM[1] + ml.LEVEL2_LINK_3_NUM[2]; i++) { Assert.AreEqual(model.level2_nodes[2], model.level3_nodes[i].prelevel); } for (int i = ml.LEVEL2_LINK_3_NUM[0] + ml.LEVEL2_LINK_3_NUM[1] + ml.LEVEL2_LINK_3_NUM[2]; i < ml.LEVEL2_LINK_3_NUM[0] + ml.LEVEL2_LINK_3_NUM[1] + ml.LEVEL2_LINK_3_NUM[2] + ml.LEVEL2_LINK_3_NUM[3]; i++) { Assert.AreEqual(model.level2_nodes[3], model.level3_nodes[i].prelevel); } for (int i = 0 ; i < ml.LEVEL3_LINK_4_NUM[0][0] ; i++) { Assert.AreEqual(model.level3_nodes[0], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] ; i++) { Assert.AreEqual(model.level3_nodes[1], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] ; i++) { Assert.AreEqual(model.level3_nodes[2], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] ; i++) { Assert.AreEqual(model.level3_nodes[3], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] ; i++) { Assert.AreEqual(model.level3_nodes[4], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] ; i++) { Assert.AreEqual(model.level3_nodes[5], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] ; i++) { Assert.AreEqual(model.level3_nodes[6], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] ; i++) { Assert.AreEqual(model.level3_nodes[7], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] + ml.LEVEL3_LINK_4_NUM[1][4] ; i++) { Assert.AreEqual(model.level3_nodes[8], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] + ml.LEVEL3_LINK_4_NUM[1][4] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] + ml.LEVEL3_LINK_4_NUM[1][4] + ml.LEVEL3_LINK_4_NUM[2][0] ; i++) { Assert.AreEqual(model.level3_nodes[9], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] + ml.LEVEL3_LINK_4_NUM[1][4] + ml.LEVEL3_LINK_4_NUM[2][0] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] + ml.LEVEL3_LINK_4_NUM[1][4] + ml.LEVEL3_LINK_4_NUM[2][0] + ml.LEVEL3_LINK_4_NUM[2][1] ; i++) { Assert.AreEqual(model.level3_nodes[10], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] + ml.LEVEL3_LINK_4_NUM[1][4] + ml.LEVEL3_LINK_4_NUM[2][0] + ml.LEVEL3_LINK_4_NUM[2][1] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] + ml.LEVEL3_LINK_4_NUM[1][4] + ml.LEVEL3_LINK_4_NUM[2][0] + ml.LEVEL3_LINK_4_NUM[2][1] + ml.LEVEL3_LINK_4_NUM[3][0] ; i++) { Assert.AreEqual(model.level3_nodes[11], model.level4_nodes[i].prelevel); } for (int i = ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] + ml.LEVEL3_LINK_4_NUM[1][4] + ml.LEVEL3_LINK_4_NUM[2][0] + ml.LEVEL3_LINK_4_NUM[2][1] + ml.LEVEL3_LINK_4_NUM[3][0] ; i < ml.LEVEL3_LINK_4_NUM[0][0] + ml.LEVEL3_LINK_4_NUM[0][1] + ml.LEVEL3_LINK_4_NUM[0][2] + ml.LEVEL3_LINK_4_NUM[0][3] + ml.LEVEL3_LINK_4_NUM[1][0] + ml.LEVEL3_LINK_4_NUM[1][1] + ml.LEVEL3_LINK_4_NUM[1][2] + ml.LEVEL3_LINK_4_NUM[1][3] + ml.LEVEL3_LINK_4_NUM[1][4] + ml.LEVEL3_LINK_4_NUM[2][0] + ml.LEVEL3_LINK_4_NUM[2][1] + ml.LEVEL3_LINK_4_NUM[3][0] + ml.LEVEL3_LINK_4_NUM[3][1] ; i++) { Assert.AreEqual(model.level3_nodes[12], model.level4_nodes[i].prelevel); } }
public void RemoveLink(ModelLink ml) { links.Remove(ml); }
public void AddLink(ModelLink ml) { links.Add(ml); }
public ProceduralMapModel(int rows, int columns, ModelLink link, GameController gameController, StationModel stationModel) : base() { base.stationModel = stationModel; base.gameController = gameController; base.link = link; this.rows = rows; this.columns = columns; map = new SpaceModel[rows][]; SpaceModel tempSpace; /* CREATING SECTORS * 0. Nebula Field * 1. Asteroid Field * 2. Colonized * 3. Empty * 4. Pirate base */ sectors = new int[rows / SECTOR_SIZE, columns / SECTOR_SIZE / 2]; for (int x = 0; x < rows / SECTOR_SIZE; x++) { for (int y = 0; y < columns / SECTOR_SIZE / 2; y++) { int sectorType = UnityEngine.Random.Range(0, 4); sectors[x, y] = sectorType; } } //make the middle spot a colonized area. sectors[2, 2] = 3; int randomAxis = UnityEngine.Random.Range(0, 2); int randomSide = UnityEngine.Random.Range(0, 2); int position = UnityEngine.Random.Range(0, 5); if (randomAxis == 0) { // pirate base is on top or bottom sectors[position, randomSide * 4] = 4; } else { // pirate base is on left or right sectors[randomSide * 4, position] = 4; } //Debug.Log(randomSide + " : " + randomAxis); for (int row = 0; row < rows; row++) { map[row] = new SpaceModel[columns]; if (row % 2 == 0) { for (int column = 0; column < columns; column += 2) { int sectorType = sectors[row / SECTOR_SIZE, column / SECTOR_SIZE / 2]; //rates (out of 625) int nebulaRate = 100; int asteroidRate = 100; int platformRate = 1; //empty space makes up the rest int stationRate = 5; int refineryRate = 20; int miningRate = 20; int generalRate = 20; int planetRate = 30; int factoryRate = 10; switch (sectorType) { case 0: //Nebula Field nebulaRate = 150; asteroidRate = 50; platformRate = 1; refineryRate = 40; miningRate = 20; generalRate = 5; planetRate = 5; factoryRate = 5; break; case 1: //Asteroid Field nebulaRate = 50; asteroidRate = 150; platformRate = 1; refineryRate = 20; miningRate = 40; generalRate = 5; planetRate = 5; factoryRate = 5; break; case 2: // Empty nebulaRate = 30; asteroidRate = 30; platformRate = 2; refineryRate = 10; miningRate = 10; generalRate = 20; planetRate = 5; factoryRate = 5; break; case 3: //colonised nebulaRate = 50; asteroidRate = 50; platformRate = 1; stationRate = 7; refineryRate = 5; miningRate = 5; generalRate = 20; planetRate = 30; factoryRate = 15; break; case 4: //pirate base nebulaRate = 100; asteroidRate = 100; platformRate = 50; stationRate = 0; break; default: break; } int randomNumber = UnityEngine.Random.Range(1, 625); if (randomNumber <= nebulaRate) { tempSpace = new NebulaSpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateNebulaSpace((NebulaSpaceModel)tempSpace); } else if (randomNumber <= nebulaRate + asteroidRate) { tempSpace = new AsteroidSpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateAsteroidSpace((AsteroidSpaceModel)tempSpace); } else { tempSpace = new SpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateSpaceView(tempSpace); } //see if there are pirates randomNumber = UnityEngine.Random.Range(1, 625); if (randomNumber <= platformRate) { pirates.Add(new PlatformAi(PirateModel.PirateType.Platform, this, link, tempSpace, gameController)); } if (randomNumber > platformRate && randomNumber <= platformRate + stationRate) { int randomType = UnityEngine.Random.Range(1, generalRate + refineryRate + miningRate + planetRate + factoryRate + 1); StationModel.StationType type; if (randomType < generalRate) { type = StationModel.StationType.General; } else if (randomType < generalRate + refineryRate) { type = StationModel.StationType.Refinery; } else if (randomType < generalRate + refineryRate + miningRate) { type = StationModel.StationType.Mining; } else if (randomType < generalRate + refineryRate + miningRate + planetRate) { type = StationModel.StationType.Planet; } else { type = StationModel.StationType.Factory; } stationModel.CreateStation(tempSpace, type, link); } } } else { for (int column = 1; column < columns; column += 2) { int sectorType = sectors[row / SECTOR_SIZE, column / SECTOR_SIZE / 2]; //rates (out of 625) int nebulaRate = 100; int asteroidRate = 100; int platformRate = 1; //empty space makes up the rest int stationRate = 5; int refineryRate = 20; int miningRate = 20; int generalRate = 20; int planetRate = 20; int factoryRate = 20; switch (sectorType) { case 0: //Nebula Field nebulaRate = 150; asteroidRate = 50; platformRate = 1; refineryRate = 40; miningRate = 20; generalRate = 5; planetRate = 5; factoryRate = 5; break; case 1: //Asteroid Field nebulaRate = 50; asteroidRate = 150; platformRate = 1; refineryRate = 20; miningRate = 40; generalRate = 5; planetRate = 5; factoryRate = 5; break; case 2: // Empty nebulaRate = 30; asteroidRate = 30; platformRate = 2; refineryRate = 10; miningRate = 10; generalRate = 20; planetRate = 5; factoryRate = 5; break; case 3: //colonised nebulaRate = 50; asteroidRate = 50; platformRate = 1; stationRate = 7; refineryRate = 5; miningRate = 5; generalRate = 20; planetRate = 30; factoryRate = 15; break; case 4: //pirate base nebulaRate = 100; asteroidRate = 100; platformRate = 50; stationRate = 0; break; default: break; } int randomNumber = UnityEngine.Random.Range(1, 625); if (randomNumber <= nebulaRate) { tempSpace = new NebulaSpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateNebulaSpace((NebulaSpaceModel)tempSpace); } else if (randomNumber <= nebulaRate + asteroidRate) { tempSpace = new AsteroidSpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateAsteroidSpace((AsteroidSpaceModel)tempSpace); } else { tempSpace = new SpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateSpaceView(tempSpace); } //see if there are pirates randomNumber = UnityEngine.Random.Range(1, 625); if (randomNumber <= platformRate) { pirates.Add(new PlatformAi(PirateModel.PirateType.Platform, this, link, tempSpace, gameController)); } if (randomNumber > platformRate && randomNumber <= platformRate + stationRate) { int randomType = UnityEngine.Random.Range(1, generalRate + refineryRate + miningRate + planetRate + factoryRate + 1); StationModel.StationType type; if (randomType < generalRate) { type = StationModel.StationType.General; } else if (randomType < generalRate + refineryRate) { type = StationModel.StationType.Refinery; } else if (randomType < generalRate + refineryRate + miningRate) { type = StationModel.StationType.Mining; } else if (randomType < generalRate + refineryRate + miningRate + planetRate) { type = StationModel.StationType.Planet; } else { type = StationModel.StationType.Factory; } stationModel.CreateStation(tempSpace, type, link); } } } } // Setting each space's adjacent spaces. Must be done after the map is generated for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { if (map[row][column] != null) { map[row][column].SetAdjacentSpaces(); } } } for (int i = 0; i < 50; i++) { List <SpaceModel> patrolPoints = new List <SpaceModel>(); for (int j = 0; j < 3; j++) { patrolPoints.Add(GetRandomSpace()); } pirates.Add(new PatrolAI(PirateModel.PirateType.Scout, this, link, patrolPoints, gameController)); } for (int i = 0; i < 35; i++) { List <SpaceModel> patrolPoints = new List <SpaceModel>(); for (int j = 0; j < 3; j++) { patrolPoints.Add(GetRandomSpace()); } pirates.Add(new PatrolAI(PirateModel.PirateType.Frigate, this, link, patrolPoints, gameController)); } for (int i = 0; i < 10; i++) { List <SpaceModel> patrolPoints = new List <SpaceModel>(); for (int j = 0; j < 3; j++) { patrolPoints.Add(GetRandomSpace()); } pirates.Add(new PatrolAI(PirateModel.PirateType.Destroyer, this, link, patrolPoints, gameController)); } for (int i = 0; i < 5; i++) { List <SpaceModel> patrolPoints = new List <SpaceModel>(); for (int j = 0; j < 3; j++) { patrolPoints.Add(GetRandomSpace()); } pirates.Add(new PatrolAI(PirateModel.PirateType.Dreadnought, this, link, patrolPoints, gameController)); } }
public new void Remove(T item) { base.Remove(item); ModelLink?.Refresh(ModelField); }
public new void Add(T item) { base.Add(item); ModelLink?.Refresh(ModelField); }
private async Task <Tuple <bool, ModelType> > LoadVendorModel(ModelLink modelLink) { var targetPath = Path.Combine(Path.GetTempPath() + Guid.NewGuid()); var dependencyResolver = this.GetDependencyResolver(); var ds = dependencyResolver.Resolve <IDownloadService>(); var pleaseWaitService = dependencyResolver.Resolve <IPleaseWaitService>(); var mbs = dependencyResolver.Resolve <IMessageBoxService>(); var status = new Tuple <bool, ModelType>(false, ModelType.XModel); pleaseWaitService.Show(); if (modelLink.Software == ModelType.Prop) { bool success = await ds.GetFileAsync(modelLink.Link, targetPath); if (success) { LoadPropFromPath(targetPath); status = new Tuple <bool, ModelType>(true, ModelType.Prop);; } else { mbs.ShowError("Unable to download the model from the vendor.\nEnsure you have an active internet connection.", "Error Downloading Model."); } } else { //The vendors provide a link to the xModel, but may have a Vixen prop of the same name alongside it. //If it exists we will prefer it. string propUrl = modelLink.Link.AbsoluteUri.Replace(@".xmodel", @".prp"); bool success = await ds.GetFileAsync(new Uri(propUrl), targetPath); if (success) { LoadPropFromPath(targetPath); status = new Tuple <bool, ModelType>(true, ModelType.Prop);; } else { success = await ds.GetFileAsync(modelLink.Link, targetPath); if (success) { await ImportProp(targetPath); status = new Tuple <bool, ModelType>(true, ModelType.XModel); } else { mbs.ShowError("Unable to download the model from the vendor.\nEnsure you have an active internet connection.", "Error Downloading Model."); } } } pleaseWaitService.Hide(); return(status); }
// Create a map. TODO nothing in this map yet. public MapModel(int rows, int columns, ModelLink link, GameController gameController, StationModel stationModel) { this.gameController = gameController; this.link = link; this.rows = rows; this.columns = columns; this.stationModel = stationModel; map = new SpaceModel[rows][]; SpaceModel tempSpace; for (int row = 0; row < rows; row++) { map[row] = new SpaceModel[columns]; if (row % 2 == 0) { for (int column = 0; column < columns; column += 2) { int randomNumber = UnityEngine.Random.Range(1, 11); if (randomNumber <= NEBULA_RATE) { tempSpace = new NebulaSpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateNebulaSpace((NebulaSpaceModel)tempSpace); } else if (randomNumber <= ASTEROID_RATE) { tempSpace = new AsteroidSpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateAsteroidSpace((AsteroidSpaceModel)tempSpace); } else { tempSpace = new SpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateSpaceView(tempSpace); } if (UnityEngine.Random.Range(1, 101) < PLATFORM_RATE) { pirates.Add(new PlatformAi(PirateModel.PirateType.Platform, this, link, tempSpace, gameController)); } if (UnityEngine.Random.Range(1, 101) == 1) { int stationType = UnityEngine.Random.Range(1, 6); stationModel.CreateStation(tempSpace, (StationModel.StationType)stationType, link); } } } else { for (int column = 1; column < columns; column += 2) { int randomNumber = UnityEngine.Random.Range(1, 11); if (randomNumber <= NEBULA_RATE) { tempSpace = new NebulaSpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateNebulaSpace((NebulaSpaceModel)tempSpace); } else if (randomNumber <= ASTEROID_RATE) { tempSpace = new AsteroidSpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateAsteroidSpace((AsteroidSpaceModel)tempSpace); } else { tempSpace = new SpaceModel(row, column, this); map[row][column] = tempSpace; link.CreateSpaceView(tempSpace); } if (UnityEngine.Random.Range(1, 101) < PLATFORM_RATE) { pirates.Add(new PlatformAi(PirateModel.PirateType.Platform, this, link, tempSpace, gameController)); } if (UnityEngine.Random.Range(1, 101) == 1) { int stationType = UnityEngine.Random.Range(1, 6); stationModel.CreateStation(tempSpace, (StationModel.StationType)stationType, link); } } } } // Setting each space's adjacent spaces. Must be done after the map is generated for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { if (map[row][column] != null) { map[row][column].SetAdjacentSpaces(); } } } }