Exemplo n.º 1
0
        public static void Starved(Settler settler)
        {
            var contents = "{0}" + Console.Color(" starved today!", ConsoleColor.DarkRed);

            contents = string.Format(contents, Console.Color(settler.Name, SettlerColor));
            EventManager.AddEvent(new Event(contents, EventType.SettlerStarved));
        }
Exemplo n.º 2
0
        public static void Ate(Settler settler, Resource resource)
        {
            var contents = "{0} ate some {1}";

            contents = string.Format(contents, Console.Color(settler.Name, SettlerColor), resource);
            EventManager.AddEvent(new Event(contents, EventType.SettlerAte));
        }
        public override void LoadContent(ContentManager content)
        {
            var map = Map;

            var platform = PlatformFactory.Get(EStructureType.Blank, ref mDirector, 3000, 3000);

            GameScreen.AddObject(platform);

            var platform2 = PlatformFactory.Get(EStructureType.Blank, ref mDirector, 3000, 2500);

            GameScreen.AddObject(platform2);

            var road = new Road(platform, platform2, ref mDirector);

            GameScreen.AddObject(road);

            var platform3 = PlatformFactory.Get(EStructureType.Blank, ref mDirector, 2700, 2700);

            GameScreen.AddObject(platform3);

            var road2 = new Road(platform2, platform3, ref mDirector);

            GameScreen.AddObject(road2);

            var road3 = new Road(platform, platform3, ref mDirector);

            GameScreen.AddObject(road3);


            var settler = new Settler(new Vector2(3000, 3200), Camera, ref mDirector, GameScreen, Ui);

            GameScreen.AddObject(settler);
        }
Exemplo n.º 4
0
    public void Setup(Settler settler, GameObject settlerScreen)
    {
        if (settler == null)
        {
            Debug.LogWarning("Settler cannot be null!");
            return;
        }
        else if (settlerScreen == null)
        {
            Debug.LogWarning("SettlerScreen cannot be null!");
            return;
        }

        if (s_count % 2 == 0)
        {
            gameObject.GetComponent <Image>().color = backgroundAColor;
            m_baseColor = backgroundAColor;
        }
        else
        {
            gameObject.GetComponent <Image>().color = backgroundBColor;
            m_baseColor = backgroundBColor;
        }


        m_settler = settler;
        name.text = settler.GetName();
        settlerPortrait.sprite = M_SettlersManager.SGetPortrait(settler.GetPortraitId());
        m_settlerScreen        = settlerScreen;
        infoButton.onClick.AddListener(OnClickInfo);
        employButton.onClick.AddListener(OnClickEmploy);
        deemployButton.onClick.AddListener(OnClickDeemploy);

        s_count++;
    }
Exemplo n.º 5
0
        public static void Idle(Settler settler)
        {
            var contents = "{0} is idle today.";

            contents = string.Format(contents, Console.Color(settler.Name, SettlerColor));
            EventManager.AddEvent(new Event(contents, EventType.SettlerIdle));
        }
Exemplo n.º 6
0
        private void MoveSettler(Settler settler)
        {
            settler.Life--;

            if (settler.LastDirectionX != 0 || settler.LastDirectionY != 0)
            {
                var land = _world.Land.GetCell(settler.X + settler.LastDirectionX, settler.Y + settler.LastDirectionY);
                if (!IsWater(land))
                {
                    settler.X = land.X;
                    settler.Y = land.Y;
                    return;
                }
            }

            var potentialTilesSorted = _world.Land.GetNeumannNeighborsExclusive(settler.X, settler.Y)
                                       .Where(l => !IsWater(l))
                                       .OrderBy(l => l.Food + l.Animals + l.MaxFood + l.MaxAnimals).ToArray();

            var goal = Random.value < 0.5f ? potentialTilesSorted[0] : potentialTilesSorted[Random.Range(0, potentialTilesSorted.Length)];

            settler.LastDirectionX = goal.X - settler.X;
            settler.LastDirectionY = goal.Y - settler.Y;
            settler.X = goal.X;
            settler.Y = goal.Y;
        }
Exemplo n.º 7
0
 public override void HostWork(Settler worker, Game game)
 {
     foreach (var(resource, amount) in Rates)
     {
         game.Settlement.AddResource(resource, amount);
     }
 }
Exemplo n.º 8
0
 public void UISelectSettler(Settler settler)
 {
     this.SelectedSettler = settler;
     settlerIP.gameObject.SetActive(true);
     settlerIP.AssignContent(settler);
     settlerIP.Draw();
 }
Exemplo n.º 9
0
 public static void SAddEmployee(Settler settler)
 {
     if (s_instance != null)
     {
         s_instance.AddEmployee(settler);
     }
 }
Exemplo n.º 10
0
        public void AddDTO(PersonDTO personDTO)
        {
            var contacts     = _unit.ContactsRepository.Get();
            int maxContactID = contacts.Any() ? contacts.Max(x => x.ContactsId) : 0;
            var contact      = _mapper.Map <Contact>(personDTO.Contacts);

            contact.ContactsId = maxContactID + 1;
            _unit.ContactsRepository.Add(contact);

            int maxPersonId = _unit.PersonsRepository.Get().Max(x => x.PersonId);
            var person      = _mapper.Map <Person>(personDTO);

            person.PersonId = maxPersonId + 1;
            _unit.PersonsRepository.Add(person);

            var settler = new Settler
            {
                ContactId  = contact.ContactsId,
                FlatArea   = personDTO.FlatArea,
                FlatNumber = personDTO.FlatNumber,
                PersonId   = person.PersonId
            };

            _unit.SettlersRepository.Add(settler);
            _unit.Submit();
        }
Exemplo n.º 11
0
        public static void Rehomed(Settler settler, ResidentialBuilding home)
        {
            var contents = "{0} moved into {1}";

            contents = string.Format(contents, Console.Color(settler.Name, SettlerColor), home.Name);
            EventManager.AddEvent(new Event(contents, EventType.SettlerRehomed));
        }
Exemplo n.º 12
0
        public static void Homeless(Settler settler)
        {
            var contents = "{0}" + Console.Color(" is homeless!", ConsoleColor.Red);

            contents = string.Format(contents, Console.Color(settler.Name, SettlerColor));
            EventManager.AddEvent(new Event(contents, EventType.SettlerHomeless));
        }
Exemplo n.º 13
0
        public static void Birthday(Settler settler)
        {
            var contents = "It's {0}'s birthday!";

            contents = string.Format(contents, Console.Color(settler.Name, SettlerColor));
            EventManager.AddEvent(new Event(contents, EventType.SettlerBirthday));
        }
        public void CreateCity()
        {
            EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
            Entity        entity        = Settler.GetSelected(entityManager);

            SettlerActions.AddCommandCreateCity(entity);
            UISettlerPanel.Hide();
        }
Exemplo n.º 15
0
 public static void GenerateTraits(Settler settler)
 {
     foreach (var trait in Trait.Traits)
     {
         settler.Traits[trait] = RandomUtil.WeightedGet(TraitLevel.TraitLevels, TraitLevel.Average, TraitLevel.Weight);
     }
     EnsureMajorTrait(settler);
 }
Exemplo n.º 16
0
 public RelationshipRole Role(Settler settler)
 {
     if (settler == Settler1)
     {
         return(Role1);
     }
     return(settler == Settler2 ? Role2 : null);
 }
Exemplo n.º 17
0
        public static void SkillIncreased(Settler settler, Skill skill)
        {
            var contents = "{0} became a {1} {2}";

            contents = string.Format(contents, Console.Color(settler.Name, SettlerColor),
                                     Skill.LevelToString(skill.Level), Skill.AgentFromSkillType(skill.Type));
            EventManager.AddEvent(new Event(contents, EventType.SettlerSkillIncrease));
        }
Exemplo n.º 18
0
 public Settler Other(Settler settler)
 {
     if (settler == Settler1)
     {
         return(Settler2);
     }
     return(settler == Settler2 ? Settler1 : null);
 }
Exemplo n.º 19
0
 public static void EnsureMajorTrait(Settler settler)
 {
     //Always some major trait
     if (Trait.Traits.ToList().TrueForAll(trait => settler.Traits[trait] > TraitLevel.Low && settler.Traits[trait] < TraitLevel.High))
     {
         settler.Traits[RandomUtil.Get(Trait.Traits)] = RandomUtil.Get(new[]
                                                                       { TraitLevel.VeryLow, TraitLevel.Low, TraitLevel.High, TraitLevel.VeryHigh });
     }
 }
Exemplo n.º 20
0
    private void CreateSettlers(Tile goal)
    {
        int settlerCount = population / 4;

        Settler settler = new Settler(this, goal, settlerCount);

        population -= settlerCount;

        settlers.Add(settler);
    }
Exemplo n.º 21
0
 public void AddEmployee(Settler settler)
 {
     if (settler == m_employee)
     {
         m_employee = null;
         return;
     }
     m_employee = settler;
     RefreshUI();
 }
Exemplo n.º 22
0
 public void AddSettler(Settler settler)
 {
     if (workingSettlers == null)
     {
         workingSettlers = new List <Settler>();
     }
     workingSettlers.Add(settler);
     settler.GetEntity().MoveTo(GetHitpoint(settler.gameObject.transform.position), true);
     settler.CurrentBuilding = this;
 }
Exemplo n.º 23
0
        private MarriedRelationship(SettlerManager sm, int value, Settler partner1, Settler partner2) : base(sm, value, partner1, GetMarriedRole(partner1), partner2, GetMarriedRole(partner2))
        {
            //Remove prior loverRelationship
            var loverRelationship =
                partner1.Relationships.FirstOrDefault(rel => rel is LoverRelationship love && love.Contains(partner2));

            if (loverRelationship != null)
            {
                partner1.Relationships.Remove(loverRelationship);
                partner2.Relationships.Remove(loverRelationship);
            }
        }
Exemplo n.º 24
0
        protected Relationship(SettlerManager sm, int value, Settler settler1, RelationshipRole role1, Settler settler2,
                               RelationshipRole role2)
        {
            Value    = value;
            Settler1 = settler1;
            Role1    = role1;
            Settler2 = settler2;
            Role2    = role2;

            settler1.Relationships.Add(this);
            settler2.Relationships.Add(this);
            sm.Add(this);
        }
Exemplo n.º 25
0
        public override void LoadContent(ContentManager content)
        {
            //INGAME OBJECTS INITIALIZATION ===================================================

            //SetUnit
            var settler = new Settler(new Vector2(2900, 3200), Camera, ref mDirector, GameScreen, Ui);

            Camera.CenterOn(settler.AbsolutePosition);

            GameScreen.AddObject(settler);

            GameScreen.AddObject(new Puddle(new Vector2(3300, 2500), ref mDirector));
            GameScreen.AddObject(new Puddle(new Vector2(4500, 2700), ref mDirector, false));
        }
Exemplo n.º 26
0
        public static List <Settler> GetSiblings(Settler settler)
        {
            var siblings = new List <Settler>();

            foreach (var relationship in settler.Relationships)
            {
                if (relationship is SiblingRelationship siblingRelationship)
                {
                    siblings.Add(siblingRelationship.Other(settler));
                }
            }

            return(siblings);
        }
Exemplo n.º 27
0
        private ParentChildRelationship(SettlerManager sm, int value, Settler parent, Settler child) : base(sm, value, parent, GetParentRole(parent), child, GetChildRole(child))
        {
            //Add siblings
            var currentSiblings = SiblingRelationship.GetSiblings(child);
            var actualSiblings  = GetChildren(parent).Where(c => c != child);

            foreach (var sibling in actualSiblings)
            {
                if (!currentSiblings.Contains(sibling))
                {
                    SiblingRelationship.Make(sm, 0, child, sibling);
                }
            }
        }
Exemplo n.º 28
0
        public static List <Settler> GetChildren(Settler settler)
        {
            var children = new List <Settler>();

            foreach (var relationship in settler.Relationships)
            {
                if (relationship is ParentChildRelationship parentChildRelationship && parentChildRelationship.Role(settler) == Parent)
                {
                    children.Add(parentChildRelationship.Other(settler));
                }
            }

            return(children);
        }
Exemplo n.º 29
0
        public void Work(SettlersOfValgard game, Settler settler)
        {
            var table = Terrain.GatherTable;

            if (table == null || table.Count == 0)
            {
                //empty table
                VConsole.WriteWarning(settler + VConsole.Text(" is working on a barren ") + Terrain + VConsole.Text(" terrain!"));
                return;
            }

            var total  = table.Aggregate(0, (prev, next) => next.Item2 + prev);
            var random = Noise.GetRecursiveNoise(game.Seed, game.Settlement.Day, settler.Id) % total;
        }
Exemplo n.º 30
0
        public static List <Settler> GetParents(Settler settler)
        {
            var parents = new List <Settler>();

            foreach (var relationship in settler.Relationships)
            {
                if (relationship is ParentChildRelationship parentChildRelationship && parentChildRelationship.Role(settler) == Child)
                {
                    parents.Add(parentChildRelationship.Other(settler));
                }
            }

            return(parents);
        }