Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        float value = FMPlayer.GetOrCreateInstance().m_Capital;

        value *= multiplier;  //because humans' psychology ;)

        m_CapitalDisplayText.text = value.ToString();
    }
Esempio n. 2
0
    private void FMCodfather_OnMessage(string username, string message)
    {
        if (!m_ShowingMafia && message.ToLower().Contains("mafia"))
        {
            StartCoroutine(SpawnMafia());
        }

        if (message.ToLower().Contains("donate"))
        {
            FMPlayer.GetOrCreateInstance().IncrementCapital((int)Random.Range(1.0f, 5.0f));
        }
    }
Esempio n. 3
0
    protected override void TriggerTask()
    {
        base.TriggerTask();

        // determine capital gain
        float totalAmount = GetCurrentResourceSum();
        float capitalGain = m_WorkerStagingArea.transform.childCount * m_PerDemandRevenue;

        FMPlayer.GetOrCreateInstance().IncrementCapital(capitalGain);

        // deplete resource
        var   resourcesToDeplete = m_ConsumerTriggerResourceAmount;
        float triggeredSickness  = 0f;
        var   depletedAmount     = 0f;

        while (depletedAmount < m_ConsumerTriggerResourceAmount && m_Resources.Count > 0)
        {
            var resource      = m_Resources.Peek();
            var thisDepletion = Mathf.Min(resource.m_ProcessedAmount, resourcesToDeplete);

            float percentageSicknessToUse = thisDepletion / m_ConsumerTriggerResourceAmount;
            resource.m_ProcessedAmount -= thisDepletion;
            triggeredSickness          += percentageSicknessToUse * resource.m_Sickness;
            depletedAmount             += thisDepletion;
            resourcesToDeplete         -= thisDepletion;

            if (resource.m_ProcessedAmount <= 0)
            {
                m_Resources.Dequeue();
            }
        }

        totalAmount -= depletedAmount;
        m_SinkLevelDisplay.UpdateLevelDisplay(totalAmount);
        if (totalAmount <= 0)
        {
            m_TaskProcessing = false;
            SetProgress(0f);
        }

        // Spawn coins...
        if (this.m_CoinPrefab)
        {
            for (int i = 0; i < 3; i++)
            {
                Instantiate(this.m_CoinPrefab, this.transform.position, Quaternion.identity, this.transform);
            }
        }

        // get people sick
        m_CurrentSicknessLevel = triggeredSickness;
    }
Esempio n. 4
0
    private IEnumerator SpawnMafia()
    {
        m_ShowingMafia = true;
        var mafiaInstance = Instantiate(m_MafiaPrefab, m_SpawnCanvas.transform);
        // get a random sink and put mafia there...
        //var potentialSinks = FMBoardReferences.GetOrCreateInstance().m_ResourceSinks;
        //int randomSink = Random.Range(0, potentialSinks.Length);
        //var sink = potentialSinks[randomSink];
        var staging = FMBoardReferences.GetOrCreateInstance().m_WorkerPoolStagingArea;

        staging.AddToStaging(mafiaInstance.transform);
        FMPlayer.GetOrCreateInstance().IncrementCapital(-25f);
        //TODO: have the mafia say something
        yield return(new WaitForSeconds(5f));

        m_LastMafiaSpawnTime = Time.time;
        Destroy(mafiaInstance);
        m_ShowingMafia = false;
    }
Esempio n. 5
0
 private void Awake()
 {
     FMPlayer.GetOrCreateInstance().OnCapitalIncrease += OnCapitalIncrease;
 }