Esempio n. 1
0
    //***************************************************************************
    //对蛇的相关操作


    private void AddOneBody()
    {
        snakeLength++;

        DiamondGameManager.GetTheInstance().SetScore(0);
        tSnakeBodyObj = Instantiate(snakeBodyObj, snakeTail.transform.position, snakeTail.transform.rotation) as GameObject;
        tSnakeBody    = tSnakeBodyObj.GetComponent <DiamondSnakeBody>();

        tSnakeBody.SetAllMemember(snakeTail, snakeLength, null);
        snakeTail.SetNextBody(tSnakeBodyObj);
        snakeTail = tSnakeBody;
        snakeBodySpriteRenderer.sortingOrder--;//确定体节的前后覆盖关系
        DiamondGameManager.GetTheInstance().SetLenText(snakeLength);
    }
Esempio n. 2
0
    private void MinusOneBody()
    {
        DiamondGameManager.GetTheInstance().SetScore(1);

        if (snakeLength == 1)
        {
            whetherAlive = false;
            return;
        }
        snakeLength--;

        snakeTail = snakeTail.GetLastSnakeBodyDiamondBody();
        Destroy(snakeTail.GetNextSnakeBodyObj());
        snakeTail.SetNextBody(null);
        snakeBodySpriteRenderer.sortingOrder++;
        DiamondGameManager.GetTheInstance().SetLenText(snakeLength);
    }