public void Shoot(Vector3 point) { if (!aiming) { return; } //myTrans.rotation = Quaternion.LookRotation (point - myTrans.position, myTrans.up); rotating = false; aiming = false; CurveCaster.singleton.done = true; myTrans.rotation = targetRotation; //CurveCaster.singleton.SetTarget (point); Vector3 pos = CurveCaster.singleton.myTrans.position; Vector3 spd = CurveCaster.singleton.myTrans.rotation * Vector3.forward * CurveCaster.singleton.speed; TauntingRock rock = ((GameObject)GameObject.Instantiate(GameManager.singleton.rock, pos, CurveCaster.singleton.myTrans.rotation)).GetComponent <TauntingRock> (); rock.tauntRadiusMul = CurveCaster.singleton.tauntRadiusMul; //rock.Throw (CurveCaster.singleton.myTrans.position, CurveCaster.singleton.dir * CurveCaster.singleton.speed); rock.Throw(pos, spd); //CurveCaster.singleton.StopAim (); CurveCaster.singleton.timer = CurveCaster.singleton.time; CurveCaster.singleton.stopper = rock.gameObject; Vector3 v = spd; Debug.DrawLine(pos, pos + v, Color.red, 5); Vector3 xz = Vector3.ProjectOnPlane(v, Vector3.up); Debug.DrawLine(pos + xz, pos + v, Color.red, 5); Debug.DrawLine(pos, pos + xz, Color.red, 5); MySlider.singleton.StopSlider(); }
public float RockSight(TauntingRock c, float dt) { if (ctrl.HasBuff(BuffIndex.blind) || ctrl.HasBuff(BuffIndex.stun)) { return(0); } if (c.done) { return(0); } Vector3 tPos = c.myTrans.position; Vector3 delta = tPos - myPos; float dist = delta.magnitude; Vector3 dir; if (dist == 0) { dir = Vector3.zero; } else { dir = delta / dist; } bool hear = false; if (Vector3.Angle(delta.normalized, worldLookDir) > 60) { return(0); } float mul = 1 / Mathf.Max(1, dist - sightRange); int hitCount = Physics.RaycastNonAlloc(myPos, dir, hits, dist, mask, QueryTriggerInteraction.Collide); if (hitCount > 0) { for (int i = 0; i < hitCount; i++) { if (Obstacle.obstaclesByCollider.ContainsKey(hits [i].collider)) { Obstacle o = Obstacle.obstaclesByCollider [hits [i].collider]; mul *= o.sightMul; } } } //mul *= dt; if (ctrl.HasBuff(BuffIndex.hazy)) { mul *= 0.5f; } return(mul); }