public override void Update(float delta) { endMotion -= delta; ((MonsterSyncData)sync).Update(delta); if (IsDead()) { respawnTimer -= delta; if (respawnTimer <= 0) { ((MonsterSyncData)sync).Revive(maxhp, init_yRot, init_wRot); target = null; startMotion = 0; } } else { if (target != null) { if (target.IsDead()) { ((MonsterSyncData)sync).SetRotate(init_yRot, init_wRot); ((MonsterSyncData)sync).SetAnime(0); target = null; startMotion = 0; } else { AttackEnemy(delta); } } } }
public static Quaternion LookAt(ServerSideObject source, ServerSideObject dest) { Vector3 sourcePoint = new Vector3(source.GetXPos(), 0, source.GetZPos()); Vector3 destPoint = new Vector3(dest.GetXPos(), 0, dest.GetZPos()); return(LookAt(sourcePoint, destPoint)); }
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 override void Damaged(ServerSideObject attacker, int amount) { ((HeroSyncData)sync).DecreaseHP(amount); if (IsDead()) { respawnTimer = CalcRespawnTime(((HeroSyncData)sync).level); } }
public override void Damaged(ServerSideObject attacker, int amount) { ((CoreSyncData)sync).DecreaseHP(amount); if (IsDead()) { //未実装 } }
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); } } } }
public static ServerSideObject GetNearMinionsHeroes(ServerSideObject tower, float attackRange) { ServerSideObject ret = null; float mindistance = float.MaxValue; foreach (KeyValuePair <ushort, Minion> minion in minions) { if (!minion.Value.IsDead() && minion.Value.GetFaction() != tower.GetFaction()) { float distance = ServerMath.Distance(tower, minion.Value); if (distance <= attackRange && distance < mindistance) { ret = minion.Value; mindistance = distance; } } } if (ret != null) { return(ret); } foreach (KeyValuePair <ushort, Hero> hero in heroes) { if (!hero.Value.IsDead() && hero.Value.GetFaction() != tower.GetFaction()) { float distance = ServerMath.Distance(tower, hero.Value); if (distance <= attackRange && distance < mindistance) { ret = hero.Value; mindistance = distance; } } } return(ret); }
public override void Damaged(ServerSideObject attacker, int amount) { ((MonsterSyncData)sync).DecreaseHP(amount); if (IsDead()) { respawnTimer = CalcRespawnTime(); } else { if (target == null) { if (attacker.GetType() == typeof(Fireground)) { target = ((Ability)attacker).caster; } else { target = attacker; } } } }
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; } }
public override void Damaged(ServerSideObject attacker, int amount) { ((MinionSyncData)sync).DecreaseHP(amount); }
public static float Distance(ServerSideObject a, ServerSideObject b) { return(Vector2.Distance(new Vector2(a.GetXPos(), a.GetZPos()), new Vector2(b.GetXPos(), b.GetZPos())) - a.radius - b.radius); }
public static ServerSideObject GetNearMinionsCoresTowersHeroes(ServerSideObject myminion, float attackRange) { ServerSideObject ret = null; float mindistance = float.MaxValue; foreach (KeyValuePair <ushort, Minion> minion in minions) { if (!minion.Value.IsDead() && minion.Value.GetFaction() != myminion.GetFaction()) { float distance = ServerMath.Distance(myminion, minion.Value); if (distance <= attackRange && distance < mindistance) { ret = minion.Value; mindistance = distance; } } } if (ret != null) { return(ret); } foreach (KeyValuePair <ushort, Core> core in cores) { if (!core.Value.IsDead() && core.Value.GetFaction() != myminion.GetFaction()) { float distance = ServerMath.Distance(myminion, core.Value); if (distance <= attackRange && distance < mindistance) { ret = core.Value; mindistance = distance; } } } if (ret != null) { return(ret); } foreach (KeyValuePair <ushort, Tower> tower in towers) { if (!tower.Value.IsDead() && tower.Value.GetFaction() != myminion.GetFaction()) { float distance = ServerMath.Distance(myminion, tower.Value); if (distance <= attackRange && distance < mindistance) { ret = tower.Value; mindistance = distance; } } } if (ret != null) { return(ret); } foreach (KeyValuePair <ushort, Hero> hero in heroes) { if (!hero.Value.IsDead() && hero.Value.GetFaction() != myminion.GetFaction()) { float distance = ServerMath.Distance(myminion, hero.Value); if (distance <= attackRange && distance < mindistance) { ret = hero.Value; mindistance = distance; } } } return(ret); }