示例#1
0
    public void CheckEat(BBBB.SnakeNode sn, List <BBBB.Fruit> f)
    {
        for (int i = 0; i < f.Count; i++)
        {
            float dis = Vector3.Distance(sn.GetPosition(), f[i].GetPosition());

            if (dis <= 1.5f)
            {
                if (BBBB.SnakeNode.AteRainbow == true)
                {
                    sn.EatFood(sn, Color.white, snakeTexture);
                }
                else
                {
                    if (f[i].IsRainbow == true)
                    {
                        BBBB.SnakeNode.AteRainbow = true;
                        // animation
                        sn.EatFood(sn, Color.white, snakeTexture);
                    }
                    else
                    {
                        sn.EatFood(sn, Color.gray, null);
                    }
                }

                // pop out the list
                f[i].ClearFruit();
                f.RemoveAt(i);
            }
        }
    }
示例#2
0
    void InitiateSnake(Color[] colors)
    {
        snakeNode = new BBBB.SnakeNode(snakePrefab, new Vector3(3, 0.5f, 0), colors[0], null);

        for (int i = 1; i < colors.Length; i++)
        {
            snakeNode.EatFood(snakeNode, colors[i], null);
        }
    }