void ApplyOutcome(EventOutcome outcome)
    {
        bottomText.text = ResolveTextSize(outcome.eventOutcomeText);

        outcomeSlide.renderer.material.mainTexture = outcome.eventOutcomePicture;
        outcomeSlide.state = SlideState.Entering;
    }
예제 #2
0
    public void SelectChoice(EventChoice choice, Item usage)
    {
        EventOutcome outcome = choice.Outcome(currentUnit, usage, text);

        text.ClearChoices();
        DisplayOutcome(outcome);
        text.NextLine();
    }
예제 #3
0
    IEnumerator ListenForPlayerSelection(EventOutcome outcome)
    {
        while (selectedPlayer == null)
        {
            yield return(0);
        }

        //We've been given a player, now fire the outcome
        FireEventOutcome(outcome);
        GameObject.FindGameObjectWithTag("GUIManager").GetComponent <GUIManager>().RecieveEventTextFromEventCompletion(delayedOutcomeText);
        m_eventShouldSelfDestruct = true;
    }
예제 #4
0
 public void DisplayOutcome(EventOutcome outcome)
 {
     text.CreateDialogue(outcome.description);
     if (outcome.IsItem)
     {
         text.CreateReward(outcome.items);
     }
     if (outcome.IsEffect)
     {
         text.CreateAbility(outcome.effects);
     }
     if (outcome.isEnd)
     {
         text.CreateEnd();
     }
 }
예제 #5
0
        public EventOutcome GetEventOutcomeForMarket(string eventId, string marketId)
        {
            var eventById = GetById(eventId, true, true);

            if (eventById == null)
            {
                return(null);
            }
            var eventOutcome = new EventOutcome {
                EventId = eventId
            };

            if (eventById.EventMarkets == null || eventById.EventMarkets.Count == 0 || eventById.EventMarkets.FirstOrDefault(m => m.Id == marketId) == null)
            {
                return(eventOutcome);
            }
            eventOutcome.WinningMarketId = marketId;
            eventOutcome.WinningMarket   = eventById.EventMarkets.FirstOrDefault(m => m.Id == marketId);

            eventById.EventMarkets.ForEach(market =>
            {
                var marketOutcome = new MarketOutcome
                {
                    Market = market,
                    MarketLoseProfitAmount = market.GetMarketLoseProfitAmount(),
                    MarketWinPayoutAmount  = market.GetMarketWinPayoutAmount()
                };
                eventOutcome.PossibleMarketOutcomes.Add(marketOutcome);
                if (market.Id == marketId) //Minus payout amount
                {
                    eventOutcome.PLAmount -= marketOutcome.MarketWinPayoutAmount;
                }

                eventOutcome.PLAmount += marketOutcome.MarketLoseProfitAmount;
            });

            return(eventOutcome);
        }
예제 #6
0
    void FireEventOutcome(EventOutcome outcome)
    {
        switch (outcome.m_typeOfOutcome)
        {
        case OutcomeType.AffectsCapitalShipMoveTarget:
        {
            //Set CShip target
            GameObject.FindGameObjectWithTag("Capital").GetComponent <CapitalShipScript>().SetTargetPoint(outcome.m_outcomeFocusPoint);
            break;
        }

        case OutcomeType.AffectsCapitalShipObjective:
        {
            //TODO: Add this in after the CShip objective system
            break;
        }

        case OutcomeType.AffectsCapitalShipResource:
        {
            switch (outcome.m_affectedResource)
            {
            case ResourceType.CShipFuel:
            {
                if (outcome.m_outcomeMagnitude < 0)
                {
                    GameObject.FindGameObjectWithTag("Capital").GetComponent <CapitalShipScript>().ReduceResourceFuel(-outcome.m_outcomeMagnitude);
                }
                else
                {
                    GameObject.FindGameObjectWithTag("Capital").GetComponent <CapitalShipScript>().IncreaseResourceFuel(outcome.m_outcomeMagnitude);
                }
                break;
            }

            case ResourceType.CShipWater:
            {
                if (outcome.m_outcomeMagnitude < 0)
                {
                    GameObject.FindGameObjectWithTag("Capital").GetComponent <CapitalShipScript>().ReduceResourceWater(-outcome.m_outcomeMagnitude);
                }
                else
                {
                    GameObject.FindGameObjectWithTag("Capital").GetComponent <CapitalShipScript>().IncreaseResourceWater(outcome.m_outcomeMagnitude);
                }
                break;
            }

            case ResourceType.CShipMass:
            {
                if (outcome.m_outcomeMagnitude < 0)
                {
                    GameObject.FindGameObjectWithTag("Capital").GetComponent <CapitalShipScript>().ReduceResourceMass(-outcome.m_outcomeMagnitude);
                }
                else
                {
                    GameObject.FindGameObjectWithTag("Capital").GetComponent <CapitalShipScript>().IncreaseResourceMass(outcome.m_outcomeMagnitude);
                }
                break;
            }

            default:
            {
                Debug.Log("Couldn't find appropriate capital resource " + outcome.m_affectedResource.ToString());
                break;
            }
            }
            break;
        }

        case OutcomeType.AffectsPlayerCash:
        {
            //We should be passed a player that will be affected, so we'll store that in a temp for now
            if (outcome.m_outcomeMagnitude < 0)
            {
                selectedPlayer.GetComponent <PlayerControlScript>().RemoveSpaceBucks(-outcome.m_outcomeMagnitude);
            }
            else
            {
                selectedPlayer.GetComponent <PlayerControlScript>().AddSpaceBucks(outcome.m_outcomeMagnitude);
            }
            break;
        }

        case OutcomeType.CreatesNewSpawnPoint:
        {
            GameObject newSpawnPoint = new GameObject();
            newSpawnPoint.transform.position = outcome.m_outcomeFocusPoint.position;
            newSpawnPoint.AddComponent <EnemySpawnPointScript>();
            newSpawnPoint.tag = "SpawnPoint";

            //Generate list of GOs to spawn
            List <WaveInfo> enemyWaves = new List <WaveInfo>();
            foreach (WaveInfo wave in outcome.m_enemiesAssociated)
            {
                enemyWaves.Add(wave);
            }

            //EnemySpawnPointScript spawnPoint = newSpawnPoint.GetComponent<EnemySpawnPointScript>();
            //spawnPoint.SetSpawnList(enemyWaves, timeBetweenWaves);
            //spawnPoint.m_shouldStartSpawning = true;
            break;
        }

        case OutcomeType.ImmediatelySpawnsEnemies:
        {
            if (outcome.m_outcomeFocusPoint != null)
            {
                //Immediately spawn the enemies at the focus point
                List <GameObject> enemiesToSpawn = new List <GameObject>();
                foreach (WaveInfo wave in outcome.m_enemiesAssociated)
                {
                    foreach (GameObject enemy in wave.GetRawWave())
                    {
                        enemiesToSpawn.Add(enemy);
                    }
                }

                foreach (GameObject enemy in enemiesToSpawn)
                {
                    Network.Instantiate(enemy, outcome.m_outcomeFocusPoint.position, outcome.m_outcomeFocusPoint.rotation, 0);
                }

                break;
            }
            else
            {
                //Otherwise spawn it where the event object is
                List <GameObject> enemiesToSpawn = new List <GameObject>();
                foreach (WaveInfo wave in outcome.m_enemiesAssociated)
                {
                    foreach (GameObject enemy in wave.GetRawWave())
                    {
                        enemiesToSpawn.Add(enemy);
                    }
                }

                foreach (GameObject enemy in enemiesToSpawn)
                {
                    Network.Instantiate(enemy, this.transform.position, this.transform.rotation, 0);
                }

                break;
            }
        }

        case OutcomeType.CausesCShipDamage:
        {
            GameObject.FindGameObjectWithTag("Capital").GetComponent <HealthScript>().DamageMobHullDirectly(outcome.m_outcomeMagnitude);
            break;
        }

        case OutcomeType.CausesPlayerDamage:
        {
            //selectedPlayer.GetComponent<HealthScript>().DamageMob(outcome.m_outcomeMagnitude, null);
            selectedPlayer.GetComponent <HealthScript>().DamageMobHullDirectly(outcome.m_outcomeMagnitude);
            break;
        }
        }
    }
예제 #7
0
    public string ActivateOption(int optionNum)
    {
        //We should assume the requirements are already met, since the gui shouldn't let them click it if they aren't met
        networkView.RPC("PropagateTriggered", RPCMode.All, true);

        //Get the selected option
        EventOption selectedOption = m_possibleOptions[optionNum];

        //Generate a number from 1 to the total percentage of all outcome groups
        int totalPercentage = 0;

        foreach (EventOutcomeGroup group in selectedOption.m_optionGroups)
        {
            totalPercentage += group.percentageChance;
        }


        int rand     = Random.Range(0, totalPercentage);
        int previous = 0;
        //Debug.Log ("Total Percentage = " + totalPercentage + ", Rand = " + rand + ".");


        //Find the appropiate outcome group to be triggered
        EventOutcomeGroup groupToBeTriggered = null;

        foreach (EventOutcomeGroup group in selectedOption.m_optionGroups)
        {
            if (rand < (group.percentageChance + previous))
            {
                groupToBeTriggered = group;
                break;
            }
            else
            {
                previous += group.percentageChance;
            }
        }

        //Get all outcomes of this group and trigger them
        //If any of the outcomes need a player, then pause
        bool         playerReqd           = false;
        EventOutcome outcomePlayerReqdFor = null;

        if (groupToBeTriggered != null)
        {
            foreach (EventOutcome outcome in groupToBeTriggered.m_outcomesInThisGroup)
            {
                if (outcome.m_outcomeRequiresSpecificPlayer)
                {
                    playerReqd           = true;
                    outcomePlayerReqdFor = outcome;
                }
                else
                {
                    FireEventOutcome(outcome);
                }
            }
        }
        else
        {
            Debug.LogError("An outcome group was not selected!");
        }

        //foreach(EventOutcomeGroup

        /*foreach(EventOutcome outcome in selectedOption.m_optionOutcome)
         * {
         *      FireEventOutcome(outcome);
         * }*/

        if (playerReqd)
        {
            selectedPlayer = null;
            StartCoroutine(ListenForPlayerSelection(outcomePlayerReqdFor));
            delayedOutcomeText = groupToBeTriggered.m_groupOutcomeText;
            GameObject.FindGameObjectWithTag("GUIManager").GetComponent <GUIManager>().RecievePlayerRequiresSelectingForEvent("A player selection is required");
            return("A player selection is required");
        }
        else
        {
            //Return the string so the GUI can draw it
            string text = "YOU SHOULDN'T SEE THIS";
            if (groupToBeTriggered != null)
            {
                text = groupToBeTriggered.m_groupOutcomeText;
            }
            GameObject.FindGameObjectWithTag("GUIManager").GetComponent <GUIManager>().RecieveEventTextFromEventCompletion(text);
            m_eventShouldSelfDestruct = true;
            return(text);
        }
    }
예제 #8
0
        /// <summary>
        /// Initialize the timeline event.
        /// </summary>
        /// <param name="timeline">The timeline this event is part of.</param>
        /// <param name="start">The start of the event.</param>
        /// <param name="dependentOn">An optional event to be dependent upon, ie. wait for.</param>
        protected virtual void Initialize(Timeline timeline, float start, TimelineEvent dependentOn)
        {
            //Initialize the variables.
            _Timeline = timeline;
            _StartTime = start;
            _EndTime = start;
            _DependentOn = dependentOn;
            _Outcome = EventOutcome.None;
            _State = TimelineState.Idle;

            //If this event is dependent upon someone else, subscribe to it.
            if (_DependentOn != null) { _DependentOn.OnConcluded += OnDependentEnded; }
        }
예제 #9
0
    public void SelectOption(int selection)
    {
        currentEvent.hasChosen = true;

        selectedOutcome = currentEvent.options.ElementAt(selection).getRandomOutcome();
    }
    public void ApplyOutcomeEffect(EventOutcome outcome, Boat target)
    {
        switch (outcome.TargetResource)
        {
        case ResourceType.Boat:
            if (outcome.AffectOtherInZone)
            {
                foreach (Boat b in target.CurrentZone.PlacedBoats)
                {
                    _playerController.RemoveBoat(b);
                }
            }
            else
            {
                _playerController.RemoveBoat(target);
            }
            break;

        case ResourceType.Crew:
            if (outcome.AffectOtherInZone)
            {
                foreach (Boat b in target.CurrentZone.PlacedBoats)
                {
                    _playerController.KillMemberFromBoat(b);
                }
            }
            else
            {
                _playerController.KillMemberFromBoat(target);
            }
            break;

        case ResourceType.Health:
            if (outcome.AffectOtherInZone)
            {
                foreach (Boat b in target.CurrentZone.PlacedBoats)
                {
                    b.CurrentHealth += outcome.Value;
                }
            }
            else
            {
                target.CurrentHealth += outcome.Value;
            }
            break;

        case ResourceType.Money:
            float moneyGain = outcome.Value;
            if (outcome.AffectOtherInZone)
            {
                moneyGain *= target.CurrentZone.PlacedBoats.Count;
            }
            _playerController.AddToMoneyAmount(moneyGain);
            break;

        case ResourceType.ZoneHealth:
            target.CurrentZone.CurrentHealth -= outcome.Value;
            break;

        default:
            break;
        }
    }