//$----------------------------------------------------------------------------- //@ Starts a Shield Turning On type effect on the EchoLogin Shield Shader //@ //@ Parameters: //@ //# iego - EchoGameObject that will have this EchoFXEvent //# imaxalpha - Maximum alpha of the hit effect //# ifxduration - Duration of this effect. 0.0f = forever //&----------------------------------------------------------------------------- public static EchoFXEvent ShieldOn_echoShader(EchoGameObject iego, float imaxalpha, float ifxduration = 1.0f) { EchoFXEvent efx; efx = PoolGetFreeInactive(poolListID) as EchoFXEvent; if (efx != null) { iego.EchoActive(true); efx.echoFilter = EchoFilter.LINEAR; efx.eventType = EchoET.SHIELD_ON; efx.ego = iego; efx.fxStage = 0; efx.fxTime = 0; efx.fxDuration = ifxduration; efx.fxArg1 = imaxalpha; } return(efx); }
//=========================================================================== public override void ProcessInUpdate() { if (fxStartDelay > 0.0) { fxStartDelay -= Time.deltaTime; if (fxStartDelay < 0.0) { fxEventStart(); fxEventStart = EventStartNull; } else { return; } } fxTime += Time.deltaTime; fxPer = 0.0f; if (forceStop) { fxPer = 1.0f; } if (fxDuration > 0.0f) { fxPer = fxTime / fxDuration; if (forceStop || fxPer > 1.0f) { fxPer = 1.0f; } switch (echoFilter) { case EchoFilter.SINE: fxRatio = Mathf.Sin(fxOffset + (Mathf.PI * 2.0f * fxPer * fxPeriod)) * fxAmplitude; break; case EchoFilter.SQUARED: fxRatio = fxPer * fxPer; break; case EchoFilter.CUBED: fxRatio = fxPer * fxPer * fxPer; break; case EchoFilter.SQRT: fxRatio = Mathf.Sqrt(fxPer); fxRatio = Mathf.Sqrt(fxRatio); fxRatio = Mathf.Sqrt(fxRatio); break; default: fxRatio = fxPer; break; } } if (_fxEventProgressFlag) { fxEventProgress(fxPer, fxStage); } switch (eventType) { case EchoET.BLINK_UVSET: if (fxTime < fxDuration) { if (_ticks % 3 == 0) { if (Random.Range(0, 100) < 50) { ego.UVSet(fxIArg1); } else { ego.UVSet(fxIArg2); } } } else { ego.UVSet(fxIArg2); fxOver = true; } break; case EchoET.CELLANIM_UVSET: ego.UVSet((int)fxFrameCur); ProcessAnimation(); if (fxPer >= 1.0f) { fxOver = true; } break; case EchoET.BLINK_ECHOUV: if (fxTime < fxDuration) { if (_ticks % 3 == 0) { if (Random.Range(0, 100) < 50) { ego.ShaderSet_echoUV(fxUV1, fxUse_MainTex_ST); } else { ego.ShaderSet_echoUV(fxUV2, fxUse_MainTex_ST); } } } else { ego.ShaderSet_echoUV(fxUV2, fxUse_MainTex_ST); fxOver = true; } AddToEgoList(); break; case EchoET.SHAKE_OBJECT: if (fxPer <= 1.0) { fxArg2 = Mathf.Lerp(0.0f, fxArg1, fxRatio); fxTransform.position = new Vector3(fxPosHold.x + Random.Range(-fxArg2, fxArg2), fxPosHold.y + Random.Range(-fxArg2, fxArg2), fxPosHold.z + Random.Range(-fxArg2, fxArg2)); } else { fxTransform.position = fxPosHold; fxOver = true; } break; case EchoET.RANDOM_MIX: if (_ticks % 3 == 0) { fxNum1 = Mathf.Lerp(fxArg1, fxArg2, Random.Range(fxArg1, fxArg2)); ego.ShaderSet_echoMix(fxNum1); } if (fxPer >= 1.0f) { fxOver = true; } AddToEgoList(); break; case EchoET.DISSOLVE: fxNum1 = Mathf.Lerp(fxArg1, fxArg2, fxPer); ego.ShaderSet_echoMix(fxNum1); if (fxPer >= 1.0f) { fxOver = true; } AddToEgoList(); break; case EchoET.SCROLL_ECHOUV: if (fxAnimCurCellDir < 0) { fxUVBase -= fxUVAdd * Time.deltaTime; } if (fxAnimCurCellDir > 0) { fxUVBase += fxUVAdd * Time.deltaTime; } fxUVBase = ego.ShaderSet_echoUV(fxUVBase, fxUse_MainTex_ST); if (fxPer >= 1.0f) { fxOver = true; } AddToEgoList(); break; case EchoET.SCROLL_SECTION_ECHOUV: fxUVBase = Vector4.Lerp(fxUV1, fxUV2, fxPer); fxUVBase = ego.ShaderSet_echoUV(fxUVBase, fxUse_MainTex_ST); if (fxPer >= 1.0f) { fxTime = 0.0f; if (fxAnimReps > 0) { fxAnimReps--; if (fxAnimReps <= 0) { fxOver = true; } } } AddToEgoList(); break; case EchoET.CELLANIM_ECHOUV: if (fxPer >= 1.0) { fxNum1 = ((int)fxAnimCurCell % fxIArg1) * fxArg1; fxNum2 = 1.0f - ((int)fxAnimCurCell / fxIArg1) * fxArg2; fxUVBase.x = fxNum1; fxUVBase.y = fxNum2; fxUVBase.z = fxNum1; fxUVBase.w = fxNum2; ego.ShaderSet_echoUV(fxUVBase, fxUse_MainTex_ST); fxTime = 0.0f; fxAnimCurCell++; if (fxAnimCurCell >= fxAnimCellCount) { fxAnimCurCell = fxAnimCellStart; if (fxAnimReps > 0) { fxAnimReps--; if (fxAnimReps <= 0) { fxOver = true; } } } AddToEgoList(); } break; case EchoET.CELLANIM_BLEND: if (fxPer >= 1.0) { ego.ShaderSet_echoMix(0); fxNum1 = ((int)fxAnimCurCell % fxIArg1) * fxArg1; fxNum2 = 1.0f - ((int)fxAnimCurCell / fxIArg1) * fxArg2; fxUVBase.x = fxNum1; fxUVBase.y = fxNum2; fxTempNum = (int)fxAnimCurCell + 1; if (fxTempNum >= fxAnimCellCount) { fxTempNum = fxAnimCellStart; } fxNum1 = (fxTempNum % fxIArg1) * fxArg1; fxNum2 = 1.0f - (fxTempNum / fxIArg1) * fxArg2; fxUVBase.z = fxNum1; fxUVBase.w = fxNum2; ego.ShaderSet_echoUV(fxUVBase, fxUse_MainTex_ST); fxTime = 0.0f; fxAnimCurCell++; if (fxAnimCurCell >= fxAnimCellCount) { fxAnimCurCell = fxAnimCellStart; if (fxAnimReps > 0) { fxAnimReps--; if (fxAnimReps <= 0) { fxOver = true; } } } } else { ego.ShaderSet_echoMix(fxPer); } AddToEgoList(); break; case EchoET.RANDOM_ECHOUV: fxUVAdd.x = Random.Range(0.0f, 1.0f); fxUVAdd.y = Random.Range(0.0f, 1.0f); fxUVAdd.z = Random.Range(0.0f, 1.0f); fxUVAdd.w = Random.Range(0.0f, 1.0f); ego.ShaderSet_echoUV(fxUVAdd, fxUse_MainTex_ST); if (fxPer >= 1.0f) { fxOver = true; } AddToEgoList(); break; case EchoET.ANIMATE_TILING: if (fxPer >= 1.0) { fxTileBase = new Vector2(1.0f, 1.0f); ego.ShaderSetTiling(fxTileBase); fxOver = true; } else { fxTileBase = Vector2.Lerp(fxTile1, fxTile2, fxRatio); ego.ShaderSetTiling(fxTileBase); } AddToEgoList(); break; case EchoET.SHIELD_HIT: ego.renderer.enabled = true; fxNum1 = Mathf.Lerp(0.15f, 0.25f, Random.Range(0.0f, 1.0f)); fxNum2 = Random.Range(fxArg1, fxArg2); ego.ShaderSet_echoHitMix(fxShieldHitID, fxNum1); ego.ShaderSet_echoAlpha(fxNum2); // turn hit off if (fxPer >= 1.0f) { ego.ShaderSet_echoHitMix(fxShieldHitID, 0.0f); ego.ShaderSet_echoAlpha(0.0f); ego.ShaderSet_echoHitVectorOff(fxShieldHitID); ego.renderer.enabled = false; fxOver = true; } AddToEgoList(); break; case EchoET.SHIELD_ON: ego.renderer.enabled = true; if (fxPer >= 1.0f) { ego.ShaderSet_echoAlpha(0.0f); ego.renderer.enabled = false; fxOver = true; } else { fxNum1 = Mathf.Sin(fxPer * Mathf.PI) * fxArg1; ego.ShaderSet_echoAlpha(fxNum1); } AddToEgoList(); break; case EchoET.SHIELD_OFF: ego.renderer.enabled = true; switch (fxStage) { case 0: case 1: case 2: fxPer = fxTime / (fxDuration * 0.2f); if (fxPer >= 1.0f) { fxTime = 0.0f; fxStage++; } else { ego.ShaderSet_echoAlpha(Mathf.PingPong(fxPer, fxArg1)); } break; case 3: fxPer = fxTime / fxDuration; if (fxPer >= 1.0f) { ego.ShaderSet_echoAlpha(0.0f); ego.renderer.enabled = false; ego.EchoActive(false); fxOver = true; fxStage = -1; } else { ego.ShaderSet_echoAlpha(Mathf.Sin(fxPer * Mathf.PI) * fxArg1); } break; } AddToEgoList(); break; case EchoET.SHIELD_DOWN: ego.renderer.enabled = true; if (fxPer >= 1.0f) { ego.ShaderSet_echoAlpha(0.0f); ego.EchoActive(false); ego.renderer.enabled = false; fxOver = true; fxStage = -1; } else { if (Random.Range(0, 100) < 40 && fxStage == 0) { ego.ShaderSet_echoAlpha(Mathf.Sin(fxPer * Mathf.PI) * fxArg1); } else { if (fxStage == 0) { ego.ShaderSet_echoAlpha(0.0f); } fxStage = (fxStage + 1) % 2; } } AddToEgoList(); break; case EchoET.FUSION: ego.ShaderSet_echoHitMix(0, Mathf.Lerp(fxArg1, fxArg2, fxRatio + Random.Range(0.0f, fxArg3))); if (fxPer >= 1.0f) { fxOver = true; } AddToEgoList(); break; case EchoET.ECHORGBA: ego.ShaderSet_echoRGBA(Vector4.Lerp(fxRGBA1, fxRGBA2, fxRatio)); if (fxPer >= 1.0f) { fxOver = true; } AddToEgoList(); break; case EchoET.ECHOSCALE: ego.ShaderSet_echoScale(Vector4.Lerp(fxScale1, fxScale2, fxRatio)); if (fxPer >= 1.0f) { fxOver = true; } AddToEgoList(); break; case EchoET.ECHOALPHA: ego.ShaderSet_echoAlpha(Mathf.Lerp(fxArg1, fxArg2, fxRatio)); if (fxPer >= 1.0f) { fxOver = true; } AddToEgoList(); break; case EchoET.CUSTOM: fxOver = fxEventCustom(ego, fxPer, fxRatio, fxTime); if (fxOver || forceStop) { fxEventCustom = EventCustomNull; } if (ego != null) { AddToEgoList(); } break; } if (forceStop || fxOver) { PoolMoveActive2Inactive(this); fxEventDone(forceStop); fxEventDone = EventDoneNull; forceStop = false; fxOver = false; } }