/// <summary> /// 绘制属性 /// </summary> public override void DrawAttr() { base.DrawAttr(); m_TriggerTimer = m_BaseTrigger as TriggerTimer; m_TriggerTimer.m_fTimerTime = EditorGUILayout.FloatField("等候时长(秒)", m_TriggerTimer.m_fTimerTime); }
public void SetupTriggerCondition() { _triggerObject = GetTriggerObject(_triggerController); if (_triggerObject == null) { TriggerTimer.Construct(this.gameObject, _time, _timeOffset, _myTriggerData.GO); } else { TriggerSwitchBase.Construct(_triggerObject, _myTriggerData.GO); } }
public override void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera) { ParticleEmitter._camera = camera; List <Particle> toRemove = new List <Particle>(); TriggerTimer.Update(gameTime); if (TriggerTimer.HasTriggered && Data.ParticlesPerFrame > 0) { Trigger(Data.ParticlesPerFrame, Vector3.Zero, Tint); } bool particlePhysics = GameSettings.Default.ParticlePhysics; foreach (Particle p in Particles) { float vel = p.Velocity.LengthSquared(); if (!Data.Sleeps || vel > 0.2f) { if (Data.EmitsLight && p.Scale > 0.1f) { DynamicLight.TempLights.Add(new DynamicLight(10.0f, 255.0f, false) { Position = p.Position }); } p.Position += p.Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; if (Data.RotatesWithVelocity) { Vector3 cameraVel = camera.Project(p.Velocity + camera.Position); float projectionX = cameraVel.X; float projectionY = cameraVel.Y; p.Angle = (float)Math.Atan2(projectionY, projectionX); } else { p.Angle += (float)(p.AngularVelocity * gameTime.ElapsedGameTime.TotalSeconds); } p.Velocity += Data.ConstantAccel * (float)gameTime.ElapsedGameTime.TotalSeconds; p.Velocity *= Data.LinearDamping; p.AngularVelocity *= Data.AngularDamping; } else if (Data.Sleeps && vel < 0.2f) { p.Velocity = Vector3.Zero; } if (!Data.UseManualControl) { p.LifeRemaining -= Data.ParticleDecay * (float)gameTime.ElapsedGameTime.TotalSeconds; } p.Scale += Data.GrowthSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; p.Scale = Math.Max(p.Scale, 0.0f); var v = new VoxelHandle(chunks.ChunkData, GlobalVoxelCoordinate.FromVector3(p.Position)); if (Data.HasLighting) { if (v.IsValid && v.IsEmpty) { p.Tint = new Color(v.SunColor, 255, 0); } } if (Data.CollidesWorld && particlePhysics && vel > 0.2f) { BoundingBox b = new BoundingBox(p.Position - Vector3.One * p.Scale * 0.5f, p.Position + Vector3.One * p.Scale * 0.5f); if (v.IsValid && !v.IsEmpty) { Physics.Contact contact = new Physics.Contact(); if (Physics.TestStaticAABBAABB(b, v.GetBoundingBox(), ref contact)) { p.Position += contact.NEnter * contact.Penetration; Vector3 newVelocity = Vector3.Reflect(p.Velocity, -contact.NEnter); p.Velocity = newVelocity * Data.Damping; p.AngularVelocity *= 0.5f; } } } if (p.LifeRemaining < 0) { if (p.InstanceData != null) { p.InstanceData.ShouldDraw = false; p.InstanceData.Transform = Matrix.CreateTranslation(camera.Position + new Vector3(-1000, -1000, -1000)); Sprites[p.Frame].Remove(p.InstanceData); } toRemove.Add(p); } else if (p.InstanceData != null) { p.TimeAlive += (float)gameTime.ElapsedGameTime.TotalSeconds + MathFunctions.Rand() * 0.01f; int prevFrame = p.Frame; int newFrame = AnimPlayer.GetFrame(p.TimeAlive); if (newFrame != prevFrame) { p.Frame = newFrame; if (Sprites.Count > 0) { Sprites[prevFrame].Remove(p.InstanceData); Sprites[newFrame].Add(p.InstanceData); } if (/*!Data.Animation.Loops && */ p.Frame == Data.Animation.Frames.Count - 1) { p.LifeRemaining *= 0.1f; } } p.InstanceData.ShouldDraw = true; p.InstanceData.Transform = MatrixFromParticle(p); p.InstanceData.Color = p.Tint; } } foreach (Particle p in toRemove) { Particles.Remove(p); } foreach (var sprites in Sprites) { sprites.Update(gameTime, camera, chunks.Graphics, chunks.ChunkData.MaxViewingLevel); } if (Particles.Count > 0) { base.Update(gameTime, chunks, camera); } }
// Use this for initialization void Start() { curveName = kurve.name; gg = GameObject.Find("0 Toggle GG").GetComponent<ToggleGG>(); hint = GameObject.Find(curveName + "_hint"); looked = false; exit = false; frame = 0; show = true; hintActive = false; curvePre = curveName.Split('_')[0]; zc = GameObject.Find(curvePre).GetComponent<ZoneControl>(); car = GameObject.FindGameObjectWithTag("Player").GetComponent<CarController>(); wps = GetAllWaypoints(); currentWaypoint = 0; hint.transform.position = wps[0]; inTrigger = false; lockframes = 0; tt = GameObject.Find("StartGoal").GetComponent<TriggerTimer>(); sb = new StringBuilder(); headSet = false; /* filename = TriggerTimer.filename; string tmp = filename.Split('.')[0]; filename = tmp + "_gaze.csv"; if (!File.Exists(TriggerTimer.path + filename)) { string head = string.Format("{0},{1},{2},{3},{4},{5},{6}{7}", "Zone","Round", "Time", "PosHint", "PosGaze", "Distance", "CarSpeed", Environment.NewLine); sb.Append(head); } */ if (gameObject.name.Equals(curvePre + "_1_Trigger")) { isFirst = true; } else { isFirst = false; } }