public TreePrefab(RenderContext context, TreeName name, string assetFile) { Name = name; if (m_Model == null) { m_Model = context.Content.Load <Model>("Model/m_" + assetFile); } if (m_Body == null) { m_Body = BodyFactory.CreateBody(context.World); // empty body for tree m_Body.BodyType = BodyType.Static; m_Body.Enabled = false; m_Body.IsSensor = true; //pickups are always triggers } if (!File.Exists("Content/Textures/Models/D_" + assetFile + ".xnb")) { TextureData.Diffuse = context.Content.Load <Texture2D>("Textures/Models/D_Default"); Console.WriteLine("Failed to load Texture " + assetFile); } else { TextureData.Diffuse = context.Content.Load <Texture2D>("Textures/Models/D_" + assetFile); } }
public static T GetPrefab <T>(TreeName name) { //See if Exists if (!m_PrefabList.ContainsKey(name)) { return(default(T)); } var data = m_PrefabList[name]; T obj = (T)Activator.CreateInstance(typeof(T), data.Model, data.Body, data.TextureData); return(obj); }
protected override void OnCreate(Bundle bundle) { int TreeNameId; base.OnCreate (bundle); SetContentView (Resource.Layout.TreeName); int.TryParse (Intent.GetStringExtra ("TreeNameId"), out TreeNameId); _TreeName = DAL.TreeNameRepository.Instance.GetTreeNameForId (TreeNameId); _lblCommonName = FindViewById<TextView> (Resource.Id.lblCommonName); _lblCommonName.Text = _TreeName.CommonName; _lblLatinName = FindViewById<TextView> (Resource.Id.lblLatinName); _lblLatinName.Text = _TreeName.LatinName; }
public async Task <IActionResult> Update([FromBody] TreeName updateTreeName) { //check for valid object if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //check for node's existence if (!await repos.isExisted(updateTreeName.Id)) { return(NotFound("Không thể tìm loại cây!")); } //update to database await repos.Update(updateTreeName); return(Ok()); }
//Update public async Task <Boolean> Update(TreeName treeName) { if (treeName == null) { return(false); } UpdateResult result = await TreeNameCollection.UpdateOneAsync( Builders <TreeName> .Filter.Eq("_id", new ObjectId(treeName.Id)), Builders <TreeName> .Update .Set("name", treeName.Name) ); if (result.IsAcknowledged) { return(result.MatchedCount > 0 && result.ModifiedCount > 0); } return(false); }
public async Task <IActionResult> Create([FromBody] TreeName treename) { //check for valid object if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //check for tree name's existence if (await repos.FindByName(treename.Name) != null) { return(BadRequest("Loại cây với tên " + treename.Name + " đã có.")); } //insert to database await repos.Create(treename); return(Ok()); }
public TreeName_iOSViewController(int id) : base("TreeName_iOSViewController", null) { _TreeName = DAL.TreeNameRepository.Instance.GetTreeNameForId (id); }
//Create public async Task <TreeName> Create(TreeName treeName) { await TreeNameCollection.InsertOneAsync(treeName); return(treeName); }