コード例 #1
0
 public bool ExtendBound(ref Position bottomLeft, ref Position topRight)
 {
     using (Database.DatabaseManager db = new Database.DatabaseManager())
     {
         Position    tempMin = bottomLeft;
         Position    tempMax = topRight;
         int         step    = 10;
         List <Tile> tile    = db.Tile.Where(t => (((t.x <= tempMin.x && t.x > tempMin.x - step) ||
                                                    (t.x >= tempMax.x && t.x < tempMax.x + step)) &&
                                                   (t.y > tempMin.y - step && t.y < tempMax.y + step))
                                             ||
                                             (((t.y <= tempMin.y && t.y > tempMin.y - step) ||
                                               (t.y >= tempMax.y && t.y < tempMax.y + step)) &&
                                              (t.x > tempMin.x - step && t.x < tempMax.x + step))).ToList();
         foreach (Tile currentTile in tile)
         {
             currentTile.LoadTile();
             m_map.Add(currentTile.GetPosition(), currentTile);
         }
         bottomLeft.x -= step;
         topRight.x   += step;
         bottomLeft.y -= step;
         topRight.y   += step;
     }
     return((bottomLeft.x - topRight.x) > 100);
 }
コード例 #2
0
ファイル: Kingdom.cs プロジェクト: ZXYmania/Chevauchee
 protected void AddDuke(Character givenDuke)
 {
     using (Database.DatabaseManager db = new Database.DatabaseManager())
     {
         Nobility currentTitle = new Nobility(this, givenDuke, Title.Duke);
         db.SaveChanges();
     }
 }
コード例 #3
0
ファイル: Kingdom.cs プロジェクト: ZXYmania/Chevauchee
 public void Coronate(Character givenKing)
 {
     using (Database.DatabaseManager db = new Database.DatabaseManager())
     {
         Nobility currentTitle = new Nobility(this, givenKing, Title.King);
         db.SaveChanges();
     }
 }
コード例 #4
0
ファイル: Kingdom.cs プロジェクト: ZXYmania/Chevauchee
 private void SetEmperor(Character givenEmperor)
 {
     using (Database.DatabaseManager db = new Database.DatabaseManager())
     {
         Nobility currentTitle = new Nobility(this, givenEmperor, Title.Emperor);
         db.SaveChanges();
     }
 }
コード例 #5
0
ファイル: Domain.cs プロジェクト: ZXYmania/Chevauchee
 public Tile GetCapital()
 {
     using (Database.DatabaseManager db = new Database.DatabaseManager())
     {
         Tile capitalProperty = db.Tile.Single(t => t.domain == GetId());
         return(capitalProperty);
     }
 }
コード例 #6
0
ファイル: Kingdom.cs プロジェクト: ZXYmania/Chevauchee
 public void AcceptFealty(Character givenCharacter)
 {
     givenCharacter.SwearFealty();
     using (Database.DatabaseManager db = new Database.DatabaseManager())
     {
         db.Nobility.Where(n => n.kingdom == id && n.character == givenCharacter.id);
         AddDuke(givenCharacter);
     }
 }
コード例 #7
0
ファイル: TestMain.cs プロジェクト: ZXYmania/Chevauchee
    public void CreateGameState()
    {
        m_map = new Map();
        using (Database.DatabaseManager db = new Database.DatabaseManager())
        {
            if (db.Database.EnsureCreated())
            {
                environmentCharacter = new Character("Environment");
                environmentDomain    = new Domain("Environment", environmentCharacter);
                db.Character.Add(environmentCharacter);
                db.Domain.Add(environmentDomain);
                db.SaveChanges();
                m_map.GenerateMap();
            }
            else
            {
                Debug.Log("Map has NOT been loaded");
            }
        }
        m_player = new Player[] { gameObject.AddComponent <Player>() };
        Character firstPlayer = new Character("Trajan");

        m_player[0].Initialise(firstPlayer);

        /*CharacterDictionary.AddCharacter("Hannibal");
         * CharacterDictionary.AddCharacter("Trajan");
         * CharacterDictionary.AddCharacter("Pompeii");
         * CharacterDictionary.AddCharacter("Caeser");
         * CharacterDictionary.AddCharacter("Darius");
         *
         * KingdomDictionary.AddKingdom("Persia", "Darius");
         * KingdomDictionary.AddKingdom("Rome", "Trajan");
         * Kingdom rome = KingdomDictionary.GetKingdom("Rome");
         * rome.AcceptFealty(CharacterDictionary.GetCharacter("Pompeii"));
         * rome.AcceptFealty(CharacterDictionary.GetCharacter("Caeser"));
         * KingdomDictionary.AddKingdom("Carthage", "Hannibal");
         *
         * DomainDictionary.AddDomain("Carthage", CharacterDictionary.GetCharacter("Hannibal"));
         * DomainDictionary.AddDomain("Ravenna", CharacterDictionary.GetCharacter("Trajan"));
         * DomainDictionary.AddDomain("Milan", CharacterDictionary.GetCharacter("Caeser"));
         * DomainDictionary.AddDomain("Ostia", CharacterDictionary.GetCharacter("Trajan"));
         * DomainDictionary.AddDomain("Persia", CharacterDictionary.GetCharacter("Darius"));
         *
         * Trade.Initialise();
         * try
         * {
         *  //Trade.StartTradeKingdom("Rome");
         * }
         * catch (TileOutofBoundsException e)
         * {
         *  Debug.Log("Domain trade is unimplemented");
         * }
         * m_player = new Player[] { gameObject.AddComponent<Player>() };
         * m_player[0].Initialise(CharacterDictionary.GetCharacter("Trajan"));*/
    }
コード例 #8
0
 public static void Initialise()
 {
     m_network = new TradeNetwork[1] {
         new TradeNetwork()
     };
     using (Database.DatabaseManager db = new Database.DatabaseManager())
     {
         Character currentCharacter = TestMain.GetPlayer().GetCharacter();
         throw new NotImplementedException();
         //m_network[0].AddKingdom(db.Kingdom.Single(k => k.king.Contains(currentCharacter.id)));
     }
 }
コード例 #9
0
ファイル: Kingdom.cs プロジェクト: ZXYmania/Chevauchee
 public List <Domain> GetDomain()
 {
     using (Database.DatabaseManager db = new Database.DatabaseManager())
     {
         List <Domain> allDomain = (from d in db.Domain
                                    join c in db.Character
                                    on d.character equals c.id
                                    join n in db.Nobility
                                    on c.id equals n.character
                                    where n.kingdom == id
                                    select d).ToList();
         return(allDomain);
     }
 }
コード例 #10
0
    public void CreateMapDataBase()
    {
        SpriteMap oceanMap = TextureController.GetAnimations("Mediterranean_map", Color.black);

        Color[] mapPixel = oceanMap.GetAnimation(0).GetSprite(0).texture.GetPixels();
        MAPWIDTH  = (int)oceanMap.GetAnimation(0).GetSprite(0).texture.width;
        MAPHEIGHT = (int)oceanMap.GetAnimation(0).GetSprite(0).texture.height;
        using (Database.DatabaseManager db = new Database.DatabaseManager())
        {
            for (int i = 0; i < mapPixel.Length; i++)
            {
                Color        currentColour = mapPixel[i];
                int          currX         = (i % MAPWIDTH) - 1;
                int          currY         = (Mathf.FloorToInt(i / MAPWIDTH)) - 1;
                Tile.Terrain currTerrain;
                if (currX > 0 && currY > 0 && currX < MAPWIDTH - 2 && currY < MAPHEIGHT - 2)
                {
                    if (mapPixel[i] == Color.black)
                    {
                        currTerrain = Tile.Terrain.ocean;
                    }
                    else
                    {
                        int probability = UnityEngine.Random.Range(0, 10);
                        if (probability < 4)
                        {
                            currTerrain = Tile.Terrain.smooth;
                        }
                        else if (probability < 7)
                        {
                            currTerrain = Tile.Terrain.forest;
                        }
                        else if (probability < 9)
                        {
                            currTerrain = Tile.Terrain.rough;
                        }
                        else
                        {
                            currTerrain = Tile.Terrain.mountain;
                        }
                    }
                    db.Tile.Add(new Tile(currX, currY, currTerrain, TestMain.environmentDomain));
                }
            }
            db.SaveChanges();
        }
    }
コード例 #11
0
ファイル: Domain.cs プロジェクト: ZXYmania/Chevauchee
    public ResourceList GetMaintenance()
    {
        ResourceList totalmaintenance = new ResourceList();

        using (Database.DatabaseManager db = new Database.DatabaseManager())
        {
            List <Tile> m_tile = db.Tile.Where(t => t.domain == GetId()).ToList();
            foreach (Tile currTile in m_tile)
            {
                Building[] currentBuilding = currTile.GetBuildings();
                for (int i = 0; i < currentBuilding.Length; i++)
                {
                    totalmaintenance.Add(currentBuilding[i].GetMaintenance());
                }
            }
        }
        return(totalmaintenance);
    }
コード例 #12
0
ファイル: Domain.cs プロジェクト: ZXYmania/Chevauchee
    public ResourceList GetProduction()
    {
        ResourceList totalproduction = new ResourceList();

        using (Database.DatabaseManager db = new Database.DatabaseManager())
        {
            List <Tile> m_tile = db.Tile.Where(t => t.domain == GetId()).ToList();
            foreach (Tile currTile in m_tile)
            {
                Building[] currentBuilding = currTile.GetBuildings();
                for (int i = 0; i < currentBuilding.Length; i++)
                {
                    if (currentBuilding[i] is Industrial)
                    {
                        totalproduction.Add(((Industrial)currentBuilding[i]).ProduceResource());
                    }
                }
            }
        }
        return(totalproduction);
    }
コード例 #13
0
    public void CreateMapView(ref Position bottomLeft, ref Position topRight)
    {
        int step = 50;

        bottomLeft.x -= step;
        bottomLeft.y -= step;
        topRight.x   += step;
        topRight.y   += step;
        Position tempMin = bottomLeft;
        Position tempMax = topRight;

        using (Database.DatabaseManager db = new Database.DatabaseManager())
        {
            List <Tile> grid = db.Tile.Where(t => t.x > tempMin.x && t.y > tempMin.y && t.x < tempMax.x && t.y < tempMax.y).ToList();
            foreach (Tile currentTile in grid)
            {
                currentTile.LoadTile();
                m_map.Add(currentTile.GetPosition(), currentTile);
            }
        }
        //Task.Run(() => ExtendBound(bottomLeft, topRight));
    }
コード例 #14
0
 private void ManageDatabase(object sender, EventArgs e)
 {
     Database.DatabaseManager form = new Database.DatabaseManager();
     form.TopMost = true;
     form.Show();
 }