Example #1
0
    public bool IsFillingPercentageCorrect(ElementsProperties elem)
    {
        bool result;

        switch (FillingPercentages.Count)
        {
        case 0:
            result = true;
            break;

        case 1:
            switch (FillingVerificationType)
            {
            case ">": result = elem.FillingPercentage > FillingPercentages[0]; break;

            case "<": result = elem.FillingPercentage < FillingPercentages[0]; break;

            case "==": result = elem.FillingPercentage == FillingPercentages[0]; break;

            case "=": result = elem.FillingPercentage == FillingPercentages[0]; break;

            case ">=": result = elem.FillingPercentage >= FillingPercentages[0]; break;

            case "<=": result = elem.FillingPercentage <= FillingPercentages[0]; break;

            case "!=": result = elem.FillingPercentage != FillingPercentages[0]; break;

            default:
                result = false;
                Debug.LogWarning("Error, Filling condition type is invalid.");
                break;
            }
            ; break;

        case 2:
            switch (FillingVerificationType)
            {
            case "==": result = elem.FillingPercentage >= FillingPercentages[0] && elem.FillingPercentage <= FillingPercentages[1]; break;

            case "=": result = elem.FillingPercentage >= FillingPercentages[0] && elem.FillingPercentage <= FillingPercentages[1]; break;

            case "!=": result = !(elem.FillingPercentage >= FillingPercentages[0] && elem.FillingPercentage <= FillingPercentages[1]); break;

            case "!": result = !(elem.FillingPercentage >= FillingPercentages[0] && elem.FillingPercentage <= FillingPercentages[1]); break;

            default:
                result = false;
                Debug.LogWarning("Error, Filling condition type is invalid.");
                break;
            }
            ; break;

        default:
            result = false;
            Debug.LogWarning("Error, too many Percentages in condition");
            break;
        }

        return(result);
    }
    public void Explode()
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, radius);

        foreach (Collider nearbyObject in colliders)
        {
            Rigidbody rb = nearbyObject.GetComponent <Rigidbody>();

            if (rb != null)
            {
                if (rb.gameObject.transform.GetComponent <ElementsProperties>() != null)
                {
                    elem = rb.gameObject.transform.GetComponent <ElementsProperties>();
                    GameObject.Find("GameManager").GetComponent <FireConditions>().OnElementDetected(elem);
                }
            }
        }

        GameObject ptcStarInstance;

        ptcStarInstance = Instantiate(ptcStarPrefab, transform.parent.position, Quaternion.identity);
        Destroy(ptcStarInstance, 8f);

        Destroy(transform.parent.gameObject);
    }
Example #3
0
    private void OnElementMatchConditions(ElementsProperties elem)
    {
        SpawnFluid(elem);
        gameObject.GetComponent <CameraShake>().StartShakeExplosion();
        smash.Play();

        gameManagement.AddScore();
        combo++;

        GameObject ptcScore100Instance;

        ptcScore100Instance = Instantiate(ptcScore100Prefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
        Destroy(ptcScore100Instance, 5f);

        if (elem.gameObject.transform.localScale.x > 1.1f)
        {
            print("BONUS");
            gameManagement.AddScore();
            combo++;

            GameObject ptcScore100Instance2;
            ptcScore100Instance2 = Instantiate(ptcScore100Prefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
            Destroy(ptcScore100Instance2, 5f);
        }

        if (combo >= 4)
        {
            gameManagement.StartHighFeedbackScore();
            gameManagement.Pactole();
            combo = 0;
            good4.Play();

            GameObject ptcScore400Instance;
            ptcScore400Instance = Instantiate(ptcScore400Prefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
            Destroy(ptcScore400Instance, 5f);
        }
        else
        {
            gameManagement.StartLowFeedbackScore();
            if (combo == 3)
            {
                good3.Play();
            }
            else if (combo == 2)
            {
                good2.Play();
            }
            else if (combo == 1)
            {
                good1.Play();
            }
        }

        Destroy(elem.gameObject);
        gameManagement.OnElementDestroyed();
    }
Example #4
0
    public bool IsMatchingConditions(ElementsProperties elem)
    {
        bool result = false;

        if (conditions.Count > 0)
        {
            foreach (Condition c in conditions)
            {
                result |= c.IsVerifyingConditions(elem);
            }
        }
        else
        {
            result = true;
        }

        return(result);
    }
Example #5
0
    public void OnElementDetected(ElementsProperties elem)
    {
        if (IsMatchingConditions(elem))
        {
            Debug.Log("Conditions match.");
            OnElementMatchConditions(elem);
        }
        else
        {
            GameObject ptcEvaporationInstance;
            ptcEvaporationInstance = Instantiate(ptcEvaporationPrefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
            Destroy(ptcEvaporationInstance, 10f);

            Destroy(elem.gameObject);

            combo = 0;
        }
    }
Example #6
0
 public bool IsColorCorrect(ElementsProperties elem)
 {
     return(Colors.Contains(elem.Color) || Colors.Count == 0);
 }
Example #7
0
 public bool IsPlaceCorrect(ElementsProperties elem)
 {
     return(Places.Contains(elem.Place) || Places.Count == 0);
 }
Example #8
0
 public bool IsShapeCorrect(ElementsProperties elem)
 {
     return(Shapes.Contains(elem.Shape) || Shapes.Count == 0); //return true if the shapes contains the good string or if shapes is empty
 }
Example #9
0
 public bool IsVerifyingConditions(ElementsProperties elem)
 {
     return(IsShapeCorrect(elem) && IsColorCorrect(elem) && IsPlaceCorrect(elem) && IsFillingPercentageCorrect(elem));
 }
Example #10
0
    /// <summary>
    /// Permet de faire spawn un fluide coloré à l'explosion de l'élément
    /// </summary>
    /// <param name="elem">Le script de l'élément</param>
    private void SpawnFluid(ElementsProperties elem)
    {
        if (elem.Color == "red")
        {
            GameObject ptcExplosionRedInstance;
            ptcExplosionRedInstance = Instantiate(ptcExplosionRedPrefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
            Destroy(ptcExplosionRedInstance, 10f);

            GameObject ptcViscosityRedInstance;
            ptcViscosityRedInstance = Instantiate(ptcViscosityRedPrefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
            Destroy(ptcViscosityRedInstance, 10f);

            if (elem.FillingPercentage <= 50)
            {
                GameObject ptcRedLowInstance;
                ptcRedLowInstance = Instantiate(ptcRedLowPrefab, elem.gameObject.transform.position, Quaternion.identity);
                Destroy(ptcRedLowInstance, 10f);
            }
            else
            {
                GameObject ptcRedHighInstance;
                ptcRedHighInstance = Instantiate(ptcRedHighPrefab, elem.gameObject.transform.position, Quaternion.identity);
                Destroy(ptcRedHighInstance, 10f);
            }
        }
        else if (elem.Color == "blue")
        {
            GameObject ptcExplosionBlueInstance;
            ptcExplosionBlueInstance = Instantiate(ptcExplosionBluePrefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
            Destroy(ptcExplosionBlueInstance, 10f);

            GameObject ptcViscosityBlueInstance;
            ptcViscosityBlueInstance = Instantiate(ptcViscosityBluePrefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
            Destroy(ptcViscosityBlueInstance, 10f);

            if (elem.FillingPercentage <= 50)
            {
                GameObject ptcBlueLowInstance;
                ptcBlueLowInstance = Instantiate(ptcBlueLowPrefab, elem.gameObject.transform.position, Quaternion.identity);
                Destroy(ptcBlueLowInstance, 10f);
            }
            else
            {
                GameObject ptcBlueHighInstance;
                ptcBlueHighInstance = Instantiate(ptcBlueHighPrefab, elem.gameObject.transform.position, Quaternion.identity);
                Destroy(ptcBlueHighInstance, 10f);
            }
        }
        else if (elem.Color == "green")
        {
            GameObject ptcExplosionGreenInstance;
            ptcExplosionGreenInstance = Instantiate(ptcExplosionGreenPrefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
            Destroy(ptcExplosionGreenInstance, 10f);

            GameObject ptcViscosityGreenInstance;
            ptcViscosityGreenInstance = Instantiate(ptcViscosityGreenPrefab, elem.gameObject.transform.position, Quaternion.Euler(elem.gameObject.transform.up));
            Destroy(ptcViscosityGreenInstance, 10f);

            if (elem.FillingPercentage <= 50)
            {
                GameObject ptcGreenLowInstance;
                ptcGreenLowInstance = Instantiate(ptcGreenLowPrefab, elem.gameObject.transform.position, Quaternion.identity);
                Destroy(ptcGreenLowInstance, 10f);
            }
            else
            {
                GameObject ptcGreenHighInstance;
                ptcGreenHighInstance = Instantiate(ptcGreenHighPrefab, elem.gameObject.transform.position, Quaternion.identity);
                Destroy(ptcGreenHighInstance, 10f);
            }
        }
    }