public void UpdateResolvedSources(CorruptionSource cs)
    {
        resolvedSources++;

        GameObject ps = assteroidDestruction;

        foreach (Transform child in cs.gameObject.transform)
        {
            if (child.tag == "ParticleSpawner")
            {
                GameObject psinstance = Instantiate(ps, child.position, child.rotation);

                StartCoroutine("DestoryAsteroidParticles", psinstance);
                Destroy(cs.gameObject);
                FindObjectOfType <AudioManager>().Play("Crystal");
            }
        }


        if (resolvedSources == sources)
        {
            // GAME WON
            Debug.Log("GAME WON");

            StartCoroutine("Won");
        }
    }
Esempio n. 2
0
 public CorruptionSourceData(CorruptionSource corruptionSource)
 {
     id                = corruptionSource.id;
     isCleansed        = corruptionSource.isCleansed;
     bufferDestroyAnim = corruptionSource.bufferDestroyAnim;
     foreach (CorruptionCheckpoint cp in corruptionSource.checkpoints)
     {
         checkpoints.Add(cp.cleansed);
     }
 }
Esempio n. 3
0
    void Start()
    {
        adjacentCorruption = new List <Corruption>();
        GameObject[] sources = GameObject.FindGameObjectsWithTag("AssT");

        float dist  = int.MaxValue;
        int   index = 0;

        for (int i = 0; i < sources.Length; i++)
        {
            float distance = Vector3.Distance(sources[i].transform.position, transform.position);
            if (distance < dist)
            {
                index = i;
                dist  = distance;
            }
        }

        corruptionSource = sources[index].GetComponent <CorruptionSource>();

        corruptionSource.allcorupted.Add(this);


        //find adjacent
        GameObject[] corruptions = GameObject.FindGameObjectsWithTag("Tree");

        for (int i = 0; i < corruptions.Length; i++)
        {
            float distance = Vector3.Distance(transform.position, corruptions[i].transform.position);

            if (distance <= radius)
            {
                Corruption c = corruptions[i].GetComponent <Corruption>();
                adjacentCorruption.Add(c);
            }
        }

        // get corrupt and healed versions

        foreach (Transform child in transform)
        {
            if (child.tag == "CTree")
            {
                corrupSide = child.gameObject;
            }
            if (child.tag == "GTree")
            {
                healedSide = child.gameObject;
            }
        }

        //set as healed
        SetCorrupted();
        corruptionSource.AddTree();
    }
    public void StopCleansing()
    {
        if (threeCheckpointBox != null)
        {
            threeCheckpointBox.GetComponent <CorruptionBar>().onWaitForCheckpointAnimCallback -= CheckpointEvent;
            Destroy(threeCheckpointBox.gameObject);
        }
        if (fiveCheckpointBox != null)
        {
            fiveCheckpointBox.GetComponent <CorruptionBar>().onWaitForCheckpointAnimCallback -= CheckpointEvent;
            Destroy(fiveCheckpointBox.gameObject);
        }

        checkpoints       = null;
        currentSource     = null;
        recentlyClearedNR = 0;
    }
Esempio n. 5
0
    //public CorruptionCheckpoint script { get { return (target as CorruptionCheckpoint); } }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector(); // for other non-HideInInspector fields

        CorruptionSource script = target as CorruptionSource;

        // draw checkbox for the bool
        for (int i = 0; i < script.checkpoints.Count; i++)
        {
            // script.checkpoints[i].cleansed = EditorGUILayout.Toggle(true);
            if (/*script.checkpoints[i].option == CheckpointOptions.Health || script.checkpoints[i].option == CheckpointOptions.Gaia*/ script.checkpoints[i].cleansed) // if bool is true, show other fields
            {
                //script.rewardAmount = EditorGUILayout.ObjectField("I Field", script.rewardAmount, typeof(int), true) as int;
                //script.rewardAmount = EditorGUILayout.ObjectField("Template", script.rewardAmount, typeof(int), true) as int;
                script.checkpoints[i].rewardAmount = (int)EditorGUILayout.IntField(script.checkpoints[i].rewardAmount);
            }
        }
    }
    public void StartCleansing()
    {
        if (inFrontOfPlayerTrigger.GetCollidingTileableStatus())
        {
            GameObject colliding = inFrontOfPlayerTrigger.GetCollidingGameObject();

            if (colliding.GetComponent <CorruptionSource>() != null)
            {
                currentSource = colliding.GetComponent <CorruptionSource>();

                if (currentSource.GetNumberOfCheckpoints() == 3)
                {
                    checkpoints = currentSource.GetCheckpoints();

                    threeCheckpointBox = Instantiate(threeCheckpointBoxPrefab, overWorldCanvas.transform);

                    threeCheckpointBox.GetComponent <CorruptionBar>().onWaitForCheckpointAnimCallback += CheckpointEvent;
                    recentBackground = currentSource.GetBattleBackground();
                    threeCheckpointBox.GetComponent <CorruptionBar>().SetNrOfCheckpoints(checkpoints.Count);

                    for (int i = 0; i < checkpoints.Count; i++)
                    {
                        if (checkpoints[i].cleansed)
                        {
                            bool isLast = false;

                            if (i == checkpoints.Count - 1)
                            {
                                isLast = true;
                            }
                            threeCheckpointBox.GetComponent <CorruptionBar>().SetCheckpoints(i, GetOptionString(checkpoints[i].option), isLast);
                        }
                    }
                }

                else if (currentSource.GetNumberOfCheckpoints() == 5)
                {
                    checkpoints = currentSource.GetCheckpoints();

                    fiveCheckpointBox = Instantiate(fiveCheckpointBoxPrefab, overWorldCanvas.transform);

                    fiveCheckpointBox.GetComponent <CorruptionBar>().onWaitForCheckpointAnimCallback += CheckpointEvent;
                    recentBackground = currentSource.GetBattleBackground();
                    fiveCheckpointBox.GetComponent <CorruptionBar>().SetNrOfCheckpoints(checkpoints.Count);

                    for (int i = 0; i < checkpoints.Count; i++)
                    {
                        if (checkpoints[i].cleansed)
                        {
                            bool isLast = false;

                            if (i == checkpoints.Count - 1)
                            {
                                isLast = true;
                            }
                            fiveCheckpointBox.GetComponent <CorruptionBar>().SetCheckpoints(i, GetOptionString(checkpoints[i].option), isLast);
                        }
                    }
                }
            }
            else if (colliding.GetComponent <TileTreasure>() != null)
            {
                colliding.GetComponent <IInteractable>().Interact();
                StartCoroutine(WaitForFlipAnimGaia(colliding));
            }
            else if (colliding.GetComponent <MonsterTile>() != null)
            {
                StartCoroutine(WaitForFlipAnimMonster(colliding));
            }
        }
    }