Exemple #1
0
        public void OrdersUpdate(GameTime gt, LocalUnits lh, SectorMap smap)
        {
            ClearingOrders(lh);
            GivingOrders(lh);
            MakingOrders(gt, lh, smap);

            s10 += gt.ElapsedGameTime;
            if (s10.TotalSeconds >= 1) {
                s10 -= TimeSpan.FromSeconds(1);
                foreach (Order order in N) {
                    order.sleep = false;
                }
            }
        }
Exemple #2
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            lineBatch = new LineBatch(GraphicsDevice);

            base.LoadContent();
            object_tex = ContentLoad(@"Textures\Objects\Blocks\Blocks");

            texatlas = Content.Load<Texture2D>(@"Textures\BlocktexAtlas");
            Commons.TextureAtlas.Y = texatlas.Height;
            Commons.TextureAtlas.X = texatlas.Width;

            var temp = new Texture2D[5];
            for (int i = 0; i <= 4; i++) {
                temp[i] =
                    ContentLoad(@"Textures\Objects\OnStore\wood_log" + (i + 1));
            }
            onstore_tex.Add(OnStoreTexes.Wood_log, temp);

            temp = new Texture2D[5];
            for (int i = 0; i <= 4; i++) {
                temp[i] = ContentLoad(@"Textures\Objects\OnStore\stone" + (i + 1));
            }
            onstore_tex.Add(OnStoreTexes.Stone, temp);

            LoadTexture2D(unit_tex, @"Textures\transparent_pixel"); //0
            LoadTexture2D(unit_tex, @"Textures\Units\human1"); //1
            LoadTexture2D(unit_tex, @"Textures\Units\human2"); //2
            LoadTexture2D(unit_tex, @"Textures\Units\human3"); //3

            LoadTexture2D(interface_tex, @"Textures\Interface\Selector2"); //0
            LoadTexture2D(interface_tex, @"Textures\Interface\PointBar"); //1
            LoadTexture2D(interface_tex, @"Textures\Interface\Selector3_1"); //2
            LoadTexture2D(interface_tex, @"Textures\Interface\Selector3_2"); //3
            LoadTexture2D(interface_tex, @"Textures\Interface\dig"); //4
            LoadTexture2D(interface_tex, @"Textures\Interface\digpit"); //5
            LoadTexture2D(interface_tex, @"Textures\Interface\Int_up"); //6
            LoadTexture2D(interface_tex, @"Textures\Interface\Int_10x50"); //7
            LoadTexture2D(interface_tex, @"Textures\Interface\Int_10x100"); //8
            LoadTexture2D(interface_tex, @"Textures\Interface\Int_1x15"); //9
            LoadTexture2D(interface_tex, @"Textures\Interface\Int_left"); //10
            LoadTexture2D(interface_tex, @"Textures\Interface\Int_10x10"); //11
            LoadTexture2D(interface_tex, @"Textures\Interface\Int_5x5"); //12
            LoadTexture2D(interface_tex, @"Textures\Interface\Int_5x5cross"); //13
            LoadTexture2D(interface_tex, @"Textures\Interface\Int_5x5pike"); //14
            LoadTexture2D(interface_tex, @"Textures\Interface\mork1"); //15
            LoadTexture2D(interface_tex, @"Textures\Interface\Saving"); //16
            LoadTexture2D(interface_tex, @"Textures\Interface\Building_41x28_16fr"); //17
            LoadTexture2D(interface_tex, @"Textures\Interface\build"); //18
            LoadTexture2D(interface_tex, @"Textures\Interface\supply"); //19

            gears = new List<Texture2D>();
            gears.Add(Content.Load<Texture2D>(@"Textures\Interface\g1"));
            gears.Add(Content.Load<Texture2D>(@"Textures\Interface\g2"));
            gears.Add(Content.Load<Texture2D>(@"Textures\Interface\g3"));

            g1r = gears[0].Height/2;
            g2r = gears[1].Height/2;
            g3r = gears[2].Height/2;

            Font1 = Content.Load<SpriteFont>(@"Textures\SpriteFont1");
            Font2 = Content.Load<SpriteFont>(@"Textures\SpriteFont2");

            dbobject = new DB_LMO(); //!!!!
            dbcreatures = new DB_LMC(); //!!!!
            //buildings = new Stores(); //!!!!
            gmap = new GMap(); //!!!!

            WindowsDesigner();

            var blockeffect = Content.Load<Effect>(@"Effects\SolidBlockEffect");

            smap = new SectorMap(GraphicsDevice, blockeffect);
            imap = new IntersectMap();

            players.Add(new Player(GraphicsDevice, texatlas, "Player us"));
            player_us = players[0];

            MeTexoncurA = 1;
            MeTexoncurB = 5;
        }
Exemple #3
0
        private void MakingOrders(GameTime gt, LocalUnits lh, SectorMap smap)
        {
            for (int o = 0; o < lh.N.Count; o++) {
                LocalUnit h = lh.N[o];
                if (h.CurrentOrder is DestroyOrder && IsNear(h.Pos, h.CurrentOrder.dest)) {
                    smap.At(h.CurrentOrder.dest.X, h.CurrentOrder.dest.Y, h.CurrentOrder.dest.Z).Health -=
                        (float) (10*gt.TotalGameTime.TotalSeconds);
                    if (
                        smap.At(h.CurrentOrder.dest.X, h.CurrentOrder.dest.Y, h.CurrentOrder.dest.Z).Health <= 0) {
                        Main.smap.KillBlock((int) h.CurrentOrder.dest.X, (int) h.CurrentOrder.dest.Y,
                                            (int) h.CurrentOrder.dest.Z);
                        h.CurrentOrder.complete = true;
                        h.CurrentOrder = new NothingOrder();
                    }
                }

                if (h.CurrentOrder is CollectOrder && IsNear(h.Pos, h.CurrentOrder.dest)) {
                    //var temp = Main.localitems.GetNearItem(h.pos);
                    if ((h.CurrentOrder as CollectOrder).tocollect.id != 0 && h.Carry.id == 0) {
                        //if (Main.localitems.n.Contains((h.current_order as CollectOrder).tocollect))
                        //{
                        h.Carry.id = (h.CurrentOrder as CollectOrder).tocollect.id;
                        h.Carry.count = (h.CurrentOrder as CollectOrder).tocollect.count;

                        Main.localitems.n.Remove((h.CurrentOrder as CollectOrder).tocollect);

                        h.CurrentOrder.complete = true;

                        if (Main.globalstorage.n.Count > 0) {
                            Vector3 st = Main.globalstorage.GetFreeStorage();
                            if (st != new Vector3(-1)) {
                                h.CurrentOrder = new ToStoreOrder {dest = st};
                                Main.AddToLog("ToStoreOrder patch find for " + h.Pos + " " + h.Patch.Count);
                                h.Patch = Main.smap.FindPatch(h.Pos, st);
                                (h.CurrentOrder as ToStoreOrder).storagepos = st;
                            }
                        }
                        //}
                    }
                }

                //if (h.current_order is ToStoreOrder && IsNear(h.pos, h.current_order.dest))
                //{
                //    if (h.carry.id != 0)
                //    {
                //        Vector3 st = (h.current_order as ToStoreOrder).storagepos;
                //        LocalItems tempstor = Main.mmap.n[(int)st.X, (int)st.Y, (int)st.Z].tags["storage"] as LocalItems;
                //        if (tempstor.n.Count < tempstor.carp)
                //        {
                //            tempstor.n.Add(new LocalItem() { count = h.carry.count, id = h.carry.id });
                //            h.carry = new LocalItem();
                //            h.current_order = new NothingOrder();
                //        }
                //        else
                //        {
                //            Main.localitems.n.Add(new LocalItem() { count = h.carry.count, id = h.carry.id });
                //            h.carry = new LocalItem();
                //            h.current_order = new NothingOrder();
                //        }
                //    }
                //}

                if (h.CurrentOrder is BuildOrder && IsNear(h.Pos, h.CurrentOrder.dest)) {
                    bool allow = true;
                    foreach (LocalUnit he in lh.N) {
                        if ((int) he.Pos.X == (int) h.CurrentOrder.dest.X &&
                            (int) he.Pos.Z == (int) h.CurrentOrder.dest.Z &&
                            (int) he.Pos.Z == (int) h.CurrentOrder.dest.Z) {
                            allow = false;
                        }
                    }
                    if (Main.smap.At(h.CurrentOrder.dest).BlockID == 0 && allow &&
                        Main.iss.n[(h.CurrentOrder as BuildOrder).blockID].count >= 1) {
                        Main.smap.SetBlock(h.CurrentOrder.dest, (h.CurrentOrder as BuildOrder).blockID);
                        Main.iss.n[(h.CurrentOrder as BuildOrder).blockID].count--;
                        h.CurrentOrder.complete = true;
                        h.CurrentOrder = new NothingOrder();
                    }
                }

                if (h.IddleTime >= TimeSpan.FromSeconds(10)) {
                    h.CurrentOrder.taken = false;
                    h.CurrentOrder.sleep = true;
                    h.CurrentOrder = new NothingOrder();
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// заменить всем id, которых нет в базе, но есть на карте, на блоки ошибки, которые ничего не делают, но не убивают игру
 /// </summary>
 /// <param name="map"></param>
 public static void PrepairMapDeleteWrongIDs(ref SectorMap map)
 {
     int a;
     for (int i = 0; i < map.N.Length; i++) {
         for (int j = 0; j < map.N[i].N.Length; j++) {
             a = map.N[i].N[j].BlockID;
             if (!dbobject.Data.ContainsKey(a)) {
                 map.N[i].N[j] = new MError(a);
             }
         }
     }
 }