protected override void OnCollision(IHit hit) { if (Destroyed || CheckFriendlyFire(hit.Box.Data) || hit.Box.Data is Bullet) { return; } if (hit.Box.Data is Enemy enemy) { bool parried = Util.Parry(this, enemy, Box.Bounds); if (!parried) { if (enemy.CanDamage) { enemy.AddStatusEffect(new Stun(enemy, 120)); enemy.Hit(Velocity, 0, 20, Boomerang.Damage); } Bounced = true; } } if (hit.Box.Data is Tile tile) { if (tile.CanDamage) { tile.HandleTileDamage(Boomerang.Damage); } Bounced = true; } }
private Rect Simulate(List <IHit> hits, List <IObstacle> ignoring, IBox box, Rect origin, Rect destination, Func <ICollision, ICollisionResponse> filter) { IHit nearest = this.Hit(origin, destination, ignoring); if (nearest != null) { hits.Add(nearest); Rect impact = new Rect(nearest.Position, origin.Size); AABB.Collision collision = new AABB.Collision() { Box = box, Hit = nearest, Goal = destination, Origin = origin }; ICollisionResponse response = filter(collision); ignoring.Add(nearest.Box); if (response != null && destination != response.Destination) { return(this.Simulate(hits, ignoring, box, impact, response.Destination, filter));//hit something; estimate based on the new trajectory } else { return(this.Simulate(hits, ignoring, box, origin, destination, filter));//didn't hit something; estimate based on the current trajectory again } } return(destination); }
protected override void OnCollision(IHit hit) { if (Destroyed || CheckFriendlyFire(hit.Box.Data) || hit.Box.Data is Bullet) { return; } bool bounced = true; if (hit.Box.Data is Tile tile) { tile.HandleTileDamage(knifeDamage); } if (hit.Box.Data is Enemy enemy && enemy.CanHit) { bool parried = Util.Parry(this, enemy, Box.Bounds); if (!parried) { if (enemy.CanDamage) { bounced = false; } enemy.Hit(new Vector2(Math.Sign(Velocity.X), -2), 20, 50, knifeDamage); } } if (bounced) { new KnifeBounced(World, Position, new Vector2(Math.Sign(Velocity.X) * -1.5f, -3f), MathHelper.Pi * 0.3f, 24); PlaySFX(sfx_sword_bink, 1.0f, 0.1f, 0.3f); } Destroy(); }
protected override void OnCollision(IHit hit) { if (Destroyed || CheckFriendlyFire(hit.Box.Data) || hit.Box.Data is Bullet) { return; } bool hitwall = true; if (hit.Box.Data is Tile tile) { tile.HandleTileDamage(ShockwaveForce); if (tile.CanDamage == false && !Destroyed) { Destroy(); } ShockwaveForce -= 20; } if (hit.Box.Data is Enemy enemy && enemy.CanHit) { if (enemy.CanDamage) { hitwall = false; } enemy.Hit(new Vector2(Math.Sign(Velocity.X), -2), 20, 50, Math.Floor(ShockwaveForce * 0.20)); ShockwaveForce -= 20; } if (hitwall) { PlaySFX(sfx_sword_bink, 1.0f, 0.1f, 0.3f); } if (ShockwaveForce <= 0 && !Destroyed) { Destroy(); } }
private void AttackState() { var pos = GameController.Instance.Player.gameObject.transform.position; MoveDirection = transform.forward * Speed * 2; transform.rotation = Utils.LookAtSmooth(transform, pos, 30f); if (Target == null || !Target.Alive) { Target = null; Action = ACTION.GO_BACK; TargetPosition = new Vector3(Positions[CurrentPosition].position.x, StartPosition.y, Positions[CurrentPosition].position.z); return; } if (Vector3.Distance(transform.position, Target.gameObject.transform.position) < 0.15f) { Animator.SetTrigger("Attack"); Target.Hit(IHitType.ENEMY); Target.gameObject.transform.SetParent(transform); Action = ACTION.POS_ATTACK; var clone = GameController.Instance.GetPool("WaterSplash").Get(); clone.transform.position = transform.position; clone.SetActive(true); SoundController.PlaySound("BigSplash"); SoundController.PlaySound("Bite"); SplashSound = false; } }
public IBulkResponse IndexSearchResults(ISearchResponse <T> searchResult, IObserver <IReindexResponse <T> > observer, string toIndex, int page) { if (!searchResult.IsValid) { throw new ReindexException(searchResult.ConnectionStatus, "reindex failed on scroll #" + page); } var bb = new BulkDescriptor(); foreach (var d in searchResult.Hits) { IHit <T> d1 = d; bb.Index <T>(bi => bi.Object(d1.Source).Type(d1.Type).Index(toIndex).Id(d.Id)); } var indexResult = this.CurrentClient.Bulk(b => bb); if (!indexResult.IsValid) { throw new ReindexException(indexResult.ConnectionStatus, "reindex failed when indexing page " + page); } observer.OnNext(new ReindexResponse <T>() { BulkResponse = indexResult, SearchResponse = searchResult, Scroll = page }); return(indexResult); }
public IHit Hit(RectangleF origin, RectangleF destination, IEnumerable <IBox> ignoring = null) { //rectangle fully containing the origin and destination rectangle. var wrap = new RectangleF(origin, destination); var boxes = this.Find(wrap.X, wrap.Y, wrap.Width, wrap.Height); if (ignoring != null) { boxes = boxes.Except(ignoring); } IHit nearest = null; foreach (var other in boxes) { var hit = Humper.Hit.Resolve(origin, destination, other); if (hit != null && (nearest == null || hit.IsNearest(nearest, origin.Center))) { nearest = hit; } } return(nearest); }
/// <summary> /// Default search hit, which utilizes a 'vulcanSearchDescription' to set the summary, which can be added to content models via IVulcanSearchHitDescription; /// </summary> /// <param name="contentHit"></param> /// <param name="contentLoader"></param> /// <returns></returns> public static VulcanSearchHit DefaultBuildSearchHit(IHit <IContent> contentHit, IContentLoader contentLoader) { ContentReference contentReference = null; if (ContentReference.TryParse(contentHit.Id, out contentReference)) { IContent content; if (contentLoader.TryGet(contentReference, out content)) { var searchDescriptionCheck = contentHit.Fields.Where(x => x.Key == SearchDescriptionField).FirstOrDefault(); string storedDescription = searchDescriptionCheck.Value != null ? (searchDescriptionCheck.Value as JArray).FirstOrDefault().ToString() : null; var fallbackDescription = content as IVulcanSearchHitDescription; string description = storedDescription != null?storedDescription.ToString() : fallbackDescription != null ? fallbackDescription.VulcanSearchDescription : string.Empty; var result = new VulcanSearchHit() { Id = content.ContentLink, Title = content.Name, Summary = description, Url = urlResolver.GetUrl(contentReference) }; return(result); } } throw new Exception($"{nameof(contentHit)} doesn't implement IContent!"); }
public IHit Hit(Vector2 origin, Vector2 destination, IEnumerable <IBox> ignoring = null) { var min = Vector2.Min(origin, destination); var max = Vector2.Max(origin, destination); var wrap = new RectangleF(min, max - min); var boxes = this.Find(wrap.X, wrap.Y, wrap.Width, wrap.Height); if (ignoring != null) { boxes = boxes.Except(ignoring); } IHit nearest = null; foreach (var other in boxes) { var hit = Humper.Hit.Resolve(origin, destination, other); if (hit != null && (nearest == null || hit.IsNearest(nearest, origin))) { nearest = hit; } } return(nearest); }
public JobLink ConvertDoc(IHit <JobLink> hit) { var jo = hit.Source; jo.id = hit.Id; return(jo); }
public IBulkResponse IndexSearchResults(ISearchResponse <T> searchResult, IObserver <IReindexResponse <T> > observer, IndexName toIndex, int page) { if (!searchResult.IsValid) { throw new ElasticsearchClientException(PipelineFailure.BadResponse, $"Indexing failed on scroll #{page}.", searchResult.ApiCall); } var bb = new BulkDescriptor(); foreach (var d in searchResult.Hits) { IHit <T> d1 = d; bb.Index <T>(bi => bi.Document(d1.Source).Type(d1.Type).Index(toIndex).Id(d.Id)); } var indexResult = this._client.Bulk(b => bb); if (!indexResult.IsValid) { throw new ElasticsearchClientException(PipelineFailure.BadResponse, $"Failed indexing page {page}.", indexResult.ApiCall); } observer.OnNext(new ReindexResponse <T>() { BulkResponse = indexResult, SearchResponse = searchResult, Scroll = page }); return(indexResult); }
public IHit Hit(Loc origin, Loc destination, IEnumerable <IObstacle> ignoring = null) { var min = Loc.Min(origin, destination); var max = Loc.Max(origin, destination); var wrap = new Rect(min, max - min); var boxes = this.FindPossible(wrap.X, wrap.Y, wrap.Width, wrap.Height); if (ignoring != null) { boxes = boxes.Except(ignoring); } IHit nearest = null; foreach (var other in boxes) { var hit = AABB.Hit.Resolve(origin, destination, other); if (hit != null && (nearest == null || hit.IsNearest(nearest, origin))) { nearest = hit; } } return(nearest); }
public PiconModel ToModel(IHit <Picon> hit) { Id = hit.Id; this.Path = hit.Source.Path; Url = hit.Source.Url; return(this); }
/// <summary> /// Anonymous method to translate from a Hit to our customer DTO /// </summary> /// <param name="hit"></param> /// <returns></returns> private DTO.Customer ConvertHitToCustumer(IHit <DTO.Customer> hit) { Func <IHit <DTO.Customer>, DTO.Customer> func = (x) => { hit.Source.Id = Convert.ToInt32(hit.Id); return(hit.Source); }; return(func.Invoke(hit)); #region Notes /* * Its a necessary workaround to get the "_id" property that remains in a upper level. * Take this json return as sample: * * { * "_index": "crud_sample", * "_type": "Customer_Info", * "_id": "4", <- ID of the row * "_score": 1, * "_source": { <- All other properties are in the "_source" level: * "age": 32, * "birthday": "19830101", * "enrollmentFee": 100.1, * "hasChildren": false, * "name": "Juan", * "opinion": "¿Qué tal estás?" * } * */ #endregion }
public DangTin ConvertDoc(IHit <DangTin> hit) { var tin = hit.Source; tin.id = hit.Id; return(tin); }
private UngVien ConvertDoc(IHit <UngVien> hit) { var uv = hit.Source; uv.id = hit.Id; return(uv); }
private GroupUser ConvertDoc(IHit <GroupUser> hit) { GroupUser g = hit.Source; g.id = hit.Id; return(g); }
public TvChannelModel ToModel(IHit <tvChannel> hit) { Id = hit.Id; icon = hit.Source.icon; id = hit.Source.id; displayname = hit.Source.displayname; return(this); }
public void ApplyHit(GameObject gameObject) { IHit hit = gameObject.GetComponent <IHit>(); if (hit != null) { hit.DealDamage(Damage); } }
private void Start() { _mainCamera = Camera.main; var listenerHitShowDamage = new ListenerHitShowDamage(); EnemyHit = Enemy2; listenerHitShowDamage.Add(Enemy); listenerHitShowDamage.Add(EnemyHit); }
private Vessel ConvertHitToVessel(IHit <Vessel> hit) { Func <IHit <Vessel>, Vessel> func = (x) => { return(hit.Source); }; return(func.Invoke(hit)); }
private static SystemProperties RetrieveSystemProperty(IHit <dynamic> hit) { var sysHit = hit.Source["sys"]; SystemProperties sys = new SystemProperties { Id = sysHit["id"] }; return(sys); }
private string GetHightlightFieldValue(IHit <Product> hit, string field) { field = field.Substring(0, 1).ToLower() + field.Substring(1); if (hit.Highlights.ContainsKey(field)) { return(hit.Highlights[field].Highlights.FirstOrDefault()); } return(null); }
public MediaRefModel ToModel(IHit <MediaRef> hit) { Id = hit.Id; Cultures = hit.Source.Cultures; DisplayNames = hit.Source.DisplayNames; Groups = hit.Source.Groups; MediaType = hit.Source.MediaType; Tvg = hit.Source.Tvg; return(this); }
private void OnTriggerEnter(Collider other) { IHit obj = other.GetComponent <IHit>(); if (Target == null && obj != null && obj.Alive && (obj.Type == IHitType.PLAYER || obj.Type == IHitType.PLAYER_AI)) { Target = obj; Action = ACTION.ATTACK; } }
public SitePackChannelModel ToModel(IHit <SitePackChannel> hit) { Id = hit.Source.Id; Channel_name = hit.Source.Source; Site = hit.Source.Site; Site_id = hit.Source.Site_id; Source = hit.Source.Source; Update = hit.Source.Update; Xmltv_id = hit.Source.Xmltv_id; return(this); }
private void OnTriggerEnter(Collider other) { if (other.CompareTag(targetTag)) { IHit hit = other.GetComponent <IHit>(); if (hit != null) { hit.TakeDamage(weapon.damage); Destroy(gameObject); } } }
public bool IsNearest(IHit than, Loc origin) { if (this.Amount < than.Amount) { return(true); } else if (this.Amount > than.Amount) { return(false); } return(this.Normal != Dir4.None && than.Normal == Dir4.None); }
public async Task ShouldFindByField() { //Arrange IHit <TestEntity> hit = null; int hitCount = 0; await _clFx.UseTmpIndexWithMap(async indNm => { var indexResponse = await _clFx.EsClient.IndexManyAsync( new [] { new TestEntity { Id = 10, Value = "foo" }, new TestEntity { Id = 1, Value = "bar" } }, indNm); _output.WriteLine("Index response: \n" + indexResponse.DebugInformation); await Task.Delay(1000); if (indexResponse.IsValid) { //Act var sr = await _clFx.EsClient.SearchAsync <TestEntity>(sd => sd.Index(indNm) .Query(q => q .Range(r => r.Field(ent => ent.Id) .GreaterThan(2)))); hit = sr.Hits?.FirstOrDefault(); hitCount = sr.Hits?.Count ?? 0; } }); if (hit != null) { var str = JsonConvert.SerializeObject(hit, Formatting.Indented); _output.WriteLine(""); _output.WriteLine("HIT:"); _output.WriteLine(str); } //Assert Assert.Equal(1, hitCount); Assert.NotNull(hit); Assert.Equal(10, hit.Source.Id); Assert.Equal("foo", hit.Source.Value); }
protected T HitToDocument <T>(IHit <T> hit) where T : class { var doc = hit.Source; Type t = doc.GetType(); PropertyInfo piShared = t.GetProperty("id"); if (piShared != null) { piShared.SetValue(doc, hit.Id); } return(doc); }
private IndexDescriptor<JObject> ConfigureItem(IndexDescriptor<JObject> idx, IHit<JObject> hit, string targetIndex) { idx.Index(targetIndex); idx.Type(hit.Type); idx.Id(hit.Id); if (!String.IsNullOrEmpty(hit.Version)) { long version; if (!Int64.TryParse(hit.Version, out version)) version = 1; idx.Version(version); } if (hit.Fields?.FieldValuesDictionary != null && hit.Fields.FieldValuesDictionary.ContainsKey("_parent")) idx.Parent(hit.Fields.FieldValuesDictionary["_parent"].ToString()); return idx; }
private BulkIndexDescriptor<JObject> ConfigureItem(BulkIndexDescriptor<JObject> idx, IHit<JObject> hit, string targetIndex) { idx.Index(targetIndex); idx.Type(hit.Type); idx.Id(hit.Id); idx.Version(hit.Version); idx.Document(hit.Source); if (hit.Fields?.FieldValuesDictionary != null && hit.Fields.FieldValuesDictionary.ContainsKey("_parent")) idx.Parent(hit.Fields.FieldValuesDictionary["_parent"].ToString()); return idx; }
private void ConfigureIndexItem(BulkDescriptor d, IHit<JObject> hit, string targetIndex) { d.Index<JObject>(idx => ConfigureItem(idx, hit, targetIndex)); }