Ejemplo n.º 1
0
        public List <TravelMessenger.PartyMessageDto> Eat()
        {
            var travelMessenger = Object.FindObjectOfType <TravelMessenger>();

            if (_companions == null || _companions.Count < 1)
            {
                var partyDto = new TravelMessenger.PartyMessageDto
                {
                    Message   = "No mouths to feed!",
                    TextColor = new Color32(1, 1, 1, 1)
                };

                return(new List <TravelMessenger.PartyMessageDto> {
                    partyDto
                });
            }

            var eatResult = new List <TravelMessenger.PartyMessageDto>();

            //todo choose random order to feed companions. This allows for some to eat and not others when food is low. Then subtract morale for the hungry.

            if (Food < _companions.Count)
            {
                Food = 0;

                foreach (var companion in _companions.Values)
                {
                    companion.SubtractMorale(MoraleFoodModifier);
                }

                var partyDto = new TravelMessenger.PartyMessageDto
                {
                    Message   = "Not enough food! Party morale drops!",
                    TextColor = travelMessenger.penaltyColor
                };

                eatResult.Add(partyDto);

                Debug.Log("Not enough food! Party morale drops!");
            }
            else
            {
                Food -= _companions.Count * FoodConsumedPerCompanion;

                var partyDto = new TravelMessenger.PartyMessageDto
                {
                    Message   = $"Party ate {_companions.Count * FoodConsumedPerCompanion} food!",
                    TextColor = travelMessenger.rewardColor
                };

                eatResult.Add(partyDto);

                Debug.Log($"Party ate {_companions.Count * FoodConsumedPerCompanion} food!");
            }

            //todo food amount changed event to update party status bar

            return(eatResult);
        }
Ejemplo n.º 2
0
        private void ApplyPartyPenalty(Penalty partyPenalty)
        {
            if (_travelMessenger == null)
            {
                _travelMessenger = FindObjectOfType <TravelMessenger>();
            }

            var penaltiesText = new List <TravelMessenger.PartyMessageDto>();

            if (partyPenalty.PartyLosses != null && partyPenalty.PartyLosses.Count > 0)
            {
                foreach (var partyLoss in partyPenalty.PartyLosses)
                {
                    var lossType = partyLoss.Key;

                    switch (lossType)
                    {
                    case PartySupplyTypes.Food:
                        Party.Food -= partyLoss.Value;
                        break;

                    case PartySupplyTypes.HealthPotions:
                        Party.HealthPotions -= partyLoss.Value;
                        break;

                    case PartySupplyTypes.Gold:
                        Party.Gold -= partyLoss.Value;
                        break;

                    default:
                        Debug.Log($"Invalid loss type! {lossType}");
                        break;
                    }

                    var partyDto = new TravelMessenger.PartyMessageDto
                    {
                        Message   = BuildPartyLossTextItem(partyLoss.Value, lossType),
                        TextColor = _travelMessenger.penaltyColor
                    };

                    penaltiesText.Add(partyDto);
                }
            }

            _travelMessenger.QueuePartyMessages(penaltiesText);
        }
Ejemplo n.º 3
0
        public void ApplyPartyReward(Reward partyReward)
        {
            if (_travelMessenger == null)
            {
                _travelMessenger = FindObjectOfType <TravelMessenger>();
            }

            var rewardsText = new List <TravelMessenger.PartyMessageDto>();

            if (partyReward.PartyGains != null && partyReward.PartyGains.Count > 0)
            {
                foreach (var partyGain in partyReward.PartyGains)
                {
                    var gainType = (PartySupplyTypes)partyGain.Key;

                    switch (gainType)
                    {
                    case PartySupplyTypes.Food:
                        Party.Food += partyGain.Value;
                        break;

                    case PartySupplyTypes.HealthPotions:
                        Party.HealthPotions += partyGain.Value;
                        break;

                    case PartySupplyTypes.Gold:
                        Party.Gold += partyGain.Value;
                        break;

                    default:
                        Debug.Log($"Invalid gain type! {gainType}");
                        break;
                    }

                    var partyDto = new TravelMessenger.PartyMessageDto
                    {
                        Message   = BuildPartyRewardTextItem(partyGain.Value, gainType),
                        TextColor = _travelMessenger.rewardColor
                    };

                    rewardsText.Add(partyDto);
                }
            }

            _travelMessenger.QueuePartyMessages(rewardsText);
        }
Ejemplo n.º 4
0
        private void ApplyInventoryAdditions(Reward reward)
        {
            if (reward.InventoryGains == null || reward.InventoryGains.Count < 1)
            {
                return;
            }

            var inventory = Inventory.GetPartyInventory();

            foreach (var item in reward.InventoryGains)
            {
                inventory.AddToFirstEmptySlot(item, 1);

                var partyDto = new TravelMessenger.PartyMessageDto
                {
                    Message   = BuildItemAdditionTextItem(item),
                    TextColor = _travelMessenger.rewardColor
                };

                _travelMessenger.QueuePartyMessages(new List <TravelMessenger.PartyMessageDto> {
                    partyDto
                });
            }
        }