Ejemplo n.º 1
0
 void MoveAllParts(SensFx sens)
 {
     if (this.allModelParts != null)
     {
         if (sens == SensFx.Explosion)
         {
             for (int i = 0; i < allModelParts.Length; i++)
             {
                 StartCoroutine(BumpOutline(this.allMatParts[i]));
                 Vector3 posToReach = this.allDirExplosion[i] * this.GlobalAmplificator;
                 posToReach.z *= Random.Range(1, this.ZExplosionAmplificator);
                 posToReach.y *= Random.Range(1, this.YExplosionAmplificator);
                 posToReach.x *= Random.Range(1, this.XExplosionAmplificator);
                 Vector3 randomRot = Random.rotation.eulerAngles.normalized;
                 StartCoroutine(MoveFxCoroutine(posToReach, randomRot, this.allModelParts[i], this.allMatParts[i], sens, this.delay));
             }
         }
     }
 }
Ejemplo n.º 2
0
    IEnumerator MoveFxCoroutine(Vector3 posTarget, Vector3 rotTarget, Transform targetToMove, Material matTarget, SensFx sens, float delay)
    {
        if (delay != 0.0f)
        {
            yield return(new WaitForSeconds(delay));
        }

        float lerp      = 0;
        float newAmount = matTarget.GetFloat(AmountProperty);

        try
        {
            while (Vector3.Distance(posTarget, targetToMove.localPosition) > 0.05f)
            {
                lerp = this.ProjectilleBehavior.Evaluate(Time.deltaTime * this.speedAnimation);
                //Partie physics
                targetToMove.localPosition = Vector3.Lerp(targetToMove.localPosition, posTarget, lerp);
                if (sens == SensFx.Explosion)
                {
                    targetToMove.Rotate(rotTarget * this.coeffRotate * lerp);
                    //Partie Dissolve
                    matTarget.SetVector(DirectionProperty, posTarget.normalized);
                    newAmount = Mathf.Lerp(newAmount, this.valMax, lerp);
                    matTarget.SetFloat(AmountProperty, newAmount);
                }
                else
                {
                    targetToMove.Rotate(rotTarget * lerp);
                    /////
                    //Utiliser cette methode si c sur le modèle avec peu de pièces !!
                    //targetToMove.localEulerAngles = Vector3.Lerp(targetToMove.localEulerAngles, rotTarget, lerp);
                    ////
                    //Partie Dissolve
                    matTarget.SetVector(DirectionProperty, posTarget.normalized);
                    newAmount = Mathf.Lerp(newAmount, this.valMin, lerp);
                    matTarget.SetFloat(AmountProperty, newAmount);
                }
                yield return(new WaitForSeconds(0));
            }
        }
        finally
        {
            if (sens == SensFx.Integration)
            {
                targetToMove.localEulerAngles = rotTarget;
                targetToMove.localPosition    = posTarget;
                matTarget.SetFloat(AmountProperty, valMin);
                StartCoroutine(BumpOutline(matTarget));
            }
        }
        yield break;
    }