예제 #1
0
        //public void OnStreet(Entity entity)
        //{
        //    X = entity.X;
        //    Y = entity.Y;
        //    Z = entity.Z;
        //    Map = entity.Map;

        //    Roads = new Road[0];
        //    Road road = new Road(X, Y, Z);
        //    road.Add(new Point3D(X, Y, Z));
        //    Add(road);
        //    OnStreet(road, entity);
        //}
        void OnStreet(Road road, Entity entity)
        {
            road.Closed = true;

            Cube      cube_dest;
            Direction direction;

            if (road.Street.Length < Range)
            {
                //for (int i = 1; i < 27; i++)
                for (int i = 0; i < 24; i++)
                {
                    direction = Info.IntToDirection(i);

                    if (Contains(road.X + direction.X, road.Y + direction.Y, road.Z + direction.Z))
                    {
                        continue;
                    }

                    cube_dest = Map.FindCube(road.X + direction.X, road.Y + direction.Y, road.Z + direction.Z);
                    if (cube_dest == null || !cube_dest.Cross || cube_dest.Climb)
                    {
                        continue;                                                          //
                    }
                    if (direction.X != 0 && direction.Y != 0)
                    {
                        Coin coin = new Coin(road.X, road.Y, road.Z, direction, Map);
                        if (!coin.Movement())
                        {
                            continue;
                        }
                    }

                    if (entity != null && !entity.CanMoveTo(cube_dest.X, cube_dest.Y, cube_dest.Z, Map))
                    {
                        continue;
                    }

                    Road next_road = new Road(cube_dest.X, cube_dest.Y, cube_dest.Z);
                    next_road.CopyAndAdd(road, new Point3D(cube_dest.X, cube_dest.Y, cube_dest.Z));
                    Add(next_road);
                }
            }

            for (int i = 0; i < Roads.Length; i++)
            {
                if (!Roads[i].Closed)
                {
                    OnStreet(Roads[i], entity); break;
                }
            }
        }