Exemplo n.º 1
0
 static void RenderSearchExtent(Layer <TestTile> layer, MapAStar <TestTile> search)
 {
     foreach (var loc in search._closedList)
     {
         layer.Set(loc.Key, new TestTile('*'));
     }
     Console.WriteLine(layer);
 }
Exemplo n.º 2
0
 static void RenderPath(Layer <TestTile> layer, MapAStar <TestTile> search)
 {
     if (search.result.Count > 0)
     {
         for (int step = 0; step < search.result.Count; ++step)
         {
             layer.Set(search.result[step], new TestTile((step % 10).ToString()[0]));
         }
         layer.Set(search.result[0], new TestTile('S'));
         Console.WriteLine(layer);
     }
     else
     {
         Console.WriteLine("No path?");
     }
 }
Exemplo n.º 3
0
        public MoveTo(World world, Actor mover, Point <int> target)
        {
            this.mover = mover;

            // determine the path, set the actor along it
            var search = new MapAStar <Tile>();

            search.PathFind(world.walls, t => { return(t.IsEmpty); }, mover.pos.ToInt(), target);

            // There's no deque in C#.  To avoid shifting the array each time we remove an item, just reverse the list and work backward.
            //KAI: just turn this into LinkedList...
            search.result.Reverse();
            path = search.result;

#if DEBUG_MOVE
            Console.WriteLine("MoveTo evaluated path with {0} tiles", path.Count);
#endif
        }
Exemplo n.º 4
0
        static void PathfindTest()
        {
            var map = new Map <TestTile>(1, 100, 20);

            PopulateMap(map);
            Console.WriteLine(map);

            var search = new MapAStar <TestTile>();

            search.PathFind(map.Get(0), t => TestTile.IsPassable(t.type), new Point <int>(2, 0), new Point <int>(98, 19));

            RenderPath(map.Get(0), search);

            var solutionRender = new Layer <TestTile>(map.width, map.height);

            RenderSearchExtent(solutionRender, search);

            var layer = new Layer <TestTile>(100, 20);

            // create a bunch of walls
            layer.Fill((x, y, oldTile) =>
            {
                return(new TestTile('.'));
            });
            for (int c = 0; c < layer.size.x; c += 2)
            {
                for (int r = 1; r < layer.size.y; ++r)
                {
                    layer.Set(c, r, new TestTile('x'));
                }
                c += 2;
                for (int r = 0; r < layer.size.y - 1; ++r)
                {
                    layer.Set(c, r, new TestTile('x'));
                }
            }
            Console.WriteLine(layer);

            search = new MapAStar <TestTile>();
            search.PathFind(layer, (TestTile t) => TestTile.IsPassable(t.type), new Point <int>(0, 0), new Point <int>(99, 19));
            RenderPath(layer, search);
        }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        Assert.assert(_instance == null);
        _instance = this;

        if (AppConfig.DEBUGGING)
        {
            new MyTest();
        }

        CreateBattleData();         // SceneBattle

        _camera = GameObject.FindGameObjectWithTag(AppConfig.TAB_MAIN_CAMERA);

        //todo, use define in mission
        _unitGroup = new UnitGroup();
        _mapGrid   = new MapGrid(InstancePlayer.instance.battle.dataMap);
        _mapAStar  = new MapAStar(_mapGrid);
        _mapCamera = new MapCamera();

        _gameEntering = new BattleGameEntering(this);

        _mouseContorl = new MouseControl(this);

        _gameSkill        = new GameSkill();
        _gameSkillControl = new GameSkillControl(this);

//		MapAStar.PATH path = _mapAStar.Calc (5, 2, 15, 2);
//		_mapGrid.AddPath (path);

        AudioGroup.Play(GetComponent <AudioGroup> ().music, _camera, AudioGroup.TYPE.MUSIC);

        UnitTrackControl.ClearTrackTiles();

        BattleGameHelper.PreloadAssets();
    }