示例#1
0
        SnakeNode CreateSnake()
        {
            SnakeNode snakehead = new SnakeNode(snakePrefab, new Vector3(3, 0.5f, 0), new Color(0.5f, 0, 0));

            snakehead.Grow(Color.gray);
            snakehead.Grow(new Color(0.5f, 0, 0.5f));
            return(snakehead);
        }
示例#2
0
 public void Grow(Color _bodycolor)
 {
     if (this.nextNode == null)
     {
         this.nextNode = new SnakeNode(snakeObj, snakeObj.transform.position, _bodycolor);
     }
     else
     {
         this.nextNode.Grow(_bodycolor);
     }
 }
示例#3
0
 public bool Move(SnakeNode node, Vector3 _pos)
 {
     if (node == null)
     {
         return(false);
     }
     if (node.snakeObj.transform.position == _pos)
     {
         return(false);
     }
     Move(node.nextNode, node.snakeObj.transform.position);
     node.snakeObj.transform.position = _pos;
     return(true);
 }
示例#4
0
 // Start is called before the first frame update
 void Start()
 {
     snakeNode = CreateSnake();
     Snacks    = CreateFruits();
 }