private void Awake()
 {
     if (instance != null)
     {
         Debug.LogWarning("CFX_SpawnSystem: There should only be one instance of CFX_SpawnSystem per Scene!");
     }
     instance = this;
 }
Beispiel #2
0
    void Awake()
    {
        if (instance != null)
        {
            Debug.LogWarning("CFX_SpawnSystem: There should only be one instance of CFX_SpawnSystem per Scene!");
        }

        instance = this;
    }
Beispiel #3
0
    /// <summary>
    /// Spawns an explosion at the target location - used within ResolveCombat()
    /// </summary>
    /// <param name="target"> position information held within explosionQueue[] </param>
    private void ExplodeAt(Vector3 target)
    {
        GameObject explode = CFX_SpawnSystem.GetNextObject(explosionPrefab, false);                 //WarFX by JMO
        Vector3    exPos   = target;

        exPos.z = 1.1f;
        explode.transform.position = exPos;
        explode.SetActive(true);
    }
    //--------------------------------

    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogWarning("CFX_SpawnSystem: There should only be one instance of CFX_SpawnSystem per Scene!\n", this.gameObject);
        }

        instance = this;
    }
 private void Start()
 {
     this.allObjectsLoaded = false;
     for (int i = 0; i < this.objectsToPreload.Length; i++)
     {
         CFX_SpawnSystem.PreloadObject(this.objectsToPreload[i], this.objectsToPreloadTimes[i]);
     }
     this.allObjectsLoaded = true;
 }
Beispiel #6
0
    public void Set5Moves(int addsteps)
    {
        var explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.RingExplosion()) as GameObject);

        explosion.transform.position = movesText.gameObject.transform.position;

        moves += addsteps;

        movesText.text = moves.ToString();
    }
Beispiel #7
0
 void NomNomNom()
 {
     myPac.ChangeDonkey();
     collider.enabled = false;
     body.enabled     = false;
     deadTimer        = 10;
     dead             = true;
     CFX_SpawnSystem.GetNextObject(killParticle).transform.position = transform.position;
     AudioPlayer.instance.Explosion();
     CameraShake.Shake(0.1f, 1f);
     //Play SFX of nom
 }
Beispiel #8
0
 public void Cast(int type)
 {
     // a square was formed
     if (Game.isSuper)
     {
         GameObject effect = CFX_SpawnSystem.GetNextObject(effects[type].super);
     }
     else     // normal spell
     {
         GameObject effect = CFX_SpawnSystem.GetNextObject(effects[type].normal);
     }
 }
 void Update()
 {
     if (Input.anyKeyDown && grounded && Time.timeScale > 0)
     {
         pushingTheFlap = true;
         CFX_SpawnSystem.GetNextObject(impact).transform.position = transform.position;
         if (isPacman)
         {
             AudioPlayer.instance.Jump();
         }
     }
 }
Beispiel #10
0
    // Use this for initialization
    void Start()
    {
        //	EnemyObj = GameObject.FindGameObjectWithTag ("Enemy");
        PlayerObj = GameObject.FindGameObjectWithTag("Player");
        EnemyObj  = this.gameObject;


        // Soul Anim
        Instantiate(myPrefab);
        CFX_SpawnSystem.GetNextObject(myPrefab);
        PotionObj = this.gameObject;
    }
Beispiel #11
0
    void Awake()
    {
        charStates.Add(new LandState());
        charStates.Add(new AquaticState());

        stateIndex = 0;
        currentState = charStates[stateIndex];
        sprite.spriteName = "grobo1";

        spawnSystem = GameObject.FindObjectOfType<CFX_SpawnSystem>();
        OnValidate();
    }
Beispiel #12
0
    private void MakeNewSwimmer()
    {
        print("newWholeName " + newWholeName);
        newWhole = wholeObjs[newWholeName];
        GameObject expl = CFX_SpawnSystem.GetNextObject(mergeEffect);

        expl.transform.position = new Vector3(0f, randY, 0f);
        dt.MakeDriftingText("200", new Vector3(0f, randY, 0f), 2f);
        if (newWhole != null)
        {
            Instantiate(newWhole, new Vector3(0f, randY, 0f), Quaternion.identity);
        }
    }
Beispiel #13
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject explosionAnimation = CFX_SpawnSystem.GetNextObject(this.explosionAnimation);

        Destroy(gameObject);
        explosionAnimation.transform.position = transform.position;

        Health health = collision.gameObject.GetComponent <Health>();

        if (health != null)
        {
            health.RemoveHealth(damage);
        }
    }
Beispiel #14
0
    public void DecreaseMoves(bool effect = false)
    {
        if (effect == true)
        {
            var explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.RingExplosion()) as GameObject);
            explosion.transform.position = movesText.gameObject.transform.position;
        }

        if (moves > 0)
        {
            moves--;

            movesText.text = moves.ToString();
        }
    }
Beispiel #15
0
    public static IEnumerator FxHereAndFire(Vector3 here, GameObject prefab, float delay = 0)
    {
        if (prefab == null || here == Vector3.zero)
        {
            yield break;
        }

        if (delay > 0)
        {
            yield return(new WaitForSeconds(delay));
        }

        var fx = CFX_SpawnSystem.GetNextObject(prefab, false);

        fx.transform.position = here;
        fx.gameObject.SetActive(true);
    }
Beispiel #16
0
    /*
     * Deal damage to the hit object based on the current attack.
     */
    virtual protected void OnWeaponHit(RaycastHit hit)
    {
        GameObject hitGameObject = hit.transform.gameObject;
        GameObject fx            = CFX_SpawnSystem.GetNextObject(wallHitFX);

        if (hitGameObject.CompareTag(Tags.ENEMY))
        {
            fx = CFX_SpawnSystem.GetNextObject(enemyHitFX);
        }
        fx.transform.position = hit.point;
        fx.particleSystem.Simulate(0.05f);
        fx.particleSystem.Play();

        // Assign the hit location to the damage
        damageOut.HitLocation = hit;
        hitGameObject.SendMessage("ApplyDamage", damageOut, SendMessageOptions.DontRequireReceiver);
        weaponUser.SendMessage("NotifyAttackHit", SendMessageOptions.DontRequireReceiver);
    }
Beispiel #17
0
    public override void Pickup()
    {
        AudioPlayer.instance.PickUp();
        if (Time.timeScale == 0f)
        {
            return;
        }

        Pellet.pelletsAmount--;
        if (Pellet.pelletsAmount <= 0)
        {
            GameObject.Find("Illuminati").SendMessage("LetMayhemInsueOnceMore");
        }

        CFX_SpawnSystem.GetNextObject(particle, true).transform.position = transform.position;

        Destroy(gameObject);
    }
Beispiel #18
0
    // see how many blocks are left after the last collision
    void CountRemainingBlocks()
    {
        int numBlocks = GameData.shooter.GetComponent <Shooter>().GetRemainingBlockCount();

        // show how many blocks are remaining
        GameData.remainingBlocks = numBlocks - (GameData.numCols * GameData.numRows / 2);         //numBlocks;
        if (GameData.remainingBlocks < 0)
        {
            GameData.remainingBlocks = 0;
        }
        blocksLeftText.text = GameData.remainingBlocks.ToString();

        if (!GameData.toldUserHalfway && GameData.remainingBlocks == 0)
        {
            GameData.toldUserHalfway = true;
            SoundManager.PlaySFX("Halfway");
            // show particle effect on numblocks field
            Vector3    buttonPos = GameObject.Find("Canvas/BlankWindow/NumBlocks").GetComponent <RectTransform>().TransformPoint(Camera.main.transform.position);
            GameObject halfway   = CFX_SpawnSystem.GetNextObject(halfwayPrefab);
            halfway.transform.position = buttonPos;

            GameData.skipLevelBtn.SetActive(true);
        }

        if (numBlocks == 0)
        {
            // bonus for getting all blocks in this level
            Vector3 bonusPos    = new Vector3(-8.3f, -4.1f, 0);
            int     finishBonus = 5000 * GameData.dungeonLevel;
            dt.MakeDriftingText(finishBonus.ToString(), bonusPos, 2f);
            GameData.score += finishBonus;
            // update the score on the screen
            if (scoreText != null)
            {
                scoreText.text = GameData.score.ToString("N0");
            }

            GameData.lastGameState = GameData.gameState;
            GameData.gameState     = "won";
            print("Sending to GoToWonLevel");
            GameData.skipLevelBtn.SetActive(false);
            Invoke("GoToWonLevel", 0f);
        }
    }
Beispiel #19
0
        public override IEnumerator Activate(GameObject go)
        {
            if (!IsInPreviewMode && go.tag.Contains("Wolf"))
            {
                GameObject boom = CFX_SpawnSystem.GetNextObject(ExplosionEffect);
                boom.transform.position = gameObject.transform.position;

                foreach (var superTarget in Physics
                         .OverlapSphere(transform.position, GameVariables.Trap.LandMine.radius[Level - 1])
                         .Where(T => T.gameObject.tag.Contains("Wolf")))
                {
                    WolfHealth wolf = (WolfHealth)superTarget.GetComponent <WolfHealth>();
                    wolf.takeDamage(Pows[Level - 1]);
                }
                Durability--;
                if (Durability == 0)
                {
                    Destroy(gameObject);
                }
            }
            yield break;
        }
Beispiel #20
0
    /*
     * Deal damage to the hit object based on the current attack.
     */
    override protected void OnWeaponHit(RaycastHit hit)
    {
        Damage actualDamage = new Damage(damageOut);

        actualDamage.Amount = Mathf.Ceil(actualDamage.Amount * weaponUser.ChargePercentage);

        GameObject hitGameObject = hit.transform.gameObject;
        GameObject fx            = CFX_SpawnSystem.GetNextObject(wallHitFX);

        if (hitGameObject.CompareTag(Tags.ENEMY))
        {
            fx = CFX_SpawnSystem.GetNextObject(enemyHitFX);
        }
        fx.transform.position = hit.point;
        fx.particleSystem.Simulate(0.05f);
        fx.particleSystem.Play();

        // Assign the hit location to the damage
        actualDamage.HitLocation = hit;
        hitGameObject.SendMessage("ApplyDamage", actualDamage, SendMessageOptions.DontRequireReceiver);
        weaponUser.SendMessage("NotifyAttackHit", SendMessageOptions.DontRequireReceiver);
    }
    // will eventually need spell sounds?
    // will need combo or not effects.
    public void PlayerTakesDamage(PlayerUIEffectsController player, string fxName = null)
    {
        RectTransform lifeRect = player.LifeBar.btmBar.gameObject.GetComponent <RectTransform>();
        Vector3       center   = lifeRect.rect.center;


        Vector3    worldPos = lifeRect.TransformPoint(new Vector3(lifeRect.rect.xMax, center.y, 0));
        GameObject fx;


        Func <GameObject> GetRadomFX = () =>
        {
            int rnd = UnityEngine.Random.Range(0, effects.Count);
            //Debug.Log(""+rnd);
            return(CFX_SpawnSystem.GetNextObject(effects[rnd], false));
        };


        if (fxName == null)
        {
            fx = GetRadomFX();
        }
        else
        {
            if (FX_Placement.fx_lookup.ContainsKey(fxName))
            {
                fx = CFX_SpawnSystem.GetNextObject(FX_Placement.fx_lookup[fxName], false);
            }
            else
            {
                fx = GetRadomFX();
            }
        }

        fx.transform.position = new Vector3(FX_Cam.transform.position.x + worldPos.x, FX_Cam.transform.position.y + worldPos.y, -23f);

        fx.SetActive(true);
    }
    public void TestFx(GameplayEnemyController enemy, string fxName = null)
    {
        Vector3 center = enemy.myRT.rect.center;

        int rng = Mathf.FloorToInt(UnityEngine.Random.Range(5, 25));
        //Vector3 worldPos = FX_Cam.ScreenToWorldPoint(new Vector3(center.x, center.y, rng));

        Vector3 worldPos = enemy.myRT.TransformPoint(new Vector3(center.x, center.y + (enemy.myRT.offsetMin.y * .40f), rng));

        Func <GameObject> GetRadomFX = () =>
        {
            int rnd = UnityEngine.Random.Range(0, effects.Count);
            Debug.Log("" + rnd);
            return(CFX_SpawnSystem.GetNextObject(effects[rnd], false));
        };

        GameObject fx;

        if (fxName == null)
        {
            fx = GetRadomFX();
        }
        else
        {
            if (FX_Placement.fx_lookup.ContainsKey(fxName))
            {
                fx = CFX_SpawnSystem.GetNextObject(FX_Placement.fx_lookup[fxName], false);
            }
            else
            {
                fx = GetRadomFX();
            }
        }
        fx.transform.position = FX_Cam.transform.position + new Vector3(worldPos.x, worldPos.y, 5f);

        //txtPos.text = string.Format("ClickPos: [x]:{0}, [y]:{1}, [z]:{2}", center.x, center.y, rng);
        fx.SetActive(true);
    }
Beispiel #23
0
    /// <summary>
    /// Wait until the FX have been loaded, thn iterate over all of our instantiated FX
    /// and move them into the FX POOL.
    /// </summary>
    IEnumerator ParentFXWhenLoaded()
    {
        CFX_SpawnSystem fxSpawner = GetComponent <CFX_SpawnSystem> ();
        Transform       container = GameObject.Find(SceneObjectNames.FX_POOL).transform;

        // Spin until the FX are loaded
        while (!CFX_SpawnSystem.AllObjectsLoaded)
        {
            yield return(null);
        }

        // Parent all the FX objects
        for (int i = 0; i < fxSpawner.objectsToPreload.Length; ++i)
        {
            GameObject objectToMove = fxSpawner.objectsToPreload [i];
            GameObject instancedObj = CFX_SpawnSystem.GetNextObject(objectToMove, false);
            while (instancedObj.transform.parent != container)
            {
                instancedObj.transform.parent = container;
                instancedObj = CFX_SpawnSystem.GetNextObject(objectToMove, false);
            }
        }
    }
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "PlayerBall")
        {
            if (explosionFX != null)
            {
                GameObject go = CFX_SpawnSystem.GetNextObject(explosionFX, false);
                go.transform.position = transform.position;
                go.transform.rotation = Quaternion.identity;
                go.SetActive(true);
            }

            Collider[] hitColliders = Physics.OverlapSphere(transform.position, explosionRadius, LayerMask.GetMask("Attackable"));
            foreach (Collider c in hitColliders)
            {
                if (c.gameObject != gameObject)
                {
                    c.gameObject.SetActive(false);
                }
            }

            Destroy(this.gameObject);
        }
    }
    void Grounding()
    {
        bool wasGrounded = grounded;

        grounded = false;
        if (flapTimer < Time.time)
        {
            RaycastHit[] raycastshit = Physics.RaycastAll(transform.position, Vector3.down, 0.52f);
            foreach (RaycastHit shiet in raycastshit)
            {
                if (shiet.transform.name == "Cube")
                {
                    if (!wasGrounded)
                    {
                        CFX_SpawnSystem.GetNextObject(impact).transform.position = transform.position;
                        if (isPacman)
                        {
                            AudioPlayer.instance.Land();
                        }
                    }
                    grounded = true;
                }
            }
        }

        if (!grounded)
        {
            yTank -= Time.deltaTime * gravity;
        }
        else
        {
            yTank = 0;
        }

        transform.position += transform.forward * Time.deltaTime * powerAid - (Vector3.down * yTank * Time.deltaTime);
    }
Beispiel #26
0
    private void PlayAlertAnimation()
    {
        GameObject alert = CFX_SpawnSystem.GetNextObject(alertAnimation); // More efficient than Instantiate() - pools objects.

        alert.transform.position = enemyPosition;
    }
Beispiel #27
0
    public void PackageBoxExplode()
    {
        if (packagebox == null)
        {
            return;
        }

//        GameObject explosion = null;

//        if (item != null)
//        {
//            switch (item.GetCookie(item.type))
//            {
//                case ITEM_TYPE.COOKIE_1:
//                    explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.BlueCookieExplosion()) as GameObject);
//                    break;
//                case ITEM_TYPE.COOKIE_2:
//                    explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.GreenCookieExplosion()) as GameObject);
//                    break;
//                case ITEM_TYPE.COOKIE_3:
//                    explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.OrangeCookieExplosion()) as GameObject);
//                    break;
//                case ITEM_TYPE.COOKIE_4:
//                    explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.PurpleCookieExplosion()) as GameObject);
//                    break;
//                case ITEM_TYPE.COOKIE_5:
//                    explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.RedCookieExplosion()) as GameObject);
//                    break;
//                case ITEM_TYPE.COOKIE_6:
//                    explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.YellowCookieExplosion()) as GameObject);
//                    break;
//            }
//        }

        // board.CollectJelly(jelly);

//        if (explosion != null) explosion.transform.position = item.transform.position;

        AudioManager.instance.CageExplodeAudio();//todo:音效 修改

        if (packagebox.type == PACKAGEBOX_TYPE.PACKAGEBOX_1)
        {
            GameObject explosion = null;
            explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.PackageBox1Effects()) as GameObject);
            if (explosion != null)
            {
                explosion.transform.position = item.transform.position;
            }


            GameObject flyingItem = null;
            var        order      = 0;

            for (int k = 0; k < LevelLoader.instance.targetList.Count; k++)
            {
                if (LevelLoader.instance.targetList[k].Type == TARGET_TYPE.PACKAGEBOX &&
                    board.targetLeftList[k] > 0
                    )
                {
                    board.targetLeftList[k]--;
                    flyingItem = new GameObject();
                    order      = k;
                    break;
                }
            }

            if (flyingItem != null)
            {
                flyingItem.transform.position = item.transform.position;
                flyingItem.name  = "Flying PackageBox";
                flyingItem.layer = LayerMask.NameToLayer("On Top UI");

                SpriteRenderer spriteRenderer = flyingItem.AddComponent <SpriteRenderer>();

                GameObject prefab = Resources.Load(Configure.PackageBox1()) as GameObject;

                if (prefab != null)
                {
                    spriteRenderer.sprite = prefab.GetComponent <SpriteRenderer>().sprite;
                }

                StartCoroutine(board.CollectItemAnim(flyingItem, order));
            }


            Destroy(packagebox.gameObject);

            packagebox = null;
        }
        else if (packagebox.type == PACKAGEBOX_TYPE.PACKAGEBOX_2)
        {
            var prefab = Resources.Load(Configure.PackageBox1()) as GameObject;

            packagebox.gameObject.GetComponent <SpriteRenderer>().sprite = prefab.GetComponent <SpriteRenderer>().sprite;

            packagebox.type = PACKAGEBOX_TYPE.PACKAGEBOX_1;
        }
        else if (packagebox.type == PACKAGEBOX_TYPE.PACKAGEBOX_3)
        {
            var prefab = Resources.Load(Configure.PackageBox2()) as GameObject;

            packagebox.gameObject.GetComponent <SpriteRenderer>().sprite = prefab.GetComponent <SpriteRenderer>().sprite;

            packagebox.type = PACKAGEBOX_TYPE.PACKAGEBOX_2;
        }
        else if (packagebox.type == PACKAGEBOX_TYPE.PACKAGEBOX_4)
        {
            var prefab = Resources.Load(Configure.PackageBox3()) as GameObject;

            packagebox.gameObject.GetComponent <SpriteRenderer>().sprite = prefab.GetComponent <SpriteRenderer>().sprite;

            packagebox.type = PACKAGEBOX_TYPE.PACKAGEBOX_3;
        }
        else if (packagebox.type == PACKAGEBOX_TYPE.PACKAGEBOX_5)
        {
            var prefab = Resources.Load(Configure.PackageBox4()) as GameObject;

            packagebox.gameObject.GetComponent <SpriteRenderer>().sprite = prefab.GetComponent <SpriteRenderer>().sprite;

            packagebox.type = PACKAGEBOX_TYPE.PACKAGEBOX_4;
        }
        else if (packagebox.type == PACKAGEBOX_TYPE.PACKAGEBOX_6)
        {
            var prefab = Resources.Load(Configure.PackageBox5()) as GameObject;

            packagebox.gameObject.GetComponent <SpriteRenderer>().sprite = prefab.GetComponent <SpriteRenderer>().sprite;

            packagebox.type = PACKAGEBOX_TYPE.PACKAGEBOX_5;
        }

        StartCoroutine(item.ResetDestroying());
    }
    //--------------------------------
    void Awake()
    {
        if(instance != null)
            Debug.LogWarning("CFX_SpawnSystem: There should only be one instance of CFX_SpawnSystem per Scene!\n", this.gameObject);

        instance = this;
    }
Beispiel #29
0
    private void PlayDeathAnimation()
    {
        GameObject deathAnim = CFX_SpawnSystem.GetNextObject(deathAnimation);

        deathAnim.transform.position = transform.position;
    }
Beispiel #30
0
 // Use this for initialization
 void Start()
 {
     Instantiate(myPrefab);
     CFX_SpawnSystem.GetNextObject(myPrefab);
     PotionObj = this.gameObject;
 }
Beispiel #31
0
    // Update is called once per frame
    void Update()
    {
        GameObject instance = CFX_SpawnSystem.GetNextObject(myPrefab);

        instance.transform.position = PotionObj.transform.position;
    }
Beispiel #32
0
    void GotAHit(GameObject animal)
    {
        if (GameData.gameState != "playing")
        {
            return;
        }

        int scoreAmount = 10 * GameData.dungeonLevel;         // larger points for higher levels

        // see if any matching animals are touching and collect them
        GetConnected(myGridPos);

        // give bonus for more connecting blocks
        if (connectedBlocks.Count > 0)
        {
            scoreAmount = (connectedBlocks.Count + 1) * 100 * GameData.dungeonLevel;
        }

        GameData.score += scoreAmount;
        dt.MakeDriftingText(scoreAmount.ToString(), transform.position);

        if ((connectedBlocks.Count + 1) >= 3)
        {
            //print("Bonus: " + (connectedBlocks.Count+1)/3 + " added to " + GameData.shooter.GetComponent<Shooter>().numberSwaps);
            GameData.shooter.GetComponent <Shooter>().numberSwaps += (connectedBlocks.Count + 1) / 3;        //a swap for every 3
            GameData.shooter.GetComponent <Shooter>().UpdateSwaps();

            dt.MakeDriftingText("Extra Swap!", transform.position + Vector3.right, 2.0f);
            GameObject extraSwap = CFX_SpawnSystem.GetNextObject(extraSwapPrefab);
            extraSwap.transform.position = swapButtonPos;

            SoundManager.PlaySFX("Swish 2");
        }
        else
        {
            SoundManager.PlaySFX("Hit 1");             // sound for just a single or double match.
        }
        // set the to-be-deleted blocks to null in the grid
        foreach (GameObject gObj in connectedBlocks)
        {
            Int2 pos = gObj.GetComponent <Block>().myGridPos;
            GameData.gridBlocks[pos] = null;
        }

        // show particles for each to-be-deleted block and destroy it.
        foreach (GameObject gObj in connectedBlocks)
        {
            dt.MakeDriftingText(scoreAmount.ToString(), gObj.transform.position);
            GameObject leaves1 = CFX_SpawnSystem.GetNextObject(hitPrefab);
            leaves1.transform.position = gObj.transform.position;
            Destroy(gObj, 0.2f);
            GameData.score += scoreAmount;
        }
        // update the score on the screen
        if (scoreText != null)
        {
            scoreText.text = GameData.score.ToString("N0");
        }

        GameData.gridBlocks[myGridPos] = null;
        GameObject leaves2 = CFX_SpawnSystem.GetNextObject(hitPrefab);

        leaves2.transform.position = gameObject.transform.position;

        SpriteRenderer[] spriteRenderers;
        spriteRenderers = gameObject.GetComponentsInChildren <SpriteRenderer>();
        foreach (SpriteRenderer spr in spriteRenderers)
        {
            spr.enabled = false;
        }

        Destroy(gameObject, 0.5f);         // delay killing us so other code can get finished

        //Invoke("MoveBlocksDown", 0.2f);
        //Invoke("MoveBlocksLeft", 0.2f);
        GameObject.Find("SceneManager").GetComponent <ShiftBlocks>().ShiftDown();
        GameObject.Find("SceneManager").GetComponent <ShiftBlocks>().ShiftLeft();

        CountRemainingBlocks();
    }
Beispiel #33
0
    /*
     *  Have to look for the Cover > Cover > hiddenObj to match against the name
     * */

    IEnumerator KillAllMatchingGems(string theName, string catalyst)
    {
        List <GameObject> matchingCells = new List <GameObject>();

        for (int row = 0; row < cg.numRows; row++)
        {
            for (int col = 0; col < cg.numCols; col++)
            {
                int2 gridPos = new int2(col, row);
                if (GameData.gridPieces.ContainsKey(gridPos))
                {
                    GameObject gObj = GameData.gridPieces[gridPos];
                    if (gObj != null && gObj.GetComponent <Cover>().hiddenObj.name == theName ||
                        gObj != null && gObj.GetComponent <Cover>().hiddenObj.name == catalyst)
                    {
                        matchingCells.Add(gObj);
                        if (gObj.GetComponent <SpriteRenderer>().sprite.name == "seashell2")
                        {
                            SoundManager.PlaySFX("splash");
                        }
                        gObj.GetComponent <Cover>().ShowHiddenObject();
                        GameObject expl = CFX_SpawnSystem.GetNextObject(matchedCovers);
                        expl.transform.position = gObj.transform.position;

                        yield return(new WaitForSeconds(0.25f));
                    }
                }
            }
        }

        bool captured = false;
        int  c        = 1;

        // now that we have a list of the matching gems, blow them up one at a time.
        if (matchingCells.Count > 0)
        {
            foreach (GameObject gObj in matchingCells)
            {
                yield return(new WaitForSeconds(0.5f));

                SoundManager.PlaySFX("implosion");
                GameObject expl = CFX_SpawnSystem.GetNextObject(explodeCover);
                expl.transform.position = gObj.transform.position;
                ProCamera2DShake.Instance.Shake("New ShakePreset");
                if (scoring.score > 0)
                {
                    dt.MakeDriftingText("-10", gObj.transform.position);
                    scoring.AddToScore(-10);
                }
                StartCoroutine(DestroyCell(gObj));
                //Application.CaptureScreenshot("Screenshot" + c + ".png");
                //c++;
            }

            GameData.matchesFound += matchingCells.Count / 2;

            GameData.canClick = true;

            //Invoke("CheckForFinish", 1f);
            CheckForFinish();
        }
    }