Esempio n. 1
0
 void Update()
 {
     if (!whetherAlive)
     {
         DiamondGameManager.GetTheInstance().TheSnakDie();
     }
 }
Esempio n. 2
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. 3
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);
    }
Esempio n. 4
0
    private void Awake()
    {
        tVel         = new Vector3(0f, 0f, 0f);
        tdPos        = new Vector3(snakeSpeed, 0f, 0f);
        whetherAlive = true;
        theInstance  = this;


        SetStartHistoryArray();                   //纯数值处理,对前面的流程无依赖
        LoadSkinSprite();                         //加载皮肤资源,对前面的流程无依赖
        SetPrefabSnakeHeadAndBody();              //加载pefab,并设定皮肤,要求前面已加载皮肤
        snakeBodySpriteRenderer.sortingOrder = 0; //要求prefab已加载

        InstantiateFirstBody();                   //生成第一个体节


        DiamondGameManager.GetTheInstance().SetLenText(snakeLength);
        DiamondGameManager.GetTheInstance().SetSpeedText((int)(snakeSpeed));
    }