Beispiel #1
0
 public void OnWorldClick(string world)
 {
     DestroyObjs();
     CurrentWorld = world;
     _createdObjects.Add(CreateButton("<--", x => OnLoadClick()));
     _createdObjects.AddRange(CreateButtonList(DDA.GetWorldSaves(world), DoSceneTransition));
 }
Beispiel #2
0
        DataTable IMyMetaPlugin.GetTables(string database)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateTablesDataTable();

                db = DDA.OpenDatabase(this.GetFullDatabaseName(),
                                      VistaDBDatabaseOpenMode.NonexclusiveReadOnly, "");

                ArrayList tables = db.EnumTables();

                foreach (string table in tables)
                {
                    IVistaDBTableSchema tblStructure = db.TableSchema(table);

                    DataRow row = metaData.NewRow();
                    metaData.Rows.Add(row);

                    row["TABLE_NAME"]  = tblStructure.Name;
                    row["DESCRIPTION"] = tblStructure.Description;
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
 void Start()
 {
     RebuildCache();
     startingPoint = DDA.playerPos();
     Game.Player.Reload(new Vector3(0, 0, 0));
     RebuildAll();
 }
Beispiel #4
0
 //--------------------------------------
 public void SpawnLanes(int amountToSpawn, bool isInitialSpawn)
 {
     if(isInitialSpawn){
         //GetComponent<BiomeClass> ().SwitchBiome (BiomeClass.Biomes.Start);
         gameManager = GameObject.FindGameObjectWithTag("Manager").GetComponent<GameManager> ();
         dDA = GameObject.FindGameObjectWithTag("Manager").GetComponent<DDA> ();
         ResetLanes();
     }
     for(int i = 0; i < amountToSpawn; i++){
         GameObject newLane = (GameObject)Instantiate(ChooseType(), new Vector3(0.75f, 0, spawnerZPos), Quaternion.identity);
         newLane.transform.parent = gameObject.transform;
         newLane.GetComponent<Lane>().OnLanePlaced();
         if(newLane.GetComponent<Lane>().laneType == LaneClass.LaneTypes.Road && lastLanePlaced == LaneClass.LaneTypes.Road){
             PlaceRoadLines(spawnerZPos, newLane);
         }
         lastLanePlaced = newLane.GetComponent<Lane>().laneType;
         //setting the cells in the Grid Matrix
         for (int j = 0; j < LaneClass.laneWidth; j++){
             clutterSpawner.Grid[amountOfLanesSpawned, j] = newLane.GetComponent<Lane>().cells[j];
             //telling clutter to be placed
             clutterSpawner.SpawnClutter(amountOfLanesSpawned, j);
         }
         dynamicPlacer.PlaceDynamics(newLane);
         clutterSpawner.SpawnExtras(newLane);
         spawnerZPos += ChosenLaneWidth(newLane.GetComponent<Lane>().laneType);
         amountOfLanesSpawned ++;
         CheckBiome(amountOfLanesSpawned);
         DestroyOld(amountOfLanesSpawned - destroyLeway);
     }
     if (isInitialSpawn) {
         DonePrePlacing ();
     }
 }
Beispiel #5
0
        public void Start()
        {
            var playerPos = DDA.playerPos();

            CreateMap(playerPos);
            Game.Player.Reload(playerPos);
            Game.Camera.MoveTo(playerPos);
        }
Beispiel #6
0
 public static void Main()
 {
     Point[] points = DDA.rasteriza(new Point(-2, 3), new Point(10, 15));
     foreach (Point point in points)
     {
         Console.WriteLine("({0}, {1})", point.x, point.y);
     }
 }
 //----------------------------------------
 public void SetUp()
 {
     gameManager   = GameObject.Find("MANAGER").GetComponent <GameManager> ();
     dDA           = GameObject.Find("MANAGER").GetComponent <DDA> ();
     forwardOffset = 0;
     gameStats     = GameObject.Find("MANAGER").GetComponent <GameStats> ();
     GetComponent <MovementEffects> ().SetUp();
     SetRects();
 }
Beispiel #8
0
 void Start()
 {
     gameManager = GameObject.Find ("MANAGER").GetComponent<GameManager> ();
     dDA = GameObject.Find ("MANAGER").GetComponent<DDA> ();
     camOrigin = gameObject.transform.position;
     P = GameObject.FindGameObjectWithTag("Player");
     //tar = gameObject.transform.FindChild ("TARGET").gameObject;
     //tar.transform.position = P.transform.position + new Vector3 (0, 0, 5f);
     cameraSpeed = dDA.gameSpeed;
 }
Beispiel #9
0
 void Start()
 {
     gameManager = GameObject.Find("MANAGER").GetComponent <GameManager> ();
     dDA         = GameObject.Find("MANAGER").GetComponent <DDA> ();
     camOrigin   = gameObject.transform.position;
     P           = GameObject.FindGameObjectWithTag("Player");
     //tar = gameObject.transform.FindChild ("TARGET").gameObject;
     //tar.transform.position = P.transform.position + new Vector3 (0, 0, 5f);
     cameraSpeed = dDA.gameSpeed;
 }
Beispiel #10
0
    private void Update()
    {
        if (Input.GetKeyUp(KeyCode.F5))
        {
            _data      = DDA.GetGameData();
            needReload = true;
        }

        if (needReload)
        {
            GameObject.Destroy(cached);
            cached = new GameObject("cache");
            foreach (var obj in objects)
            {
                GameObject.Destroy(obj.Value);
            }

            objects = new Dictionary <int, GameObject>();
            try
            {
                Debug.Log(_data.playerPosition);
                Game.Player.Reload(_data.playerPosition);
                Game.Camera.MoveTo(new Vector3(_data.playerPosition.x, 0, _data.playerPosition.z));
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }

            try
            {
                Game.UI.SetUI(_data.weather, _data.calendar);
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }
            Debug.Log("reloading...");
            GameObject.Destroy(frame);
            frame = new GameObject("frame");
            frame.transform.parent = this.gameObject.transform;

            foreach (var tile in _data.map.tiles)
            {
                AddOrInstantiate(tile.loc, tile.ter, "t_unknown");
                if (tile.furn != 0)
                {
                    AddOrInstantiate(tile.loc, tile.furn, "f_unknown");
                }
                // tyomalu: changed tile.ter to int
            }
            needReload = false;
        }
    }
Beispiel #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            _myBitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            _g        = Graphics.FromImage(_myBitmap);
            DDA     dda = new DDA();
            Point2D p1  = new Point2D((double)numericUpDown1.Value, (double)numericUpDown2.Value);
            Point2D p2  = new Point2D((double)numericUpDown3.Value, (double)numericUpDown4.Value);

            dda.DrawLine(_g, p1, p2);
            pictureBox1.Image = _myBitmap;
        }
    public static void StartDdaGame()
    {
        DDA.init();
        var worlds = DDA.GetWorldNames();

        Debug.Log("Found " + worlds.Length + " worlds");
        WorldName = worlds[0];

        Debug.Log("Loading " + WorldName);

        DDA.loadGame(WorldName);
        Debug.Log("Game loaded");
    }
 void Start()
 {
     clutterSpawner = clutterSpawner.GetComponent <ClutterSpawner> ();
     dynamicPlacer  = dynamicPlacer.GetComponent <DynamicPlacer> ();
     biome          = GetComponent <BiomeClass> ();
     dDA            = dDA.GetComponent <DDA> ();
     gameStats      = gameStats.GetComponent <GameStats> ();
     if (GameObject.FindGameObjectWithTag("Player"))
     {
         P = GameObject.FindGameObjectWithTag("Player");
     }
     pChecker = LaneClass.playerSpawnLocation + new Vector3(0, 0, 1.5f);
 }
 void Start()
 {
     _ints = this;
     //screen things
     Screen.orientation = ScreenOrientation.AutoRotation;
     //----
     gameManger       = GetComponent <GameManager> ();
     adMan            = GetComponent <AdMan> ();
     menuManager      = GetComponent <MenuManager> ();
     dDA              = GetComponent <DDA> ();
     currentGameState = GameStates.GameStart;
     SwitchGameState(GameStates.GameLoad);
 }
    public void RebuildCache()
    {
        voxModelsCache.Clear();
        terIds.Clear();
        tilesFolder = tilesFolder.Trim();
        if (!Directory.Exists(tilesFolder))
        {
            return;
        }
        var       files          = Directory.GetFiles(tilesFolder, "*.vox");
        Texture2D terrainTexture = null;

        foreach (var file in files)
        {
            var name  = Path.GetFileNameWithoutExtension(file).ToLower();
            var model = new VOX.Model(file);

            if (terrainTexture == null)
            {
                scale          = 1.0f / model.sizeX;
                tileSize       = model.sizeX * scale;
                terrainTexture = VOX.Texture.FromModel(model, 16);
            }

            var mesh = VOX.Mesh.FromModel(model, scale, removeEdges, 1.0f / terrainTexture.width / 2.0f);
            voxModelsCache[name] = mesh;
            terIds[0]            = "t_null";
            int terId  = DDA.terId(name);
            int monId  = DDA.monId(name);
            int furnId = DDA.furnId(name);
            if (terId != 0)
            {
                terIds[terId] = name;
            }
            if (monId != -1)
            {
                monIds[monId] = name;
            }
            if (furnId != -1)
            {
                furnIds[furnId] = name;
            }
        }

        terrainMaterial = new UnityEngine.Material(Shader.Find("Standard"));
        terrainMaterial.SetTexture("_MainTex", terrainTexture);
        UpdateGrid();
        terrainMaterial.EnableKeyword("_SPECULARHIGHLIGHTS_OFF");
        terrainMaterial.SetFloat("_SpecularHighlights", 0f);
    }
Beispiel #16
0
        List <string> IPlugin.GetPrimaryKeyColumns(string database, string table)
        {
            List <string>    primaryKeys = new List <string>();
            IVistaDBDatabase db          = null;

            try
            {
                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                IVistaDBTableSchema tblStructure = db.TableSchema(table);

                string[] pks = null;
                if (tblStructure.Indexes.Contains("PrimaryKey"))
                {
                    pks = tblStructure.Indexes["PrimaryKey"].KeyExpression.Split(';');
                }
                else
                {
                    foreach (IVistaDBIndexInformation pk in tblStructure.Indexes)
                    {
                        if (pk.Primary)
                        {
                            pks = pk.KeyExpression.Split(';');
                            break;
                        }
                    }
                }

                if (pks != null)
                {
                    foreach (string pkColName in pks)
                    {
                        primaryKeys.Add(pkColName);
                    }
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(primaryKeys);
        }
Beispiel #17
0
        DataTable IPlugin.GetTableIndexes(string database, string table)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateIndexesDataTable();

                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                ArrayList tables = db.EnumTables();

                IVistaDBTableSchema tblStructure = db.TableSchema(table);

                foreach (IVistaDBIndexInformation indexInfo in tblStructure.Indexes)
                {
                    string[] pks = indexInfo.KeyExpression.Split(';');

                    int index = 0;
                    foreach (string colName in pks)
                    {
                        DataRow row = metaData.NewRow();
                        metaData.Rows.Add(row);

                        row["TABLE_CATALOG"] = GetDatabaseName();
                        row["TABLE_NAME"]    = tblStructure.Name;
                        row["INDEX_CATALOG"] = GetDatabaseName();
                        row["INDEX_NAME"]    = indexInfo.Name;
                        row["UNIQUE"]        = indexInfo.Unique;
                        row["COLLATION"]     = indexInfo.KeyStructure[index++].Descending ? 2 : 1;
                        row["COLUMN_NAME"]   = colName;
                    }
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
Beispiel #18
0
    private void Start()
    {
        cached = new GameObject("cache");
        try
        {
            var sw = Stopwatch.StartNew();
            sw.Stop();
            Debug.Log(string.Format("Request sent in {0}ms", sw.ElapsedMilliseconds));
            _data = DDA.GetGameData();

            needReload = true;
        }
        catch (Exception)
        {
            Debug.Log("Map.json not created yet");
        }
    }
    public void RemoveOldChunks()
    {
        foreach (Transform child in gameObject.transform)
        {
            var        chunk     = child.gameObject.GetComponent <TestChunk>();
            Vector3Int playerPos = DDA.playerPos();

            Vector2Int truncStartingPoint = new Vector2Int(playerPos.x / chunkSize * chunkSize + chunkSize, playerPos.z / chunkSize * chunkSize + chunkSize);
            Vector2Int chunkStart         = new Vector2Int(truncStartingPoint.x - chunkSize / 2 - chunkRadius * chunkSize, truncStartingPoint.y - chunkSize / 2 - 1 - chunkRadius * chunkSize);
            Vector2Int chunkEnd           = new Vector2Int(truncStartingPoint.x + chunkSize / 2 + chunkRadius * chunkSize, truncStartingPoint.y + chunkSize / 2 - 1 + chunkRadius * chunkSize);

            if (chunk.start.x < chunkStart.x || chunk.start.y < chunkStart.y ||
                chunk.end.x > chunkEnd.x || chunk.end.y > chunkEnd.y)
            {
                Destroy(child.gameObject);
            }
        }
    }
    public void Update()
    {
        int i = 0;

        if (!needReload)
        {
            return;
        }
        needReload = false;
        Vector3Int playerPos          = DDA.playerPos();
        Vector2Int truncPlayerPos     = new Vector2Int(playerPos.x / chunkSize * chunkSize, playerPos.z / chunkSize * chunkSize);
        Vector2Int truncStartingPoint = new Vector2Int(truncPlayerPos.x + chunkSize, truncPlayerPos.y + chunkSize);
        Vector2Int dTruncPos          = new Vector2Int((playerPos.x - startingPoint.x) / chunkSize * chunkSize - chunkSize, (playerPos.z - startingPoint.z) / chunkSize * chunkSize - chunkSize);

        for (int x = -chunkRadius; x <= chunkRadius; x++)
        {
            for (int y = -chunkRadius; y <= chunkRadius; y++)
            {
                var        chunkStart = new Vector2Int(x * chunkSize, y * chunkSize);
                Vector2Int start      = new Vector2Int(truncStartingPoint.x - chunkSize / 2 - 1 + chunkStart.x, truncStartingPoint.y - chunkSize / 2 - 1 + chunkStart.y);
                Vector2Int end        = new Vector2Int(truncStartingPoint.x + chunkSize / 2 - 1 + chunkStart.x, truncStartingPoint.y + chunkSize / 2 - 1 + chunkStart.y);
                string     chunkName  = "chunk_" + start.x.ToString("D2") + "_" + start.y.ToString("D2");

                if (GameObject.Find("Map/" + chunkName) == null)
                {
                    var obj   = new GameObject();
                    var chunk = obj.AddComponent <TestChunk>();

                    chunk.start                   = start;
                    chunk.end                     = end;
                    obj.transform.parent          = gameObject.transform;
                    obj.name                      = chunkName;
                    chunk.transform.localPosition = new Vector3(
                        (chunkStart.x - startingPoint.x % chunkSize + dTruncPos.x + chunkSize / 2 + chunkSize - 1) * tileSize,
                        0,
                        (chunkStart.y - startingPoint.z % chunkSize + dTruncPos.y + chunkSize / 2 + chunkSize - 1) * tileSize);
                    chunk.Rebuild(i * 10);
                    i++;
                }
            }
        }
    }
    // TODO: almost the same as UpdateEntities, need to refactor
    public void UpdateFurniture()
    {
        GameObject furnObj = GameObject.Find("furniture");

        if (furnObj != null)
        {
            ClearGameObject(furnObj);
        }
        else
        {
            furnObj = new GameObject("furniture");
        }

        Vector3Int playerPos = DDA.playerPos();
        int        size      = 60;
        Vector2Int from      = new Vector2Int(playerPos.x - size, playerPos.z - size);
        Vector2Int to        = new Vector2Int(playerPos.x + size, playerPos.z + size);

        Tile[] tiles = DDA.GetTilesBetween(from, to).tiles;

        foreach (var tile in tiles)
        {
            if (tile.furn == 0)
            {
                continue;
            }
            string stringId;
            furnIds.TryGetValue(tile.furn, out stringId);
            string name = stringId == null ? "f_unknown" : stringId;

            GameObject obj = new GameObject(name);
            obj.transform.parent = furnObj.transform;
            var pos = new Vector3(tile.loc.x, 0, tile.loc.z);
            obj.transform.Translate((pos - startingPoint) * tileSize);
            // probably should prepare GameObjects and do their clones instead
            var mr = obj.AddComponent <MeshRenderer>();
            var mf = obj.AddComponent <MeshFilter>();
            mf.sharedMesh     = voxModelsCache[name].ToMesh();
            mr.sharedMaterial = terrainMaterial;
            mf.sharedMesh.RecalculateNormals();
        }
    }
    public void Rebuild()
    {
        Vector3Int playerPos = DDA.playerPos();

        Game.Player.Reload((playerPos - startingPoint) * tileSize);
        //if (TestGame.Started == false) return;

        // only for editor mode:
        // ReattachMainDispatch();

        RemoveOldChunks();
        needReload = true; // reload on next frame because Destroy method finishes at the end of frame

        if (voxModelsCache.Count == 0)
        {
            RebuildCache();
        }
        UpdateEntities();
        UpdateFurniture();
    }
Beispiel #23
0
        public void Create(Vector3Int chunkSize)
        {
            if (_created)
            {
                return;
            }
            var sw        = new Stopwatch();
            var chunkFrom = new Vector2Int((int)(Location.x * chunkSize.x), (int)(Location.y * chunkSize.y));
            var chunkTo   = new Vector2Int((int)(chunkFrom.x + chunkSize.x - 1), (int)(chunkFrom.y + chunkSize.y - 1));
            var map       = DDA.GetTilesBetween(chunkFrom, chunkTo);

            foreach (var tile in map.tiles)
            {
                // _blocks.Add(tile.loc, BlockLoader.CreateBlock(tile.ter, tile.loc, this)); // tymalu: changed tile.ter to int type, so this does not work anymore
            }

            _created = true;
            sw.Stop();
            CreateTiming = sw;
        }
    public void UpdateEntities()
    {
        GameObject entitiesObj = GameObject.Find("entities");

        if (entitiesObj != null)
        {
            ClearGameObject(entitiesObj);
        }
        else
        {
            entitiesObj = new GameObject("entities");
        }

        Vector3Int playerPos = DDA.playerPos();
        int        size      = 60;
        Vector2Int from      = new Vector2Int(playerPos.x - size, playerPos.z - size);
        Vector2Int to        = new Vector2Int(playerPos.x + size, playerPos.z + size);

        Entity[] entities = DDA.GetEntities(from, to);
        Debug.Log("found " + entities.Length + " entities: ");
        foreach (var entity in entities)
        {
            Debug.Log(entity.name);
            string stringId;
            monIds.TryGetValue(entity.type, out stringId);
            string     name = stringId == null ? "mon_unknown" : stringId;
            GameObject obj  = new GameObject(name);
            obj.transform.parent = entitiesObj.transform;
            var pos = new Vector3(entity.loc.x, 0, entity.loc.y);
            obj.transform.Translate((pos - startingPoint) * tileSize);
            // probably should prepare GameObjects and do their clones instead
            var mr = obj.AddComponent <MeshRenderer>();
            var mf = obj.AddComponent <MeshFilter>();
            mf.sharedMesh     = voxModelsCache[name].ToMesh();
            mr.sharedMaterial = terrainMaterial;
            mf.sharedMesh.RecalculateNormals();
        }
    }
Beispiel #25
0
        public void Update()
        {
            var zoomDelta = Input.GetAxis("Mouse ScrollWheel");

            if (zoomDelta != 0f)
            {
                Game.Camera.AdjustZoom(zoomDelta);
            }

            if (Input.GetKeyDown(KeyCode.Q))
            {
                Game.Camera.AdjustRotation(1);
                //Game.Camera.AdjustRotation(rotationDelta);
            }
            if (Input.GetKeyDown(KeyCode.E))
            {
                Game.Camera.AdjustRotation(-1);
            }

            var xDelta = Input.GetAxis("Horizontal");
            var zDelta = Input.GetAxis("Vertical");

            if (xDelta != 0f || zDelta != 0f)
            {
                Game.Camera.AdjustPosition(xDelta, zDelta);
            }

            var sw      = Stopwatch.StartNew();
            var binding = Bindings.GetInputCommand();

            if (binding != null)
            {
                UnityEngine.Debug.Log(string.Format("Command for key is {0}", binding.DDACommand));
                DDA.doAction(binding.DDACommand);
            }
            sw.Stop();
            //UnityEngine.Debug.Log(string.Format("Found binding in {0}ms", sw.ElapsedMilliseconds));
        }
 //--------------------------------------
 public void SpawnLanes(int amountToSpawn, bool isInitialSpawn)
 {
     if (isInitialSpawn)
     {
         //GetComponent<BiomeClass> ().SwitchBiome (BiomeClass.Biomes.Start);
         gameManager = GameObject.FindGameObjectWithTag("Manager").GetComponent <GameManager> ();
         dDA         = GameObject.FindGameObjectWithTag("Manager").GetComponent <DDA> ();
         ResetLanes();
     }
     for (int i = 0; i < amountToSpawn; i++)
     {
         GameObject newLane = (GameObject)Instantiate(ChooseType(), new Vector3(0.75f, 0, spawnerZPos), Quaternion.identity);
         newLane.transform.parent = gameObject.transform;
         newLane.GetComponent <Lane>().OnLanePlaced();
         if (newLane.GetComponent <Lane>().laneType == LaneClass.LaneTypes.Road && lastLanePlaced == LaneClass.LaneTypes.Road)
         {
             PlaceRoadLines(spawnerZPos, newLane);
         }
         lastLanePlaced = newLane.GetComponent <Lane>().laneType;
         //setting the cells in the Grid Matrix
         for (int j = 0; j < LaneClass.laneWidth; j++)
         {
             clutterSpawner.Grid[amountOfLanesSpawned, j] = newLane.GetComponent <Lane>().cells[j];
             //telling clutter to be placed
             clutterSpawner.SpawnClutter(amountOfLanesSpawned, j);
         }
         dynamicPlacer.PlaceDynamics(newLane);
         clutterSpawner.SpawnExtras(newLane);
         spawnerZPos += ChosenLaneWidth(newLane.GetComponent <Lane>().laneType);
         amountOfLanesSpawned++;
         CheckBiome(amountOfLanesSpawned);
         DestroyOld(amountOfLanesSpawned - destroyLeway);
     }
     if (isInitialSpawn)
     {
         DonePrePlacing();
     }
 }
Beispiel #27
0
        DataTable IPlugin.GetTables(string database)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateTablesDataTable();

                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                IVistaDBTableNameCollection tables = db.GetTableNames();

                foreach (string table in tables)
                {
                    IVistaDBTableSchema tblStructure = db.TableSchema(table);

                    DataRow row = metaData.NewRow();
                    metaData.Rows.Add(row);

                    row["TABLE_NAME"]  = tblStructure.Name;
                    row["DESCRIPTION"] = tblStructure.Description;
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
Beispiel #28
0
        DataTable IPlugin.GetTableColumns(string database, string table)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateColumnsDataTable();

                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                ArrayList tables = db.EnumTables();

                IVistaDBTableSchema tblStructure = db.TableSchema(table);

                foreach (IVistaDBColumnAttributes c in tblStructure)
                {
                    string colName = c.Name;

                    string def = "";
                    if (tblStructure.Defaults.Contains(colName))
                    {
                        def = tblStructure.Defaults[colName].Expression;
                    }
                    int width     = c.MaxLength;                     //c.ColumnWidth;
                    int dec       = 0;                               //c.ColumnDecimals;
                    int length    = 0;
                    int octLength = width;

                    IVistaDBIdentityInformation identity = null;
                    if (tblStructure.Identities.Contains(colName))
                    {
                        identity = tblStructure.Identities[colName];
                    }

                    string[] pks = null;
                    if (tblStructure.Indexes.Contains("PrimaryKey"))
                    {
                        pks = tblStructure.Indexes["PrimaryKey"].KeyExpression.Split(';');
                    }
                    else
                    {
                        foreach (IVistaDBIndexInformation pk in tblStructure.Indexes)
                        {
                            if (pk.Primary)
                            {
                                pks = pk.KeyExpression.Split(';');
                                break;
                            }
                        }
                    }

                    System.Collections.Hashtable pkCols = null;
                    if (pks != null)
                    {
                        pkCols = new Hashtable();
                        foreach (string pkColName in pks)
                        {
                            pkCols[pkColName] = true;
                        }
                    }

                    switch (c.Type)
                    {
                    case VistaDBType.Char:
                    case VistaDBType.NChar:
                    case VistaDBType.NText:
                    case VistaDBType.NVarChar:
                    case VistaDBType.Text:
                    case VistaDBType.VarChar:
                        length = width;
                        width  = 0;
                        dec    = 0;
                        break;

                    case VistaDBType.Money:
                    case VistaDBType.Float:
                    case VistaDBType.Decimal:
                    case VistaDBType.Real:
                        break;

                    default:
                        width = 0;
                        dec   = 0;
                        break;
                    }

                    DataRow row = metaData.NewRow();
                    metaData.Rows.Add(row);

                    row["TABLE_NAME"]               = tblStructure.Name;
                    row["COLUMN_NAME"]              = c.Name;
                    row["ORDINAL_POSITION"]         = c.RowIndex;
                    row["IS_NULLABLE"]              = c.AllowNull;
                    row["COLUMN_HASDEFAULT"]        = def == string.Empty ? false : true;
                    row["COLUMN_DEFAULT"]           = def;
                    row["IS_AUTO_KEY"]              = identity == null ? false : true;
                    row["AUTO_KEY_SEED"]            = 1;
                    row["AUTO_KEY_INCREMENT"]       = identity == null ? 0 : Convert.ToInt32(identity.StepExpression);
                    row["TYPE_NAME"]                = c.Type.ToString();
                    row["NUMERIC_PRECISION"]        = width;
                    row["NUMERIC_SCALE"]            = dec;
                    row["CHARACTER_MAXIMUM_LENGTH"] = length;
                    row["CHARACTER_OCTET_LENGTH"]   = octLength;
                    row["DESCRIPTION"]              = c.Description;

                    string type = (string)row["TYPE_NAME"];
                    row["TYPE_NAME_COMPLETE"] = this.GetDataTypeNameComplete(type, length, (short)width, (short)dec);

                    if (c.Type == VistaDBType.Timestamp)
                    {
                        row["IS_COMPUTED"] = true;
                    }

                    row["IS_CONCURRENCY"] = type == "Timestamp" ? true : false;
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
Beispiel #29
0
    public Cell[][] ComputeMap(Cell[][] baseMap, Enemy[] enemies, List <List <Vector2> > cellsByEnemy)
    {
        Cell[][] im = new Cell[cellsX][];

        for (int x = 0; x < cellsX; x++)
        {
            im [x] = new Cell[cellsZ];
            for (int y = 0; y < cellsZ; y++)
            {
                im [x] [y] = baseMap [x] [y].Copy();
            }
        }

        for (int i = 0; i < enemies.Length; i++)
        {
            Enemy enemy = enemies [i];
            // For every enemy, get their direction and current world position and scale into IM scale
            Vector2 dir = new Vector2(enemy.GetSimulatedForward().x, enemy.GetSimulatedForward().z);

            // Convert enemy position into Grid Coordinates
            Vector2 pos = new Vector2((enemy.GetSimulationPosition().x - minX) / tileSizeX, (enemy.GetSimulationPosition().z - minZ) / tileSizeZ);
            Vector2 p   = new Vector2();

            for (int x = -1; x <= 1; x++)
            {
                for (int y = -1; y <= 1; y++)
                {
                    // Check map boundaries
                    if (Mathf.FloorToInt(pos.x + x) >= 0 && Mathf.FloorToInt(pos.x + x) < cellsX && Mathf.FloorToInt(pos.y + y) >= 0 && Mathf.FloorToInt(pos.y + y) < cellsZ)
                    {
                        // (everything  here is in world coord, so we must transform back from grid coord to world coord)
                        // If the distance from the position of the guy to the middle of the 4 cells around him is leseer than the radius, we paint those cells
                        if (Vector2.Distance(new Vector2(enemy.GetSimulationPosition().x, enemy.GetSimulationPosition().z), new Vector2((Mathf.Floor(pos.x + x) + tileSizeX) * tileSizeX + minX, (Mathf.Floor(pos.y + y) + tileSizeZ) * tileSizeZ + minZ)) < enemy.radius)
                        {
                            im [Mathf.FloorToInt(pos.x + x)] [Mathf.FloorToInt(pos.y + y)].seen = true;
                            cellsByEnemy [i].Add(new Vector2(pos.x + x, pos.y + y));
                        }
                    }
                }
            }

            // if tileSizeX != tileSizeZ we can be in big trouble!
            float dist = enemy.fovDistance / ((tileSizeX + tileSizeZ) / 2);

            DDA dda = new DDA(tileSizeX, tileSizeZ, cellsX, cellsZ);

            for (int x = 0; x < cellsX; x++)
            {
                for (int y = 0; y < cellsZ; y++)
                {
                    // Skip cells that are staticly blocked or seen by other enemies
                    // Don't skip cells seen by other enemies or we won't have the correct seenCells computed
                    if (im [x] [y].blocked || im [x] [y].safe)
                    {
                        continue;
                    }

                    // This enemy haven't seen it yet
                    bool seen = false;

                    for (int px = 0; px <= 1; px++)
                    {
                        for (int py = 0; py <= 1; py++)
                        {
                            // Destination of the ray
                            p.Set(x + px, y + py);

                            // Direction of the ray
                            Vector2 res = (p - pos).normalized;

                            // Is the target within our FoV?
                            if (Vector2.Distance(p, pos) < dist && Vector2.Angle(res, dir) < enemy.fovAngle)
                            {
                                // Check if target is seen by this enemy
                                seen = seen || dda.HasLOS(im, p, pos, res, x, y);
                            }
                        }
                    }

                    // If this enemy has seen it
                    if (seen)
                    {
                        cellsByEnemy [i].Add(new Vector2(x, y));
                    }

                    // Now take into account other enemies before modifying the cells value
                    im [x] [y].seen = im [x] [y].seen || seen;
                }
            }
        }
        return(im);
    }
Beispiel #30
0
 public void DoSceneTransition(string saveName)
 {
     DDA.loadSaveGame(CurrentWorld, saveName);
     SceneManager.LoadScene("main");
 }
Beispiel #31
0
    public Cell[][] ComputeMap(Cell[][] baseMap, Enemy[] enemies, List<List<Vector2>> cellsByEnemy)
    {
        Cell[][] im = new Cell[cellsX][];

        for (int x = 0; x < cellsX; x++) {
            im [x] = new Cell[cellsZ];
            for (int y = 0; y < cellsZ; y++) {
                im [x] [y] = baseMap [x] [y].Copy ();
            }
        }

        for (int i = 0; i < enemies.Length; i++) {
            Enemy enemy = enemies [i];
            // For every enemy, get their direction and current world position and scale into IM scale
            Vector2 dir = new Vector2 (enemy.GetSimulatedForward ().x, enemy.GetSimulatedForward ().z);

            // Convert enemy position into Grid Coordinates
            Vector2 pos = new Vector2 ((enemy.GetSimulationPosition ().x - minX) / tileSizeX, (enemy.GetSimulationPosition ().z - minZ) / tileSizeZ);
            Vector2 p = new Vector2 ();

            for (int x = -1; x <= 1; x++)
                for (int y = -1; y <= 1; y++)
                    // Check map boundaries
                    if (Mathf.FloorToInt (pos.x + x) >= 0 && Mathf.FloorToInt (pos.x + x) < cellsX && Mathf.FloorToInt (pos.y + y) >= 0 && Mathf.FloorToInt (pos.y + y) < cellsZ)
                        // (everything  here is in world coord, so we must transform back from grid coord to world coord)
                        // If the distance from the position of the guy to the middle of the 4 cells around him is leseer than the radius, we paint those cells
                    if (Vector2.Distance (new Vector2 (enemy.GetSimulationPosition ().x, enemy.GetSimulationPosition ().z), new Vector2 ((Mathf.Floor (pos.x + x) + tileSizeX) * tileSizeX + minX, (Mathf.Floor (pos.y + y) + tileSizeZ) * tileSizeZ + minZ)) < enemy.radius) {
                        im [Mathf.FloorToInt (pos.x + x)] [Mathf.FloorToInt (pos.y + y)].seen = true;
                        cellsByEnemy [i].Add (new Vector2 (pos.x + x, pos.y + y));
                    }

            // if tileSizeX != tileSizeZ we can be in big trouble!
            float dist = enemy.fovDistance / ((tileSizeX + tileSizeZ) / 2);

            DDA dda = new DDA(tileSizeX, tileSizeZ, cellsX, cellsZ);

            for (int x = 0; x < cellsX; x++) {
                for (int y = 0; y < cellsZ; y++) {

                    // Skip cells that are staticly blocked or seen by other enemies
                    // Don't skip cells seen by other enemies or we won't have the correct seenCells computed
                    if (im [x] [y].blocked || im [x] [y].safe)
                        continue;

                    // This enemy haven't seen it yet
                    bool seen = false;

                    for (int px = 0; px <= 1; px++) {
                        for (int py = 0; py <= 1; py++) {

                            // Destination of the ray
                            p.Set (x + px, y + py);

                            // Direction of the ray
                            Vector2 res = (p - pos).normalized;

                            // Is the target within our FoV?
                            if (Vector2.Distance (p, pos) < dist && Vector2.Angle (res, dir) < enemy.fovAngle) {

                                // Check if target is seen by this enemy
                                seen = seen || dda.HasLOS(im, p, pos, res, x, y);

                            }
                        }
                    }

                    // If this enemy has seen it
                    if (seen)
                        cellsByEnemy [i].Add (new Vector2 (x, y));

                    // Now take into account other enemies before modifying the cells value
                    im [x] [y].seen = im [x] [y].seen || seen;
                }
            }
        }
        return im;
    }
Beispiel #32
0
 public void OnLoadClick()
 {
     DestroyObjs();
     CurrentWorld    = null;
     _createdObjects = CreateButtonList(DDA.GetWorldNames(), OnWorldClick);
 }
Beispiel #33
0
 void Start()
 {
     _ints = this;
     //screen things
     Screen.orientation = ScreenOrientation.AutoRotation;
     //----
     gameManger = GetComponent<GameManager> ();
     adMan = GetComponent<AdMan> ();
     menuManager = GetComponent<MenuManager> ();
     dDA = GetComponent<DDA> ();
     currentGameState = GameStates.GameStart;
     SwitchGameState (GameStates.GameLoad);
 }
Beispiel #34
0
        DataTable IPlugin.GetForeignKeys(string database, string tableName)
        {
            DataTable        metaData = new DataTable();
            IVistaDBDatabase db       = null;

            try
            {
                metaData = context.CreateForeignKeysDataTable();

                using (VistaDBConnection cn = new VistaDBConnection(context.ConnectionString))
                {
                    db = DDA.OpenDatabase(this.GetFullDatabaseName(), VistaDBDatabaseOpenMode.NonexclusiveReadOnly, GetPassword(cn));
                }

                ArrayList tables = db.EnumTables();

                foreach (string table in tables)
                {
                    IVistaDBTableSchema tblStructure = db.TableSchema(table);

                    //==================================================================
                    // This works around a change that was made to the VistaDB provider
                    // It's ugly, we know
                    //==================================================================
                    IEnumerator enumerator = null;

                    if (useOldForeignKeyWay)
                    {
                        enumerator = tblStructure.ForeignKeys.GetEnumerator();
                    }
                    else
                    {
                        try
                        {
                            enumerator = tblStructure.ForeignKeys.Values.GetEnumerator();
                        }
                        catch
                        {
                            enumerator          = tblStructure.ForeignKeys.GetEnumerator();
                            useOldForeignKeyWay = true;
                        }
                    }

                    // Okay, now that the version issues are over we just use the 'enumerator'
                    while (enumerator.MoveNext())
                    {
                        IVistaDBRelationshipInformation relInfo = enumerator.Current as IVistaDBRelationshipInformation;

                        if (relInfo.ForeignTable != tableName && relInfo.PrimaryTable != tableName)
                        {
                            continue;
                        }

                        string fCols = relInfo.ForeignKey;
                        string pCols = String.Empty;

                        string primaryTbl = relInfo.PrimaryTable;
                        string pkName     = "";

                        using (IVistaDBTableSchema pkTableStruct = db.TableSchema(primaryTbl))
                        {
                            foreach (IVistaDBIndexInformation idxInfo in pkTableStruct.Indexes)
                            {
                                if (!idxInfo.Primary)
                                {
                                    continue;
                                }

                                pkName = idxInfo.Name;
                                pCols  = idxInfo.KeyExpression;
                                break;
                            }
                        }

                        string [] fColumns = fCols.Split(';');
                        string [] pColumns = pCols.Split(';');

                        for (int i = 0; i < fColumns.GetLength(0); i++)
                        {
                            DataRow row = metaData.NewRow();
                            metaData.Rows.Add(row);

                            row["PK_TABLE_CATALOG"] = GetDatabaseName();
                            row["PK_TABLE_SCHEMA"]  = DBNull.Value;
                            row["FK_TABLE_CATALOG"] = DBNull.Value;
                            row["FK_TABLE_SCHEMA"]  = DBNull.Value;
                            row["FK_TABLE_NAME"]    = tblStructure.Name;
                            row["PK_TABLE_NAME"]    = relInfo.PrimaryTable;
                            row["ORDINAL"]          = 0;
                            row["FK_NAME"]          = relInfo.Name;
                            row["PK_NAME"]          = pkName;
                            row["PK_COLUMN_NAME"]   = pColumns[i];
                            row["FK_COLUMN_NAME"]   = fColumns[i];

                            row["UPDATE_RULE"] = relInfo.UpdateIntegrity;
                            row["DELETE_RULE"] = relInfo.DeleteIntegrity;
                        }
                    }
                }
            }
            finally
            {
                if (db != null)
                {
                    db.Close();
                }
            }

            return(metaData);
        }
Beispiel #35
0
 void Start()
 {
     clutterSpawner = clutterSpawner.GetComponent<ClutterSpawner> ();
     dynamicPlacer = dynamicPlacer.GetComponent<DynamicPlacer> ();
     biome = GetComponent<BiomeClass> ();
     dDA = dDA.GetComponent<DDA> ();
     gameStats = gameStats.GetComponent<GameStats> ();
     if (GameObject.FindGameObjectWithTag ("Player")) {
         P = GameObject.FindGameObjectWithTag ("Player");
     }
     pChecker = LaneClass.playerSpawnLocation + new Vector3 (0, 0, 1.5f);
 }