Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetCostantValues();
            GetBeatValues Getval = new GetBeatValues();

            // For Transactional votes
            if (Request["type"] == "Transaction")
            {
                _emiratesID    = Session["emiratesID"].ToString();
                _username      = Session["username"].ToString();
                _email         = Session["email"].ToString();
                _mobile        = Session["mobile"].ToString();
                _TransactionID = Session["transactionID"].ToString();

                Getval = Happiness.GetTransactionalBeats(_ThemeColor, _serviceProvider, _TransactionID, _gessEnabled,
                                                         _serviceCode, _serviceDescription, _channel, _source, _emiratesID, _username, _email, _mobile, _SecretKey, _lang);
            }
            // For Non Transactional votes
            else
            {
                Getval = Happiness.GetNonTransactionalBeats(_ThemeColor, _serviceProvider, _ApplicationID, _Applicationtype, _platform,
                                                            _Applicationurl, _version, _source, _emiratesID, _username, _email, _mobile, _SecretKey, _lang);
            }
            _signature   = Getval.signature;
            _jsonRequest = Getval.json_payload;
            _random      = Getval.random;
            _timestamp   = Getval.timestamp;
            _nonce       = Getval.nonce;
            _Lang        = Getval.lang;
        }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        //check happiness levels
        if (currentHappiness <= 3 && currentState != Happiness.Angry)
        {
            //change material and current state
            GetComponent <MeshRenderer>().material = materials[0];
            currentState = Happiness.Angry;
        }
        else if (currentHappiness >= 7 && currentState != Happiness.Happy)
        {
            //change material and current state
            GetComponent <MeshRenderer>().material = materials[1];
            currentState = Happiness.Happy;
        }
        else if (currentHappiness > 3 && currentHappiness < 7 && currentState != Happiness.Neutral)
        {
            //change material and current state
            GetComponent <MeshRenderer>().material = materials[2];
            currentState = Happiness.Neutral;
        }

        //don't let happiness go below zero or above ten
        if (currentHappiness < 0)
        {
            currentHappiness = 0;
        }
        else if (currentHappiness > 10)
        {
            currentHappiness = 10;
        }
    }
    static void Main()
    {
        string readLine = Console.ReadLine();

        string pattern =
            @"(?<happy>[:;][)\]}*D]|[(*c\[][:;]){1,2}|(?<sad>[:;D][(:\[{c]|[)\]][:;]){1,2}";
        MatchCollection regexHappySad = Regex.Matches(readLine, pattern);

        int happyCount = regexHappySad
                         .Cast <Match>()
                         .Where(x => x.Groups["happy"].Value != String.Empty)
                         .Count();
        int sadCount = regexHappySad
                       .Cast <Match>()
                       .Where(x => x.Groups["sad"].Value != String.Empty)
                       .Count();

        double happinessIndex = (double)happyCount / (double)sadCount;

        Happiness happiness = new Happiness()
        {
            Emoticon       = GetEmoticon(happinessIndex),
            HappinessIndex = happinessIndex,
            HappyCount     = happyCount,
            SadCount       = sadCount
        };

        PrintHappinessIndex(happiness);
    }
Exemplo n.º 4
0
 public void UpdateHappiness(Happiness newHappiness)
 {
     health      = newHappiness.health;
     home        = newHappiness.home;
     job         = newHappiness.job;
     environment = newHappiness.environment;
     safety      = newHappiness.safety;
     ComputeOverallHappiness();
 }
Exemplo n.º 5
0
 public override int GetHashCode()
 {
     return(Anger.GetHashCode() ^
            Disgust.GetHashCode() ^
            Fear.GetHashCode() ^
            Happiness.GetHashCode() ^
            Neutral.GetHashCode() ^
            Sadness.GetHashCode() ^
            Surprise.GetHashCode());
 }
 protected bool Equals(EmotionScores other)
 {
     return(Anger.Equals(other.Anger) &&
            Contempt.Equals(other.Contempt) &&
            Disgust.Equals(other.Disgust) &&
            Fear.Equals(other.Fear) &&
            Happiness.Equals(other.Happiness) &&
            Neutral.Equals(other.Neutral) &&
            Sadness.Equals(other.Sadness) &&
            Surprise.Equals(other.Surprise));
 }
Exemplo n.º 7
0
    public void InitilizePetHappinessUI()
    {
        //change the script that this script refrences to the one in the pet manager
        m_PetHappinessScript = m_PetManager.CurrentPetHappinessScript;

        m_CurrentPetHasHappiness = m_PetHappinessScript;

        //Toggle the appropriate game objects on/off depending on if this pet has happiness!
        m_HappinessView.gameObject.SetActive(m_CurrentPetHasHappiness);
        m_CuddlePetButton.gameObject.SetActive(m_CurrentPetHasHappiness);
    }
Exemplo n.º 8
0
        public void Decrease_Always_ShouldSubtractDecreaseRatexDeltaFromValue()
        {
            var hunger    = new Hunger(3.0f, 2.0f);
            var happiness = new Happiness(0.0f, 3.0f);

            hunger.Decrease(3.0f);
            happiness.Decrease(2.0f);

            Assert.Equal(-3.0f, hunger.Value);
            Assert.Equal(-6.0f, happiness.Value);
        }
        public ActionResult <Happiness> Create([FromBody] HappinessRequest happinessRequest)
        {
            Happiness happiness = new Happiness {
                Level = happinessRequest.Level
            };

            _dbContext.Happinesses.Add(happiness);
            _dbContext.SaveChanges();

            return(happiness);
        }
Exemplo n.º 10
0
        public void Boost_Always_ShouldAddAmountToValue()
        {
            var hunger    = new Hunger(3.0f, 2.0f);
            var happiness = new Happiness(0.0f, 3.0f);

            hunger.Boost(3.0f);
            happiness.Boost(2.0f);

            Assert.Equal(6.0f, hunger.Value);
            Assert.Equal(2.0f, happiness.Value);
        }
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = Anger.GetHashCode();
         hashCode = (hashCode * 397) ^ Contempt.GetHashCode();
         hashCode = (hashCode * 397) ^ Disgust.GetHashCode();
         hashCode = (hashCode * 397) ^ Fear.GetHashCode();
         hashCode = (hashCode * 397) ^ Happiness.GetHashCode();
         hashCode = (hashCode * 397) ^ Neutral.GetHashCode();
         hashCode = (hashCode * 397) ^ Sadness.GetHashCode();
         hashCode = (hashCode * 397) ^ Surprise.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 12
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Happiness != 0)
            {
                hash ^= Happiness.GetHashCode();
            }
            if (NbTreats != 0)
            {
                hash ^= NbTreats.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 13
0
        public bool CreateHappiness(HappinessCreate model)
        {
            var entity =
                new Happiness()
            {
                OwnerId        = _userId,
                HappinessLevel = model.HappinessLevel,
                EmotionNotes   = model.EmotionNotes,
                Date           = model.Date,
                PersonId       = model.PersonId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Happinesses.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 14
0
    void UpdateCitizenHappiness(Citizen citizen) //TODO consider moving this method to Citizen class.
    {
        Happiness newHappiness = new Happiness(50);

        int changeDirection = (int)Mathf.Sign((int)citizen.homeAddress.housingQuality - (int)citizen.happiness.home);

        newHappiness.home = (uint)Mathf.Clamp((int)citizen.happiness.home + (changeDirection * Citizen.happinessChangeRatePerDay), 0, 100);

        //compute environment happiness. We do that according to pollution in both house and work.
        //Work pollution contributes to happiness half that of home.
        uint homeEnvironmentHappiness = 0, workEnvironmentHappiness = 0;

        if (citizen.homeAddress != null) //Again, shouldn't happen, but better safe than sorry.
        {
            float pollutionAtHome = Grid.grid.pollutionLayer.GetCellValue(citizen.homeAddress.occupiedCell[0], citizen.homeAddress.occupiedCell[0]);
            homeEnvironmentHappiness  = (uint)Mathf.RoundToInt((float)Globals.baseEnvironmentHappiness - ((float)Globals.baseEnvironmentHappiness * (pollutionAtHome - Citizen.minPollutionToAffectHealthHappiness) / (Citizen.maxPollutionToAffectHealthHappiness - Citizen.minPollutionToAffectHealthHappiness)));
            homeEnvironmentHappiness  = (uint)Mathf.Clamp((int)homeEnvironmentHappiness, 0, (int)Globals.baseEnvironmentHappiness);
            homeEnvironmentHappiness += Park_1.EnvironmentBoostMax(citizen.homeAddress.occupiedCell[0], citizen.homeAddress.occupiedCell[1]);
            workEnvironmentHappiness  = homeEnvironmentHappiness; //incase citizen.workAddress == null.
        }

        if (citizen.workAddress != null)
        {
            float pollutionAtWork = Grid.grid.pollutionLayer.GetCellValue(citizen.workAddress.GetComponent <Building>().occupiedCell[0], citizen.workAddress.GetComponent <Building>().occupiedCell[0]);

            workEnvironmentHappiness  = (uint)Mathf.RoundToInt((float)Globals.baseEnvironmentHappiness - ((float)Globals.baseEnvironmentHappiness * (pollutionAtWork - Citizen.minPollutionToAffectHealthHappiness) / (Citizen.maxPollutionToAffectHealthHappiness - Citizen.minPollutionToAffectHealthHappiness)));
            workEnvironmentHappiness  = (uint)Mathf.Clamp((int)workEnvironmentHappiness, 0, (int)Globals.baseEnvironmentHappiness);
            workEnvironmentHappiness += Park_1.EnvironmentBoostMax(citizen.workAddress.GetComponent <Building>().occupiedCell[0], citizen.workAddress.GetComponent <Building>().occupiedCell[1]);
        }

        newHappiness.environment = (uint)Mathf.RoundToInt((float)(2 * homeEnvironmentHappiness + workEnvironmentHappiness) / 3.0f);

        if (citizen.workAddress == null) //unemployed
        {
            newHappiness.job = 0;
        }
        else
        {
            newHappiness.job = citizen.workAddress.WorkplaceQuality();
        }

        citizen.happiness.UpdateHappiness(newHappiness);
    }
Exemplo n.º 15
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (TrainerId != 0L)
            {
                hash ^= TrainerId.GetHashCode();
            }
            if (Happiness != 0)
            {
                hash ^= Happiness.GetHashCode();
            }
            if (Hp != 0)
            {
                hash ^= Hp.GetHashCode();
            }
            if (Atk != 0)
            {
                hash ^= Atk.GetHashCode();
            }
            if (Def != 0)
            {
                hash ^= Def.GetHashCode();
            }
            if (Spa != 0)
            {
                hash ^= Spa.GetHashCode();
            }
            if (Spd != 0)
            {
                hash ^= Spd.GetHashCode();
            }
            if (Spe != 0)
            {
                hash ^= Spe.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 16
0
        public void TestBgsFactionFromName()
        {
            // Setup
            string      resource = "v5/factions?";
            string      json     = Encoding.UTF8.GetString(Resources.bgsFactionResponse);
            RestRequest data     = new RestRequest();

            fakeBgsRestClient.Expect(resource, json, data);

            // Act
            Faction faction1 = fakeBgsService.GetFactionByName("The Dark Wheel");

            // Assert
            Assert.IsNotNull(faction1);
            Assert.AreEqual("The Dark Wheel", faction1.name);
            Assert.AreEqual("Democracy", faction1.Government.invariantName);
            Assert.AreEqual("Independent", faction1.Allegiance.invariantName);
            Assert.AreEqual(41917, faction1.EDDBID);
            Assert.AreNotEqual(DateTime.MinValue, faction1.updatedAt);
            Assert.AreEqual(14, faction1.presences.Count);
            var presence = faction1.presences.FirstOrDefault(p => p.systemName == "Shinrarta Dezhra");

            Assert.IsNotNull(presence);
            Assert.AreEqual(FactionState.FromEDName("civilunrest"), presence.FactionState);
            Assert.AreEqual(28.0719M, presence.influence);
            Assert.AreEqual(Happiness.FromEDName("$Faction_HappinessBand1"), presence.Happiness);
            Assert.AreEqual(1, presence.ActiveStates.Count);
            Assert.AreEqual(FactionState.FromEDName("civilunrest"), presence.ActiveStates[0]);
            Assert.AreEqual(0, presence.PendingStates.Count);
            Assert.AreEqual(0, presence.RecoveringStates.Count);

            // Even if the faction does not exist, we should return a basic object
            Faction faction2 = fakeBgsService.GetFactionByName("No such faction");

            Assert.IsNotNull(faction2);
            Assert.AreEqual("No such faction", faction2.name);
            Assert.AreEqual(Government.None, faction2.Government);
            Assert.AreEqual(Superpower.None, faction2.Allegiance);
            Assert.AreEqual(DateTime.MinValue, faction2.updatedAt);
            Assert.AreEqual(0, faction2.presences.Count);
        }
Exemplo n.º 17
0
    public void SetParticle(Happiness happiness, int score)
    {
        scoreText.text = "+" + score + "$";

        switch (happiness)
        {
        case Happiness.Good:
            spriteRenderer.sprite = goodFace;
            break;

        case Happiness.Med:
            spriteRenderer.sprite = medFace;
            break;

        case Happiness.Bad:
            spriteRenderer.sprite = badFace;
            break;

        default:
            break;
        }
    }
Exemplo n.º 18
0
        public Faction ParseFaction(object response)
        {
            try
            {
                IDictionary <string, object> factionJson = Deserializtion.DeserializeData(response.ToString());
                Faction faction = new Faction
                {
                    EDDBID     = (long)factionJson["eddb_id"],
                    name       = (string)factionJson["name"],
                    updatedAt  = (DateTime)factionJson["updated_at"],
                    Government = Government.FromName((string)factionJson["government"]),
                    Allegiance = Superpower.FromName((string)factionJson["allegiance"]),
                };

                foreach (object presence in (List <object>)factionJson["faction_presence"])
                {
                    IDictionary <string, object> presenceJson = (IDictionary <string, object>)presence;
                    FactionPresence factionPresence           = new FactionPresence()
                    {
                        systemName   = JsonParsing.getString(presenceJson, "system_name"),
                        influence    = (JsonParsing.getOptionalDecimal(presenceJson, "influence") ?? 0) * 100, // Convert from a 0-1 range to a percentage
                        FactionState = FactionState.FromEDName(JsonParsing.getString(presenceJson, "state")) ?? FactionState.None,
                    };

                    // These properties may not be present in the json, so we pass them after initializing our FactionPresence object.
                    factionPresence.Happiness = Happiness.FromEDName(JsonParsing.getString(presenceJson, "happiness")) ?? Happiness.None;
                    presenceJson.TryGetValue("updated_at", out object updatedVal);
                    factionPresence.updatedAt = (DateTime?)updatedVal ?? DateTime.MinValue;

                    // Active states
                    presenceJson.TryGetValue("active_states", out object activeStatesVal);
                    if (activeStatesVal != null)
                    {
                        var activeStatesList = (List <object>)activeStatesVal;
                        foreach (IDictionary <string, object> activeState in activeStatesList)
                        {
                            factionPresence.ActiveStates.Add(FactionState.FromEDName(JsonParsing.getString(activeState, "state")) ?? FactionState.None);
                        }
                    }

                    // Pending states
                    presenceJson.TryGetValue("pending_states", out object pendingStatesVal);
                    if (pendingStatesVal != null)
                    {
                        var pendingStatesList = (List <object>)pendingStatesVal;
                        foreach (IDictionary <string, object> pendingState in pendingStatesList)
                        {
                            FactionTrendingState pTrendingState = new FactionTrendingState(
                                FactionState.FromEDName(JsonParsing.getString(pendingState, "state")) ?? FactionState.None,
                                JsonParsing.getInt(pendingState, "trend")
                                );
                            factionPresence.PendingStates.Add(pTrendingState);
                        }
                    }

                    // Recovering states
                    presenceJson.TryGetValue("recovering_states", out object recoveringStatesVal);
                    if (recoveringStatesVal != null)
                    {
                        var recoveringStatesList = (List <object>)recoveringStatesVal;
                        foreach (IDictionary <string, object> recoveringState in recoveringStatesList)
                        {
                            FactionTrendingState rTrendingState = new FactionTrendingState(
                                FactionState.FromEDName(JsonParsing.getString(recoveringState, "state")) ?? FactionState.None,
                                JsonParsing.getInt(recoveringState, "trend")
                                );
                            factionPresence.RecoveringStates.Add(rTrendingState);
                        }
                    }

                    faction.presences.Add(factionPresence);
                }

                return(faction);
            }
            catch (Exception ex)
            {
                Dictionary <string, object> data = new Dictionary <string, object>()
                {
                    { "input", response },
                    { "exception", ex }
                };
                Logging.Error("Failed to parse BGS faction data.", data);
                return(null);
            }
        }
Exemplo n.º 19
0
 void Update()
 {
     happiness = getHappiness();
 }
Exemplo n.º 20
0
        private static Faction ParseFaction(object response)
        {
            IDictionary <string, object> factionJson = Deserializtion.DeserializeData(response.ToString());
            Faction faction = new Faction
            {
                EDDBID     = (long)factionJson["eddb_id"],
                name       = (string)factionJson["name"],
                updatedAt  = (DateTime)factionJson["updated_at"],
                Government = Government.FromName((string)factionJson["government"]),
                Allegiance = Superpower.FromName((string)factionJson["allegiance"]),
            };

            foreach (object presence in (List <object>)factionJson["faction_presence"])
            {
                IDictionary <string, object> presenceJson = (IDictionary <string, object>)presence;
                FactionPresence factionPresence           = new FactionPresence()
                {
                    systemName   = (string)presenceJson["system_name"],
                    influence    = (decimal?)(double?)presenceJson["influence"] * 100, // Convert from a 0-1 range to a percentage
                    FactionState = FactionState.FromEDName((string)presenceJson["state"]) ?? FactionState.None,
                    Happiness    = Happiness.FromEDName((string)presenceJson["happiness"]) ?? Happiness.None,
                    updatedAt    = (DateTime)presenceJson["updated_at"],
                };

                // Active states
                presenceJson.TryGetValue("active_states", out object activeStatesVal);
                if (activeStatesVal != null)
                {
                    var activeStatesList = (List <object>)activeStatesVal;
                    foreach (IDictionary <string, object> activeState in activeStatesList)
                    {
                        factionPresence.ActiveStates.Add(FactionState.FromEDName(JsonParsing.getString(activeState, "state") ?? "None"));
                    }
                }

                // Pending states
                presenceJson.TryGetValue("pending_states", out object pendingStatesVal);
                if (pendingStatesVal != null)
                {
                    var pendingStatesList = (List <object>)pendingStatesVal;
                    foreach (IDictionary <string, object> pendingState in pendingStatesList)
                    {
                        FactionTrendingState pTrendingState = new FactionTrendingState(
                            FactionState.FromEDName(JsonParsing.getString(pendingState, "state") ?? "None"),
                            JsonParsing.getInt(pendingState, "trend")
                            );
                        factionPresence.PendingStates.Add(pTrendingState);
                    }
                }

                // Recovering states
                presenceJson.TryGetValue("recovering_states", out object recoveringStatesVal);
                if (recoveringStatesVal != null)
                {
                    var recoveringStatesList = (List <object>)recoveringStatesVal;
                    foreach (IDictionary <string, object> recoveringState in recoveringStatesList)
                    {
                        FactionTrendingState rTrendingState = new FactionTrendingState(
                            FactionState.FromEDName(JsonParsing.getString(recoveringState, "state") ?? "None"),
                            JsonParsing.getInt(recoveringState, "trend")
                            );
                        factionPresence.RecoveringStates.Add(rTrendingState);
                    }
                }

                faction.presences.Add(factionPresence);
            }

            return(faction);
        }
Exemplo n.º 21
0
    public SCHEDULED_ACTIVITY[] ProcessDay() // TODO: Currently if the places where the citizen lives and works are different the time to travel
    {                                        // is calculated without taking into the consideration the TransportSector of the place where he worls
        ResetDailySchedule();                // All hours are set to NONE
        int lastWorkHour = -1;

        if (acceptedJob.JobType == Job.TYPE.NONE) // If the citizen is unenployed
        {
            acceptedJob = city.CityParts[(int)LivingPlace].IndustrySector.GetWorkOffer();
            if (acceptedJob.JobType == Job.TYPE.NONE) // If the citizen cannot find a job in his neightbourhood...
            {                                         // tries a second time. This time can be in any part of the city
                acceptedJob = city.CityParts[(int)LivingPlace].IndustrySector.GetWorkOffer();
            }
        }

        if (acceptedJob.JobType != Job.TYPE.NONE)               // If the citizen has a job
        {
            for (int i = 0; i < acceptedJob.TimeRequiered; i++) // Sets the working hours in the schedule
            {
                int j = acceptedJob.Enter + i;
                if (j > 23)
                {
                    j -= 24;
                }
                dailySchedule[j] = SCHEDULED_ACTIVITY.WORK;
            }

            // This parts calculates how mucha hours the citizen needs to travel to work
            int distanceToJob = 0;
            if (LivingPlace == acceptedJob.CityPlace)
            {
                distanceToJob += Math.Abs(acceptedJob.Coords.X - Home.X) + Math.Abs(acceptedJob.Coords.Y - Home.Y); // Manhatan distance
            }
            else
            {
                distanceToJob += acceptedJob.Coords.X + acceptedJob.Coords.Y + Home.X + Home.Y;
            }
            float enviromentalConmmitmentValue = Global.Values.citizenEnviromentalTransportPreferences[(int)enviromentalCommitment];
            int   transportHoursLimit          = Global.Values.citizenTransportTimePreferences[(int)timeManagement];
            if (transportHoursLimit > 24 - acceptedJob.TimeRequiered)
            {
                transportHoursLimit = 24 - acceptedJob.TimeRequiered;
            }
            float rand = Global.Methods.GetRandomPercentage();
            TransportSector.TransportPlan transportPlan;
            if (rand < enviromentalConmmitmentValue)  // If the citizen is pro-enviroment will probably choose the least polluting option
            {
                transportPlan =
                    city.CityParts[(int)LivingPlace].TransportSector.GetLeastPolluting(distanceToJob, transportHoursLimit);
            }
            else // otherwise will choose between safety and speed
            {
                if (Health.GetIndexState() < Index.STATE.MEDIUM)  // If the citizen's health is low, he will go for the safest option
                {
                    transportPlan =
                        city.CityParts[(int)LivingPlace].TransportSector.GetSafest(distanceToJob, transportHoursLimit);
                }
                else // if that's not the case, he will choose the fastest
                {
                    transportPlan =
                        city.CityParts[(int)LivingPlace].TransportSector.GeFastest(distanceToJob, transportHoursLimit);
                }
            }

            if (transportPlan.Transport == Transport.TYPE.NONE) // If the citizen can't go to work he gets sad, and A PANALTY
            {
                Happiness.ChangeIndexValue(Index.CHANGE.LOW_DROP);
                RemoveMoney(Global.Values.failingToWorkPenalty);
                ResetDailySchedule(); // If there is not transport there is not work either
            }
            else
            {   // Using the transport has a cost in health
                Health.ChangeIndexValue(-(1 - transportPlan.Safety));
                lastWorkHour = acceptedJob.Enter + acceptedJob.TimeRequiered;
            }

            // If the citizens has no transport plan (because there are not viable options) => transportPlan.TimeRequiered = -1
            for (int i = 1; i < transportPlan.TimeRequiered + 1; i++)  // Sets the moving to work hours in the schedule
            {
                int j = acceptedJob.Enter - i;
                if (j < 0)
                {
                    j += 24;
                }
                dailySchedule[j] = SCHEDULED_ACTIVITY.MOVE_TO_WORK;
            }

            acceptedJob.RemainingDays--;
            if (acceptedJob.RemainingDays < 0)  // The day 0 is included
            {
                acceptedJob = city.CityParts[(int)LivingPlace].IndustrySector.FreeWorkOffer(acceptedJob.Coords);
            }
        }

        LeisureSector.LeisurePlan leisurePlan = LeisureSector.GetNullPlan();
        if (Health.GetIndexState() > Index.STATE.LOW) // If the citizen is not sick he will try to have fun
        {
            int firstAvailableHour = lastWorkHour + 1;
            int lastAvailableHour  = acceptedJob.Enter - 1;
            if (lastWorkHour < 0)
            {
                firstAvailableHour = 0;
                lastAvailableHour  = 23;
            }

            float rand = Global.Methods.GetRandomPercentage();
            float moneyExpendingValue = Global.Values.citizenMoneyExpendingPreferences[(int)moneyManagement];
            if (rand < moneyExpendingValue)
            {
                leisurePlan = city.CityParts[(int)LivingPlace].LeisureSector.GetCheapestPlan(Nature, firstAvailableHour, lastAvailableHour);
            }
            else
            {
                leisurePlan = city.CityParts[(int)LivingPlace].LeisureSector.GetMostSatisfyingPlan(Nature, firstAvailableHour, lastAvailableHour);
            }
        }

        if (leisurePlan.Place != Leisure.PLACE.NONE)
        {
            RemoveMoney(leisurePlan.Cost);
            Happiness.ChangeIndexValue(leisurePlan.Satisfaction);

            for (int i = 0; i < leisurePlan.TimeExpended; i++)
            {
                int j = leisurePlan.Enter + i;
                if (j > 23)
                {
                    j -= 24;
                }
                dailySchedule[j] = SCHEDULED_ACTIVITY.HAVE_FUN;
            }
        }

        // If the citizen's schedule contains enough continious hours without activitys this ours become resting hours. Theese ones are healthy
        int continiousNoneActivutyHours = 0;
        int firstActivityHour           = -1;

        for (int i = 0; i < 24; i++)
        {
            SCHEDULED_ACTIVITY s = dailySchedule[i];
            if (s == SCHEDULED_ACTIVITY.NONE)
            {
                continiousNoneActivutyHours++;
            }
            else if (firstActivityHour < 0)
            {
                firstActivityHour = i;
            }
            if (continiousNoneActivutyHours == Global.Values.minContiniousHoursToRest)
            {
                for (int j = i; j > i - continiousNoneActivutyHours; j--)
                {
                    dailySchedule[j] = SCHEDULED_ACTIVITY.REST;
                }
                continiousNoneActivutyHours = 0;
            }
        }
        if (continiousNoneActivutyHours + firstActivityHour + 1 >= Global.Values.minContiniousHoursToRest && firstActivityHour + 1 < Global.Values.minContiniousHoursToRest)
        {
            for (int i = 0; i < continiousNoneActivutyHours + firstActivityHour + 1; i++)
            {
                int j = continiousNoneActivutyHours + i;
                if (j > 23)
                {
                    j -= 24;
                }
                dailySchedule[j] = SCHEDULED_ACTIVITY.REST;
            }
        }

        foreach (SCHEDULED_ACTIVITY s in dailySchedule)
        {
            if (s == SCHEDULED_ACTIVITY.REST)
            {
                Health.ChangeIndexValue(Global.Values.restingHourBonus);
            }
        }

        return(dailySchedule);
    }
Exemplo n.º 22
0
    void InitSwaps()
    {
        Angry.setPosition(new Position(Level.Excluded, Circle.Green));
        Blessing.setPosition(new Position(Level.Excluded, Circle.Purple));
        Child.setPosition(new Position(Level.Excluded, Circle.Red));
        Curse.setPosition(new Position(Level.Excluded, Circle.Cyan));
        Heaven.setPosition(new Position(Level.Tertiary, Circle.GreenPurpleRed));
        Happiness.setPosition(new Position(Level.Tertiary, Circle.GreenRedCyan));
        Dragon.setPosition(new Position(Level.Tertiary, Circle.RedCyanPurple));
        Dream.setPosition(new Position(Level.Secondary, Circle.CyanRed));
        Energy.setPosition(new Position(Level.Secondary, Circle.GreenRed));
        Female.setPosition(new Position(Level.Secondary, Circle.CyanPurple));
        Force.setPosition(new Position(Level.Quaternary, Circle.GreenRedCyanPurple));
        Forest.setPosition(new Position(Level.Excluded, Circle.Purple));
        Friend.setPosition(new Position(Level.Secondary, Circle.GreenPurple));
        Hate.setPosition(new Position(Level.Secondary, Circle.GreenPurple));
        Hope.setPosition(new Position(Level.Excluded, Circle.Green));
        Kindness.setPosition(new Position(Level.Tertiary, Circle.CyanPurpleGreen));
        Longevity.setPosition(new Position(Level.Secondary, Circle.CyanPurple));
        Love.setPosition(new Position(Level.Secondary, Circle.CyanPurple));
        Loyal.setPosition(new Position(Level.Secondary, Circle.GreenRed));
        Spirit.setPosition(new Position(Level.Secondary, Circle.CyanRed));
        Male.setPosition(new Position(Level.Quaternary, Circle.GreenRedCyanPurple));
        Mountain.setPosition(new Position(Level.Secondary, Circle.GreenRed));
        Night.setPosition(new Position(Level.Excluded, Circle.Red));
        Pure.setPosition(new Position(Level.Secondary, Circle.GreenPurple));
        Heart.setPosition(new Position(Level.Secondary, Circle.CyanRed));
        River.setPosition(new Position(Level.Excluded, Circle.Cyan));
        Emotion.setPosition(new Position(Level.Excluded, Circle.Cyan));
        Soul.setPosition(new Position(Level.Excluded, Circle.Purple));
        Urgency.setPosition(new Position(Level.Excluded, Circle.Red));
        Wind.setPosition(new Position(Level.Excluded, Circle.Green));

        Debug.LogFormat("[Dragon Energy #{0}] Before swapping, the displayed words are:", _moduleId);
        for (int i = 0; i < displayed.Length; i++)
        {
            Debug.LogFormat("[Dragon Energy #{0}] {1} = {2}", _moduleId, displayed[i].getWord(), displayed[i].getPosition().getCircle().ToReadable());
        }

        char[] letters    = info.GetSerialNumberLetters().ToArray();
        int    vowelCount = 0;

        foreach (char letter in letters)
        {
            if (letter == 'A' || letter == 'E' || letter == 'I' || letter == 'O' || letter == 'U')
            {
                vowelCount++;
            }
        }

        if (info.GetBatteryCount() > 10 && (info.GetSerialNumberNumbers().ToArray()[info.GetSerialNumberNumbers().ToArray().Length - 1] == 5 || info.GetSerialNumberNumbers().ToArray()[info.GetSerialNumberNumbers().ToArray().Length - 1] == 7))
        {
            Swaps(1);
        }
        else if (info.GetPortPlateCount() > info.GetBatteryHolderCount() && (modules.Contains("Morse War") || modules.Contains("Double Color")))
        {
            Swaps(2);
        }
        else if ((info.IsIndicatorOn(Indicator.SIG) && info.IsIndicatorOn(Indicator.FRK)) || (info.GetOffIndicators().Count() == 3))
        {
            Swaps(3);
        }
        else if (info.GetModuleNames().Count() > 8)
        {
            Swaps(4);
        }
        else if (vowelCount >= 2)
        {
            Swaps(5);
        }
        else if (info.GetSolvedModuleNames().Count() == 0)
        {
            Swaps(6);
            dependsOnSolvedModules = true;
        }
        else
        {
            Swaps(7);
        }

        Debug.LogFormat("[Dragon Energy #{0}] After swapping, the displayed words are:", _moduleId);
        for (int i = 0; i < displayed.Length; i++)
        {
            Debug.LogFormat("[Dragon Energy #{0}] {1} = {2}", _moduleId, displayed[i].getWord(), displayed[i].getPosition().getCircle().ToReadable());
        }
    }
Exemplo n.º 23
0
    private void UpdateHapiness()
    {
        if (headScreenUI != null && headWorldUI != null)
        {
            distance = Vector3.Distance(Camera.main.transform.position, transform.position);
            int happyInt = Mathf.Abs((int)happy);
            if (happyInt > 9)
            {
                happyInt = 9;
            }

            // if we just blinked
            if (UnityEngine.Random.RandomRange(1, 100) >= blinkRate)
            {
                happyInt   -= 1;
                lastBlink   = Time.time;
                blinkLength = UnityEngine.Random.RandomRange(0.5f, 1f);
                blinked     = true;
            }
            // or we're continuing to blink
            else if (blinked && Time.time - lastBlink <= blinkLength)
            {
                happyInt -= 1;
            }
            // or we're not blinking or done blinking
            else
            {
                blinked = false;
            }

            if (happyInt < 0)
            {
                happyInt = 0;
            }

            float happyChange = 0f;
            if (needs[0].habitPrimary != null)
            {
                happyChange += influencerHappyPerSecond;
            }
            if (needs[1].habitPrimary != null)
            {
                happyChange += influencerHappyPerSecond;
            }
            if (needs[2].habitPrimary != null)
            {
                happyChange += influencerHappyPerSecond;
            }
            if (needs[3].habitPrimary != null)
            {
                happyChange += influencerHappyPerSecond;
            }
            if (influencer)
            {
                happy += Time.deltaTime * happyChange;
            }
            if (happy > maxNeedValue)
            {
                happy = maxNeedValue;
            }
            if (happy <= minNeedValue)
            {
                happy = minNeedValue;
            }

            if (happinessBar == null)
            {
                happinessBar = GetComponentInChildren <Happiness>();
            }
            if (happy > 0f)
            {
                happinessBar.happinessPosition = happy / maxNeedValue;
            }
            else
            {
                happinessBar.happinessPosition = 0f;
            }

            // Show world happy face close or screen happy face from afar
            if (distance > distanceToUIifyFace)
            {
                //headScreenUI.gameObject.SetActive(true);
                headScreenUI.GetComponent <CanvasUIElement>().GetUI().gameObject.SetActive(true);
                headScreenUI.GetComponent <CanvasUIElement>().activated = true;
                //headWorldUI.GetComponent<CanvasUIElement>().GetUI().GetComponent<Image>().enabled = true;

                RectTransform rt = headScreenUI.GetComponent <CanvasUIElement>().GetUI();
                Transform     t  = rt.transform.GetChild(1);
                t.gameObject.SetActive(true);
                t.GetComponent <Image>().sprite = MaslowManager.Instance.happies[happyInt];

                //headScreenUI.GetComponent<CanvasUIElement>().GetUI().transform.GetChild(1).GetComponent<Image>().sprite = MaslowManager.Instance.happies[happyInt];
                headWorldUI.gameObject.SetActive(false);
            }
            else
            {
                headWorldUI.GetComponent <Image>().sprite = MaslowManager.Instance.happies[happyInt];
                //headScreenUI.GetComponent<CanvasUIElement>().activated = false;
                //headScreenUI.GetComponent<CanvasUIElement>().GetUI().gameObject.SetActive(false);
                RectTransform rt = headScreenUI.GetComponent <CanvasUIElement>().GetUI();
                Transform     t  = rt.transform.GetChild(1);
                t.gameObject.SetActive(false);

                headWorldUI.gameObject.SetActive(true);
            }
        }
    }
Exemplo n.º 24
0
 public override void OnEntityProduced(GridSystem grid)
 {
     base.OnEntityProduced(grid);
     Happiness.IncreaseBonusHappiness();
 }
Exemplo n.º 25
0
        public override void OnDestroy()
        {
            base.OnDestroy();

            Happiness.ReduceBonusHappiness();
        }
 public override string ToString()
 {
     return(Name + Environment.NewLine + Age.ToString() + Environment.NewLine + Happiness.ToString() + Environment.NewLine() + Animaltype.ToString());
 }
Exemplo n.º 27
0
 public DailyRewards()
 {
     Wallet    = new Wallet();
     Happiness = new Happiness();
 }
 private static void PrintHappinessIndex(Happiness happiness)
 {
     Console.WriteLine($"Happiness index: {happiness.HappinessIndex:F2} {happiness.Emoticon}");
     Console.WriteLine($"[Happy count: {happiness.HappyCount}, Sad count: {happiness.SadCount}]");
 }
Exemplo n.º 29
0
 /// <inheritdoc />
 public override string ToString()
 {
     return(!Type.HasValue ? Happiness.ToString() : Type.ToString());
 }
Exemplo n.º 30
0
 public int CompareTo([AllowNull] DPStatus other) => Happiness.CompareTo(other.Happiness);