예제 #1
0
func (bl *BlowList) ChooseBlowMethod(bt int) fightBase.Blower {
	dice.Shake()
	blow := bl.blows[dice.Throw(len(bl.blows), 1)-1]
	for (bt == fightBase.BT_MELEE && blow.IsRange()) || (bt == fightBase.BT_RANGE && !blow.IsRange()) {
		blow = bl.blows[dice.Throw(len(bl.blows), 1)-1]
	}
	return blow
}
예제 #2
0
func (m *Mob) chooseDir() {
	newDir := m.Dir
	for newDir == m.Dir {
		newDir = directions[dice.Throw(4, 1)-1]
	}
	m.Dir = newDir
}
예제 #3
0
func (m *Mob) GetHit(blow fightBase.Blower, attacker gameObjectsBase.Activer) consts.JsonType {
	res := m.ActiveObject.GetHit(blow, attacker)
	if t, isExist := m.GetTarget(); isExist {
		if t.GetType() != consts.PLAYER_TYPE {
			if attacker.GetType() == consts.PLAYER_TYPE {
				m.SetTarget(attacker)
			} else {
				dice.Shake()
				ary := [2]gameObjectsBase.Activer{t, attacker}
				m.SetTarget(ary[dice.Throw(2, 1)-1])
			}
		}
	} else {
		m.SetTarget(attacker)
	}
	return res
}
예제 #4
0
func (m *Mob) goToTarget() {
	target := m.Target.GetCenter()
	dx := target.X - m.Center.X
	dy := target.Y - m.Center.Y
	eps := 0.2
	if dice.Throw(4, 1)%2 == 0 {
		if math.Abs(dx) > eps {
			m.chooseHorizontalDir(dx)
		} else {
			m.chooseVerticalDir(dy)
		}
	} else {
		if math.Abs(dy) > eps {
			m.chooseVerticalDir(dy)
		} else {
			m.chooseHorizontalDir(dx)
		}
	}
}
예제 #5
0
func (dd *DmgDescription) GetDamage() int {
	dice.Shake()
	return dice.Throw(dd.edge_amount, dd.throws_amount)
}