GameObject BuildTurret(HeroBlueprint blueprint) { if (blueprint == null || PlayerStats.Energy < blueprint.cost || bluePrint.hasBuilt) { Debug.Log("Not enough energy to summon that!"); return(null); } GameObject hero = (GameObject)Instantiate(blueprint.prefab); Debug.Log("Hero " + blueprint.prefab.name + " Summoned!"); BaseHero baseHero = hero.GetComponent <BaseHero>(); baseHero.hero = hero; baseHero.heroBlueprint = blueprint; return(hero); }
public void OnBeginDrag(PointerEventData eventData) { //Debug.Log("OnBeginDrag " + gameObject.name); bluePrint = heroPool.GetBlueprintByName(gameObject.name); go = BuildTurret(bluePrint); //Debug.Log("OnDrag"); buildManager.hasDraged = true; if (go != null) { //Debug.Log("go != null start drag"); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { go.transform.position = hit.point; selfScenePosition = Camera.main.WorldToScreenPoint(go.transform.position); } else { go = null; } } }