/* public GameObjectWearable convertEnumToObject(EnumGameObjectWearable objectWearable){ switch(objectWearable){ case EnumGameObjectWearable.Axe: break; case EnumGameObjectWearable.PickAxe: break; } return null; }*/ public GameObject instanciate(EnumGameObjectWearable objectWearable) { GameObject retour = null; switch(objectWearable){ case EnumGameObjectWearable.Axe: retour = GameObject.CreatePrimitive (PrimitiveType.Sphere); retour.AddComponent<Axe> (); retour.name = retour.GetComponent<Axe>().name; break; case EnumGameObjectWearable.PickAxe: retour = GameObject.CreatePrimitive (PrimitiveType.Capsule); retour.AddComponent<PickAxe> (); retour.name = retour.GetComponent<PickAxe>().name; break; } return retour; }
/* // Update is called once per frame void Update () { if (target.focus) { if (Input.GetKeyDown (KeyCode.Keypad0)) { if (available.Count > 0) { if (available [0].buildingLevelMin <= target.level) { if (rhb.HaveRessourcesInQuantity (available [0].cost)) { Debug.Log ("Construction : " + available [0].objectWearable.ToString()); rhb.useRessources (available [0].cost); Debug.Log ("Cost : " + costToString(available [0].cost) + "\n" + "Actual ressources : " + rhb.toString()); GameObject go = GameObjectWearableFactory.getInstance().instanciate (available [0].objectWearable); go.transform.position = target.transform.position + Vector3.right*(-1) + Vector3.up; go.AddComponent<Rigidbody> (); } } } } else if (Input.GetKeyDown (KeyCode.Keypad1)) { if (available.Count > 1) { if (available [1].buildingLevelMin <= target.level) { if (rhb.HaveRessourcesInQuantity (available [1].cost)) { Debug.Log ("Construction : " + available [1].objectWearable.ToString()); rhb.useRessources (available [1].cost); Debug.Log ("Cost : " + costToString(available [1].cost) + "\n" + "Actual ressources : " + rhb.toString()); GameObject go = GameObjectWearableFactory.getInstance().instanciate (available [1].objectWearable); go.transform.position = target.transform.position + Vector3.right*(-1) + Vector3.up; go.AddComponent<Rigidbody> (); } } } } } } */ public GameObject build(EnumGameObjectWearable item) { foreach(Makeable itemBuild in available){ if(itemBuild.objectWearable == item && itemBuild.buildingLevelMin <= target.level && rhb.HaveRessourcesInQuantity (itemBuild.cost)){ Debug.Log ("Construction : " + itemBuild.objectWearable.ToString()); rhb.useRessources (itemBuild.cost); Debug.Log ("Cost : " + costToString(itemBuild.cost) + "\n" + "Actual ressources : " + rhb.toString()); GameObject go = GameObjectWearableFactory.getInstance().instanciate (itemBuild.objectWearable); go.transform.position = target.transform.position + Vector3.right*(-1) + Vector3.up; go.AddComponent<Rigidbody> (); return go; } } return null; }