public static void SetCursor(HitPoint hitPoint) { Cursor cursor = Cursors.Arrow; if (hitPoint == HitPoint.Left) { cursor = Cursors.SizeWE; } if (hitPoint == HitPoint.Top) { cursor = Cursors.SizeNS; } if (hitPoint == HitPoint.Right) { cursor = Cursors.SizeWE; } if (hitPoint == HitPoint.Bottom) { cursor = Cursors.SizeNS; } if (hitPoint == HitPoint.Center) { cursor = Cursors.Hand; } Mouse.SetCursor(cursor); //Log.Debug("SetCursor", "cursor:" + cursor); }
// Token: 0x06002009 RID: 8201 RVA: 0x000993A8 File Offset: 0x000975A8 public override void Shoot(Ray ray, out CmunePairList <BaseGameProp, ShotPoint> hits) { hits = null; Vector3 direction = WeaponDataManager.ApplyDispersion(ray.direction, this._view, this._supportIronSight); int projectileId = base.Controller.NextProjectileId(); RaycastHit raycastHit; if (Physics.Raycast(ray.origin, direction, out raycastHit, 1000f, (!base.Controller.IsLocal) ? UberstrikeLayerMasks.ShootMaskRemotePlayer : UberstrikeLayerMasks.ShootMask)) { HitPoint point = new HitPoint(raycastHit.point, TagUtil.GetTag(raycastHit.collider)); BaseGameProp component = raycastHit.collider.GetComponent <BaseGameProp>(); if (component) { hits = new CmunePairList <BaseGameProp, ShotPoint>(1); hits.Add(component, new ShotPoint(raycastHit.point, projectileId)); } this.Decorator.PlayImpactSoundAt(point); } else { raycastHit.point = ray.origin + ray.direction * 1000f; } if (this.Decorator) { this.Decorator.ShowShootEffect(new RaycastHit[] { raycastHit }); } base.OnHits(hits); }
void OnMouseDown() { if (active) { Instantiate( Resources.Load("vfx_trap"), new Vector3(transform.position.x, 3f, transform.position.z), Quaternion.AngleAxis(90f, new Vector3(1f, 0f, 0f)) ); active = false; GetComponent <Renderer>().material.color = new Color(0.0F, 0.0F, 0.0F); Invoke("Rearm", 5f); foreach (GameObject o in objectsInside) { if (o != null) { HitPoint hp = o.GetComponent <HitPoint>(); if (hp != null) { hp.hp -= damages; } } } } }
private void FindTarget() { if (this.target == null) { var enemies = GameObject.FindObjectsOfType <HitPoint>(); var nearestTarget = (HitPoint) default; float dist = Mathf.Infinity; foreach (var e in enemies) { float d = Vector3.Distance(this.transform.position, e.transform.position); var magnitude = (e.transform.position - this.transform.position).magnitude; if ((nearestTarget == null || d < dist) && magnitude < this.Range) { nearestTarget = e; dist = d; } } this.target = nearestTarget; } }
private void GenerateLineCast(GameObject viewpoint, Vector2 direction) { HitPoint hitPoint = new HitPoint(); RaycastHit2D[] rayCastHits2D; rayCastHits2D = Physics2D.RaycastAll(viewpoint.transform.position, direction); if (rayCastHits2D.Length > 0) { if ((rayCastHits2D[0].point - new Vector2(viewpoint.transform.position.x, viewpoint.transform.position.y)).magnitude < range) { hitPoint.location = rayCastHits2D[0].point; // find the index of obstacle in the hit point foreach (OBSTACLE.Obstacle obstacle in ObstaclesLine) { if (HelpFunction.isInObstacle(hitPoint.location, obstacle.obstaclePoints)) { hitPoint.obstacleIndex = obstacle.index; break; } } addPointToCriticalList(hitPoint); } else { hitPoint.location = new Vector2(viewpoint.transform.position.x, viewpoint.transform.position.y) + direction.normalized * range; hitPoint.obstacleIndex = -1; addPointToCriticalList(hitPoint); } if (!bMesh) { GenerateVisibilityEffectWithLine(viewpoint, hitPoint.location); } } }
private void SetClosestPoint(List <HitPoint> points, out bool isEmptyBelow, out bool isEmptyAbove) { isEmptyAbove = true; float topPoint = transform.position.y + (transform.localScale.y / 2); float bottomPoint = transform.position.y - (transform.localScale.y / 2); closestPoint = new HitPoint(new Vector3(), 10000); foreach (var obj in points.GetRange(180, 180)) { if (obj.Degree <= 180) { continue; } var result = Mathf.Abs(transform.position.x - obj.Vector3.x); if (result <= closestPoint.Distance) { closestPoint = new HitPoint(obj.Vector3, result); var index = obj.Degree == 0 ? 0 : obj.Degree == 180 ? 180 : 360 - obj.Degree; if (topPoint > points[index].Vector3.y) { closestPointAbove = new HitPoint(new Vector3(transform.position.x, points[index].Vector3.y)); closestPointAboveTopPoint = new HitPoint(new Vector3(transform.position.x, topPoint)); isEmptyAbove = false; } } } isEmptyBelow = !(closestPoint.Vector3.y <= bottomPoint); }
// Use this for initialization void Awake() { rigidBody = GetComponent <Rigidbody>(); hitPoints = gameObject.GetComponent <HitPoint>(); scaleBase = transform.localScale; uiGameOver = GameObject.Find("GameOverCanvas"); }
/// <summary> /// Calculates the colour of a point that is "seen" by a given ray /// </summary> /// <param name="ray">The ray used to "see"</param> /// <param name="random">An instance of <see cref="Random"/></param> /// <param name="recursionDepth">How many times the ray will be reflected</param> /// <returns>A vector containing the linear colour values in (R, G, B) order.</returns> public Vector3 CalculateColour(Ray ray, Random random, int recursionDepth) { HitPoint hitPoint = SceneObjects.FindClosestHitPoint(ray); Vector3 colour = Colour.Black; if (hitPoint != null) { colour = hitPoint.Material.Emissive; if (recursionDepth > 0) { Vector3 n = hitPoint.Normal; Vector3 randomVector; do { randomVector = random.NextVector3() * 2 - Vector3.One; } while(randomVector.Length() > 1); if (Vector3.Dot(randomVector, n) < 0) { randomVector = Vector3.Negate(randomVector); } Vector3 adjustedPosition = hitPoint.Position - ray.Direction * HIT_POINT_ADJUSTMENT; Ray newRay = new Ray(adjustedPosition, randomVector); float lambert = Vector3.Dot(randomVector, n); Vector3 BRDF = hitPoint.Material.Diffuse; colour += CalculateColour(newRay, random, recursionDepth - 1) * lambert * BRDF; colour /= 1 / (2 * (float)Math.PI); } } return(colour); }
void AssociatedObject_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { Point point = e.GetPosition(rect); hitPoint = RectangleHelper.HitTest(point, rect); if (canvas == null) { canvas = (Canvas)VisualTreeHelper.GetParent(this.AssociatedObject); } FrameworkElement element = AssociatedObject as FrameworkElement; if (hitPoint != HitPoint.None) { height = rect.ActualHeight; width = rect.ActualWidth; rect.Stroke = new SolidColorBrush(Color); if (rect.StrokeThickness <= 0 && Thickness > 0) { rect.StrokeThickness = Thickness; } isDragging = true; mouseOffset = e.GetPosition(AssociatedObject); mouseOffset2 = e.GetPosition(canvas); AssociatedObject.CaptureMouse(); } else { rect.Stroke = borderBrush; rect.StrokeThickness = borderThickness; } }
// Start is called before the first frame update void Awake() { // references initialization input = new PlayerInput(); camera = Camera.main.transform; anim = GetComponentInChildren <Animator>(); visualScript = GetComponentInChildren <PlayerAnimator>(); collider = GetComponent <Collider>(); hpbar = GameObject.FindGameObjectWithTag("Hpbar").GetComponent <HitPoint>(); // key registration input.Player.Attack.performed += _ => Attack(); input.Player.Dash.performed += _ => Dash(new Vector2(input.Player.HorizontalMove.ReadValue <float>(), input.Player.VerticalMove.ReadValue <float>())); // value initialization moveSpeedMax = moveSpeed; isAttacking = false; attackedEnemy.Clear(); immuneEnemy.Clear(); shouldAttack = false; canAttack = false; canRegisterAttack = false; isDashing = false; canRegisterDash = false; //debug // Time.timeScale = 0.2f; }
public static HitPoint HitTest(Point point, Rectangle rect) { double thickness = rect.StrokeThickness; HitPoint hitPoint = HitPoint.None; if (point.X <= thickness && point.X >= 0) { hitPoint = HitPoint.Left; } else if (point.Y <= thickness && point.X >= 0) { hitPoint = HitPoint.Top; } else if (point.X >= rect.ActualWidth - thickness && point.X <= rect.ActualWidth + thickness) { hitPoint = HitPoint.Right; } else if (point.Y >= rect.ActualHeight - thickness && point.Y <= rect.ActualHeight + thickness) { hitPoint = HitPoint.Bottom; } else if (point.X > thickness && point.X < rect.ActualWidth - thickness && point.Y > thickness && point.Y < rect.ActualHeight - thickness) { hitPoint = HitPoint.Center; } return(hitPoint); }
public void OnHit(Vector3 pos, float amount) { timeSinceHit = 0; var p = new HitPoint(amount, pos); p.Parent = this; }
public void ダメージがオーバーしてもHPはマイナスにならない() { var hp0 = new HitPoint(100); var dmg = new Damage(9999); var hp1 = dmg.GetDamagedHitPoint(hp0); Assert.That(hp1.value, Is.Not.Negative); }
public void ダメージ分HPが減る() { var hp0 = new HitPoint(100); var dmg = new Damage(60); var hp1 = dmg.GetDamagedHitPoint(hp0); Assert.That(hp1.value, Is.EqualTo(40)); }
//在新游戏开始时被调用 void Awake() { Instance = this; ///初始化面板 HP = 5; hpText.text = HP.ToString(); }
public static HitPoint retrieveHitPoint(RaycastHit hit) { HitPoint hitPoint = new HitPoint(); hitPoint.position = hit.point; hitPoint.normal = hit.normal; return(hitPoint); }
public WeaponStaff() { _minDamage = 20; _maxDamage = 55; Name = "Staff"; Description = "Good in close combat, but can prove unreliable against metal weapons."; Icon = new Image(); HitPoints = new HitPoint((_maxDamage + _minDamage) / 2); }
public WeaponNunchucks() { _minDamage = 35; _maxDamage = 65; Name = "Nunchucks"; Description = "A fast, light weapon. Requires much skill to be used efficiently."; Icon = new Image(); HitPoints = new HitPoint((_maxDamage + _minDamage) / 2); }
public WeaponHeavySword() { _minDamage = 75; _maxDamage = 100; Name = "Heavy Sword"; Description = "A heavy, powerful weapon. Does much damage, but is slow to wield."; Icon = new Image(); HitPoints = new HitPoint((_maxDamage + _minDamage) / 2); }
public WeaponElfBow() { _minDamage = 20; _maxDamage = 85; Name = "Bow and Arrow"; Description = "An excellent long range weapon. Mostly uneffective in close combat. This weapon requires a decent amout of skill to be used accurately."; Icon = new Image(); HitPoints = new HitPoint((_maxDamage + _minDamage) / 2); }
public WeaponSword() { _minDamage = 55; _maxDamage = 75; Name = "Sword"; Description = "A fast weapon, excellent in close combat."; Icon = new Image(); HitPoints = new HitPoint((_maxDamage + _minDamage) / 2); }
protected void ShootAt(HitPoint enemy) { fireCooldownLeft -= Time.deltaTime; if (fireCooldownLeft <= 0 && !isAttacking) { fireCooldownLeft = fireCooldown; this.isAttacking = true; this.Animator.SetTrigger("Attack"); } }
void Start() { PutWeaponInHand(); SetRuntimeAnimatorController(); SetHealthPoints(); hitPoint = GetComponentInChildren <HitPoint>(); weaponDamageCollider = GetComponentInChildren <WeaponHook>(); anim = GetComponent <Animator>(); audioSource = GetComponent <AudioSource>(); }
public void Enable() { player.enabled = true; MainObject = currentSkin.InitSkin(); // MainObject.transform.localScale = Vector2.zero; targetPrefab = currentSkin.TargetObject; player.SetHitObject(currentSkin.HitObject, 4); currentColor = currentSkin.GetColor(); MainObject.transform.Find("Main").GetComponent <SpriteRenderer>().color = currentColor; dir = Random.value > .5f ? 1 : -1; if (lvl.canSlowDown) { StartCoroutine(ChangeSpeed()); speed = 0; } else { speed = lvl.maxSpeed; } pointAngles = new List <HitPoint>(); var coinCount = 2f; var startPos = spawner.position; for (int i = 0; i < 18; i++) { if (Random.value < levelCoefficient) { var g = Instantiate(targetPrefab, spawner.position, spawner.rotation, MainObject.transform); var hito = new HitPoint(g, 360 - spawner.eulerAngles.z); GameObject coin = null; if (coinCount > 0 && Random.value > .7f) { coinCount--; var coinObj = Instantiate(coinPrefab, spawner.position - spawner.transform.up / 2f, spawner.rotation, MainObject.transform); // coinObj.transform.localScale = Vector3.one * 2; hito.SetCoin(coinObj); } pointAngles.Add(hito); } spawner.RotateAround(Vector3.zero, Vector3.forward, 20); } spawner.position = startPos; spawner.rotation = Quaternion.identity; score = PrefsManager.CurrentScore; OnUpdateScore(score); }
public static HitPoint GetDamagedHitPoint(this Damage damage, HitPoint original) { var remain = original.value - damage.value; if (remain < 0) { remain = 0; } return(new HitPoint(remain)); }
// Token: 0x0600200C RID: 8204 RVA: 0x000994D4 File Offset: 0x000976D4 public override void Shoot(Ray ray, out CmunePairList <BaseGameProp, ShotPoint> hits) { Dictionary <BaseGameProp, ShotPoint> dictionary = new Dictionary <BaseGameProp, ShotPoint>(this.ShotgunGauge); HitPoint hitPoint = null; RaycastHit[] array = new RaycastHit[this.ShotgunGauge]; int projectileId = base.Controller.NextProjectileId(); int num = 1000; for (int i = 0; i < this.ShotgunGauge; i++) { Vector3 direction = WeaponDataManager.ApplyDispersion(ray.direction, this._view, false); RaycastHit raycastHit; if (Physics.Raycast(ray.origin, direction, out raycastHit, (float)num, (!base.Controller.IsLocal) ? UberstrikeLayerMasks.ShootMaskRemotePlayer : UberstrikeLayerMasks.ShootMask)) { if (hitPoint == null) { hitPoint = new HitPoint(raycastHit.point, TagUtil.GetTag(raycastHit.collider)); } BaseGameProp component = raycastHit.collider.GetComponent <BaseGameProp>(); if (component) { ShotPoint shotPoint; if (dictionary.TryGetValue(component, out shotPoint)) { shotPoint.AddPoint(raycastHit.point); } else { dictionary.Add(component, new ShotPoint(raycastHit.point, projectileId)); } } array[i] = raycastHit; } else { array[i].point = ray.origin + ray.direction * 1000f; array[i].normal = raycastHit.normal; } } this.Decorator.PlayImpactSoundAt(hitPoint); hits = new CmunePairList <BaseGameProp, ShotPoint>(dictionary.Count); foreach (KeyValuePair <BaseGameProp, ShotPoint> keyValuePair in dictionary) { hits.Add(keyValuePair.Key, keyValuePair.Value); } if (this.Decorator) { this.Decorator.ShowShootEffect(array); } base.OnHits(hits); }
void Start() { hitPoint = GetComponent<HitPoint>(); tankMove = GetComponent<TankMove>(); fireCannon = GetComponent<FireCannon>(); zoomImage = GameObject.Find("ZoomImage"); respawn = GameObject.Find("Respawn").GetComponent<Text>(); respawnTextTime = GameObject.Find("RespawnTime").GetComponent<Text>(); if (pv.isMine) { Camera.main.GetComponent<SmoothCam>().target = camPivot; //메인 카메라에 추가된 스크립트에 추적 대상을 연결 } }
/// <summary> /// Finds the closest hit point for a given ray among all the objects in this container. /// Returns the closest hit point. Null if none is found. /// </summary> /// <param name="ray">Ray for which the hit points should be found</param> /// <returns>The closest hit point. Null if none is found.</returns> public HitPoint FindClosestHitPoint(Ray ray) { HitPoint closestHitPoint = null; foreach (ISceneObject sceneObject in sceneObjects) { HitPoint hitPoint = sceneObject.CalculateHitPoint(ray); if (hitPoint != null && (closestHitPoint == null || hitPoint?.Lambda < closestHitPoint?.Lambda)) { closestHitPoint = hitPoint; } } return(closestHitPoint); }
public HitPointParser(string filename) { map = new Beatmap(filename); if (map.GetTag("general", "mode") == "3") { throw new ArgumentException("Error, mania mode parsing not supported"); } List <HitPoint> hitpointbuffer = new List <HitPoint>(); string[] hitobjectids = map.GetSection("hitobjects"); for (int i = 0; i < hitobjectids.Length; i++) { try { GenericHitObject hobject = new GenericHitObject(hitobjectids[i], map); int[] positions = hobject.GetHitLocations(); int[] times = hobject.GetHitTimes(); if (positions.Length != times.Length) { throw new Exception("Error: position and times array mismatched in size\n" + "positions.Length: " + positions.Length + "\n" + "times.Length: " + times.Length + "\n" + "index: " + i); } //Add a new HitPoint for every hit position and time for (int j = 0; j < positions.Length; j++) { HitPoint point = new HitPoint(positions[j], times[j], 0, 0); hitpointbuffer.Add(point); } } catch (Exception e) { //This is zero-indexed, so the first object is object=0 throw new Exception(e.Message + "\nobject=" + i + "\n" + GetMetadata("title") + ": " + GetMetadata("version"), e); } } hitpoints = hitpointbuffer.ToArray(); }
private void LookAtTarget() { this.targetDirection = this.target.transform.position - this.transform.position; if (this.targetDirection.magnitude > this.Range) { this.target = null; return; } var lookRotation = Quaternion.LookRotation(this.targetDirection); var rotation = Quaternion.Lerp( this.RotationPart.transform.rotation, lookRotation, Time.deltaTime * this.RotationSpeed).eulerAngles; this.RotationPart.transform.rotation = Quaternion.Euler(0, rotation.y, 0); }
//Reference: http://docs.unity3d.com/ScriptReference/RaycastHit-triangleIndex.html //Reference: http://answers.unity3d.com/questions/50846/how-do-i-obtain-the-surface-normal-for-a-point-on.html public static HitPoint retrieveHitTriangleOnMesh(RaycastHit hit) { MeshCollider meshCollider = hit.collider as MeshCollider; if (meshCollider == null || meshCollider.sharedMesh == null) { return(null); } HitPoint hitPoint = new HitPoint(); Mesh mesh = meshCollider.sharedMesh; Vector3[] vertices = mesh.vertices; Vector3 p0 = vertices[mesh.triangles[hit.triangleIndex * 3 + 0]]; Vector3 p1 = vertices[mesh.triangles[hit.triangleIndex * 3 + 1]]; Vector3 p2 = vertices[mesh.triangles[hit.triangleIndex * 3 + 2]]; Transform hitTransform = hit.collider.transform; p0 = hitTransform.TransformPoint(p0); p1 = hitTransform.TransformPoint(p1); p2 = hitTransform.TransformPoint(p2); hitPoint.position = p0; //hit.barycentricCoordinate; //Vector3 n0 = mesh.normals[mesh.triangles[hit.triangleIndex * 3 + 0]]; //Vector3 n1 = mesh.normals[mesh.triangles[hit.triangleIndex * 3 + 1]]; //Vector3 n2 = mesh.normals[mesh.triangles[hit.triangleIndex * 3 + 2]]; //Vector3 interpolatedNormal = n0 * hitTriangle.position.x + n1 * hitTriangle.position.y + n2 * hitTriangle.position.z; //interpolatedNormal.Normalize(); //hitTriangle.normal = hit.transform.TransformDirection(interpolatedNormal); hitPoint.normal = Vector3.Cross(p1 - p0, p2 - p0); //if(drawDebug) //{ // Debug.DrawLine(p0, p1); // Debug.DrawLine(p1, p2); // Debug.DrawLine(p2, p0); // Debug.DrawRay(hitPoint.position, hitPoint.normal); //} return(hitPoint); }
void Awake() { player = GameObject.Find("Player"); hitpoint = GetComponent<HitPoint>(); anim = GetComponent<Animator>(); }
public void SetStart(HitPoint startPosition, int startDirection) { if(CurrentHitpoint!=null) throw new InvalidOperationException("Initial position was already set!"); CurrentHitpoint = startPosition; Direction = startDirection; }
/// <summary> /// Checks if the player will hit a wall in the next move /// </summary> /// <param name="player">The player to check</param> /// <param name="nextMove">The next move of the player</param> /// <returns>true, if the player hits a wall in the next move, else false</returns> private bool CheckPlayerHitWall(Player player, HitPoint nextMove) { if(nextMove.HitWall(MainPanel.GameScoreboardX, MainPanel.GameHeight)) { player.PlayerState.Died = true; Debug.WriteLine(player.Name +" died! (WallHit @ "+nextMove+")"); return true; } return false; }
/// <summary> /// Checks if the next move of the player collides with another player /// </summary> /// <param name="player">The player to check</param> /// <param name="nextMove">The next move of this player</param> /// <returns>true, if the player will collide with another player, else false</returns> private bool CheckPlayerHitPlayer(Player player, HitPoint nextMove) { bool hit = false; foreach (Player colCheckPlayer in Players) { PlayerState colPlayerState = colCheckPlayer.PlayerState; foreach (HitPoint colCheckHitpoint in colPlayerState.HitBox) { if(nextMove.Hit(colCheckHitpoint)) { if(colCheckPlayer != player || (colCheckPlayer == player && Environment.TickCount - colCheckHitpoint.Created > TICK_SELF_IMMUNITY)) { hit = true; break; } } } if (hit) { Debug.WriteLine(player.Name + " died! (PlayerHit " + colCheckPlayer.Name + " @ Positions: " + player.PlayerState.CurrentHitpoint + " /// " + colCheckPlayer.PlayerState.CurrentHitpoint + ")"); player.PlayerState.Died = true; return true; } } return false; }
private void CalculateHoleChance(Player player, HitPoint nextMove) { PlayerState state = player.PlayerState; if(_gameOptions.Holes && (state.DrawHoleStartTick != 0 || Random.NextDouble() < PlayerState.PROBABILITY_DRAW_HOLES_START)) { if(state.DrawHoleStartTick == 0) { state.DrawHoleStartTick = Environment.TickCount; state.DrawHoleStopTick = Environment.TickCount + Random.Next(PlayerState.MIN_HOLE_SIZE_IN_TICKS, PlayerState.MAX_HOLE_SIZE_IN_TICKS); } else if(Environment.TickCount > state.DrawHoleStopTick) { state.DrawHoleStartTick = 0; state.DrawHoleStopTick = 0; } nextMove.Enabled = false; } player.PlayerState.AddHitPoint(nextMove); }
public StartPosition(HitPoint startPos, int startDirection) { StartPos = startPos; StartDirection = startDirection; }
public void AddHitPoint(HitPoint p) { CurrentHitpoint = p; HitBox.Add(p); }