Exemplo n.º 1
0
    public void createFood()
    {
        int food_x = Random.Range(GetPlaneData.getPlaneLeftBoundary() + 1,
                                  GetPlaneData.getPlaneRightBoundary() - 1);

        int food_z = Random.Range(GetPlaneData.getPlaneUpperBoundary() + 1,
                                  GetPlaneData.getPlaneLowerBoundary() - 1);

        Vector3 foodPosition = new Vector3(food_x, 0, food_z);

        Instantiate(FoodPrefab, new Vector3(food_x, 0, food_z), Quaternion.identity);
    }
Exemplo n.º 2
0
    public static bool isCanreach(Point point, Point target)
    {
        bool isOutPlane = target.m_position.x + 1 > GetPlaneData.getPlaneRightBoundary() ||
                          target.m_position.x - 1 < GetPlaneData.getPlaneLeftBoundary() ||
                          target.m_position.z + 1 > GetPlaneData.getPlaneLowerBoundary() ||
                          target.m_position.z - 1 < GetPlaneData.getPlaneUpperBoundary();

        bool isSlashPoint = System.Math.Abs(target.m_position.x - point.m_position.x)
                            + System.Math.Abs(target.m_position.z - point.m_position.z) == 2;

        bool isSnakeHead = point.m_position == target.m_position;

        if (isOutPlane || isSlashPoint || isSnakeHead)
        {
            return(false);
        }
        return(true);
    }