public static Modulate ( Vector3 v1, Vector3 v2 ) : Vector3 | ||
v1 | Vector3 | |
v2 | Vector3 | |
리턴 | Vector3 |
protected override void DetectCollisions() { // Enemy collision detection RaycastHit hitInfo; var ray = new Ray(Origin, transform.rotation * Vector3.right); var size = transform.localScale.x; if (transform.localScale.x <= 0.1f) { size = 0.1f; } if (Physics.Raycast(ray, out hitInfo, size * 2, 1 << 8)) { if (hitInfo.collider.tag != "Enemy") { return; } OnCollide(hitInfo.collider, hitInfo.point); AlreadyHit.Remove(hitInfo.collider.gameObject); GetComponentInChildren <Stroboscope>().enabled = true; var collidee = hitInfo.collider.transform; var lastCollidePosition = collidee.position; var cp = ClosestPointOnRay(ray, lastCollidePosition - new Vector3(0, 0.4f, 0)); var enemy = hitInfo.collider.GetComponent <Enemy>(); var mat = ColorShifting.Materials[ColorShifting.EnemyMaterials[enemy.GetType()]]; if (enemy is SingleShotBehaviour && (enemy as SingleShotBehaviour).invertColors) { mat = ColorShifting.Materials["clr_Red"]; } var go = (GameObject)Instantiate(CharginTemplate, cp, Quaternion.identity); go.transform.localScale += new Vector3(0.2f, 0.2f, 0.2f); go.FindChild("Sphere.2").renderer.material = mat; go.AddComponent <FlickerOut>(); var hitPoint = collidee == null ? lastCollidePosition : collidee.position; var distance = Vector3.Distance(hitPoint, Origin); transform.localScale = VectorEx.Modulate(transform.localScale, new Vector3(0, 1, 1)) + (distance - 0.5f) / 2 * Vector3.right; transform.position = Origin + (transform.rotation * Vector3.right) * transform.localScale.x; } }
public override void OnDie() { if (Dead) { return; } base.OnDie(); var go = (GameObject)Instantiate(ToSpawn.transform.parent.gameObject); go.transform.position = transform.position; go.transform.localScale = VectorEx.Modulate(new Vector3(0.5967718f, 0.5967718f, 0.5967718f), go.transform.localScale); go.FindChild(ToSpawn.name).GetComponent <PowerUpBehaviour>().enabled = true; go = (GameObject)Instantiate(BirdTemplate); go.transform.position = transform.position; Destroy(gameObject); }