Example #1
0
        public static Resource getResource(City cityOwner, Resource pattern, App.Textures texture, App.Textures readyTexture, int x, int y)
        {
            Resource r = new Resource(cityOwner, pattern.everyTurn_productionBoost, pattern.firstTurn_productionBoost, pattern.cost, readyTexture, texture, pattern.destroyAfterDone, x, y, 1);

            r.type = pattern == resources[1] ? 1 : 0;
            return(r);
        }
Example #2
0
 private RecruitTent(Player owner, App.Textures texture, int x, int y, int z = 1)
 {
     this.owner   = owner;
     this.x       = x;
     this.y       = y;
     this.z       = z;
     this.texture = texture;
 }
Example #3
0
 public City(Player owner, App.Textures texture, string name, int x, int y, int z)
 {
     this.owner      = owner;
     this.Name       = name;
     this.Level      = 0;
     this.Production = 1;
     this.Currpop    = 0;
     this.x          = x;
     this.y          = y;
     this.z          = z;
     this.texture    = texture;
 }
Example #4
0
 private Resource(City cityOwner, int et_prodBoost, int ft_prodBoost, int cost, App.Textures readyTexture, App.Textures texture, bool destroyAfterDone, int x, int y, int z)
 {
     this.cityOwner = cityOwner;
     this.owner     = cityOwner == null ? null : cityOwner.owner;
     this.ready     = false;
     this.everyTurn_productionBoost = et_prodBoost;
     this.firstTurn_productionBoost = ft_prodBoost;
     this.cost             = cost;
     this.readyTexture     = readyTexture;
     this.texture          = texture;
     this.x                = x;
     this.y                = y;
     this.z                = z;
     this.destroyAfterDone = destroyAfterDone;
 }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type">Type of terain, see enum [Types]</param>
        public Terrain(int type, App.Textures texture, int x, int y, int z, bool makeFog, int numberOfPlayers)
        {
            this.type    = type;
            this.texture = texture;
            this.x       = x;
            this.y       = y;
            this.z       = z;
            List <bool> fog = new List <bool>();

            for (int i = 0; i < numberOfPlayers; i++)
            {
                fog.Add(makeFog);
            }
            isFogForPlayers = fog.ToArray();
        }
Example #6
0
        public override void loadFromString(string save)
        {
            string[] s = save.Split(separator);
            ready        = s[1] == "True";
            texture      = (App.Textures) int.Parse(s[2]);
            readyTexture = (App.Textures) int.Parse(s[3]);
            x            = int.Parse(s[4]);
            y            = int.Parse(s[5]);
            z            = 1;
            type         = int.Parse(s[6]);
            Resource pattern = resources[type];

            everyTurn_productionBoost = pattern.everyTurn_productionBoost;
            firstTurn_productionBoost = pattern.firstTurn_productionBoost;
            cost             = pattern.cost;
            destroyAfterDone = pattern.destroyAfterDone;
        }
Example #7
0
 private Unit(Player owner, string name, int maxhp, int turns, int attack, int defense, int cost, Ability ability, App.Textures texture, App.Textures weaponTexture, int[] reqResearch, int x, int y, int z)
 {
     this.owner         = owner;
     this.name          = name;
     this.hp            = maxhp;
     this.maxhp         = maxhp;
     this.turns         = 0;
     this.maxturns      = turns;
     this.attack        = attack;
     this.defense       = defense;
     this.cost          = cost;
     this.ability       = ability;
     this.level         = 0;
     this._exp          = 0;
     this.canAttack     = false;
     this.alive         = true;
     this.texture       = texture;
     this.weaponTexture = weaponTexture;
     this.reqResearch   = reqResearch;
     this.x             = x;
     this.y             = y;
     this.z             = z;
 }
Example #8
0
        public static RecruitTent Build(Player p, int x, int y)
        {
            if (p.resources >= price && (Game.game.Map[x, y, 0] as Terrain).type == (int)Terrain.Types.Land && Game.game.Map[x, y, 1] == null && Game.game.Map[x, y, 2] != null && (Game.game.Map[x, y, 2] as Unit).owner == p)
            {
                p.resources -= price;
                App.Textures t = App.Textures.border;
                switch (p.color)
                {
                case 0:
                    t = App.Textures.city_recruitTent_blue;
                    break;

                case 1:
                    t = App.Textures.city_recruitTent_red;
                    break;

                case 2:
                    t = App.Textures.city_recruitTent_green;
                    break;

                case 3:
                    t = App.Textures.city_recruitTent_yellow;
                    break;
                }

                if (p == Game.game.players[0])
                {
                    Achievement.recruitTentsBuilt++;
                    Achievement.Check();
                }

                return(new RecruitTent(p, t, x, y));
            }

            return(null);
        }
Example #9
0
 public override void loadFromString(string save)
 {
     string[] s = save.Split(separator);
     owner         = Game.game.players[int.Parse(s[0])];
     name          = s[1];
     maxhp         = int.Parse(s[2]);
     hp            = int.Parse(s[3]);
     maxturns      = int.Parse(s[4]);
     turns         = int.Parse(s[5]);
     attack        = int.Parse(s[6]);
     defense       = int.Parse(s[7]);
     cost          = int.Parse(s[8]);
     ability       = (Ability)int.Parse(s[9]);
     texture       = (App.Textures) int.Parse(s[10]);
     weaponTexture = (App.Textures) int.Parse(s[11]);
     reqResearch   = getReqResearches(s[12]);
     x             = int.Parse(s[13]);
     y             = int.Parse(s[14]);
     z             = int.Parse(s[15]);
     _exp          = int.Parse(s[16]);
     level         = int.Parse(s[17]);
     canAttack     = s[18] == "True";
     alive         = s[19] == "True";
 }
Example #10
0
        public static void Load(string save)
        {
            Stopwatch stop = null;

            if (App.debug)
            {
                stop = new Stopwatch();
                stop.Start();
            }

            App.isAnnounceEnabled = false;

            Achievement.Load();

            string[] mainParts = save.Split(basicSeparator);
            Game     g         = new Game(64, "", 2, false, false);

            g.fromString(mainParts[1]);
            Game.game.players.Clear();

            foreach (string s in mainParts[0].Split(listSeparator))
            {
                Player p = new Player();
                p.fromString(s);
                Game.game.players.Add(p);
            }

            // Load map part
            foreach (string s in mainParts[2].Split(listSeparator))
            {
                string[]  a = s.Split(insideSeparator);
                MapObject m = null;
                switch (int.Parse(a[0]))
                {
                case (int)moTypes.City:
                    m = new City();
                    break;

                case (int)moTypes.RecruitTent:
                    m = new RecruitTent();
                    break;

                case (int)moTypes.Resource:
                    m = new Resource();
                    break;

                case (int)moTypes.Terrain:
                    m = new Terrain();
                    break;

                case (int)moTypes.Unit:
                    m = new Unit();
                    break;
                }
                m.loadFromString(a[1]);
                Game.game.Map[m.x, m.y, m.z] = m;
            }

            // I hate javascript
            App.Textures tile0_0textureWas = Game.game.Map[0, 0, 0].texture;

            foreach (string s in mainParts[2].Split(listSeparator))
            {
                string[]  a = s.Split(insideSeparator);
                MapObject m = null;
                switch (int.Parse(a[0]))
                {
                case (int)moTypes.City:
                    m = new City();
                    break;

                case (int)moTypes.RecruitTent:
                    m = new RecruitTent();
                    break;

                case (int)moTypes.Resource:
                    m = new Resource();
                    break;

                case (int)moTypes.Terrain:
                    m = new Terrain();
                    break;

                case (int)moTypes.Unit:
                    m = new Unit();
                    break;
                }
                m.loadFromStringSecondRound(a[1]);

                Game.game.Map[m.x, m.y, m.z] = m;
            }

            // I hate javascript
            Game.game.Map[0, 0, 0].texture = tile0_0textureWas;

            App.isAnnounceEnabled = true;

            if (App.debug)
            {
                stop.Stop();
                Bridge.Script.Call("console.log", "Loading game took ms: " + stop.ElapsedMilliseconds);
                stop = null;
            }
        }
Example #11
0
 public Point getSubImageCoords(App.Textures texture)
 {
     return(new Point((int)texture * (int)App.textureMapTextureLength, 0));
 }
Example #12
0
 /// <summary>
 /// Create new unit
 /// </summary>
 /// <param name="owner">Player as owner of unit</param>
 /// <param name="pattern">Pattern, unit stats will be copied from this pattern. Get patterns from Unit.units array</param>
 /// <returns></returns>
 public static Unit getUnit(Player owner, App.Textures texture, Unit pattern, int x, int y)
 {
     return(new Unit(owner, pattern.name, pattern.maxhp, pattern.maxturns, pattern.attack, pattern.defense, pattern.cost, pattern.ability, texture, pattern.weaponTexture, pattern.reqResearch, x, y, 2));
 }