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); } } }
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); } }
public void Move(SnakeNode nd, Vector3 pos) { if (nd == null) { } else { Move(nd.nextNode, nd.node.transform.position); nd.node.transform.position = pos; } }
// 判断现在SnakeNode Class时,自己destroy自己的GameObject成员,就会Exception。。是为什么呢? public void CheckSeven(BBBB.SnakeNode sn) { if (BBBB.SnakeNode.RainbowCount == 7) { GameWin = true; sn.DestroySnake(); Debug.Log("小蛇变成了七彩艾希,像彩虹一般出现在Hank眼前。"); BBBB.SnakeNode.RainbowCount = 0; } }
public void EatFood(SnakeNode nd, Color c, Texture t) { if (nd.nextNode == null) { nd.nextNode = new SnakeNode(node, node.transform.position, c, t); if (t != null) { RainbowCount += 1; Debug.Log(RainbowCount); } } else { EatFood(nd.nextNode, c, t); } }