public void UpdatePower() { if (m_InfinitePower) { m_CurrentPower = 1.0f; } else { m_CurrentPower = Mathf.Max(m_CurrentPower - 0.1f, 0.0f); } foreach (var conduit in m_Connected) { PowerConduitPower other = null; var gop = new TwoDee.ProxyWorld.GameObjectOrProxy(conduit); if (gop.GameObject != null) { var pc = gop.GameObject.GetComponentInParent <PowerConduit>(); other = pc.m_Pcp; } else if (gop.Proxy != null) { var pc = gop.Proxy.GetData <PowerConduit.Proxy>(); if (pc != null) { other = pc.m_Pcp; } } if (other != null) { other.m_CurrentPower = Mathf.Max(other.m_CurrentPower, m_CurrentPower); } } }
protected override void SaveLoad(bool save, Rope rope) { if (save) { m_RefundItem = rope.m_RefundItem; m_Links = new LinkProxy[rope.m_Links.Count]; for (int i = 0; i < rope.m_Links.Count; i++) { m_Links[i] = new LinkProxy(); m_Links[i].Save(rope.m_Links[i]); } } else { rope.m_RefundItem = m_RefundItem; //Setup links GameObject lastLink = null; foreach (var link in m_Links) { var go = rope.CreateLink(link.m_Position, link.m_Rotation, false); rope.AttachNewLink(go, lastLink); lastLink = go; if (link.m_ConnectedPosition != Vector3.zero) { var hj2 = StandardInitHinge(go); if (!link.m_ConnectedObject.IsEmpty()) { var gop = new TwoDee.ProxyWorld.GameObjectOrProxy(link.m_ConnectedObject); if (gop.Valid && gop.GameObject != null) { hj2.connectedBody = gop.GameObject.GetComponent <Rigidbody>(); } else { UnityEngine.Debug.LogError("A rope was loaded in before an object it was connected to was loaded in."); } } hj2.anchor = go.transform.InverseTransformPoint(link.m_ConnectedPosition); // The extra parameter here is since the connection is already set up we don't want to do it again. go.GetComponent <RopeLink>().ConnectJoint(hj2, false); } } //Setup state rope.m_State = State.Idle; rope.PlaceHandles(); } }
void IMouseButtons.UseButton(MouseButtonContext context, MouseButtonEntry entry) { if (entry.m_Data.Equals(0)) { var gop = new TwoDee.ProxyWorld.GameObjectOrProxy(m_TargetGuid); if (gop.Valid) { TwoDee.EasySound.Play("teleport", gameObject); Vector3 otherEndPos = gop.Position; otherEndPos.z = 0.0f; context.m_Player.transform.position = otherEndPos; } } }
bool IProxyDataReady.ReadyToLoad() { // We need whatever we are connected to be loaded foreach (var link in m_Links) { if (link.m_ConnectedObject == null || link.m_ConnectedObject.Length == 0) { continue; } var gop = new TwoDee.ProxyWorld.GameObjectOrProxy(link.m_ConnectedObject); if (gop.Valid && gop.GameObject == null) { return(false); } } return(true); }