private void GenerateColonist(int2 position)
        {
            Type.Group groupType = Util.Misc.RandomEnumValue <Type.Group>();

            GameObject colonistGameObject = GenerateColonistObject(position);
            Colonist   colonist           = colonistGameObject.AddComponent <Colonist>();

            colonist.Entity = new Data.Entity
            {
                GameObject = colonistGameObject,
                Speed      = 0f,
                Position   = position,
                Direction  = Type.Direction.SS,
            };

            colonist.Path = new Data.Path
            {
                Progress      = 0f,
                NodePositions = new List <int2>(),
            };

            colonist.Id = new Data.Id
            {
                FullName       = NameGenerator.GetName(groupType),
                Number         = population.NextId++,
                PopulationType = Type.Population.Citizen,
                GroupType      = groupType,
            };

            colonistGameObject.name             = colonist.Id.FullName;
            colonistGameObject.transform.parent = entitiesObject.transform;

            population.Colonists.Add(colonist);
        }
예제 #2
0
        public async Task <IActionResult> GetColonyStreamerInfos()
        {
            var channel = await Task.Run(() => _api.V5.Users.GetUserByNameAsync("SeeSharpist"));

            var followers = await Task.Run(() => _api.V5.Users.GetUserFollowsAsync(channel.Matches[0].Id));

            foreach (var user in followers.Follows)
            {
                Colonist c = new Colonist()
                {
                    id      = user.Channel.Id,
                    name    = user.Channel.DisplayName,
                    avatar  = user.Channel.Logo,
                    urlpath = user.Channel.Url,
                    game    = user.Channel.Game,
                    //status = ,
                    //viewerCount = ,
                    //isLive = ,
                };
            }
            //var streams = await Task.Run(() => _api.V5.Streams.GetFollowedStreamsAsync(channel.Matches[0].Id));
            //List<Colonist>
            // filter contact records by contact id
            //var item = _context.Contact.FirstOrDefault(t => t.id == id);
            if (followers == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(followers));
        }
예제 #3
0
    // This is linked to what's called the Restart button. To be honest at this point it's really just the
    // close alert button though, with how much I reused this UI. It checks what alertType it has when you click
    // it, and closes the alert in a way that makes sense depending on the type.
    public void RestartGame()
    {
        switch (alertType)
        {
        //If the alert is gameover, just restart the game.
        case AlertType.GameOver:
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            break;

        // If the alert is robot attack, check if anyone died, and if so remove the colonist
        // and reset the dead variable. Otherwise just end the alert and dip.
        case AlertType.RobotAttack:
            CloseGameOverUI();
            GameEvents.InvokeAlertConcluded();
            if (dead != null)
            {
                GameEvents.InvokeRemoveColonist(dead);
                dead = null;
            }
            break;

        case AlertType.Start:
            CloseGameOverUI();
            GameEvents.InvokeAlertConcluded();
            break;

        // If this is a miscellaneous colonist killing alert just kill the colonist at random,
        // end the event and dip.
        case AlertType.Misc:
            CloseGameOverUI();
            GameEvents.InvokeAlertConcluded();
            GameEvents.InvokeRemoveRandomColonist();
            break;
        }
    }
    // New colonist? Roll it randomly using the colonist class, no need to give it any info, then
    // just throw it in both assignableColonists and allColonists (obviously it doesn't have a job
    // coming in fresh.) Maybe unsurprisingly, this is listening to the AddColonist Event.
    void OnAddColonist(object sender, EventArgs args)
    {
        Colonist newColonist = new Colonist();

        assignableColonists.Add(newColonist);
        allColonists.Add(newColonist);
    }
예제 #5
0
 public void AddWorker(Colonist colonist)
 {
     if (WorkerCapacity == Workers.Count)
     {
         throw new GameException($"{Name} is full");
     }
     Workers.Add(colonist);
 }
예제 #6
0
        public void AddWorker(Colonist worker)
        {
            if (Worker != null)
            {
                throw new GameException($"{Name} already has a worker");
            }

            Worker = worker;
        }
 public void CreateColonists(int count)
 {
     for (int i = 0; i < count; i++)
     {
         Colonist newColonist = new Colonist();
         colonistBase.colonists.Add(newColonist);
         SetIdleColonist(newColonist);
     }
 }
예제 #8
0
    private void EngageColonist(Colonist colonist)
    {
        if (!(CurrentWork is MoveDirectionWork))
        {
            return;
        }

        AssignWork(new FollowWork(colonist));

        Game.GetVisibleEntitiesWithinRange <Zombie>(Position, COMMUNICATION_RANGE).ForEach(x => x.EngageColonist(colonist));
    }
    public void AllocateColonistToTask(Colonist colonist, Task task)
    {
        //Remove from old task first
        if (colonist.assignedTask != null)
        {
            colonist.assignedTask.allocatedColonists.Remove(colonist);
        }

        task.allocatedColonists.Add(colonist);
        colonist.assignedTask = task;
    }
    public void AllocateColonistToBuilding(Colonist colonist, Building building)
    {
        //Remove from old building first
        if (colonist.assignedBuilding != null)
        {
            colonist.assignedBuilding.allocatedColonists.Remove(colonist);
        }

        building.allocatedColonists.Add(colonist);
        colonist.assignedBuilding = building;
    }
예제 #11
0
    public void AddFactoryTask(Item item, int colonistsAssigned, int amountToBuild)
    {
        FactoryBuildTask newFactoryTask = new FactoryBuildTask(item, amountToBuild);

        for (int i = 0; i < colonistsAssigned; i++)
        {
            Colonist idleColonist = GameController.Instance.colonistController.GetIdleColonist();
            GameController.Instance.colonistController.AllocateColonistToTask(idleColonist, newFactoryTask);
        }

        factoryData.currentBuildTasks.Add(newFactoryTask);
    }
예제 #12
0
        public Colonist RemoveWorker()
        {
            if (Worker == null)
            {
                throw new GameException($"{Name} has no worker");
            }

            var worker = Worker;

            Worker = null;
            return(worker);
        }
예제 #13
0
    public void AddFactoryTask(FactoryUIData taskData)
    {
        FactoryBuildTask newFactoryTask = new FactoryBuildTask(taskData);

        newFactoryTask.allocatedColonists = new List <Colonist>();
        for (int i = 0; i < taskData.colonistAssignedCount; i++)
        {
            Colonist idleColonist = GameController.Instance.colonistController.GetIdleColonist();
            GameController.Instance.colonistController.AllocateColonistToTask(idleColonist, newFactoryTask);
        }

        factoryData.currentBuildTasks.Add(newFactoryTask);
    }
    // This function listens to the RemoveColonist event, and it removes the colonist given in the args from
    // both lists (if they're in the lists.) It's mostly important to check if they're in the list because
    // sometimes a colonist will be in assignable and sometimes not depending on if they're given a Task.
    void OnRemoveColonist(object sender, ColonistEventArgs args)
    {
        Colonist colonistToRemove = args.colonistPayload;

        if (allColonists.Contains(colonistToRemove))
        {
            allColonists.Remove(colonistToRemove);
        }

        if (assignableColonists.Contains(colonistToRemove))
        {
            assignableColonists.Remove(colonistToRemove);
        }
    }
    // In the event of a robot attack, I want to tell the player who was killed. That's why the event this
    // function is listening to exists, and this function call is a middleman between statusUI and GameOverUI.
    //
    // StatusUI says "Ok, I rolled a robot attack. Colonist Manager, tell us who was killed?" and it calls the
    // roboAttack event. This function figures out a random colonist based on its lists, and then it says
    // "So I know who died, now someone put this on the screen" and when it calls RoboAttackUI it gives up the
    // lucky colonist.
    //
    // However, sometimes no one dies in a roboAttack, so ColonistManager also sends a boolean
    // that tells this function whether or not anyone was killed. If no one was killed this function still opens
    // the UI but it tells GameOverUI there was no casualty by sending null instead of a colonist. Apologies for the
    // novel but this is one of the more convoluted implementations so I wanted to make it clear what's happening.
    void OnRoboAttack(object sender, BooleanEventArgs args)
    {
        Boolean casualty = args.booleanPayload;

        if (casualty)
        {
            Colonist dead = allColonists[UnityEngine.Random.Range(0, allColonists.Count - 1)];
            GameEvents.InvokeRoboAttackUIStarted(dead);
        }
        else
        {
            GameEvents.InvokeRoboAttackUIStarted(null);
        }
    }
예제 #16
0
        public async Task <IActionResult> GetColonyLiveStreamerInfos()
        {
            int page = 100;

            int             followCount = 0;
            int             callCount   = 0;
            List <string>   channelIds  = new List <string>();
            List <Colonist> members     = new List <Colonist>();
            var             channel     = await Task.Run(() => _api.V5.Users.GetUserByNameAsync("SeeSharpist"));

            var followers = await Task.Run(() => _api.V5.Users.GetUserFollowsAsync(channel.Matches[0].Id, page));

            callCount   = 1;
            followCount = followers.Total;
            while (followCount > 0)
            {
                foreach (var user in followers.Follows)
                {
                    channelIds.Add(user.Channel.Id);
                }
                followCount -= page;
                followers    = await Task.Run(() => _api.V5.Users.GetUserFollowsAsync(channel.Matches[0].Id, page, callCount *page));

                callCount++;
            }

            var streams = await Task.Run(() => _api.V5.Streams.GetLiveStreamsAsync(channelIds));

            foreach (var stream in streams.Streams)
            {
                Colonist c = new Colonist()
                {
                    id          = stream.Channel.Id,
                    name        = stream.Channel.DisplayName,
                    avatar      = stream.Channel.Logo,
                    urlpath     = stream.Channel.Url,
                    game        = stream.Channel.Game,
                    status      = stream.Channel.Status,
                    viewerCount = stream.Viewers,
                    isLive      = true
                };
                members.Add(c);
            }

            if (members == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(members));
        }
예제 #17
0
    private void AddFaction(Vector3 pos)
    {
        Faction faction = new Faction("Faction!")
        {
            Base = Instantiate(prefabBase, pos, Quaternion.identity).GetComponent <Base>()
        };

        for (int i = 0; i < 5; i++)
        {
            Colonist.New(
                location: pos,
                faction: faction
                );
        }
    }
예제 #18
0
        public void SelectEntity(GameObject entity)
        {
            if (uiData.Mode == Type.UIMode.Main)
            {
                return;
            }

            ClearSelection();
            mapSystem.ClearSelection();

            entityLabeler.SelectEntity(entity);

            Colonist colonist = entity.GetComponent <Colonist>();

            infoWindow.DisplayColonist(colonist);
        }
예제 #19
0
    public static Colonist BabyMaker(string name, Colonist parentA, Colonist parentB)
    {
        string race = "Unknown";

        if (parentA.race == parentB.race)
        {
            race = parentA.race;
        }
        else if ((parentA.race == "Human" && parentB.race == "Orc") || (parentA.race == "Orc" && parentB.race == "Human"))
        {
            race = "Half-Orc";
        }

        // TODO do you want all babies to have the same name? Should the babymaker signature accept a name?
        return(new Colonist(name, race, "Baby", 100));
    }
예제 #20
0
        private static void Main()
        {
            Colony colony = new Colony();

            //Ingest our test data from input.txt
            string[] colonists = System.IO.File.ReadAllLines(@"input.txt");
            foreach (string colonist in colonists)
            {
                string[] fields = colonist.Split(',');
                colony.AddColonist(new Colonist(fields[0], fields[1], fields[2], int.Parse(fields[3])));
            }

            string babyName = "Baby";

            colony.AddColonist(Colonist.BabyMaker(babyName, colony.GetColonist("Unga"), colony.GetColonist("Bae")));
            Console.WriteLine(colony.Population());
            colony.PrintColony();
        }
예제 #21
0
    void Start()
    {
        backgroundPanel = transform.parent.GetComponent <Image>();
        mainPanel       = transform.GetComponent <Image>();
        gameOverText    = transform.GetChild(0).GetComponent <Text>();
        restartButton   = transform.GetChild(1).gameObject;
        dayDisplay      = transform.GetChild(2).GetComponent <Text>();
        dead            = null;


        GameEvents.RoboAttackUIStarted += OnRoboAttackUIStarted;
        GameEvents.AlertStarted        += OnAlertStarted;
        GameEvents.GameOver            += OnGameOver;

        OpenGameOverUI();
        alertType         = AlertType.Start;
        gameOverText.text = "You are the leader of a small resistance group against the robot menace. Feed protect and placate your colonists as you expand outwards. If you can reclaim every building in the city you will have saved your people.";
        dayDisplay.text   = "";
        restartButton.transform.GetChild(0).gameObject.GetComponent <Text>().text = "Godspeed, General";
    }
예제 #22
0
    // This bit is kind of important. When the RemoveColonist event is called, that colonist
    // obviously should not be able to resolve any tasks assigned to them. This function grabs
    // the dead colonist and searches all the tasks it has for them, and if they have a task it
    // deletes it.
    //
    // Ideally one colonist should have only one job, and I've never seen that not be
    // the case, but just in case this function checks all tasks for that colonist and can potentially
    // remove multiple..
    void OnRemoveColonist(object sender, ColonistEventArgs args)
    {
        this.currentColonists -= 1;

        if (this.currentColonists <= this.maxColonists)
        {
            canAddColonist = true;
        }

        if (this.currentColonists <= 0)
        {
            GameEvents.InvokeGameOver(this.daysPassed, false);
        }

        Colonist    colonistToRemove = args.colonistPayload;
        int         counter          = 0;
        int         target           = taskHolder.Count;
        List <Task> dummyTaskHolder  = new List <Task>();

        while (counter < target)
        {
            if (taskHolder[counter].colonist == colonistToRemove)
            {
                dummyTaskHolder.Add(taskHolder[counter]);
            }

            counter += 1;
        }

        foreach (Task badTask in dummyTaskHolder)
        {
            badTask.active = false;
            taskHolder.Remove(badTask);
            GameEvents.InvokeTaskCompleted(badTask);
        }

        dummyTaskHolder = new List <Task>();

        UpdateDisplay();
    }
예제 #23
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            var area = new List <Entity>();

            PlaceMountains(area);
            var jim = new Colonist(area)
            {
                X = 59, Y = 14
            };

            area.Add(jim);

            while (true)
            {
                // Time in ticks.
                DrawArea(area);
                jim.Tick();

                Thread.Sleep(500);
            }
        }
예제 #24
0
    // When a robot attack happens this sets the text depending on if anyone died, and changes the alert type
    // to the right one.
    void OnRoboAttackUIStarted(object sender, ColonistEventArgs args)
    {
        alertType = AlertType.RobotAttack;

        OpenGameOverUI();

        if (args.colonistPayload != null)
        {
            dead = args.colonistPayload;
            gameOverText.text = "ROBOT ATTACK: They rushed us bad last night. We held them off for now, but " + dead.name + " was killed.";
            dayDisplay.text   = "Happiness -10";
            GameEvents.InvokeHappinessChanged(-10);
            restartButton.transform.GetChild(0).gameObject.GetComponent <Text>().text = "Goodbye, " + dead.name;
        }
        else
        {
            gameOverText.text = "ROBOT ATTACK: They attacked last night, but we were ready. Even went out and popped the heads to stop the beeping.";
            dayDisplay.text   = "Happiness +10";
            GameEvents.InvokeHappinessChanged(10);
            restartButton.transform.GetChild(0).gameObject.GetComponent <Text>().text = "Nice.";
        }
    }
예제 #25
0
        /// <summary>
        /// Funkcja wywoływana przy kazdym odswierzeniu okranu
        /// </summary>
        /// <param name="sender">Obiekt wysylajacy zdazenie</param>
        /// <param name="e">Argumenty zdarzenia</param>
        public void UpdateTime(object sender, UpdateEventArgs e)
        {
            for (int index = 0; index < colonists_.Count;)
            {
                if (colonists_[index].HP.Value > 0f)
                {
                    index++;
                    continue;
                }

                colonists_[index].Die();
                colonists_.Remove(colonists_[index]);
            }

            foreach (Men colonist in Colonist.Where(c => c.Job == null))
            {
                string stateSleep = MakeDecision(colonist.RestF, colonist.Laziness);
                string stateWork  = MakeDecision(colonist.HP, colonist.Laziness);

                if (stateSleep == "Sleep")
                {
                    Bed bed = Constructs.Where(c => c is Bed)
                              .Cast <Bed>()
                              .FirstOrDefault(b => b.State == Construct.Status.Done && b.IsFree);

                    colonist.Job = new SleepJob(colonist, bed);
                }
                else if (stateWork == "Work" && JobQueue.Count > 0)
                {
                    colonist.Job = JobQueue.Dequeue();
                }
                else if (stateWork == "RestF" || colonist.HP != colonist.HP.MaxHP)
                {
                    colonist.Job = colonist.Rest;
                }
            }
        }
예제 #26
0
 public void AssignColonist(Colonist colonist)
 {
     Colonist = colonist;
 }
 public void SetIdleColonist(Colonist col)
 {
     AllocateColonistToBuilding(col, colonistBase.buildings[0]);
     colonistBase.idleColonists.Add(col);
 }
예제 #28
0
 void Clicking()
 {
     newColonist = new Colonist();
     PopulationCounter.ListUpdater();
     newColonist = null;
 }
예제 #29
0
     public override string ToString()
     {
         return($@"Choose colonist: 
 Type: {Colonist.ToString()}");
     }
예제 #30
0
 public void AddColonist(Colonist colonist)
 {
     colonists[colonist.name] = colonist;
     return;
 }