Exemple #1
0
    public static BallMatrix Create(int width, int height, float widthOffset, float heightOffset, float ballOffset)
    {
        if(instance == null)
            instance = new BallMatrix(width, height, widthOffset, heightOffset, ballOffset);

        return instance;
    }
Exemple #2
0
 public static BallMatrix Create(int width, int height, float widthOffset, float heightOffset, float ballOffset, GameObject original, Transform parent)
 {
     if (instance == null)
     {
         instance = new BallMatrix(width, height, widthOffset, heightOffset, ballOffset, original, parent);
     }
     return instance;
 }
Exemple #3
0
    public void checkDestory()
    {
        if (gameObject.name == "NeedCheck")
        {
            ballMatrix.DestoryList(gameObject, mColor);
            Debug.Log("Destory: " + ballMatrix.destory.Count);
            if (ballMatrix.destory.Count > 2)
            {
                sucessDestory = true;
                Debug.Log("Ready to destory");
                foreach (List <GameObject> goList in ballMatrix.balls)
                {
                    Excusive(goList, ballMatrix.destory);
                }
                //getScore();
                foreach (GameObject go in ballMatrix.destory)
                {
                    go.GetComponent <Ball>().Explosion();

                    Destroy(go);
                }
            }


            //else
            //{
            //    foreach (GameObject go in ballMatrix.fallDown)
            //    {
            //        go.GetComponent<Ball>().visited = false;
            //    }
            //    ballMatrix.fallDown.RemoveRange(0, ballMatrix.fallDown.Count);
            //}
            ballMatrix.destory.RemoveRange(0, ballMatrix.destory.Count);
            Debug.Log("After destory: " + ballMatrix.destory.Count);
            ballMatrix.visted.RemoveRange(0, ballMatrix.visted.Count);
            Debug.Log("After visit: " + ballMatrix.visted.Count);
            ballMatrix.fallDown = BallMatrix.Distinct(ballMatrix.fallDown);
            //ballMatrix.modifyFallList();
            Debug.Log("Fall list modified. actualFallDown count: " + ballMatrix.actualFallDown.Count);
            Debug.Log("Fall down list: " + ballMatrix.fallDown.Count);
            gameObject.name = "Ball(Clone)";
        }
    }
    // Use this for initialization
    void Start()
    {
        for (int i = 0; i <= 3; i++)
        {
            float y = 2.8f - 0.55f * i;
            if (i % 2 == 0)
            {
                for (int j = 0; j < 8; j++)
                {
                    float x = -2.24f + 0.64f * j;

                    ball_clone = Instantiate(ballPerfab, new Vector3(x, y), Quaternion.identity).GetComponent <Ball>();
                }
            }
            else
            {
                for (int j = 0; j < 7; j++)
                {
                    float x = -2.24f + 0.32f + 0.64f * j;
                    ball_clone = Instantiate(ballPerfab, new Vector3(x, y), Quaternion.identity).GetComponent <Ball>();
                }
            }
        }
        ballMatrix = BallMatrix.CreateBallMatrix;
        ballMatrix.addCurrentBalls();
        Debug.Log(ballMatrix.balls.Count);
        foreach (List <GameObject> goList in ballMatrix.balls)
        {
            foreach (GameObject go in goList)
            {
                if (go.name != "Ready")
                {
                    go.GetComponent <Ball>().getNeighbours();
                    Debug.Log("Check new neighbour");
                }
            }
        }

        initTwoBalls();
    }
Exemple #5
0
 private void Awake()
 {
     init();
     speed      = 10;
     ballMatrix = BallMatrix.CreateBallMatrix;
 }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     ballMatrix = BallMatrix.CreateBallMatrix;
 }