/// <summary>
    /// 实例化一个蛇
    /// </summary>
    /// <param name="name">蛇的名字</param>
    /// <param name="teamtype">蛇的队伍,1为黄色,2为红色</param>
    /// <param name="snaketype">蛇的种类,1为黄色,2为红色</param>
    /// <returns>返回InitSnake这个蛇类</returns>
    public InitSnake GetInstanteSnake(string name, int teamtype, int snaketype)
    {
        Length = 3;
        Name   = name;
        Score  = 0;

        if (snaketype == 1)
        {
            SnakeType = SnakeTypes.Yellow;
        }
        else if (snaketype == 2)
        {
            SnakeType = SnakeTypes.Red;
        }

        if (teamtype == 1)
        {
            SnakeType = SnakeTypes.Yellow;
        }
        else if (teamtype == 2)
        {
            SnakeType = SnakeTypes.Red;
        }

        SnakeGameObject = Instantiate(YellowSnake, new Vector3(0, 0, 0), Quaternion.identity);
        return(instance);
    }
Example #2
0
        static Snake FoodPoint()
        {
            Random     rant      = new Random();
            int        X         = rant.Next(1, 50);
            int        Y         = rant.Next(1, 30);
            SnakeTypes snakeType = SnakeTypes.Food;
            Snake      snake     = new Snake(X, Y, snakeType);

            return(snake);
        }
    public InitSnake GetInstanteSnake(Vector3 v)
    {
        Length    = 3;
        Name      = name;
        Score     = 0;
        SnakeType = SnakeTypes.Yellow;
        TeamType  = SnakeTeams.Yellow;

        SnakeGameObject = Instantiate(YellowSnake, v, Quaternion.identity);
        return(instance);
    }
Example #4
0
        static bool HitSnake(List <Snake> dangerous, Snake snake)
        {
            Random     rant      = new Random();
            int        X         = rant.Next(1, 80);
            int        Y         = rant.Next(1, 30);
            SnakeTypes snakeType = SnakeTypes.Dangerous;

            if (dangerous.Any(x => x.X == snake.X && x.Y == snake.Y))
            {
                var danger = new Snake(X, Y, snakeType);
                danger.Print();
                dangerous.Add(danger);
                return(true);
            }
            return(false);
        }
Example #5
0
 public Snake(int x, int y, SnakeTypes type)
 {
     X    = x;
     Y    = y;
     Type = type;
 }