Пример #1
0
    private void Update()
    {
        if (!failed)
        {
            gameOver.sideQuestComplete = true;
            foreach (GameObject item in GameObject.FindGameObjectsWithTag("Blade"))
            {
                foreach (string tag in tags)
                {
                    if (item.GetComponent <BladeWeed>().isDead)
                    {
                        Debug.LogWarning("Found active blades");
                        for (int i = 0; i < item.transform.childCount; i++)
                        {
                            LeafBladeSystem blade     = item.transform.Find("Blades").GetChild(i).GetComponent <LeafBladeSystem>();
                            Collider2D[]    hitPlants = Physics2D.OverlapCircleAll(blade.transform.position, blade.leafRange, blade.plantLayers);

                            foreach (Collider2D plant in hitPlants)
                            {
                                if (plant.CompareTag(tag))
                                {
                                    Debug.LogWarning("Looking for blade");
                                    switch (tag)
                                    {
                                    case "Tulipa":
                                        if (!plant.GetComponent <RedTulipa>().isDead)
                                        {
                                            failed = true;
                                            gameOver.sideQuestComplete = false;
                                            Debug.LogWarning("Failed Quest");
                                        }
                                        break;

                                    case "Green":
                                        if (!plant.GetComponent <GreenWeed>().isDead)
                                        {
                                            failed = true;
                                            gameOver.sideQuestComplete = false;
                                            Debug.LogWarning("Failed Quest");
                                        }
                                        break;

                                    case "Gold":
                                        if (!plant.GetComponent <GoldenWeed>().isDead)
                                        {
                                            failed = true;
                                            gameOver.sideQuestComplete = false;
                                            Debug.LogWarning("Failed Quest");
                                        }
                                        break;

                                    case "Evil":
                                        if (!plant.GetComponent <EvilWeed>().isDead)
                                        {
                                            failed = true;
                                            gameOver.sideQuestComplete = false;
                                            Debug.LogWarning("Failed Quest");
                                        }
                                        break;

                                    case "Blade":
                                        if (!plant.GetComponent <BladeWeed>().isDead)
                                        {
                                            failed = true;
                                            gameOver.sideQuestComplete = false;
                                            Debug.LogWarning("Failed Quest");
                                        }
                                        break;

                                    case "Bush":
                                        if (!plant.GetComponent <Bush>().isDead)
                                        {
                                            failed = true;
                                            gameOver.sideQuestComplete = false;
                                            Debug.LogWarning("Failed Quest");
                                        }
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                            if (failed)
                            {
                                break;
                            }
                        }
                        if (failed)
                        {
                            break;
                        }
                    }
                }
            }
        }
    }
Пример #2
0
    private void Update()
    {
        if (!completed)
        {
            RemoveDeadPlants();

            foreach (GameObject item in GameObject.FindGameObjectsWithTag("Blade"))
            {
                foreach (string tag in tags)
                {
                    if (item.GetComponent <BladeWeed>().isDead)
                    {
                        Debug.LogWarning("Found active blades");
                        for (int i = 0; i < item.transform.childCount; i++)
                        {
                            LeafBladeSystem blade     = item.transform.Find("Blades").GetChild(i).GetComponent <LeafBladeSystem>();
                            Collider2D[]    hitPlants = Physics2D.OverlapCircleAll(blade.transform.position, blade.leafRange, blade.plantLayers);

                            foreach (Collider2D plant in hitPlants)
                            {
                                bool goAhead = true;
                                foreach (GameObject p in alreadyHitPlants)
                                {
                                    if (plant.gameObject == p)
                                    {
                                        goAhead = false;
                                        Debug.LogWarning("Can't go ahead");
                                    }
                                }

                                if (plant.CompareTag(tag) && goAhead)
                                {
                                    Debug.LogWarning("Looking for blade");
                                    switch (tag)
                                    {
                                    case "Tulipa":
                                        if (!plant.GetComponent <RedTulipa>().isDead)
                                        {
                                            comboCounter++;
                                            alreadyHitPlants.Add(plant.gameObject);
                                            Debug.LogWarning("Made Combo");
                                        }
                                        break;

                                    case "Green":
                                        if (!plant.GetComponent <GreenWeed>().isDead)
                                        {
                                            comboCounter++;
                                            alreadyHitPlants.Add(plant.gameObject);
                                            Debug.LogWarning("Made Combo");
                                        }
                                        break;

                                    case "Gold":
                                        if (!plant.GetComponent <GoldenWeed>().isDead)
                                        {
                                            comboCounter++;
                                            alreadyHitPlants.Add(plant.gameObject);
                                            Debug.LogWarning("Made Combo");
                                        }
                                        break;

                                    case "Evil":
                                        if (!plant.GetComponent <EvilWeed>().isDead)
                                        {
                                            comboCounter++;
                                            alreadyHitPlants.Add(plant.gameObject);
                                            Debug.LogWarning("Made Combo");
                                        }
                                        break;

                                    case "Blade":
                                        if (!plant.GetComponent <BladeWeed>().isDead)
                                        {
                                            comboCounter++;
                                            alreadyHitPlants.Add(plant.gameObject);
                                            Debug.LogWarning("Made Combo");
                                        }
                                        break;

                                    case "Bush":
                                        if (!plant.GetComponent <Bush>().isDead)
                                        {
                                            comboCounter++;
                                            alreadyHitPlants.Add(plant.gameObject);
                                            Debug.LogWarning("Made Combo");
                                        }
                                        break;

                                    default:
                                        break;
                                    }

                                    if (comboCounter >= comboQuantity)
                                    {
                                        gameOver.sideQuestComplete = true;
                                        completed = true;
                                        break;
                                    }
                                }
                            }

                            if (completed)
                            {
                                break;
                            }
                        }

                        if (completed)
                        {
                            break;
                        }
                    }
                }
            }
        }
    }