private void Awake() { Vector3 pos = this.gameObject.transform.position; Quaternion rot = this.gameObject.transform.rotation; WorldObject wo = WorldObjectManager.Instance.InstantiateWorldObject(_objectType, pos, rot); TreeObjectData data = (TreeObjectData)wo.ReturnData(); data.SetTreeState(TreeObjectData.TreeStates.Default); wo.UpdateData(data); WorldObjectManager.Instance.InitializeWorldObject(wo, _objectType); Destroy(this.gameObject); }
/// <summary> /// Plant all the WorldObjects. /// </summary> private void CheckPlantTreeObject() { //Right click plants if (!Input.GetKeyDown(KeyCode.Mouse1)) return; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { WorldObject wo = WorldObjectManager.Instance.InstantiateWorldObject(WorldObjectTypes.ZonneBloem, hit.point, Quaternion.identity); TreeObjectData data = (TreeObjectData)wo.ReturnData(); data.SetTreeState(TreeObjectData.TreeStates.Default); wo.UpdateData(data); WorldObjectManager.Instance.InitializeWorldObject(wo, WorldObjectTypes.ZonneBloem); } }