Exemplo n.º 1
0
    void GenerateRaidOutcome(Raid r)
    {
        RaidSpawner.RaidInfo raidInfo = r.raidInfo;
        float       successRate       = raidInfo.successRate;
        float       successNum        = Random.Range(1f, 100f);
        RaidOutcome raidOutcome       = new RaidOutcome();

        if (successNum <= successRate)
        {
            raidOutcome.status     = RaidOutcomeStatus.Success;
            raidOutcome.goldAmount = raidInfo.goldAmount;
            float capturedNum = Random.Range(1f, 100f);
            float captureRate = raidInfo.captureChance;
            if (capturedNum <= captureRate)
            {
                raidOutcome.isCaptured = true;
            }
        }
        else
        {
            raidOutcome.status = RaidOutcomeStatus.Failure;
            float lossRate = Random.Range(1f, 100f);
            if (lossRate <= 10)
            {
                raidOutcome.isLost = true;
            }
        }
        raidOutcome.damageTaken = CalculateDamageTaken(r, successNum <= successRate);
        raidOutcome.crewLost    = CalculateCrewLost(r, successNum <= successRate);
        raidOutcome.raid        = r;
        raidOutcomes.Push(raidOutcome);
    }
Exemplo n.º 2
0
 public void ShowNextRaidOutcome()
 {
     if (GameManager.instance.IsTimeMoving())
     {
         GameManager.instance.Pause();
     }
     if (raidOutcomes.Count > 0)
     {
         RaidOutcome raidOutcome = raidOutcomes.Pop();
         if (raidOutcome.status == RaidOutcomeStatus.Success)
         {
             successfulRaidResult.ShowRaidOutcome(raidOutcome);
         }
         else
         {
             failedRaidResult.ShowRaidOutcome(raidOutcome);
         }
     }
     else
     {
         GameManager.instance.Play();
     }
 }