예제 #1
0
        private void TestFormulas()
        {
            var       Accuracy  = new Accuracy(10);
            var       Cloaking  = new Cloaking(20);
            const int allCount  = 100000;
            int       countCrit = 0;
            int       countHit  = 0;

            for (int i = 0; i < allCount; i++)
            {
                if (Accuracy.GetCriticalChance(Cloaking))
                {
                    countCrit += 1;
                }
                if (Accuracy.GetHitChance(Cloaking))
                {
                    countHit += 1;
                }
            }
            int countAll = countCrit + countHit;
            var crit     = Mathf.RoundToInt(countCrit / (float)allCount * 100);
            var hit      = Mathf.RoundToInt(countHit / (float)allCount * 100);
            var all      = Mathf.RoundToInt(countAll / (float)allCount * 100);

            Debug.LogError("crit " + crit + "% hit " + hit + "% all " + all + "%");
        }
예제 #2
0
파일: Titan.cs 프로젝트: mefist0fel/Titans
 public Titan(Faction faction, Battle battleContext, Vector3 position)
 {
     Faction     = faction;
     Name        = Faction.GetTitanName();
     Context     = battleContext;
     Speed       = 1f;
     AFrmor      = 10;
     Mover       = new TitanMover(battleContext.Planet, position, Speed);
     ModuleSlots = new ModuleSlot[12];
     for (int i = 0; i < ModuleSlots.Length; i++)
     {
         ModuleSlots[i] = new ModuleSlot(this);
     }
     Shield         = new Shield(UpdateLives);
     Armor          = new Armor(UpdateLives);
     Accuracy       = new Accuracy();
     Cloaking       = new Cloaking();
     AntiAirDefence = new AntiAirDefence();
     Components     = new List <IComponent>()
     {
         Armor,
         Shield,
         Accuracy,
         Cloaking,
         AntiAirDefence,
         new RocketLauncher(this, Context),
         new Laser(this, Context, Accuracy)
     };
     AddParams(Config.Base);
     Faction.AddUnit(this);
     // TODO kill
     ResourceUnits = 10;
     // ModuleSlots[0].Build(Config.Modules["anti_air"]);
 }
예제 #3
0
        public bool GetCriticalChance(Cloaking cloaking)
        {
            var cloakAspect = (float)cloaking.Value / (float)Value;
            var critChance  = 1f - Mathf.Min(1f, cloakAspect);

            critChance = critChance * (1f - minimalCriticalChance) + minimalCriticalChance;
            return(Random.Range(0f, 1f) < critChance);
        }
예제 #4
0
        public bool GetHitChance(Cloaking cloaking)
        {
            var accuracyAspect = (float)Value / (float)cloaking.Value;
            var missChance     = 1f - Mathf.Min(1f, accuracyAspect);

            missChance = missChance * (1f - minimalMissChance) + minimalMissChance;
            return(Random.Range(0f, 1f) > missChance);
        }