Have time to learn Unity5 practice practiced hand, a snake small demo
Simple 2D scene, objects are sprites, need to set the display level before and after, from the snake head to the tail of the order in the Layer value is 1000 decrement 1, so the effect is displayed with scales of the cascade.
Every section of the snake has a script SnakePart.cs records the location and direction of this section, including calculated values.
The snake does not eat an apple, it will instantiate the resulting section, where the newly generated section has a new script NewSnakePart.cs the main function is to initialize this section to the end of the snake including the initialization position, direction.
GameManager.cs Singleton class,list<snakepart> This is all the knots of the snake, there are randomly generated food, the game ends, restarts, the position of each section is converted (from the tail to the end of the conversion).
Finally is the PlayerScript.cs script, is hanging on the head of the snake, first said to do the game, is the mouse (or finger) to drag the snake head, so the snake will follow the move. Then the purpose of this script is to calculate the distance and direction that each section should move forward. There is the collision detection, testing to eat apples, wall and bite themselves.
In the game only the snake head is both Rigidbody and Collider, the other only Collier, this is the Unity Physics engine collision detection condition, must both have the collision body, and is the moving object must have the rigid body.
As for the Gameover UI is the use of Unity5 native Ugui at the mercy of a bit.
The script is less different than the previous version of Unity5.
Finish
??
Unity5 and Ugui's little demo snake