示例#1
0
    private void SyncCurrentMap()
    {
        foreach (IEntity e in entities)
        {
            Destroy(e.Graphics.entity);
        }

        mapView.DrawMap(CurrentMap.tiles, (int)CurrentMap.mapSize.x, (int)CurrentMap.mapSize.y);


        foreach (NPCPrototype cd in currentMap.Characters)
        {
            entities.Add(CharacterDatabase.CreateCharacter(cd));
        }

        TileMapPathfinder.SetMap(currentMap);

        List <Tile> path = TileMapPathfinder.Path(currentMap.GetTile((int)currentMap.mapSize.x / 2, (int)currentMap.mapSize.y / 2), currentMap.GetTile((int)UnityEngine.Random.Range(1, currentMap.mapSize.x - 1), (int)UnityEngine.Random.Range(1, currentMap.mapSize.y - 1)));

        foreach (Tile t in path)
        {
            t.TileType = TileType.Wall;
            mapView.RedrawTile(t);
        }
    }
    public virtual void MoveToTile(Tile target)
    {
        //save us some time not looking for paths we know we can't get to
        if (!target.IsWalkable())
        {
            return;
        }

        path = TileMapPathfinder.Path(IEntity.CurrentTile, target);
        Debug.Log(IEntity.EntityName + " moving to " + target.GetMovementCost());
    }