protected override void UpdateEntity(float dt, Entity entity) { var direction = entity.Get<Direction>(); var body = entity.Get<Body>(); var position = entity.Get<Position>(); for (int i = 0; i < entity.Count(); ++i) { direction.X[i] = direction.X[i] + dt * body.Friction[i] * (0 - direction.X[i]); direction.Y[i] += (float)Math.Pow(body.Weight[i], dt); } }
private string accountDiv(Entity[] account) { StringBuilder _sbAccount = new StringBuilder(); if (account.Count() > 0) { _sbAccount.Append("<ul>"); for (int i = 0; i < account.Count(); i++) { var t = account[i]; var _esr = new EntityServiceClient(); var _account = _esr.LoadAccount2(t.EntityID)[0]; if (i != account.Count() - 1) _sbAccount.AppendFormat("<li id='account{0}'><a onclick='clickSubEntities(this.id)' id='{0}' entitytype='{1}' er='{2}' currency='{3}' parentid='{4}' entityname='{5}' company='{6}' accountname='{7}' password='******' accounttype='{9}' bettinglimit='{10}' dateopen='{11}' personnel='{12}' ip='{13}' odds='{14}' issuesconditions='{15}' remarks='{16}' factor='{17}' perbet='{18}' status='{19}' accountid='{20}' islastlevel='{21}'><span>{5}</span></a>", t.EntityID, t.EntityType, t.ExchangeRate, t.Currency.CurrencyID, t.ParentID, t.EntityName, _account.Company, _account.AccountName, _account.Password, _account.AccountType, _account.BettingLimit, _account.DateOpen, _account.Personnel, _account.IP, _account.Odds, _account.IssuesConditions, _account.RemarksAcc, _account.Factor, _account.Perbet, _account.Status, _account.ID, t.IsLastLevel); else _sbAccount.AppendFormat("<li class='last' id='account{0}'><a onclick='clickSubEntities(this.id)' id='{0}' entitytype='{1}' er='{2}' currency='{3}' parentid='{4}' entityname='{5}' company='{6}' accountname='{7}' password='******' accounttype='{9}' bettinglimit='{10}' dateopen='{11}' personnel='{12}' ip='{13}' odds='{14}' issuesconditions='{15}' remarks='{16}' factor='{17}' perbet='{18}' status='{19}' accountid='{20}' islastlevel='{21}'><span>{5}</span></a>", t.EntityID, t.EntityType, t.ExchangeRate, t.Currency.CurrencyID, t.ParentID, t.EntityName, _account.Company, _account.AccountName, _account.Password, _account.AccountType, _account.BettingLimit, _account.DateOpen, _account.Personnel, _account.IP, _account.Odds, _account.IssuesConditions, _account.RemarksAcc, _account.Factor, _account.Perbet, _account.Status, _account.ID, t.IsLastLevel); } _sbAccount.Append("</ul>"); } return _sbAccount.ToString(); }
private static Entity.MetaItem GetMetaItemForTag(Entity.MetaItem[] meta, MetadataItemName tagName, Entity.GalleryItem galleryItem) { var tagMi = meta.FirstOrDefault(m => m.MTypeId == (int)tagName); if (tagMi != null) { return tagMi; } else { // Last item doesn't have a tag. Create one. This code path should be pretty rare. int galleryId; if (galleryItem.IsAlbum) galleryId = AlbumController.LoadAlbumInstance(galleryItem.Id, false).GalleryId; else galleryId = Factory.LoadMediaObjectInstance(galleryItem.Id).GalleryId; bool isEditable = Factory.LoadGallerySetting(galleryId).MetadataDisplaySettings.Find(tagName).IsEditable; tagMi = new Entity.MetaItem { Id = int.MinValue, MediaId = galleryItem.Id, GTypeId = galleryItem.ItemType, MTypeId = (int)tagName, Desc = tagName.ToString(), Value = String.Empty, IsEditable = isEditable }; Array.Resize(ref meta, meta.Count() + 1); meta[meta.Length - 1] = tagMi; return tagMi; } }
private void HandleCollisions(Tilemap tilemap, Entity collidable) { var position = collidable.Get<Position>(); var prevpos = collidable.Get<PreviousPosition>(); var direction = collidable.Get<Direction>(); var hotspots = collidable.Get<Hotspots>(); if (!prevpos) { for (int i = 0; i < collidable.Count(); ++i) { hotspots.BottomHit[i] = hotspots.TopHit[i] = hotspots.RightHit[i] = hotspots.LeftHit[i] = false; if (direction.Y[i] >= 0) { hotspots.BottomHit[i] = HandlePointList(tilemap, position.X[i], ref position.Y[i], ref direction.Y[i], hotspots.Bottom[i]); } else { hotspots.TopHit[i] = HandlePointList(tilemap, position.X[i], ref position.Y[i], ref direction.Y[i], hotspots.Top[i]); } if (direction.X[i] >= 0) { hotspots.RightHit[i] = HandlePointList(tilemap, ref position.X[i], position.Y[i], ref direction.X[i], hotspots.Right[i]); } else if (direction.X[i] <= 0) { hotspots.LeftHit[i] = HandlePointList(tilemap, ref position.X[i], position.Y[i], ref direction.X[i], hotspots.Right[i]); } } } if (prevpos) { for (int i = 0; i < collidable.Count(); ++i) { hotspots.BottomHit[i] = hotspots.TopHit[i] = hotspots.RightHit[i] = hotspots.LeftHit[i] = false; if (direction.Y[i] >= 0) { hotspots.BottomHit[i] = HandlePointList(tilemap, position.X[i], ref position.Y[i], ref direction.Y[i], prevpos.Y[i], hotspots.Bottom[i]); } else { hotspots.TopHit[i] = HandlePointList(tilemap, position.X[i], ref position.Y[i], ref direction.Y[i], prevpos.Y[i], hotspots.Top[i]); } if (direction.X[i] >= 0) { hotspots.RightHit[i] = HandlePointList(tilemap, ref position.X[i], position.Y[i], ref direction.X[i], prevpos.X[i], hotspots.Right[i]); } else if (direction.X[i] <= 0) { hotspots.LeftHit[i] = HandlePointList(tilemap, ref position.X[i], position.Y[i], ref direction.X[i], prevpos.X[i], hotspots.Right[i]); } } } }
private string nodeDiv(Entity[] nodeEntities, string type) { StringBuilder _sbNode = new StringBuilder(); if (nodeEntities.Count() > 0) { _sbNode.Append("<ul>"); for (int i = 0; i < nodeEntities.Count(); i++) { var t = nodeEntities[i]; if (i != nodeEntities.Count()-1) _sbNode.AppendFormat("<li id='{0}{1}'><a onclick='clickSubEntities(this.id)' id='{1}' entitytype='{2}' er='{3}' currency='{4}' parentid='{5}' entityname='{6}' sumtype='{7}' islastlevel='{8}'><span>{6}</span></a>", type, t.EntityID, t.EntityType, t.ExchangeRate, t.Currency.CurrencyID, t.ParentID, t.EntityName, t.SumType, t.IsLastLevel); else _sbNode.AppendFormat("<li id='{0}{1}' class='last'><a onclick='clickSubEntities(this.id)' id='{1}' entitytype='{2}' er='{3}' currency='{4}' parentid='{5}' entityname='{6}' sumtype='{7}' islastlevel='{8}'><span>{6}</span></a>", type, t.EntityID, t.EntityType, t.ExchangeRate, t.Currency.CurrencyID, t.ParentID, t.EntityName, t.SumType, t.IsLastLevel); } _sbNode.Append("</ul>"); } return _sbNode.ToString(); }