void PrepareCapture() { mShowGUI = false; MainCamera.camera.backgroundColor = Color.black; mElapsedTime += Time.deltaTime; if (mElapsedTime > 0.5f) { Effect.Active(); mElapsedTime = 0f; mStep = EStep.Processing; mTotalTime = 0f; mIsCapturing = false; } }
public override void Activate() { Ball.Active(); mElapsedTime = 0f; mState = EState.Fly; Ball.transform.position = Vector3.zero; }
//manually emit effect node by expected position. public EffectNode EmitNode(string eftName, Vector3 pos) { List <XffectComponent> cache = EffectDic[eftName]; if (cache == null) { Debug.LogError(name + ": cache doesnt exist!"); return(null); } if (cache.Count > 1) { Debug.LogWarning("EmitNode() only support only-one xffect cache!"); } XffectComponent xft = (XffectComponent)cache[0]; if (!XffectComponent.IsActive(xft.gameObject)) { xft.Active(); } EffectNode ret = xft.EmitByPos(pos); if (ret == null) { Debug.LogError("emit node error! may be node max count is not enough:" + eftName); } return(ret); }
void Update() { if (mState == EState.Warmup) { mElapsedTime += Time.deltaTime; if (mElapsedTime >= 2f) { mState = EState.Fly; Model.gameObject.SetActive(true); Model.transform.localPosition = Vector3.zero; Comet.Active(); mElapsedTime = 0f; } } else if (mState == EState.Fly) { Vector3 curPos = Model.transform.position; curPos.z -= Time.deltaTime * 400f; Model.transform.position = curPos; mElapsedTime += Time.deltaTime; if (mElapsedTime > 0.6f) { mState = EState.End; Comet.StopSmoothly(0.4f); Model.gameObject.SetActive(false); Comet_Explode.transform.position = Model.transform.position; Comet_Explode.Active(); } } }
public override void Activate() { Comet_Warmup.Active(); mElapsedTime = 0f; mState = EState.Warmup; gameObject.SetActive(true); }
public override void Activate() { //Set the Gravity Object and collision goal object here before activating the effect. Souls.SetGravityGoal(Target, "soul"); Souls.SetCollisionGoalPos(Target, "soul"); Souls.Active(); }
public void Reset() { //activate on death subemitter. if (Owner.UseSubEmitters && !string.IsNullOrEmpty(Owner.DeathSubEmitter)) { XffectComponent sub = Owner.SpawnCache.GetEffect(Owner.DeathSubEmitter); if (sub == null) { return; } sub.transform.position = CurWorldPos; sub.Active(); } //Position = Vector3.up * -9999; Position = Owner.ClientTransform.position; Velocity = Vector3.zero; ElapsedTime = 0f; CurWorldPos = Owner.transform.position; LastWorldPos = CurWorldPos; IsCollisionEventSended = false; if (Owner.IsRandomStartColor) { //StartColor = Owner.RandomColorParam.GetGradientColor(UnityEngine.Random.Range(0f, 1f)); StartColor = Owner.RandomColorGradient.Evaluate(UnityEngine.Random.Range(0f, 1f)); } //do not use foreach in script! for (int i = 0; i < AffectorList.Count; i++) { Affector aft = AffectorList[i]; aft.Reset(); } Scale = Vector3.one; mIsFade = false; RenderObj.Reset(); if (Owner.UseSubEmitters && SubEmitter != null && XffectComponent.IsActive(SubEmitter.gameObject) && Owner.SubEmitterAutoStop) { SubEmitter.StopEmit(); } }
public XffectComponent ReleaseEffect(string name) { XffectComponent xft = GetEffect(name); if (xft == null) { //Debug.LogWarning("can't find available effect in cache!:" + name); return(null); } xft.Active(); return(xft); }
//release effect by world position. in this case, the client transform's position should be zero. //notice: if the xffect is not auto-deactive, you should remember to manually deactive it. //** automaticaly set client to EffectCache, so you should make sure EffectCache's position is always zero. public XffectComponent ReleaseEffect(string name, Vector3 pos) { XffectComponent xft = GetEffect(name); if (xft == null) { Debug.LogWarning("can't find available effect in cache!:" + name); return(null); } xft.Active(); xft.SetClient(transform); xft.SetEmitPosition(pos); return(xft); }
void Update() { if (mState == EState.Fly) { mElapsedTime += Time.deltaTime; if (mElapsedTime > 1.8f) { mState = EState.End; Ball.DeActive(); Exp.transform.position = Ball.transform.position; Exp.Active(); } } }
public override void Activate() { Vector3 center = (Target.transform.position + transform.position) * 0.5f; Fireball1.Active(); BuildDynamicSplineFor(Fireball1, center + Vector3.up * 80f); Fireball1.SetCollisionGoalPos(Target.transform); Fireball2.Active(); BuildDynamicSplineFor(Fireball2, center + (Vector3.up + Vector3.right) * 80f); Fireball2.SetCollisionGoalPos(Target.transform); Fireball3.Active(); BuildDynamicSplineFor(Fireball3, center + (Vector3.up + Vector3.left) * 80f); Fireball3.SetCollisionGoalPos(Target.transform); }
public void CollisionDetection() { if (!Owner.UseCollisionDetection || IsCollisionEventSended) { return; } bool collided = false; GameObject collideObject = null; if (Owner.CollisionType == COLLITION_TYPE.Sphere && Owner.CollisionGoal != null) { Vector3 diff = CurWorldPos - Owner.CollisionGoal.position; float range = Owner.ColliisionPosRange + Owner.ParticleRadius; if (diff.sqrMagnitude <= range * range /*|| //fixed, don't check get through. * Vector3.Dot(diff, LastCollisionDetectDir) < 0*/) { collided = true; collideObject = Owner.CollisionGoal.gameObject; } LastCollisionDetectDir = diff; } else if (Owner.CollisionType == COLLITION_TYPE.CollisionLayer) { int layer = 1 << Owner.CollisionLayer; RaycastHit hit; Vector3 p1 = GetOriginalPos(); if (Physics.SphereCast(p1, Owner.ParticleRadius, Velocity.normalized, out hit, Owner.ParticleRadius, layer)) { collided = true; collideObject = hit.collider.gameObject; } //if (Physics.CheckSphere(GetOriginalPos(), Owner.ParticleRadius, layer)) //{ //collided = true; //} } else if (Owner.CollisionType == COLLITION_TYPE.Plane) { if (!Owner.CollisionPlane.GetSide(CurWorldPos - Owner.PlaneDir.normalized * Owner.ParticleRadius)) { collided = true; collideObject = Owner.gameObject; } } else { //Debug.LogError("invalid collision target!"); } if (collided) { if (Owner.EventHandleFunctionName != "" && Owner.EventReceiver != null) { //Owner.EventReceiver.SendMessage(Owner.EventHandleFunctionName, Owner.CollisionGoal); Owner.EventReceiver.SendMessage(Owner.EventHandleFunctionName, new CollisionParam(collideObject, GetOriginalPos(), Velocity.normalized)); } IsCollisionEventSended = true; if (Owner.CollisionAutoDestroy) { //distroy. ElapsedTime = Mathf.Infinity; } //activate on collision subemitter. if (Owner.UseSubEmitters && !string.IsNullOrEmpty(Owner.CollisionSubEmitter)) { XffectComponent sub = Owner.SpawnCache.GetEffect(Owner.CollisionSubEmitter); if (sub == null) { return; } sub.transform.position = CurWorldPos; sub.Active(); } } }
protected void AddNodes(int num) { int added = 0; for (int i = 0; i < MaxENodes; i++) { if (added == num) { break; } EffectNode node = AvailableENodes[i]; if (node != null) { AddActiveNode(node); added++; //activate on birth subemitter. if (UseSubEmitters && !string.IsNullOrEmpty(BirthSubEmitter)) { XffectComponent sub = SpawnCache.GetEffect(BirthSubEmitter); if (sub == null) { return; } node.SubEmitter = sub; sub.Active(); } emitter.SetEmitPosition(node); float nodeLife = 0; if (IsNodeLifeLoop) { nodeLife = -1; } else { nodeLife = Random.Range(NodeLifeMin, NodeLifeMax); } Vector3 oriDir = emitter.GetEmitRotation(node); float speed = OriSpeed; if (IsRandomSpeed) { speed = Random.Range(SpeedMin, SpeedMax); } Color c = Color1; if (IsRandomStartColor) { //c = RandomColorParam.GetGradientColor(Random.Range(0f, 1f)); c = RandomColorGradient.Evaluate(Random.Range(0f, 1f)); } float oriScalex = Random.Range(OriScaleXMin, OriScaleXMax); float oriScaley = Random.Range(OriScaleYMin, OriScaleYMax); if (UniformRandomScale) { oriScaley = oriScalex; } node.Init(oriDir.normalized, speed, nodeLife, Random.Range(OriRotationMin, OriRotationMax), oriScalex, oriScaley, c, UVTopLeft, UVDimension); } else { continue; } } }
public void CollisionDetection() { if (!Owner.UseCollisionDetection || IsCollisionEventSended) { return; } bool collided = false; GameObject collideObject = null; if (Owner.CollisionType == COLLITION_TYPE.Sphere && Owner.CollisionGoal != null) { Vector3 diff = CurWorldPos + Velocity.normalized * Owner.CollisionOffset - Owner.CollisionGoal.position; float range = Owner.ColliisionPosRange + Owner.ParticleRadius; if (diff.sqrMagnitude <= range * range /*|| //fixed, don't check get through. * Vector3.Dot(diff, LastCollisionDetectDir) < 0*/) { collided = true; collideObject = Owner.CollisionGoal.gameObject; } LastCollisionDetectDir = diff; } else if (Owner.CollisionType == COLLITION_TYPE.CollisionLayer) { int layer = 1 << Owner.CollisionLayer; RaycastHit hit; Vector3 p1 = GetOriginalPos() + Velocity.normalized * Owner.CollisionOffset; if (Physics.SphereCast(p1, Owner.ParticleRadius, Velocity.normalized, out hit, Owner.ParticleRadius, layer)) { collided = true; collideObject = hit.collider.gameObject; } } else if (Owner.CollisionType == COLLITION_TYPE.Plane) { //Debug.Log("particle pos "+CurWorldPos+" nor "+Owner.PlaneDir.normalized+" "+Owner.ParticleRadius); //Debug.Log("plane "+Owner.CollisionPlane.distance+" "+Owner.CollisionPlane.normal+" pos "); //var realPos = CurWorldPos + Owner.transform.position; //var realPos = CurWorldPos; var realPos = this.Position; var np = realPos - Owner.PlaneDir.normalized * Owner.ParticleRadius; /* * if(realPos.y <= 0) { * Debug.Log("Collide: "+Owner.CollisionPlane.distance+" w "+CurWorldPos+" pos "+Owner.transform.position +" np "+np+" emitPoint "+Owner.EmitPoint); * collided = true; * collideObject = Owner.gameObject; * } */ if (!Owner.CollisionPlane.GetSide(np)) { Debug.Log("Collide: " + Owner.CollisionPlane.distance + " w " + CurWorldPos + " pos " + Owner.transform.position + " np " + np + " emitPoint " + Owner.EmitPoint); //var testP = new Plane(Vector3.up, Owner.transform.position); //var side = testP.GetSide(np); //Debug.Log("TestP: "+testP.distance+" n "+testP.normal+" np "+np+" si "+side); collided = true; collideObject = Owner.gameObject; } } else { Debug.LogError("invalid collision type!"); } if (collided) { if (Owner.EventHandleFunctionName != "" && Owner.EventReceiver != null) { //Owner.EventReceiver.SendMessage(Owner.EventHandleFunctionName, Owner.CollisionGoal); Owner.EventReceiver.SendMessage(Owner.EventHandleFunctionName, new CollisionParam(collideObject, GetOriginalPos(), this)); isCollision = true; } IsCollisionEventSended = true; if (Owner.CollisionAutoDestroy) { //distroy. ElapsedTime = Mathf.Infinity; } //activate on collision subemitter. if (Owner.UseSubEmitters && !string.IsNullOrEmpty(Owner.CollisionSubEmitter)) { XffectComponent sub = Owner.SpawnCache.GetEffect(Owner.CollisionSubEmitter); if (sub == null) { return; } sub.Active(); sub.transform.position = CurWorldPos; } } }
public void Reset() { isCollision = false; isBounce = false; //activate on death subemitter. if (Owner.UseSubEmitters && !string.IsNullOrEmpty(Owner.DeathSubEmitter)) { XffectComponent sub = Owner.SpawnCache.GetEffect(Owner.DeathSubEmitter); if (sub == null) { return; } sub.Active(); sub.transform.position = CurWorldPos; } //Position = Vector3.up * -9999; //if (Owner.SpriteType == (int)STYPE.BILLBOARD_UP) { // Position = Quaternion.Euler (new Vector3 (0, Owner.transform.rotation.eulerAngles.y, 0)) * Owner.EmitPoint + Owner.transform.position; //} else { Position = Owner.EmitPoint + Owner.transform.position; //} Velocity = Vector3.zero; ElapsedTime = 0f; CurWorldPos = Owner.transform.position; LastWorldPos = CurWorldPos; IsCollisionEventSended = false; //foreach (Affector aft in AffectorList) //{ // aft.Reset(); //}V //do not use foreach in your script! for (int i = 0; i < AffectorList.Count; i++) { Affector aft = AffectorList[i]; aft.Reset(); } Scale = Vector3.one; if (Type == 1) { Sprite.SetRotation(OriRotateAngle); Sprite.SetPosition(Position); Sprite.SetColor(Color.clear); Sprite.Update(true, 0f); //TODO:should reset in ScaleAffector. Scale = Vector3.one; } else if (Type == 2) { Vector3 headpos; if (Owner.AlwaysSyncRotation) { headpos = ClientTrans.rotation * (GetRealClientPos() + Owner.EmitPoint); } else { headpos = GetRealClientPos() + Owner.EmitPoint; } Ribbon.SetHeadPosition(headpos /*+ OriDirection.normalized * Owner.TailDistance*/); Ribbon.Reset(); Ribbon.SetColor(Color.clear); Ribbon.UpdateVertices(Vector3.zero); } else if (Type == 3) { Cone.SetRotation(OriRotateAngle); Cone.SetColor(Color.clear); Cone.SetPosition(Position); Scale = Vector3.one; Cone.ResetAngle(); Cone.Update(true, 0f); } else if (Type == 4) { CusMesh.SetColor(Color.clear); CusMesh.SetRotation(OriRotateAngle); CusMesh.Update(true, 0f); } if (Owner.UseSubEmitters && SubEmitter != null && XffectComponent.IsActive(SubEmitter.gameObject)) { SubEmitter.StopEmit(); } }
public override void Activate() { LightEnergy.Active(); Exp.Active(); }