// Update is called once per frame void Update() { LastHoveredCustom = CurrentlyHoveredCustom; RaycastHit hit; if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit)) { CurrentlyHoveredCustom = LookThroughForCustom(hit.transform); } OnMouseStopHover(); if (CurrentlyHoveredCustom != null) { OnMouseDown(); OnMouseHover(); } if (LastClickedCustom != null) { OnMouseUp(); OnMouseHold(); } }
public void HandleCustomProperties(GameObject gameObject, IDictionary <string, string> customProperties) { if (behaviourTypes == null) { var test = (from domainAssembly in AppDomain.CurrentDomain.GetAssemblies() from assemblyType in domainAssembly.GetTypes() where typeof(CustomBehaviour).IsAssignableFrom(assemblyType) select assemblyType).ToArray(); behaviourTypes = new Dictionary <string, Type>(); foreach (var t in test) { if (t.Name == "CustomBehaviour") { continue; } behaviourTypes.Add(t.Name, t); } } if (customProperties.ContainsKey("Behaviour")) { String behaviour = customProperties["Behaviour"]; if (behaviourTypes.ContainsKey(behaviour)) { CustomBehaviour customBehaviour = (CustomBehaviour)gameObject.AddComponent(behaviourTypes[customProperties["Behaviour"]]); customBehaviour.Import(customProperties); } else { Debug.LogErrorFormat("CustomBehaviour {0} not defined", behaviour); } } }
void OnMouseDown() { if (Input.GetMouseButtonDown(0)) { LastClickedCustom = CurrentlyHoveredCustom; LastClickedCustom.CustomOnMouseDown(Input.mousePosition, cam); } }
public int IndexOf(CustomBehaviour element) { if (element == null || m_pool == null) { return(-1); } return(m_pool.IndexOf(element)); }
void Awake() { if (customBehaviour == null) { customBehaviour = GetComponent <BushBehaviour>(); } if (customBehaviour == null) { customBehaviour = GetComponent <PebbleBehaviour>(); } if (customBehaviour != null) { customBehaviour.customAwake(); } }
/* * Whenever the Planet is touched, Information Panel is set active and all the * text fields are populated with the planet metadata. */ void populatePanel(CustomBehaviour planet) { InformationPanel.SetActive(true); string value = ""; TextMeshProUGUI dataValue = InformationPanel.transform.Find("Name").GetComponent <TextMeshProUGUI>(); dataValue.text = planet.data.name; for (int i = 0; i < planetFields.Count; i++) { if (planet.data.planetData.TryGetValue(planetFields[i], out value)) { fields[i].text = value; } } text.text = planet.tag; return; }
public void ReturnToPool(CustomBehaviour i_obj) { i_obj.StopAllCoroutines(); if (i_obj.transform.parent != PoolManager.instance.gameObject.transform) { i_obj.transform.SetParent(PoolManager.instance.gameObject.transform); } i_obj.gameObject.SetActive(false); int index = m_pool.IndexOf(i_obj); if (index >= 0 && index < m_used.Count) { m_used[index] = false; } else { Debug.LogWarning("Returning to the wrong pool!"); } }
void OnMouseUp() { if (Input.GetMouseButtonUp(0)) { if (LastClickedCustom == null) { return; } if (CurrentlyHoveredCustom == LastClickedCustom) { CurrentlyHoveredCustom.CustomOnMouseUp(); } else { LastClickedCustom.CustomOnMouseUpOff(); } LastClickedCustom = null; } }
//void HitToken(RaycastHit hit) //{ // Token token = hit.transform.root.GetComponent<Token>(); // if (token == null) // return; // if (token.OwnerTypeOwner == Token.OwnerTypes.None) // { // token.OwnerTypeOwner = token.GetCurrentPlayer(); // //colMan.AddTokenToPool(token); // //GridMan.CheckForCompletedRegions(); // //GameObject marker = (GameObject) Instantiate(PlayerMarker, token.transform.position, Quaternion.identity); // //marker.transform.parent = token.transform; // } //} CustomBehaviour LookThroughForCustom(Transform trans) { CustomBehaviour cust = trans.GetComponent <CustomBehaviour>(); if (cust != null) { return(cust); } Transform t = trans.parent; while (t != null) { cust = t.GetComponent <CustomBehaviour>(); if (cust != null) { return(cust); } t = t.parent; } return(null); }
IEnumerator<float> StoreClip(CustomBehaviour cb) { while (cb.GetAudioSource.isPlaying) { yield return 0f; } cb.SelfStore(); }
private void autoBind(CustomBehaviour customBehaviour) { _autoBindFields.Clear(); FieldInfo[] fields = customBehaviour.GetType().GetFields(); foreach (FieldInfo field in fields) { object[] attributes = field.GetCustomAttributes(true); foreach (object attr in attributes) { if (attr is BindAttribute) { string bindName = ((BindAttribute)attr).getBindName(); if (string.IsNullOrEmpty(bindName)) { continue; } Transform bindTr = null; if (bindName.Equals(".")) { bindTr = customBehaviour.transform; } else { bindTr = customBehaviour.transform.Find(bindName); } if (bindTr == null) { Debug.LogError("cannot find object:" + bindName); continue; } Type bindType = field.FieldType; if (bindType == typeof(GameObject)) { field.SetValue(customBehaviour, bindTr.gameObject); _autoBindFields.Add(field.Name); } else if (bindType.IsSubclassOf(typeof(Component))) { Component c = bindTr.GetComponent(bindType); if (c != null) { field.SetValue(customBehaviour, c); _autoBindFields.Add(field.Name); } else { Debug.LogError("cannot find component " + bindType.Name + " in bindName"); } } else { Debug.LogError("not suport bind type: " + bindType.Name); } } } } }