コード例 #1
0
ファイル: MenagerScript.cs プロジェクト: tonesija/bbtanclone
    private void maybeCreateVerLazer(float chance)
    {
        if (chance > Random.Range(0f, 1f))
        {
            GridSpot toPut = getRandomAvailableSpot(7);

            GameObject     lazer  = Instantiate(verLazerOriginal);
            GridableObject script = lazer.GetComponent <GridableObject>();
            script.setGridPosition(toPut.getY() + 1, toPut.getX());
            grid[toPut.getY(), toPut.getX()] = true;

            temporaryObjs.Add(lazer);
        }
    }
コード例 #2
0
ファイル: MenagerScript.cs プロジェクト: tonesija/bbtanclone
 //updates grid, destroys temp objects and cleans the temporaryObjs list
 private void destroyTempObjects()
 {
     foreach (GameObject obj in temporaryObjs)
     {
         GridableObject script = obj.GetComponent <GridableObject>();
         int            x      = script.getGridX();
         int            y      = script.getGridY();
         if (x != -1)
         {
             grid[y, x] = false;
         }
         Destroy(obj);
     }
     for (int i = temporaryObjs.Count - 1; i >= 0; --i)
     {
         temporaryObjs.RemoveAt(i);
     }
 }
コード例 #3
0
ファイル: LazerScript.cs プロジェクト: tonesija/bbtanclone
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag.Equals("Ball"))
        {
            GameObject newLazer = Instantiate(lazer);
            LazerSound.Play();

            GridableObject lazerGridScript = newLazer.GetComponent <GridableObject>();
            GridableObject btnGridScript   = this.gameObject.GetComponent <GridableObject>();
            Debug.Log(btnGridScript.getGridY());

            // lazerGridScript.setGridPosition(btnGridScript.getGridY(), btnGridScript.getGridX());

            if (IsHorizontal)
            {
                lazerGridScript.setGridPosition(btnGridScript.getGridY(), 3);
            }
            else
            {
                lazerGridScript.setGridPosition(5, btnGridScript.getGridX());
            }
        }
    }
コード例 #4
0
ファイル: MenagerScript.cs プロジェクト: tonesija/bbtanclone
    public void addNewRowToList(int row)
    {
        destroyTempObjects();
        cleanObjsList();

        int AddBallCoinPosition = (int)Random.Range(0.0f, (float)ROWSIZE - 0.000001f);

        for (int i = 0; i < ROWSIZE; ++i)
        {
            bool       ObjShouldBeAdded = false;
            bool       ObjIsCoin        = false;
            GameObject block            = gameObject;

            if (i == AddBallCoinPosition)
            {
                block            = Instantiate(AddBallCoin);
                ObjShouldBeAdded = true;
                ObjIsCoin        = true;
            }
            else
            {
                float randomValue = Random.Range(0.0f, 10.0f);

                if (randomValue > 3.0f)
                {
                    ObjShouldBeAdded = true;
                    ObjIsCoin        = false;

                    if (randomValue < 8.0f)
                    {
                        block = Instantiate(originalBlock);
                    }
                    else if (randomValue > 8.0f && randomValue < 8.5f)
                    {
                        block = Instantiate(TRTriangle);
                    }
                    else if (randomValue > 8.5f && randomValue < 9.0f)
                    {
                        block = Instantiate(TLTriangle);
                    }
                    else if (randomValue > 9.0f && randomValue < 9.5f)
                    {
                        block = Instantiate(BRTriangle);
                    }
                    else if (randomValue > 9.5f)
                    {
                        block = Instantiate(BLTriangle);
                    }
                }
            }

            if (ObjShouldBeAdded)
            {
                GridableObject gridable = block.GetComponent <GridableObject>();

                if (ObjIsCoin == false)
                {
                    BlockScript script = block.GetComponent <BlockScript>();
                    script.setHealth(health);
                }
                gridable.setGridPosition(row, i);

                objs.Add(gridable);
            }
        }
        changeGridStatus();

        maybeCreateBouncer(BouncerChance);
        maybeCreateHorLazer(LazerChance);
        maybeCreateVerLazer(LazerChance);

        health++;
        //bouncerFlag = true;
    }