コード例 #1
0
ファイル: Infection.cs プロジェクト: minkooz/FungusCave
        public bool HasInfection(out InfectionTag tag, out int duration)
        {
            duration = 0;
            tag      = InfectionTag.INVALID;

            foreach (InfectionTag t in Enum.GetValues(typeof(InfectionTag)))
            {
                if (GetComponent <Infection>().HasInfection(t, out duration))
                {
                    tag = t;
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
ファイル: Infection.cs プロジェクト: minkooz/FungusCave
        private void ChooseInfection()
        {
            bool         repeat;
            InfectionTag newInfection;

            InfectionTag[] candidates = new InfectionTag[]
            { InfectionTag.Mutated, InfectionTag.Slow, InfectionTag.Weak };

            // The same infection should not appear 3 times (maxRepeat) in a row.
            do
            {
                newInfection = candidates[random.Next(SeedTag.Infection,
                                                      0, candidates.Length)];

                if (previousInfection.Count == 0)
                {
                    previousInfection.Push(newInfection);
                    break;
                }
                else if (previousInfection.Peek() == newInfection)
                {
                    if (previousInfection.Count < maxRepeat)
                    {
                        previousInfection.Push(newInfection);
                        break;
                    }
                    else
                    {
                        repeat = true;
                    }
                }
                else
                {
                    previousInfection = new Stack <InfectionTag>();
                    previousInfection.Push(newInfection);
                    break;
                }
            } while (repeat);

            infectionDict[newInfection] = infectionData.Duration;
        }
コード例 #3
0
ファイル: Infection.cs プロジェクト: minkooz/FungusCave
 public bool HasInfection(InfectionTag tag, out int duration)
 {
     duration = infectionDict[tag];
     return(duration > 0);
 }
コード例 #4
0
ファイル: Infection.cs プロジェクト: minkooz/FungusCave
 public bool HasInfection(InfectionTag tag)
 {
     return(infectionDict[tag] > 0);
 }
コード例 #5
0
 public string GetInfectionName(InfectionTag infection)
 {
     return(GetComponent <GameText>().GetStringData(
                "InfectionName", infection));
 }