public void OnTeleport(NetworkMessage netMsg) { MObjects.Teleport mObject = netMsg.ReadMessage <MObjects.Teleport>(); MobileAgent ma = MobileAgent.list.Find(x => x.id == mObject.id); if (ma != null) { mObject.pos.y = MapLoader.GetHeight(mObject.pos); ma.transform.position = mObject.pos; /* * TELEPORT EFFECT * */ CreateParticle("Teleport", ma.transform); } }
public void CheckSkill() { if (skillStart != 0 && (lastAimReceived || skillStart < Time.time - 1 || user == null) && skillStart < Time.time) { lastAimReceived = false; skillStart = 0f; nextMove = Time.time + 0.5f; /* * CREATE SKILL * */ if (!isDead) { Vector3 tPos = transform.position; bool isTeleport = skills[skillId].effectType == EffectType.Teleport; if (skills[skillId].skillType == SkillType.Area || isTeleport) { // Area Spell Vector3 v = aimPoint; if (PhysikEngine.GetDistance(aimPoint, tPos) > 10) { v = transform.position + (aimPoint - tPos).normalized * 10; } tPos = v; } if (isTeleport) { // TELEPORT SKILL transform.position = MapLoader.latestPoint(session.map, transform.position, MapLoader.latestPoint(session.map, transform.position, tPos)); MObjects.Teleport tp = new MObjects.Teleport(); tp.id = (user == null) ? customId : user.connectionId; tp.pos = transform.position; int _ca = session.users.Count; for (int i = 0; i < _ca; i++) { if (NetworkServer.connections.Contains(session.users[i])) { // send the mobject NetworkServer.SendToClient(session.users[i].connectionId, MTypes.Teleport, tp); } } } else if (!MapLoader.isBlocked(session.map, transform.position, tPos, false)) { // OTHERs GameObject skill = new GameObject("skill"); Skill s = skill.AddComponent <Skill>(); session.createdSkills.Add(skill); s.id = ((user != null) ? user.connectionId : customId) + "_" + castedSkill++; s.clientPrefab = skills[skillId].clientPrefab; s.moveSpeed = skills[skillId].moveSpeed; s.skillType = skills[skillId].skillType; s.life = skills[skillId].life; s.effectTime = skills[skillId].effectTime; s.session = session; s.hitAndDestroy = skills[skillId].hitAndDestroy; s.collision = skills[skillId].collision; s.effect = skills[skillId].GetEffect(this); s.effectType = skills[skillId].effectType; s.hitContinous = skills[skillId].hitContinous; s.transform.rotation = transform.rotation; s.activeAfter = skills[skillId].activeAfter; s.caster = this; s.transform.position = tPos; if (skills[skillId].skillType == SkillType.Self) { // This is a self type skill. Hit & Destroy Immediately. List <MobileAgent> self = new List <MobileAgent>(); self.Add(this); s.PhysikHit(self); Destroy(skill); } } cooldowns[skillId] = Time.time + skills[skillId].cooldown - (skills[skillId].cooldown * agentLevel.level.Percent_cooldown / 100f); if (user != null && NetworkServer.connections.Contains(user)) { MObjects.Cooldown _mObject = new MObjects.Cooldown(); _mObject.skillId = skillId; _mObject.time = cooldowns[skillId] - Time.time; NetworkServer.SendToClient(user.connectionId, MTypes.Cooldown, _mObject); } } /* * */ Stop(); MObjects.EndSkill mObject = new MObjects.EndSkill(); mObject.id = (user != null) ? user.connectionId: customId; int _c = session.users.Count; for (int i = 0; i < _c; i++) { if (NetworkServer.connections.Contains(session.users[i])) { // send the mobject NetworkServer.SendToClient(session.users[i].connectionId, MTypes.EndSkill, mObject); } } } }