1、血量、伤害两个因素作用,击杀目标
正常状态下:hp -= attackValue;
特殊状态下:attackValue *=2; //伤害翻倍
如飞机/坦克大战中,击杀对方;受到伤害时,装备道具磨损失效;
public int hp=10;
private bool isDebuff;
public void AttackEnemy(int attackValue)
{
if (isDebuff) attackValue *= 2;
hp -= attackValue;
if (hp <= 0) isDead = true;
}
--*************************************************************************************************--
2、血量(不可变)、伤害、以及随机成功概率三个因素作用,概率性击杀目标
伤害数值设计思路:
targetRate是随机出来的此次目标概率;hp越大越难,attackValue越大越容易;
若各因素叠加后的概率大于目标概率,则能击杀成功。
随机数:targetRate = Mathf.Floor(Random.Range(0,100));
公式1:if (targetRate <=( 50-(hp-attackValue) )/2 ){isOk = true;} 50表示基础概率;
公式2:if (targetRate <= attackValue*3 - hp/10){isOk = true;}
如捕鱼达人中每次成功攻击鱼时捕获成功的概率;
private bool isOk = false;
public int hp =