/// <summary> /// 实例化一个蛇,名字是0到999999的数字,黄色颜色的蛇和黄色队伍的蛇 /// </summary> /// <returns>返回InitSnake这个蛇类</returns> public InitSnake GetInstanteSnake() { string name = Random.Range(0, 999999).ToString(); instance = GetInstanteSnake(name, 1, 1); return(instance); }
public void ExpandSnake(InitSnake Snake) { int length = Snake.SnakeGameObject.transform.childCount; GameObject G; if (length % 2 == 0) { G = Instantiate(YellowSnakeBody, Snake.SnakeGameObject.transform.GetChild(length - 1).transform.position, Quaternion.identity); } else { G = Instantiate(RedSnakeBody, Snake.SnakeGameObject.transform.GetChild(length - 1).transform.position, Quaternion.identity); } G.transform.SetParent(Snake.SnakeGameObject.transform); G.name = length.ToString(); }
public void GetInstanteSnake() { MySnake = InitSnake.instance.GetInstanteSnake(); head = MySnake.SnakeGameObject.transform.GetChild(0).gameObject; lastBody = MySnake.SnakeGameObject.transform.GetChild(0).gameObject; }
void Awake() { instance = this; }