public void AddButtonClick() { if (oracle.faithPoint >= requiredPoint) { oracle.DecreaseFaith(requiredPoint); //GameObject enemy; //enemy = Instantiate(EnemySlot, enemySlotParent); //enemyList.Add(enemy.GetComponent<EnemyBabyDate>()); enemyList[targetSlot].ID = ID; enemyList[targetSlot].LV = LV; enemyList[targetSlot].Gold = money; /* enemyList[enemyList.Count-1].ID = ID; * enemyList[enemyList.Count-1].LV = LV; * enemyList[enemyList.Count-1].Gold = money; */ var image = slots[targetSlot].transform.GetChild(0).GetComponent <Image>(); image.sprite = enemyDates[enemyList[targetSlot].ID].image; image.gameObject.SetActive(true); UIUpdate(); } else { requiredPointsText.text = "信仰Pが足りない"; } }
void Update() { CheckPossible(); if (type == MODE_TYPE.Neutral) { generateStart = false; } else { generateStart = true; } if (generateStart == true) { var ray = mainCamera.ScreenPointToRay(Input.mousePosition); var raycastHitList = Physics.RaycastAll(ray).ToList(); if (raycastHitList.Any())//虚空をクリックしていない時のみ。 { var distance = Vector3.Distance(mainCamera.transform.position, raycastHitList.First().point); var mousePosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance); float duration = 3; // 光線の出ている時間 receiveEvent.dammy.transform.position = raycastHitList.First().point; Debug.DrawRay(ray.origin, ray.direction * distance, Color.red, duration, false); } delayTime++;//一回目のクリックで生成されてしまわないように。 if (Input.GetMouseButtonDown(0) && delayTime > 1) { GameObject obj; if (!EventSystem.current.IsPointerOverGameObject()) { switch (type) { case MODE_TYPE.Neutral: break; case MODE_TYPE.house: obj = Instantiate(house, receiveEvent.dammy.transform.position, Quaternion.identity); obj.GetComponent <MeshRenderer>().material = makkuro; oracle.DecreaseFaith(houseGeneratePoint); worldController.architectsNumber--; break; case MODE_TYPE.INN: obj = Instantiate(INN, receiveEvent.dammy.transform.position, Quaternion.identity); obj.GetComponent <MeshRenderer>().material = makkuro; oracle.DecreaseFaith(INNGeneratePoint); worldController.architectsNumber--; break; case MODE_TYPE.church: obj = Instantiate(church, receiveEvent.dammy.transform.position, Quaternion.identity); obj.GetComponent <MeshRenderer>().material = makkuro; oracle.DecreaseFaith(churchGeneratePoint); worldController.architectsNumber--; break; case MODE_TYPE.blacksmith: obj = Instantiate(blacksmith, receiveEvent.dammy.transform.position, Quaternion.identity); obj.GetComponent <MeshRenderer>().material = makkuro; oracle.DecreaseFaith(blacksmithGeneratePoint); worldController.architectsNumber--; break; case MODE_TYPE.architectureHouse: obj = Instantiate(architectureHouse, receiveEvent.dammy.transform.position, Quaternion.identity); obj.GetComponent <MeshRenderer>().material = makkuro; oracle.DecreaseFaith(architectureHouseGeneratePoint); worldController.architectsNumber--; break; } } delayTime = 0; generateStart = false; type = MODE_TYPE.Neutral; // Debug.Log("ダミーの座標" + receiveEvent.dammy.transform.position); // Debug.Log("本当の座標" + raycastHitList.First().point); raycastHitList.Clear(); receiveEvent.dammy.SetActive(false); } else { //type = MODE_TYPE.Neutral; } } }