// Use this for initialization void Start() { width = Mathf.RoundToInt(width * PlayerPrefs.GetFloat("MichaelBay", 1.0f)); GameObject spawnedGraphic = (GameObject)GameObject.Instantiate(graphic, transform.position, Quaternion.identity); Vector3 direction = new Vector3(0, 0, 0); direction.x = Random.Range(-1.0f, 1.0f); direction.y = Random.Range(-1.0f, 1.0f); direction.Normalize(); float speed = wiggleBase + Random.Range(-wiggleVariation, wiggleVariation); Drift drift = spawnedGraphic.AddComponent <Drift>(); drift.direction = direction; drift.speed = speed; if (depth == 0) { Destroy(gameObject); return; } for (int i = 0; i < width; ++i) { Vector3 jiggle = new Vector3(0, 0, 0); direction.x = Random.Range(-1.0f, 1.0f); direction.y = Random.Range(-1.0f, 1.0f); jiggle.Normalize(); jiggle = jiggle * (wiggleBase + Random.Range(-wiggleVariation, wiggleVariation)); GameObject spawnedObject = (GameObject)GameObject.Instantiate(gameObject, jiggle + transform.position, Quaternion.identity); spawnedObject.GetComponent <Explosion>().depth -= 1; } Destroy(gameObject); }
//--------------------------------------------------------------------------- public bool Update(float deltaTime, ParticleDesc desc) { LifeTime += deltaTime; RelativeLifeTime = (LifeTime / MaxLifeTime); if (LifeTime >= MaxLifeTime) { return(true); } Velocity = (Velocity - Vector3.UnitZ * desc.Gravity(RelativeLifeTime)) * (1.0f - desc.Inertia(RelativeLifeTime)); if (Drift.Length() > 0) { Matrix rotMatrix = Matrix.CreateFromAxisAngle(Vector3.Normalize(Drift), MathHelper.ToRadians(Drift.Length())); Velocity = Vector3.Transform(Velocity, rotMatrix); } Location += Velocity; if (Location.Z < 0) { Location = new Vector3(Location.X, Location.Y, 0); Velocity = new Vector3(Velocity.X, Velocity.Y, -Velocity.Z * desc.Restitution(RelativeLifeTime)); } return(false); }
// Update is called once per frame void Update() { //Find player vector position player = GameObject.FindWithTag("Player"); //Instantiate this number of bullet toward player position if (Time.time > timeStamp + cooldown) { laser_p = Instantiate(laser, transform.position, Quaternion.identity) as GameObject; Drift laser_temp = laser_p.AddComponent <Drift>(); laser_temp.speed = spd; Vector2 pos = (player.transform.position - transform.position); // Shoot underneath the player. pos.y -= 1; pos.Normalize(); laser_temp.direction = pos; Transform start = laser_p.transform.GetChild(0).transform; Vector3 direction = player.transform.position - start.position; float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; start.rotation = Quaternion.AngleAxis(angle, Vector3.forward); timeStamp = Time.time; } }
public void AddFloatingObject(GameObject baseObject) { Drift drift = baseObject.AddComponent <Drift>(); drift.direction = new Vector3(0, 1, 0); drift.speed = currentSpeed; floatingObjects.Add(drift); }
public ActionComponent( DirectionalAction direction, SecondaryAction SecondaryAct, PrimaryAction primaryAct, Drift drifting = Drift.None) { this.curDirection = direction; this.secondaryAction = SecondaryAct; this.primaryAction = primaryAct; this.drift = drifting; }
public override int GetHashCode() => Timestamp.GetHashCode() ^ (Call == null ? 0 : Call.GetHashCode()) ^ Frequency.GetHashCode() ^ Snr.GetHashCode() ^ Drift.GetHashCode() ^ Grid.GetHashCode() ^ Power.GetHashCode() ^ (ReporterCallsign == null ? 0 : ReporterCallsign.GetHashCode()) ^ (ReporterLocator == null ? 0 : ReporterLocator.GetHashCode()) ^ Km.GetHashCode() ^ (Mode == null ? 0 : Mode.GetHashCode());
/// <summary> /// 构造函数 /// </summary> public Tips() : base() { this.handle = null; this.matte = false; this.Alpha = 85; this.arise = null; this.quote = null; this.fonts = null; this.gauge = null; this.drift = null; this.point = null; this.scrap = null; this.color = Color.FromRgb(204, 85, 34); }
private void meshGen(Vector2[] vertices) { var triangulator = new Triangulator(vertices); int[] indices = triangulator.Triangulate(); Vector3[] vertices3D = System.Array.ConvertAll <Vector2, Vector3>(vertices, v => v); Vector3 sum = Vector3.zero; int count = 0; foreach (Vector3 v in vertices3D) { sum += v; count++; } Vector3 center = sum / count; Mesh mesh = new Mesh(); mesh.vertices = vertices3D; mesh.triangles = indices; mesh.RecalculateNormals(); mesh.RecalculateBounds(); GameObject empty = new GameObject("test"); //empty.AddComponent(typeof(PolygonCollider2D)); //empty.GetComponent<PolygonCollider2D>().points = vertices; //empty.layer = LayerMask.NameToLayer("Chunk"); empty.AddComponent(typeof(MeshRenderer)); MeshRenderer meshrenderer = empty.GetComponent <MeshRenderer>(); meshrenderer.material = inMaterial; meshrenderer.material.color = new Color32(255, 255, 255, 255); MeshFilter filter = empty.AddComponent(typeof(MeshFilter)) as MeshFilter; filter.mesh = mesh; empty.AddComponent(typeof(Drift)); Drift drift = empty.GetComponent <Drift>(); drift.center = center; drift.UpdatePosition(mouseEnter); //empty.AddComponent(typeof(Cut)); }
public override void Spawn() { GameObject spawnedObject = (GameObject)GameObject.Instantiate(spawnPrefab, transform.position, transform.rotation); Vector2 direction = driftDirection; if (driftDirection.x == 0 && driftDirection.y == 0) { direction.x = Random.Range(-1.0f, 1.0f); direction.y = Random.Range(-1.0f, 1.0f); direction.Normalize(); } Drift drift = spawnedObject.AddComponent <Drift>(); drift.direction = direction; drift.speed = driftSpeedBase + Random.Range(-driftSpeedVariation, driftSpeedVariation); condition.OnSpawn(spawnedObject); }