示例#1
0
 //Increse the chance to hit with a shot as the distance between 2 mechs gets smaller.
 private void GaugeDistance(BaseMech user, BaseMech comp, int distance, Random rnd)
 {
     if (distance < 1000 && distance >= 700)
     {
         Fire(user, comp, 60, rnd);
         Fire(comp, user, 60, rnd);
     }
     else if (distance < 700 && distance > 300)
     {
         Fire(user, comp, 75, rnd);
         Fire(comp, user, 75, rnd);
     }
     else
     {
         Fire(user, comp, 90, rnd);
         Fire(comp, user, 90, rnd);
     }
 }
示例#2
0
        private void Fire(BaseMech mech, BaseMech opponent, double hitChance, Random rnd)
        {
            double tempMechAttack = 0;
            int mechAttack = 0;
            int divisor = 4;            //Break the mech's total attack rating into 4 seperate shots.
            tempMechAttack = (double)mech.MechAttack / divisor;

            for (int i = 0; i < divisor; i++)
            {
                if (rnd.Next(1, 100) <= hitChance)  //Check if the random number falls within the chance to hit.
                {
                    mechAttack += (int)tempMechAttack;  //If the shot is successful, add it to the mech's attack for this turn.
                }
            }
            opponent.MechDefense -= mechAttack;        //Subtract the successful shots total from the oppenents defense rating.
        }