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); }
public void Grow(Color _bodycolor) { if (this.nextNode == null) { this.nextNode = new SnakeNode(snakeObj, snakeObj.transform.position, _bodycolor); } else { this.nextNode.Grow(_bodycolor); } }
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); }
// Start is called before the first frame update void Start() { snakeNode = CreateSnake(); Snacks = CreateFruits(); }