void AttackEnemy(float delta) { float distance = ServerMath.Distance(this, target); if (distance <= attackRange) { Quaternion rot = ServerMath.LookAt(this, target); ((MonsterSyncData)sync).SetRotate(rot.Y, rot.W); ((MonsterSyncData)sync).SetAnime(2); if (endMotion <= 0) { startMotion += delta; if (startMotion >= realAttackTime) { Attack(target, GetAutoAttackPower()); ObjectManager.AddBullet(this.GetObjID(), target.GetObjID()); startMotion = 0; endMotion = cooldownTime; } } } else { ((MonsterSyncData)sync).SetRotate(init_yRot, init_wRot); ((MonsterSyncData)sync).SetAnime(0); target = null; startMotion = 0; } }
public static void ApplyAutoAttack(NetConnection connet, ushort tarObjID) { ushort objID = clients[connet].objID; Hero hero = heroes[objID]; ServerSideObject target = GetObject(tarObjID); if (target != null) { hero.Attack(target, hero.GetAutoAttackPower()); AddBullet(hero.GetObjID(), target.GetObjID()); } }
void AttackMove(float delta) { if (currentPath < relayPoints.Count) { Vector3 src = new Vector3(GetXPos(), 0, GetZPos()); Vector3 dest = new Vector3(relayPoints[currentPath].X, 0, relayPoints[currentPath].Y); if (Vector3.Distance(src, dest) < 0.2f) { currentPath++; } else { ServerSideObject target = ObjectManager.GetNearMinionsCoresTowersHeroes(this, attackRange); if (target != null) { Quaternion rot = ServerMath.LookAt(this, target); ((MinionSyncData)sync).SetRotate(rot.Y, rot.W); ((MinionSyncData)sync).SetAnime(2); if (endMotion <= 0) { startMotion += delta; if (startMotion >= realAttackTime) { Attack(target, GetAutoAttackPower()); ObjectManager.AddBullet(this.GetObjID(), target.GetObjID()); startMotion = 0; endMotion = cooldownTime; } } } else { Quaternion rot = ServerMath.LookAt(src, dest); ((MinionSyncData)sync).SetRotate(rot.Y, rot.W); ((MinionSyncData)sync).SetAnime(1); Vector3 direct = (dest - src); direct.Normalize(); Vector3 newPos = src + direct * moveSpeed * delta; ((MinionSyncData)sync).SetPosition(newPos.X, newPos.Z); } } } }
void AttackEnemy(float delta) { ServerSideObject target = ObjectManager.GetNearMinionsHeroes(this, attackRange); if (target != null) { if (endMotion <= 0) { startMotion += delta; if (startMotion >= realAttackTime) { Attack(target, GetAutoAttackPower()); ObjectManager.AddBullet(this.GetObjID(), target.GetObjID()); startMotion = 0; endMotion = cooldownTime; } } } else { startMotion = 0; } }