Exemple #1
0
 public bool equal(MyPoint _point)
 {
     if (this.x == _point.GetX() && this.y == _point.GetY())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #2
0
    //返回临近的活着的植物坐标
    List <MyPoint> FindNearPlant()
    {
        skinMap  = GardenMap.skinMap;
        mapState = GardenMap.mapstate;

        List <MyPoint> points = new List <MyPoint>();

        MyPoint nextPoint = new MyPoint(-1, -1);

        nextPoint.SetX(this.point.GetX() + 1);
        nextPoint.SetY(this.point.GetY());
        if (plantAlive(nextPoint.GetX(), nextPoint.GetY()))
        {
            points.Insert(0, nextPoint);
        }

        nextPoint = new MyPoint(-1, -1);
        nextPoint.SetX(point.GetX() - 1);
        nextPoint.SetY(point.GetY());
        if (plantAlive(nextPoint.GetX(), nextPoint.GetY()))
        {
            points.Insert(0, nextPoint);
        }

        nextPoint = new MyPoint(-1, -1);
        nextPoint.SetX(point.GetX());
        nextPoint.SetY(point.GetY() - 1);
        if (plantAlive(nextPoint.GetX(), nextPoint.GetY()))
        {
            points.Insert(0, nextPoint);
        }

        nextPoint = new MyPoint(-1, -1);
        nextPoint.SetX(point.GetX());
        nextPoint.SetY(point.GetY() + 1);
        if (plantAlive(nextPoint.GetX(), nextPoint.GetY()))
        {
            points.Insert(0, nextPoint);
        }

        /*
         * nextPoint = new MyPoint(-1, -1);
         * nextPoint.SetX(this.point.GetX() + 1);
         * nextPoint.SetY(this.point.GetY() + 1);
         * if (plantAlive(nextPoint.GetX(), nextPoint.GetY()))
         * {
         *  points.Insert(0, nextPoint);
         * }
         *
         * nextPoint = new MyPoint(-1, -1);
         * nextPoint.SetX(point.GetX() - 1);
         * nextPoint.SetY(point.GetY() - 1);
         * if (plantAlive(nextPoint.GetX(), nextPoint.GetY()))
         * {
         *  points.Insert(0, nextPoint);
         * }
         *
         * nextPoint = new MyPoint(-1, -1);
         * nextPoint.SetX(point.GetX() + 1);
         * nextPoint.SetY(point.GetY() - 1);
         * if (plantAlive(nextPoint.GetX(), nextPoint.GetY()))
         * {
         *  points.Insert(0, nextPoint);
         * }
         *
         * nextPoint = new MyPoint(-1, -1);
         * nextPoint.SetX(point.GetX() - 1);
         * nextPoint.SetY(point.GetY() + 1);
         * if (plantAlive(nextPoint.GetX(), nextPoint.GetY()))
         * {
         *  points.Insert(0, nextPoint);
         * }
         */

        return(points);
    }