Inheritance: MonoBehaviour
Ejemplo n.º 1
1
		public override void Parse(byte[] buffer)
		{
			Reader reader = new Reader(new MemoryStream(buffer));
			
			reader.ReadByte(); // Id
			AttackerId = reader.ReadInt32();

			Hit hit = new Hit()
			{
				TargetId = reader.ReadInt32(),
				Damage = reader.ReadInt32(),
				Flags = reader.ReadByte()
			};

			Position = new Library.Point(
				reader.ReadInt32(),
				reader.ReadInt32(),
				reader.ReadInt32()
			);

			int count = reader.ReadInt16();
			Hits = new Hit[count + 1];
			Hits[0] = hit;
			for (int i = 1; i < Hits.Length; i++)
				Hits[i] = new Hit()
				{
					TargetId = reader.ReadInt32(),
					Damage = reader.ReadInt32(),
					Flags = reader.ReadByte()
				};
		}
Ejemplo n.º 2
0
		public bool IsMatch (Hit hit)
		{
			return (Uri == null || BU.StringFu.GlobMatch (Uri, hit.Uri.ToString ()))
				&& (Type == null || BU.StringFu.GlobMatch (Type, hit.Type))
				&& (MimeType == null || BU.StringFu.GlobMatch (MimeType, hit.MimeType))
				&& (Source == null || BU.StringFu.GlobMatch (Source, hit.Source));
		}
        internal Response(Hit[] hits,
                          Request input,
                          Model.Link[] links)
        {
            if (links == null) throw new ArgumentNullException("links"); 

            Hits = hits;
            Input = input;
            Links = links;

            var newLinks = new List<Model.Link>();

            foreach (Model.Link link in links)
            {
                Model.Link newLink;

                switch (link.Rel)
                {
                    case "self":
                        newLink = new Model.ReverseGeocode.Link(link.Rel, link.Href);
                        break;
                    default:
                        newLink = link;
                        break;
                }

                newLinks.Add(newLink);
            }

            Links = newLinks.ToArray();
        }
Ejemplo n.º 4
0
		static public HitFlavor Get (Hit hit)
		{
			if (flavorArray == null) {
				flavorArray = new ArrayList ();
				ScanAssembly (Assembly.GetExecutingAssembly ());
			}

			HitFlavor flavorBest = null;
			int weightBest = -1;

			foreach (HitFlavor flavor in flavorArray) {
				if (flavor.IsMatch (hit)) {
					int weight = flavor.Weight;
					if (weight > weightBest) {
						flavorBest = flavor;
						weightBest = weight;
					} else if (weight == weightBest && flavor.Name != flavorBest.Name) {
						// This shouldn't happen.
						Console.WriteLine ("HitFlavor Weight tie! {0} and {1}",
								   flavorBest, flavor);
					}
				}
			}

			return flavorBest;
		}
Ejemplo n.º 5
0
	public void TakesHit(Hit hit)
	{
		player.HP -= (int)(hit.weapon.damage * game.dDamageMod);

		//params for ShakeCamera = duration, strength, vibrato, randomness
		EventKit.Broadcast<float, float, int, float>("shake camera", .5f, .3f, 20, 5f);
		EventKit.Broadcast<int>("reduce hp", player.HP);

		if (hit.hitFrom == RIGHT)
		{
			BroadcastMessage("RepulseToLeft", 5.0F);
		}
		else
		{
			BroadcastMessage("RepulseToRight", 5.0F);
		}

		if (player.HP > 0)
		{
			MFX.FadeToColorAndBack(spriteRenderer, MCLR.bloodRed, 0f, .2f);
		}
		else
		{
			EventKit.Broadcast<int, Weapon.WeaponType>("player dead", hit.hitFrom, hit.weaponType);
		}
	}
Ejemplo n.º 6
0
    public void CheckObjectCollision(List<FutilePlatformerBaseObject> objects)
    {
        foreach (FutilePlatformerBaseObject o in objects)
        {
            if (o is Enemy)
            {
                Enemy e = (Enemy)o;
                if (!hits.Contains(e) && e.isColliding(this))
                {
                    hits.Add(e);
                    e.TakeDamage(GetUnitVectorDirection(CurrentDirection) * 2);
                    Hit h = new Hit();
                    h.SetPosition((this.GetPosition() + e.GetPosition()) / 2f);
                    world.AddForegroundSprite(h);
                }
            }
            if (o is Ninja)
            {
                Ninja n = (Ninja)o;
                if (!n.isRetreating && !hits.Contains(n) && n.isoHeight < 6 && n.isColliding(this))
                {
                    hits.Add(n);
                    n.TakeDamage(GetUnitVectorDirection(CurrentDirection) * 2);
                    Hit h = new Hit();
                    h.SetPosition((this.GetPosition() + n.GetPosition()) / 2f);
                    world.AddForegroundSprite(h);
                }

            }
        }
    }
 // Use this for initialization
 void Start()
 {
     word = gameObject.GetComponent<Word>();
     hit  = gameObject.GetComponent<Hit>();
     textBox = transform.GetComponentInChildren<TextMesh>();
     textBox.text = word.word;
     wordLength = word.word.Length;
 }
Ejemplo n.º 8
0
 public void Hurt(Hit hit)
 {
     _stats.health -= hit.damage;
     if (_stats.health <= 0)
         Die();
     rigidbody2D.AddForce(Vector2.right * -Mathf.Sign(hit.transform.position.x - transform.position.x) * meleeAttackForce + Vector2.up * meleeAttackForce);
     StartCoroutine("ShowMarker");
 }
Ejemplo n.º 9
0
		private static string GetHitProperty (Hit hit, string name)
		{
			// FIXME: We should handle this case better, but
			// for now, if we match an attachment, we just want
			// to display the properties for the parent message.
			if (!IsAttachment (hit))
				return hit [name];
			else
				return hit ["parent:" + name];
		}
Ejemplo n.º 10
0
		public void RegisterHit (Hit hit)
		{
			//Logger.Log.Debug ("httpitemhandler: registering {0}", hit.Uri);

			if (hit.Uri == null) {
				Logger.Log.Debug ("httpitemhandler: cannot register hits with no URIs");
				return;
			}

			items [hit.Uri] = hit;
		}
Ejemplo n.º 11
0
 // Constructor(s)
 public Shot(Vector2 position, float direction, float damage, Hit hit, List<String> targets, float shieldPiercing, int chance)
 {
     this.Position = position;
     this.Direction = direction;
     this.Damage = damage;
     this.Effect = hit;
     this.Texture = TextureManager.shot;
     this.Targets = new List<string>();
     this.Targets = targets;
     this.ShieldPiercing = shieldPiercing;
     this.Chance = chance;
 }
Ejemplo n.º 12
0
		protected void EnqueueMedia (Hit hit)
		{
			Process p = new Process ();
			p.StartInfo.UseShellExecute = false;
			p.StartInfo.FileName = "totem";
			p.StartInfo.Arguments = "--enqueue " + hit.PathQuoted;

			try {
				p.Start ();
			} catch (Exception e) {
				Console.WriteLine ("Error in EnqueueMedia: " + e);
			}
		}
Ejemplo n.º 13
0
 public ActionResult GetHits(Hit hit, int? o, string s)
 {
     ViewBag.Search = s;
     ViewBag.Offset = o ?? 0;
     ViewBag.Max = Max;
     if (!string.IsNullOrEmpty(s)) {
         try {
             return View(_hitRepository.Get(s, Max, o ?? 0));
         }
         catch (Exception e) {
             ModelState.AddModelError("s", e.Message);
         }
     }
     return View(_hitRepository.Get(Max, o ?? 0));
 }
Ejemplo n.º 14
0
 // Constructor(s)
 public Shot(Vector2 position, float direction, float damage, Hit hit, List<string> targets, float shieldPiercing, int chance)
 {
     this.Position = position;
     this.Direction = direction;
     this.Damage = damage;
     this.HitTarget = hit;
     this.Texture = TextureManager.shot;
     this.Targets = new List<string>();
     this.Targets = targets;
     this.ShieldPiercing = shieldPiercing;
     this.Chance = chance;
     this.timer = 60;
     this.Speed = 5;
     this.changeSpeed = 5;
     this.Colour = Color.Red;
     this.firstFrame = true;
 }
        private void addCentreHit(bool strong)
        {
            Hit h = new Hit
            {
                StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
                IsStrong  = strong
            };

            h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());

            if (strong)
            {
                rulesetContainer.Playfield.Add(new DrawableCentreHitStrong(h));
            }
            else
            {
                rulesetContainer.Playfield.Add(new DrawableCentreHit(h));
            }
        }
Ejemplo n.º 16
0
            public static Base Parse(Systems.Client client, Systems.Server server)
            {
                var hit = new Hit(client);

                hit.EntityID = client.Reader.ReadUInt64();
                hit.TargetID = client.Reader.ReadUInt64();
                hit.Damage = client.Reader.ReadSingle();
                hit.Critical = client.Reader.ReadByte();
                client.Reader.ReadBytes(3);
                hit.StunDuration = client.Reader.ReadUInt32();
                hit.Something8 = client.Reader.ReadUInt32();
                hit.Position = client.Reader.ReadQVector3();
                hit.HitDirection = client.Reader.ReadVector3();
                hit.Skill = client.Reader.ReadByte();
                hit.HitType = client.Reader.ReadByte();
                hit.ShowLight = client.Reader.ReadByte();
                client.Reader.ReadBytes(1);
                return hit;
            }
Ejemplo n.º 17
0
        protected override DetailsPane GetDetails()
        {
            DetailsPane details = new DetailsPane();

            // FIXME: The icon needs a nice frame as in the spec (?)

            details.AddTitleLabel(Title);
            details.AddTextLabel(Description);
            details.AddNewLine();

            string[] tags = Hit.GetProperties("dc:subject");
            if (tags != null && tags.Length > 0)
            {
                details.AddLabelPair(Catalog.GetString("Tags:"), String.Join(", ", tags));
            }

            details.AddLabelPair(Catalog.GetString("Modified:"), Utils.NiceVeryLongDate(Hit.FileInfo.LastWriteTime));
            details.AddLabelPair(Catalog.GetString("Full Path:"), Hit.Uri.LocalPath);

            // Get comments from the image.  FIXME: These should be unified into a single field.
            string comment = Hit.GetFirstProperty("png:comment");

            if (String.IsNullOrEmpty(comment))
            {
                comment = Hit.GetFirstProperty("jfif:Comment");
            }

            if (!String.IsNullOrEmpty(comment))
            {
                details.AddLabelPair(Catalog.GetString("Comment:"), comment);
                //details.AddNewLine ();
                //details.AddTextLabel (comment);
            }

            if (Hit ["fspot:Description"] != null && Hit ["fspot:Description"] != "")
            {
                details.AddNewLine();
                details.AddTextLabel(Hit ["fspot:Description"]);
            }

            return(details);
        }
Ejemplo n.º 18
0
        public override void Open()
        {
            // If we are not a feed from Thunderbird just open based on mime
            if (Hit.GetFirstProperty("fixme:client") != "thunderbird")
            {
                base.OpenFromUri(Hit ["dc:identifier"]);
                return;
            }

#if ENABLE_THUNDERBIRD
            // Here's the Thunderbird specific part
            SafeProcess p = Thunderbird.GetSafeProcess("-viewbeagle", Hit.GetFirstProperty("fixme:uri"));

            try {
                p.Start();
            } catch (SafeProcessException e) {
                Console.WriteLine("Unable to run {0}: {1}", p.Arguments [0], e.Message);
            }
#endif
        }
Ejemplo n.º 19
0
        private void OnCollisionEnter2D(Collision2D other)
        {
            if (hit)
            {
                return;
            }
            if (other.collider.CompareTag(@"Wall"))
            {
                return;
            }

            hit = true;
            sfxManager.Play(TetoSfxType.Hit);

//            dropEffect.Stop();
//            Destroy(dropEffect.gameObject, 1.0f);
            Destroy(this);

            Hit?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 20
0
        private bool HitIsValidRemovable(Hit hit)
        {
            if (mount_dir == null || hit.Uri.Scheme != "removable")
            {
                return(true);
            }

            hit.AddProperty(Beagrep.Property.NewKeyword("beagrep:RemovableUri",
                                                        hit.EscapedUri));

            string path = hit.Uri.LocalPath;

            path    = path.Substring(1);           // Remove initial '/'
            path    = Path.Combine(mount_dir, path);
            hit.Uri = UriFu.PathToFileUri(path);

            hit.AddProperty(Beagrep.Property.NewKeyword("fixme:mount_dir", mount_dir));

            return(true);
        }
Ejemplo n.º 21
0
        public async Task Store(Hit hit)
        {
            if (OnlyHits && hit.Type != "SUCCESS")
            {
                return;
            }

            using var client = new HttpClient();

            var webhook = $"{new Uri(ApiServer)}bot{Token}/sendMessage";

            var obj = new Dictionary <string, object>()
            {
                { "chat_id", ChatId },
                { "text", hit.ToString() }
            };

            await client.PostAsync(webhook,
                                   new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json"));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Clones the block sounds.
        /// </summary>
        /// <returns></returns>
        public BlockSounds Clone()
        {
            BlockSounds sounds = new BlockSounds()
            {
                Walk              = Walk == null ? null : Walk.Clone(),
                Inside            = Inside == null ? null : Inside.Clone(),
                Break             = Break == null ? null : Break.Clone(),
                Place             = Place == null ? null : Place.Clone(),
                Hit               = Hit == null ? null : Hit.Clone(),
                Ambient           = Ambient == null ? null : Ambient.Clone(),
                AmbientBlockCount = AmbientBlockCount
            };

            foreach (var val in ByTool)
            {
                sounds.ByTool[val.Key] = val.Value.Clone();
            }

            return(sounds);
        }
Ejemplo n.º 23
0
    private bool LocalRaycastRef(Ray worldRay, ref Hit hit)
    {
        Matrix4x4 worldToLocalMatrix = base.transform.worldToLocalMatrix;
        Vector3   origin             = worldToLocalMatrix.MultiplyPoint(worldRay.origin);
        Ray       ray     = new Ray(origin, worldToLocalMatrix.MultiplyVector(worldRay.direction));
        Hit       invalid = Hit.invalid;

        if (this.DoRaycastRef(ray, ref invalid))
        {
            worldToLocalMatrix = base.transform.localToWorldMatrix;
            hit.point          = worldToLocalMatrix.MultiplyPoint(invalid.point);
            hit.normal         = worldToLocalMatrix.MultiplyVector(invalid.normal);
            hit.ray            = worldRay;
            hit.distance       = Vector3.Dot(worldRay.direction, hit.point - worldRay.origin);
            hit.hotSpot        = this;
            hit.panel          = this.panel;
            return(true);
        }
        return(false);
    }
Ejemplo n.º 24
0
    public void IngredientHit(Hit hitType, IngredientSO ingredient)
    {
        if (!IsMissionCompleted())
        {
            if (hitType == Hit.Perfect)
            {
                _perfectsCollected++;
            }
            else if (hitType != Hit.Perfect)
            {
                _perfectsCollected = 0;
            }

            if (_isMissionFinished == false && IsMissionCompleted())
            {
                _isMissionFinished = true;
                _missionManager.MissionFinished(this);
            }
        }
    }
Ejemplo n.º 25
0
        private void OnCollisionEnter2D(Collision2D other)
        {
            if (isControlable && other.gameObject.tag != "Wall")
            {
                isControlable = false;

                hitSound.Play();
                dropEffect.Stop();
                Destroy(dropEffect.gameObject, 1.0f);

                if (onCeiling)
                {
                    HitOnCeiling?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    Hit?.Invoke(this, EventArgs.Empty);
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Uses the provided document hit to pull out the highlighted summary
        /// </summary>
        /// <param name="hit"></param>
        /// <returns></returns>
        private ResultsModel GetDocumentWithHighlight(Hit <ResultsModel> hit)
        {
            ResultsModel document   = hit.Source as ResultsModel;
            string       highlights = GetHighlights(hit);

            if (highlights != null && highlights.Length > 15)   // minimum size for valid snippet
            {
                document.HitHighlightedSummary = highlights;
            }
            else if (hit.Source.Content != null && hit.Source.Content.Length > 254)
            {
                document.HitHighlightedSummary = hit.Source.Content.Substring(0, 254);
            }
            else if (hit.Source.Content != null)
            {
                document.HitHighlightedSummary = hit.Source.Content;
            }

            return(document);
        }
Ejemplo n.º 27
0
    public void AddHit(Vector2 viewportPos, float timeValue, float dist, HitType hitType, bool assistanceValue)
    {
        Field cell = matchPosToCell(viewportPos);
        Hit   hit  = new Hit {
            xPos = viewportPos.x, yPos = viewportPos.y,
            time = timeValue, distance = dist, type = hitType,
            assistanceWasActive = assistanceValue
        };

        Debug.Log("AddHit: " + hit.ToString() + " to cell " + cell.XYString());
        levelHitsList[cell.xIndex, cell.yIndex].Add(hit);
        if (hit.time > -1.0f)
        {
            sessionHitTimesList[cell.xIndex, cell.yIndex].Add(hit.time);
        }
        if (hit.distance > -1.0f)
        {
            sessionHitDistancesList[cell.xIndex, cell.yIndex].Add(hit.distance);
        }
    }
    private void Grab(Hit hit, Collider2D collider)
    {
        if (collider.tag == "Player")
        {
            PlayerCharacter player = collider.GetComponent <PlayerCharacter>();

            if (player == enemy.currentTarget)
            {
                ++phase;
                t_phase = 0;


                enemyRigidbody.velocity = Vector2.zero;

                enemy.OnAttack.RemoveListener(Grab);

                enemy.DisableHitBox(hitBox);
            }
        }
    }
        public IList ToDomainObject(HitInfo[] hitInfos, HitType hitType)
        {
            var hitList = new List <Hit>();

            if (hitInfos != null && hitInfos.Length > 0)
            {
                var articleConverter = new ArticleConverter();
                foreach (var hitInfo in hitInfos)
                {
                    var hit = new Hit();
                    hit.HitId            = hitInfo.HitId;
                    hit.ResourceId       = hitInfo.ResourceId;
                    hit.IPAddress        = hitInfo.IPAddress;
                    hit.HitType          = hitType;
                    hit.CreationDatetime = hitInfo.CreationDatetime;
                    hitList.Add(hit);
                }
            }
            return(hitList);
        }
Ejemplo n.º 30
0
        public async Task <Hit> GetHit(string signature)
        {
            // Get a list of the hits
            var errorsCollection = _mongoDatabase.GetCollection <BsonDocument>("errors");
            var filter           = Builders <BsonDocument> .Filter.Eq("signature", signature);

            using (var cursor = await errorsCollection.FindAsync(new BsonDocument()))
            {
                while (await cursor.MoveNextAsync())
                {
                    var batch = cursor.Current;
                    foreach (var document in batch)
                    {
                        var         hit = new Hit();
                        BsonElement service;
                        BsonElement stacktrace;
                        BsonElement firstOccurance;
                        hit.Signature = signature;

                        if (document.TryGetElement("service", out service))
                        {
                            hit.Service = service.Value.AsString;
                        }
                        ;
                        if (document.TryGetElement("stacktrace", out stacktrace))
                        {
                            hit.Stacktrace = stacktrace.Value.AsString;
                        }
                        ;
                        if (document.TryGetElement("firstOccurance", out firstOccurance))
                        {
                            hit.FirstOccurance = firstOccurance.Value.ToUniversalTime();
                        }
                        ;
                        hit.CurrentValue = 1000;
                        return(hit);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 31
0
        public override CommandResult Invoke(Entity caster, Cell target)
        {
            if (target == null)
            {
                throw new NotImplementedException("Target cell needed.");
            }

            Cell affected = Bresenhams.GetLine(
                caster.Level, caster.Cell, target).ElementAtOrLast(Range);

            Entity enemy = affected.Actor;

            if (enemy == null)
            {
                Locator.Audio.Buffer(
                    Assets.Audio["SFX_Toss"],
                    affected.Position.ToVector3());
                Locator.Log.Send(
                    $"{Strings.Subject(caster, true)}" +
                    $" {Verbs.Swing(caster)} at nothing.",
                    Color.grey);
                return(CommandResult.Succeeded);
            }

            if (Accuracy < Random.Range(0, 101))
            {
                Locator.Log.Send(
                    Verbs.Miss(caster, enemy), Color.grey);
                return(CommandResult.Succeeded);
            }

            Locator.Audio.Buffer(
                Assets.Audio["SFX_Punch"],
                affected.Position.ToVector3());

            Hit hit = new Hit(Damages);

            Locator.Log.Send(Verbs.Hit(caster, enemy, hit), Color.white);
            enemy.TakeHit(caster, hit);
            return(CommandResult.Succeeded);
        }
Ejemplo n.º 32
0
        private Hit XmlBugToHit(XmlDocument xml, string c)
        {
            string bug_num, product, summary, owner, status;

            // see if the bug was even found. If there wasn't a bug, there will be
            // an error attribute on the /bug element that says NotFound if one didn't exist.
            if (!IsValidBug(xml))
            {
                return(null);
            }

            try {
                bug_num = this.GetXmlText(xml, "//bug_id");
                product = this.GetXmlText(xml, "//product");
                summary = this.GetXmlText(xml, "//short_desc");
                summary = summary.Substring(0, Math.Min(summary.Length, 50));
                owner   = this.GetXmlText(xml, "//assigned_to");
                status  = this.GetXmlText(xml, "//bug_status");
            } catch {
                Logger.Log.Warn("Could not get bug fields");
                return(null);
            }

            string bug_url = String.Format("{0}/show_bug.cgi?id={1}", bugzilla_host, bug_num);

            Hit hit = new Hit();

            hit.Uri      = new Uri(bug_url, true);
            hit.Type     = "Bugzilla";
            hit.MimeType = "text/html";             // FIXME
            hit.Source   = "Bugzilla";
            hit.ScoreRaw = 1.0;

            hit ["Number"]  = bug_num;
            hit ["Product"] = product;
            hit ["Owner"]   = owner;
            hit ["Summary"] = summary;
            hit ["Status"]  = status;

            return(hit);
        }
Ejemplo n.º 33
0
        private Color Enlight(Color emittance, Hit hit)
        {
            var ambientFactor = 1f;

            if (Scene.AmbientOcclusion)
            {
                ambientFactor = CalcAmbientOcclusion(hit);
            }

            if (!Scene.SoftShadows)
            {
                var color = new Color();

                foreach (var light in Scene.Lights)
                {
                    color += LightIntensity(hit, light, light.Shape.Position, Scene.AmbientColor, ambientFactor);
                }

                emittance *= color;
            }
            else
            {
                var color = new Color();

                foreach (var light in Scene.Lights)
                {
                    for (int i = 0; i < Scene.GISamples; i++)
                    {
                        var random        = new Vector3(Rand.Float() * 2 - 1, Rand.Float() * 2 - 1, Rand.Float() * 2 - 1);
                        var lightPosition = light.Shape.Position + light.Shape.GetLightEmission(random);

                        color += LightIntensity(hit, light, lightPosition, Scene.AmbientColor, ambientFactor);
                    }
                }

                emittance *= color / Scene.GISamples;
            }


            return(emittance);
        }
Ejemplo n.º 34
0
        private Hit HitTest(Point _point)
        {
            // Hit Result:
            // -1: miss, 0: on source window, 1: on magnification window, 1+: on source resizer.

            Hit res = Hit.None;

            Rectangle srcRectangle = new Rectangle(m_iSrcCustomLeft, m_iSrcCustomTop, m_iSrcCustomWidth, m_iSrcCustomHeight);
            Rectangle magRectangle = new Rectangle(m_iMagLeft, m_iMagTop, m_iMagWidth, m_iMagHeight);

            // We widen the size of handlers rectangle for easier selection.
            int widen = 6;

            if (new Rectangle(m_iSrcCustomLeft - widen, m_iSrcCustomTop - widen, widen * 2, widen * 2).Contains(_point))
            {
                res = Hit.TopLeftResizer;
            }
            else if (new Rectangle(m_iSrcCustomLeft - widen, m_iSrcCustomTop + m_iSrcCustomHeight - widen, widen * 2, widen * 2).Contains(_point))
            {
                res = Hit.BottomLeftResizer;
            }
            else if (new Rectangle(m_iSrcCustomLeft + m_iSrcCustomWidth - widen, m_iSrcCustomTop - widen, widen * 2, widen * 2).Contains(_point))
            {
                res = Hit.TopRightResizer;
            }
            else if (new Rectangle(m_iSrcCustomLeft + m_iSrcCustomWidth - widen, m_iSrcCustomTop + m_iSrcCustomHeight - widen, widen * 2, widen * 2).Contains(_point))
            {
                res = Hit.BottomRightResizer;
            }
            else if (srcRectangle.Contains(_point))
            {
                res = Hit.SourceWindow;
            }
            else if (magRectangle.Contains(_point))
            {
                res = Hit.MagnifyWindow;
            }


            return(res);
        }
Ejemplo n.º 35
0
    public Hit?Hit(Ray ray)
    {
        var   oc  = ray.origin.Sub(this.center);
        float a   = ray.direction.Dot(ray.direction);
        float b   = oc.Dot(ray.direction);
        float c   = oc.Dot(oc) - this.radius * this.radius;
        float dis = b * b - a * c;

        if (dis > 0)
        {
            float e = (float)Math.Sqrt(dis);

            float t = (-b - e) / a;
            if (t > 0.007f)
            {
                var hit = new Hit();

                hit.dist   = t;
                hit.point  = ray.Point(t);
                hit.normal = hit.point.Sub(this.center).Unit();

                return(hit);
            }

            t = (-b + e) / a;
            if (t > 0.007f)
            {
                var hit = new Hit();

                hit.dist   = t;
                hit.point  = ray.Point(t);
                hit.normal = hit.point.Sub(this.center).Unit();

                return(hit);
            }

            return(null);
        }

        return(null);
    }
Ejemplo n.º 36
0
        //Returns: false, if Hit does not match any filter
        //		   true,  if Hit URI is part of any specified filter
        public bool FilterHit(Hit hit)
        {
            if ((hit == null) || (matchers.Count == 0))
            {
                return(false);
            }

            string uri = hit.UriAsString;

            foreach (SimpleMatcher matcher in matchers)
            {
                if (uri.IndexOf(matcher.Match) == -1)
                {
                    continue;
                }

                return(hit.IsFile);                  //return true;
            }

            return(false);
        }
Ejemplo n.º 37
0
        private static void CreateField(Hit hit, DataRow row, QueryData query)
        {
            if (query.DocValueFields == null)
            {
                return;
            }

            foreach (var docValueField in query.DocValueFields)
            {
                var value = row.Table.Columns.Contains(docValueField) ? row[docValueField] : null;
                if (value == null)
                {
                    continue;
                }

                // datetime fields are written as is, usually in UTC timezone.
                hit.Fields.Add(docValueField, new List <object> {
                    value
                });
            }
        }
Ejemplo n.º 38
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.gameObject.tag == "Player" && p.isStopped)
        {
            AudioHelper.Instance.MakeHydrantSound();
            p.Play();
            if (!isHydrant)
            {
                CarStatus cs = (CarStatus)coll.GetComponent("CarStatus");
                cs.CLEAN -= 20;
            }

            GameLogic gl = (GameLogic)GAMELOGIC.GetComponent("GameLogic");
            Objective o  = gl.getCurrentObjective();
            if (o is Hit)
            {
                Hit h = (Hit)o;
                h.OnHit(isHydrant);
            }
        }
    }
Ejemplo n.º 39
0
    public void SetClimbing()
    {
        PerformRaycast();
        List <Hit> leftFiltered  = leftRays.Where(r => r.raycastHit.normal.y <= 0.1 && r.vertical == 0 && Mathf.Abs(r.colliderCrossPoint.x - r.raycastHit.point.x) < 0.1f).ToList();
        List <Hit> rightFiltered = rightRays.Where(r => r.raycastHit.normal.y <= 0.1 && r.vertical == 0 && Mathf.Abs(r.colliderCrossPoint.x - r.raycastHit.point.x) < 0.1f).ToList();

        Vector2 translateDistance;

        if (leftFiltered.Count >= 3 && transform.localScale.x < 0)
        {
            Hit closest = leftFiltered.OrderBy(r => r.distance).FirstOrDefault();
            translateDistance = closest.raycastHit.point - closest.colliderCrossPoint;
            EnterClimb(translateDistance);
        }
        else if (rightFiltered.Count >= 3 && transform.localScale.x > 0)
        {
            Hit closest = rightFiltered.OrderBy(r => r.distance).FirstOrDefault();
            translateDistance = (closest.raycastHit.point - closest.colliderCrossPoint) * 0.9f;
            EnterClimb(translateDistance);
        }
    }
Ejemplo n.º 40
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (_isStop)
        {
            return;
        }
        Bullet bullet = other.GetComponent <Bullet>();

        if (bullet != null)
        {
            Hit?.Invoke(this);
        }
        else
        {
            Ship ship = other.GetComponent <Ship>();
            if (ship != null)
            {
                ShipCollision?.Invoke(this);
            }
        }
    }
Ejemplo n.º 41
0
    static double ray_trace(Vec light, Ray ray, Scene scene)
    {
        Hit i = scene.intersect(new Hit(infinity, new Vec(0, 0, 0)), ray);

        if (i.lambda == infinity)
        {
            return(0);
        }
        Vec o = add(ray.orig, add(scale(i.lambda, ray.dir),
                                  scale(delta, i.normal)));
        double g = dot(i.normal, light);

        if (g >= 0)
        {
            return(0.0);
        }
        Ray sray = new Ray(o, scale(-1, light));
        Hit si   = scene.intersect(new Hit(infinity, new Vec(0, 0, 0)), sray);

        return(si.lambda == infinity ? -g : 0);
    }
Ejemplo n.º 42
0
        private IList <PulseSpaceDurationList> CaptureIR()
        {
            List <PulseSpaceDurationList> receivedMessages = new List <PulseSpaceDurationList>();

            while (receivedMessages.Count < TargetCaptures)
            {
                Waiting?.Invoke(this, EventArgs.Empty);
                CaptureFromDevice();
                Hit?.Invoke(this, EventArgs.Empty);
                if (_lastReceived == null)
                {
                    throw new Exception("Expected this to have a value.");
                }
                receivedMessages.Add(_lastReceived);
                if (CaptureDelay > TimeSpan.Zero)
                {
                    System.Threading.Thread.Sleep(CaptureDelay);
                }
            }
            return(receivedMessages);
        }
Ejemplo n.º 43
0
 private void Attack()
 {
     if (pos.y > status.S1 && pos.y < status.E1)
     {
         Debug.Log("Attack!");
         Enemy.tag = "Untagged";
         Destroy(Enemy);
         Enemies = GameObject.FindGameObjectsWithTag("Enemy");
         Hit.SetActive(true);
     }
     else
     {
         Debug.Log("Damage!");
         Hp -= 1;
         if (Hp == 0)
         {
             EndMessage.SetActive(true);
         }
     }
     var Y = pos.y;
 }
Ejemplo n.º 44
0
        public int TakeDamage(Hit hit, PRNG dice = null)
        {
            int damage = hit.NominalDamage;

            if (Population.Any() && Units.Any())
            {
                // for now, have a 50% chance to hit population first and a 50% chance to hit units first
                // TODO - base the chance to hit population vs. units on relative HP or something?
                var coin = RandomHelper.Next(2, dice);
                int leftover;
                if (coin == 0)
                {
                    leftover = TakePopulationDamage(hit, damage, dice);
                }
                else
                {
                    leftover = TakeUnitDamage(hit, damage, dice);
                }
                if (coin == 0)
                {
                    return(TakeUnitDamage(hit, leftover, dice));
                }
                else
                {
                    return(TakePopulationDamage(hit, damage, dice));
                }
            }
            else if (Population.Any())
            {
                return(TakePopulationDamage(hit, damage, dice));
            }
            else if (Units.Any())
            {
                return(TakeUnitDamage(hit, damage, dice));
            }
            else
            {
                return(damage);                // nothing to damage
            }
        }
Ejemplo n.º 45
0
        /// <summary>
        /// This constructor is used while retrieving the hit from the dump
        /// </summary>
        /// <param name="ltask">The dump indexer this Wiki topic belongs to</param>
        /// <param name="hit">The Lucene Hit object</param>
        public PageInfo(Indexer ixr, Hit hit)
        {
            TreatRedirectException = false;
            Indexer = ixr;

            // Decoder setter sort Beginnings and Ends.
            _decoder = ixr;

            Score = hit.GetScore();

            Document doc = hit.GetDocument();

            TopicId = Convert.ToInt64(doc.GetField("topicid").StringValue());

            Name = doc.GetField("title").StringValue();

            Beginnings = new long[doc.GetFields("beginning").Length];
            Ends       = new long[doc.GetFields("end").Length];

            int i = 0;

            foreach (byte[] binVal in doc.GetBinaryValues("beginning"))
            {
                Beginnings[i] = BitConverter.ToInt64(binVal, 0);

                i++;
            }

            i = 0;

            foreach (byte[] binVal in doc.GetBinaryValues("end"))
            {
                Ends[i] = BitConverter.ToInt64(binVal, 0);

                i++;
            }

            Array.Sort(Beginnings);
            Array.Sort(Ends);
        }
Ejemplo n.º 46
0
		Hit FromGoogleResultElement (ResultElement res, int rank)
		{
			Hit hit = new Hit ();

			hit.Uri      = new Uri (res.URL, true);
			hit.Type     = "Google";
			hit.MimeType = "text/html"; // FIXME
			hit.Source   = "Google";

			// FIXME: We don't get scoring information from Google
			// other than the ranks.  This is a hack.
			hit.Score    = 0.2f / (1 + rank);

			hit ["Summary"]        = res.summary;
			hit ["Snippet"]        = res.snippet;
			hit ["Title"]          = res.title;
			hit ["CachedSize"]     = res.cachedSize;
			hit ["HostName"]       = res.hostName;
			hit ["DirectoryTitle"] = res.directoryTitle;

			return hit;
		}
Ejemplo n.º 47
0
		public void AddHit (Hit hit)
		{
			string uri = hit.Uri.ToString ();

			values["Uri"] = uri;

			if (uri.Length > 40)
				uri = uri.Substring (0, 40) + "...";
			values["DisplayUri"] = uri;

			values["MimeType"] = hit.MimeType;
			values["Source"] = hit.Source;
			values["Score"] = hit.Score.ToString ();
			values["Timestamp"] = BU.StringFu.DateTimeToString (hit.Timestamp);
			values["Path"] = hit.Path;
			values["FileName"] = hit.FileName;
			values["DirectoryName"] = hit.DirectoryName;
			if (hit.FileInfo != null) 
				values["FolderName"] = hit.FileInfo.Directory.Name;
			else if (hit.DirectoryInfo != null)
				values["FolderName"] = hit.DirectoryInfo.Parent.Name;
			AddProperties (hit.Properties);
		}
Ejemplo n.º 48
0
        public static string ToString(Hit blastHit, int blastHspId)
        {
            Hsp hsp = blastHit.Hsps[blastHspId];
            string pa = "";
            pa += String.Format(">{0} {1}\r\n", blastHit.Id, blastHit.Def);
            pa += String.Format("Length={0}\r\n\r\n", blastHit.Length);
            pa += String.Format(" Score = {0} bits ({1}), Expect = {2}\r\n", hsp.BitScore, hsp.Score, hsp.EValue);
            int percentId = (int)Math.Round(((hsp.IdentitiesCount / (double)hsp.AlignmentLength) * 100.0), 0);
            int percentPos = (int)Math.Round(((hsp.PositivesCount / (double)hsp.AlignmentLength) * 100.0), 0);
            int percentGap = (int)Math.Round(((hsp.Gaps / (double)hsp.AlignmentLength) * 100.0), 0);
            pa += String.Format(" Identities = {0}/{1} ({2}%), Positives = {3}/{4} ({5}%), Gaps = {6}/{7} ({8}%)\r\n", hsp.IdentitiesCount,
                                                                                                                        hsp.AlignmentLength,
                                                                                                                        percentId,
                                                                                                                        hsp.PositivesCount,
                                                                                                                        hsp.AlignmentLength,
                                                                                                                        percentPos,
                                                                                                                        hsp.Gaps,
                                                                                                                        hsp.AlignmentLength,
                                                                                                                        percentGap);
            pa += String.Format(" Frame = {0}\r\n", hsp.HitFrame);
            pa += "\r\n";

            for (int k = 0; k < hsp.AlignmentLength; k += 60)
            {
                long tl = 60;
                if ((k + tl) > hsp.AlignmentLength)
                {
                    tl = hsp.AlignmentLength - k;
                }

                pa += String.Format("Query  {1,-5}  {0}  {2,-5}\r\n", hsp.QuerySequence.Substring(k, (int)tl), hsp.QueryStart + k, hsp.QueryStart + k + tl - 1);
                pa += String.Format("       {1,-5}  {0}  {2,-5}\r\n", hsp.Midline.Substring(k, (int)tl), "", "");
                pa += String.Format("Sbjct  {1,-5}  {0}  {2,-5}\r\n", hsp.HitSequence.Substring(k, (int)tl), hsp.HitStart + k, hsp.HitStart + k + tl - 1);
                pa += "\r\n";
            }
            return pa;
        }
Ejemplo n.º 49
0
 public void setHit2(Hit hit)
 {
     this.hit2 = hit;
 }
Ejemplo n.º 50
0
 public void setHit1(Hit hit)
 {
     this.hit1 = hit;
 }
Ejemplo n.º 51
0
 public void clear()
 {
     hit1 = null;
     hit2 = null;
 }
Ejemplo n.º 52
0
 public Hits()
 {
     hit1 = null;
     hit2 = null;
 }
Ejemplo n.º 53
0
		// Remap uri based on mount point for removable indexes
		// FIXME: Allow option to search unmounted media ? Return false in that case.
		override protected bool HitFilter (Hit hit)
		{
			if (! HitIsValid (hit.Uri))
				return false;

			return HitIsValidRemovable (hit);
		}
Ejemplo n.º 54
0
        private static dynamic GetConcreteTypeUsingSelector(
			ConcreteTypeConverter realConcreteConverter,
			JObject jObject)
        {
            var baseType = realConcreteConverter._baseType;
            var selector = realConcreteConverter._concreteTypeSelector;

            Hit<dynamic> hitDynamic = new Hit<dynamic>();
            dynamic d = jObject;

            //favor manual mapping over doing Populate twice.
            hitDynamic.Fields = d.fields;
            hitDynamic.Source = d._source;
            hitDynamic.Index = d._index;
            hitDynamic.Score = (d._score is double) ? d._score : default(double);
            hitDynamic.Type = d._type;
            hitDynamic.Version = d._version;
            hitDynamic.Id = d._id;
            hitDynamic.Sorts = d.sort;
            hitDynamic._Highlight = d.highlight is Dictionary<string, List<string>> ? d.highlight : null;
            hitDynamic.Explanation = d._explanation is Explanation ? d._explanation : null;

            var concreteType = selector(hitDynamic.Source, hitDynamic);
            return concreteType;
        }
Ejemplo n.º 55
0
		public TileContact (Hit _hit) : base (_hit,
						      "template-contact.html")
		{
		}
Ejemplo n.º 56
0
 public ActionResult RecordHit(Hit hit)
 {
     hit.ClientIP = Request.UserHostAddress;
     _hitRepository.Record(hit);
     return File(tinyImage, "image/gif");
 }
Ejemplo n.º 57
0
		override public ISnippetReader GetSnippet (string[] query_terms, Hit hit, bool full_text, int ctx_length, int snp_length) 
		{
			if (text_cache == null)
				return null;

			Uri uri;

			if (mount_dir == null || hit ["beagle:RemovableUri"] == null)
				uri = hit.Uri;
			else
				uri = UriFu.EscapedStringToUri (hit ["beagle:RemovableUri"]);

			// Look up the hit in our local text cache.
			// Need to handle self-cached removable:/// uris
			bool self_cache = true;
			TextReader reader = text_cache.GetReader (uri, ref self_cache);

			if (self_cache)
				reader = new StreamReader (hit.Uri.LocalPath);
			else if (reader == null)
				return null;
			
			return SnippetFu.GetSnippet (query_terms, reader, full_text, ctx_length, snp_length);
		}
Ejemplo n.º 58
0
		public ISnippetReader GetSnippet (string[] query_terms, Hit hit, bool full_text, int ctx_length, int snp_length)
		{
			return null;
		}
Ejemplo n.º 59
0
		//////////////////////////////////////////////////
		// Convert matches to Hits

		private Hit PathToHit (string path)
		{
			// Check if hidden
			if (path.IndexOf ("/.") != -1)
				return null;

			Hit hit = new Hit ();
			hit.Uri = UriFu.PathToFileUri (path);
			hit.Timestamp = File.GetLastWriteTimeUtc (path);
                        hit.AddProperty (Property.NewUnsearched ("beagle:HitType", "File"));
			// Prevent any mimetype matching
                        hit.AddProperty (Property.NewUnsearched ("beagle:MimeType", "beagle/x-locate-result"));
                        hit.AddProperty (Property.NewUnsearched ("beagle:Source", "Locate"));
			// Use a generic enough filetype to hint there is _no_ special properties
			// for this hit
                        hit.AddProperty (Property.NewUnsearched ("beagle:FileType", "document"));
			hit.Score = 1.0;

			foreach (Property std_prop in Property.StandardFileProperties (Path.GetFileName (path), true))
				hit.AddProperty (std_prop);

			hit.AddProperty (Property.NewUnsearched (
					 Property.ParentDirUriPropKey,
					 UriFu.PathToFileUri (Path.GetDirectoryName (path))));

			return hit;
		}
Ejemplo n.º 60
0
		private bool HitIsValidRemovable (Hit hit)
		{
			if (mount_dir == null || hit.Uri.Scheme != "removable")
				return true;

			hit.AddProperty (Beagle.Property.NewKeyword ("beagle:RemovableUri",
								     hit.EscapedUri));

			string path = hit.Uri.LocalPath;
			path = path.Substring (1); // Remove initial '/'
			path = Path.Combine (mount_dir, path);
			hit.Uri = UriFu.PathToFileUri (path);

			hit.AddProperty (Beagle.Property.NewKeyword ("fixme:mount_dir", mount_dir));

			return true;
		}