Exemplo n.º 1
0
 public Tribe
 (
     byte id,
     Headquarter hq
 )
 {
     this.Id = id;
     this.HQ = hq;
     this.CurrentBuildings = new Dictionary <Type, int> {
         { typeof(Woodcutter), 0 },
         { typeof(LandRoad), 0 },
         { typeof(Storage), 0 },
         { typeof(Quarry), 0 },
         { typeof(CoalMine), 0 },
         { typeof(Smelter), 0 },
         { typeof(Bridge), 0 },
         { typeof(Market), 0 },
         { typeof(Fisher), 0 },
         { typeof(WheatFarm), 0 },
         { typeof(CowFarm), 0 },
         { typeof(Bakery), 0 },
         { typeof(Butcher), 0 },
         { typeof(Tanner), 0 },
         { typeof(Barracks), 0 }
     };
 }
Exemplo n.º 2
0
        public static bool VerifyBuildHQ(HexCoordinates coords, Headquarter hq, Player player)
        {
            HexCell cell = grid.GetCell(coords);

            if (hq == null)
            {
                return(false);
            }

            if (!PlayerInRange(coords, player))
            {
                return(false);
            }

            hq.Tribe = (byte)Tribes.Count;

            //check if the building can be placed at the position
            if (!hq.IsPlaceable(cell))
            {
                return(false);
            }

            if (player.Tribe != null)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public static void HandleBuildHQ(int fromClient, Packet packet)
        {
            int clientIDCheck = packet.ReadInt();

            if (fromClient != clientIDCheck)
            {
                Console.WriteLine($"Player with ID: \"{fromClient}\" has assumed the wrong client ID: \"{clientIDCheck}\"!");
            }

            Player player = Server.clients[fromClient].Player;

            HexCoordinates coordinates = packet.ReadHexCoordinates();
            Headquarter    hq          = new Headquarter();

            if (GameLogic.VerifyBuildHQ(coordinates, hq, player))
            {
                Tribe tribe = GameLogic.ApplyBuildHQ(coordinates, hq);
                player.Tribe = tribe;
                ServerSend.BroadcastApplyBuildHQ(coordinates);
                ServerSend.BroadcastPlayer(player);
                Console.WriteLine("Player: " + player.Name + " successfully placed a HQ.");
            }
            else
            {
                Console.WriteLine("Player: " + player.Name + " failed to build HQ");
            }
            Server.SaveGame();
        }
Exemplo n.º 4
0
        public static Tribe AddTribe(byte tribeID, Headquarter hq)
        {
            Tribe newTribe = new Tribe(tribeID, hq);

            Tribes.Add(newTribe);
            return(newTribe);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a headquarter to track
        /// </summary>
        public void Create(Team team)
        {
            Headquarter newhq = new Headquarter(team, 0, _bountyLevels);

            newhq.LevelModify += onLevelModify;
            _headquarters.Add(newhq);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Headquarter headquarter = db.Headquarters.Find(id);

            db.Headquarters.Remove(headquarter);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "city_id,city_name,headquarter_address,state,time_start")] Headquarter headquarter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(headquarter).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(headquarter));
 }
 public ActionResult Edit([Bind(Include = "HeadquartersId,Name,Address,Phone")] Headquarter headquarter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(headquarter).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(headquarter));
 }
        public ActionResult Create([Bind(Include = "HeadquartersId,Name,Address,Phone")] Headquarter headquarter)
        {
            if (ModelState.IsValid)
            {
                db.Headquarters.Add(headquarter);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(headquarter));
        }
Exemplo n.º 10
0
 public Tribe
 (
     byte id,
     Headquarter hq,
     Dictionary <Type, int> currentBuildings
 )
 {
     this.Id = id;
     this.HQ = hq;
     this.CurrentBuildings = currentBuildings;
 }
        private void SpawnHeadquarter(Tile tile)
        {
            EntityFactory factory = new EntityFactory();

            _headquarter = factory.Create(EntityId.Headquarter, this) as Headquarter;
            _headquarter.SetWhenIsKilledCallback(NotifyWhenEntityIsKilled);

            _entitiesList.Add(_headquarter);
            tile.SetAiEntity(_headquarter);
            StrengthController.GainTerritory();
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "city_id,city_name,headquarter_address,state,time_start")] Headquarter headquarter)
        {
            if (ModelState.IsValid)
            {
                db.Headquarters.Add(headquarter);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(headquarter));
        }
Exemplo n.º 13
0
        public void Create(HeadquarterWithoutIdModel model)
        {
            var newHeadquarter = new Headquarter
            {
                Id      = Guid.NewGuid().ToString(),
                Country = model.Country,
                City    = model.City,
                Street  = model.Street
            };

            db.Headquarters.Add(newHeadquarter);

            db.SaveChanges();
        }
        // GET: Headquarters/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Headquarter headquarter = db.Headquarters.Find(id);

            if (headquarter == null)
            {
                return(HttpNotFound());
            }
            return(View(headquarter));
        }
Exemplo n.º 15
0
    public static Headquarter GetHeadquarterEarly(Vector3 position, Player player)
    {
        float       distance = float.MaxValue;
        Headquarter target   = null;

        foreach (var headquarter in headquarters)
        {
            if (player == headquarter.Player && Vector3.Distance(headquarter.transform.position, position) < distance)
            {
                target   = headquarter;
                distance = Vector3.Distance(headquarter.transform.position, position);
            }
        }

        return(target);
    }
Exemplo n.º 16
0
 public static Headquarter Instance()
 {
     if (instance != null)
         return instance;
     lock (instance_lock)
     {
         instance = (Headquarter)FindObjectOfType(typeof(Headquarter));
         if (FindObjectsOfType(typeof(Headquarter)).Length > 1)
         {
             Debug.LogError("There can only be one instance!");
             return instance;
         }
         if (instance != null)
             return instance;
         Debug.LogError("Could not find a instance!");
         return null;
     }
 }
Exemplo n.º 17
0
        public static Tribe ApplyBuildHQ(HexCoordinates coords, Headquarter hq)
        {
            HexCell cell = grid.GetCell(coords);

            if (cell.Structure != null)
            {
                DestroyStructure(coords);
            }
            cell.Structure = hq;
            hq.Cell        = cell;

            Tribe tribe = AddTribe((byte)Tribes.Count, hq);

            hq.Tribe = tribe.Id;

            AddStructureToList(hq);

            ComputeConnectedStorages();

            return(tribe);
        }
Exemplo n.º 18
0
        public void CreateCompanyAndHeadquarter(CompanyAndHeadquarterModel model)
        {
            var newHeadquarter = new Headquarter
            {
                Id      = Guid.NewGuid().ToString(),
                Country = model.Country,
                City    = model.City,
                Street  = model.Street
            };

            var newCompany = new Company
            {
                Id            = Guid.NewGuid().ToString(),
                Name          = model.Name,
                HeadquarterId = newHeadquarter.Id
            };

            db.Headquarters.Add(newHeadquarter);
            db.Companies.Add(newCompany);

            db.SaveChanges();
        }
Exemplo n.º 19
0
 private void OnValidate()
 {
     headquarter = GetComponentInParent <Headquarter>();
 }
Exemplo n.º 20
0
 internal void SetHeadquarter(Headquarter headquarter)
 {
     this.headquarter = headquarter;
 }