private void LateUpdate_UCE_Mount() { if (Player.localPlayer == this) { if (Input.GetMouseButtonDown(0) && !Utils.IsCursorOverUserInterface() && Input.touchCount <= 1) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { UCE_MountedMount mountedMount = hit.transform.GetComponent <UCE_MountedMount>(); if (mountedMount != null) { if (mountedMount.owner == this) { Cmd_UCE_Unmount(); } } UCE_Mount mount = hit.transform.GetComponent <UCE_Mount>(); if (mount != null && mount.isAlive) { if (mount.owner == this) { UCE_TryMount(mount.gameObject); } } } } } if (isClient) { if (UCE_mounted && (state == "MOVING" || state == "IDLE")) { foreach (Animator anim in GetComponentsInChildren <Animator>()) { if (anim.parameters.Any(x => x.name == "MOUNTED")) { anim.SetBool("MOUNTED", UCE_mounted); } if (anim.parameters.Any(x => x.name == "MOVING")) { anim.SetBool("MOVING", false); } } } } }
public void Cmd_UCE_Ride() { if (unmountedMount == null || UCE_mounted) { return; } GameObject go = Instantiate(unmountedMount.mountedMount.gameObject, transform.position, Quaternion.identity); UCE_MountedMount mount = go.GetComponent <UCE_MountedMount>(); mount.health = unmountedMount.health; mount.level = unmountedMount.level; mount.experience = unmountedMount.experience; mount.autoRide = unmountedMount.autoRide; mount.owner = this; mount.transform.position = transform.position; mount.transform.rotation = transform.rotation; mount.GetComponent <UCE_MountedMount>().owner = this; NetworkServer.Spawn(go); _UCE_mountedMount = go; // -- Buff if (mountedMount.applyBuffWhileMounted) { AddOrRefreshBuff(new Buff(mountedMount.applyBuffWhileMounted, mountedMount.buffLevel)); } // -- Speed UCE_ModifySpeedPercentage(mountedMount.speedModiferPercent); // -- Visibility if (mountedMount.playerInvisibleWhileMounted) { UCE_ToggleVisibility(false); } // -- active Skills _cannotCast = go.GetComponent <UCE_MountedMount>().cannotCastWhileMounted; transform.position = go.GetComponent <UCE_MountedMount>().mountPoint.transform.position; NetworkServer.Destroy(_UCE_unmountedMount.gameObject); UCE_mounted = true; }
public void UCE_SummonAndRideMount(ItemSlot slot) { if (UCE_mounted) { return; } UCE_Tmpl_MountItem data = (UCE_Tmpl_MountItem)slot.item.data; GameObject go = Instantiate(((UCE_Mount)data.summonPrefab).mountedMount.gameObject, transform.position, Quaternion.identity); UCE_MountedMount mount = go.GetComponent <UCE_MountedMount>(); mount.health = slot.item.summonedHealth; mount.level = slot.item.summonedLevel; mount.experience = slot.item.summonedExperience; mount.autoRide = data.autoRide; mount.owner = this; mount.transform.position = transform.position; mount.transform.rotation = transform.rotation; NetworkServer.Spawn(go); _UCE_mountedMount = go; // -- Buff if (mountedMount.applyBuffWhileMounted) { AddOrRefreshBuff(new Buff(mountedMount.applyBuffWhileMounted, mountedMount.buffLevel)); } // -- Speed UCE_ModifySpeedPercentage(mountedMount.speedModiferPercent); // -- Visibility if (mountedMount.playerInvisibleWhileMounted) { UCE_ToggleVisibility(false); } // -- active Skills _cannotCast = go.GetComponent <UCE_MountedMount>().cannotCastWhileMounted; transform.position = go.GetComponent <UCE_MountedMount>().mountPoint.transform.position; UCE_mounted = true; }