public void spentFuel() //PlanetManage, StarNavigation, ButtonController(TransSceneToMain)에서 씬전환시 호출함 { SelectDB.Instance().table = "userTable"; SelectDB.Instance().column = "cFood, shipNum"; SelectDB.Instance().where = " "; SelectDB.Instance().Select(2); SelectDB.Instance().food = SelectDB.Instance().food - GameManager.Instance().spentFuel; UpdateDB.Instance().table = "userTable"; UpdateDB.Instance().setColumn = "\"cFood\" = " + SelectDB.Instance().food.ToString(); UpdateDB.Instance().where = " "; UpdateDB.Instance().UpdateData(); }
// 메인화면 // 탐사화면 1: 미탐사행성, 2: 별 public void explore(int type) { Time.timeScale = 1; //관리중인 오브젝트 개수 체크 //SelectDB.Instance().table = "managePlanetTable"; //SelectDB.Instance().column = "Count(*)"; //SelectDB.Instance().Select(0); //SelectDB.Instance().table = "zodiacTable"; //SelectDB.Instance().column = "Count(*)"; //SelectDB.Instance().where = "WHERE open = 1 AND find = 1 AND active = 0"; if (type == 1) { Debug.Log("행성을 탐사합니다!"); //Vector3 spawnPoint = GameManager.Instance().planetSpawnPoint; //충돌한 물음표 행성 비활성화 GameManager.Instance().tempPlanet.SetActive(false); //행성 생성 Debug.Log("<b>SpawnPoint!!</b> " + GameManager.Instance().planetSpawnPoint); PlanetManager script = GameObject.Find("PlanetManager").GetComponent <PlanetManager>(); script.planetChange(GameManager.Instance().planetSpawnPoint); //탐사 UI 비활성화 GameManager.Instance().exploreUi.SetActive(false); //Scene 전환(PlanetManager : 260 에서 동작함) } else if (type == 2) { UpdateDB.Instance().table = "zodiacTable"; UpdateDB.Instance().setColumn = "\"open\" = 1, \"find\" = 1 "; UpdateDB.Instance().where = "WHERE \"rowid\" = " + SelectDB.Instance().starRowid; UpdateDB.Instance().UpdateData(); GameObject.Find("OBJ").GetComponent <OBJScript>().rowid = SelectDB.Instance().starRowid; DontDestroyOnLoad(GameObject.Find("OBJ")); SoundManager.Instance().nextSceneName = "Star"; SceneManager.LoadScene("loading"); } }
int treeCheck(string treeCntStr) { if (treeCntStr == "tree1") { return(SelectDB.Instance().tree1); } else if (treeCntStr == "tree2") { return(SelectDB.Instance().tree2); } else if (treeCntStr == "tree3") { return(SelectDB.Instance().tree3); } else if (treeCntStr == "tree4") { return(SelectDB.Instance().tree4); } else { return(0); } }
void OnTriggerEnter(Collider other) { Debug.Log("Planet_OnTriggerEnter"); Debug.Log(other.tag); //충돌 오브젝트 종류 체크 if (other.tag == "PlanetSpawn") { SelectDB.Instance().table = "managePlanetTable"; SelectDB.Instance().column = "Count(*)"; SelectDB.Instance().where = " "; SelectDB.Instance().Select(0); SelectDB.Instance().table = "zodiacTable"; SelectDB.Instance().column = "Count(*)"; SelectDB.Instance().where = "WHERE \"open\" = 1 AND \"find\" = 1 AND \"active\" = 0"; SelectDB.Instance().Select(0); Debug.Log(SelectDB.Instance().planetCount); if (SelectDB.Instance().planetCount >= 11) { GameManager.Instance().noMorePS.SetActive(true); GameManager.Instance().tempPlanet = other.gameObject; } else { //충돌 행성 위치 저장 GameManager.Instance().planetSpawnPoint = other.gameObject.GetComponent <Transform>().position; //탐사 UI 활성화 SoundManager.Instance().PlaySfx(SoundManager.Instance().getFood); GameManager.Instance().exploreUi.transform.FindChild("Ok").GetComponent <Button>().onClick.AddListener(() => GameObject.Find("GameManager").gameObject.GetComponent <ButtonController>().explore(1)); GameManager.Instance().exploreUi.SetActive(true); //물음표 행성 오브젝트 임시 저장 GameManager.Instance().tempPlanet = other.gameObject; //행성 생성(ButtonController.cs에 'explore()'로 이동) } //게임 시간 정지 Time.timeScale = 0; } else if (other.tag == "Stars") { SoundManager.Instance().PlaySfx(SoundManager.Instance().getFood); SelectDB.Instance().table = "zodiacTable"; SelectDB.Instance().column = "Count(*)"; SelectDB.Instance().where = "WHERE \"open\" = 1 AND \"find\" = 1 AND \"active\" = 0"; SelectDB.Instance().Select(0); Debug.Log("starcnt" + SelectDB.Instance().starCount); if (SelectDB.Instance().starCount == 5) { //게임 시간 정지 Time.timeScale = 0; GameManager.Instance().noMorePS.SetActive(true); //별 충돌시 우회 기동, 예외처리 필요함 } else { SelectDB.Instance().table = "zodiacTable"; SelectDB.Instance().column = "rowid, open, find, active"; SelectDB.Instance().where = "WHERE zID = " + "'" + other.name + "'"; SelectDB.Instance().Select(4); if (SelectDB.Instance().starOpen == 0 && SelectDB.Instance().starFind == 0 && SelectDB.Instance().starActive == 0) { //게임 시간 정지 Time.timeScale = 0; GameManager.Instance().exploreUi_star.SetActive(true); GameManager.Instance().exploreUi_star.transform.FindChild("Ok").GetComponent <Button>().onClick.AddListener(() => GameObject.Find("GameManager").GetComponent <ButtonController>().explore(2)); } else { turnShip(); } } } else if (other.name != "SpaceCheck" && other.tag != "Missile") { turnShip(); } }
void Update() { if (MainSingleTon.Instance.shipTouch == true) { SelectDB.Instance().column = "cFood, shipNum"; SelectDB.Instance().table = "userTable"; //SelectDB.Instance().where = "WHERE zID= " + "'" + hit.transform.name + "'"; SelectDB.Instance().Select(2); SelectDB.Instance().table = "managePlanetTable"; SelectDB.Instance().column = "Count(*)"; SelectDB.Instance().Select(0); SelectDB.Instance().table = "zodiacTable"; SelectDB.Instance().column = "Count(*)"; SelectDB.Instance().where = "WHERE \"open\" = 1 AND \"find\" = 1 AND \"active\" = 0"; SelectDB.Instance().Select(0); GameData.Instance().shipNum = SelectDB.Instance().shipNum; switch (SelectDB.Instance().shipNum) { case 1: maxFood = 300; break; case 2: maxFood = 350; break; case 3: maxFood = 400; break; case 4: maxFood = 600; break; case 5: maxFood = 700; break; } if (SelectDB.Instance().food < maxFood) { MainSingleTon.Instance.shipTouch = false; GameObject.Find("UI").gameObject.GetComponent <csScreenPointTouch>().enabled = false; warning_ui.SetActive(true); warning_ui.transform.FindChild("Food").GetComponent <Text>().text = maxFood.ToString(); StartCoroutine(returnMain()); } else if (SelectDB.Instance().food >= maxFood) { MainSingleTon.Instance.shipTouch = false; if (SelectDB.Instance().planetCount + SelectDB.Instance().starCount == 16) { GameObject.Find("UI").gameObject.GetComponent <csScreenPointTouch>().enabled = false; notanymore_ui.SetActive(true); } else { GameData.Instance().maxFuel = maxFood; transScenetoMap(); } } } }
void Update() { if (WorldMapManager.Instance().dragState == false) { //if (Input.GetButtonUp("Fire1")) // Debug Mode //{ // Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // Debug Mode // RaycastHit hit; // Debug Mode foreach (Touch touch in Input.touches) // Build Mode { Ray ray = Camera.main.ScreenPointToRay(touch.position); // Build Mode RaycastHit hit; // Build Mode if (Physics.Raycast(ray, out hit)) { if (WorldMapManager.Instance().dragState == false) { if (hit.transform.tag.Equals("Stars")) { SoundManager.Instance().PlaySfx(SoundManager.Instance().getFood); SelectDB.Instance().column = "locationX,locationY,locationZ,name,zodiac"; SelectDB.Instance().table = "zodiacTable"; SelectDB.Instance().where = "WHERE zID= " + "'" + hit.transform.name + "'"; SelectDB.Instance().Select(1); GameData.Instance().starPosition = SelectDB.Instance().starPosition; WorldMapManager.Instance().ChooseStar.SetActive(false); WorldMapManager.Instance().Touch.SetActive(false); WorldMapManager.Instance().Destination_ui.SetActive(true); if (SelectDB.Instance().zodiacName == "Aquarius") { zodiac = "물병자리"; } else if (SelectDB.Instance().zodiacName == "Pisces") { zodiac = "물고기자리"; } else if (SelectDB.Instance().zodiacName == "Aries") { zodiac = "양자리"; } else if (SelectDB.Instance().zodiacName == "Taurus") { zodiac = "황소자리"; } else if (SelectDB.Instance().zodiacName == "Gemini") { zodiac = "쌍둥이자리"; } else if (SelectDB.Instance().zodiacName == "Cancer") { zodiac = "게자리"; } else if (SelectDB.Instance().zodiacName == "Leo") { zodiac = "사자자리"; } else if (SelectDB.Instance().zodiacName == "Virgo") { zodiac = "처녀자리"; } else if (SelectDB.Instance().zodiacName == "Libra") { zodiac = "천칭자리"; } else if (SelectDB.Instance().zodiacName == "Scorpius") { zodiac = "전갈자리"; } else if (SelectDB.Instance().zodiacName == "Sagittarius") { zodiac = "궁수자리"; } else if (SelectDB.Instance().zodiacName == "Capricornus") { zodiac = "염소자리"; } WorldMapManager.Instance().Destination_ui.GetComponentInChildren <Text>().text = zodiac + " " + SelectDB.Instance().starName; } //else //{ // WorldMapManager.Instance().Touch.SetActive(false); // WorldMapManager.Instance().Destination_ui.SetActive(true); // WorldMapManager.Instance().Destination_ui.GetComponentInChildren<Text>().text = hit.transform.name; //} } } } // Build Mode //} // Debug Mode } WorldMapManager.Instance().dragState = false; }
void loadStar() { SelectDB.Instance().table = "zodiacTable"; SelectDB.Instance().column = "Count(*)"; SelectDB.Instance().Select(0); for (int i = 1; i <= SelectDB.Instance().starCount; i++) { SelectDB.Instance().table = "zodiacTable"; SelectDB.Instance().column = "rowid, open, find, active, zID, zodiac"; SelectDB.Instance().where = "WHERE \"rowid\" =" + i; SelectDB.Instance().Select(4); if (SelectDB.Instance().starActive == 0) { GameObject.Find(SelectDB.Instance().zodiacID).gameObject.GetComponent <SphereCollider>().enabled = true; GameObject.Find(SelectDB.Instance().zodiacID).gameObject.GetComponent <SphereCollider>().isTrigger = true; } else if (SelectDB.Instance().starActive == 1) { Debug.Log(SelectDB.Instance().zodiacName); if (SelectDB.Instance().zodiacName == "Aquarius") { WorldMapManager.Instance().zodiacCnt1 += 1; } else if (SelectDB.Instance().zodiacName == "Pisces") { WorldMapManager.Instance().zodiacCnt2++; } else if (SelectDB.Instance().zodiacName == "Aries") { WorldMapManager.Instance().zodiacCnt3++; } else if (SelectDB.Instance().zodiacName == "Taurus") { WorldMapManager.Instance().zodiacCnt4++; } else if (SelectDB.Instance().zodiacName == "Gemini") { WorldMapManager.Instance().zodiacCnt5++; } else if (SelectDB.Instance().zodiacName == "Cancer") { WorldMapManager.Instance().zodiacCnt6++; } else if (SelectDB.Instance().zodiacName == "Leo") { WorldMapManager.Instance().zodiacCnt7++; } else if (SelectDB.Instance().zodiacName == "Virgo") { WorldMapManager.Instance().zodiacCnt8++; } else if (SelectDB.Instance().zodiacName == "Libra") { WorldMapManager.Instance().zodiacCnt9++; } else if (SelectDB.Instance().zodiacName == "Scorpius") { WorldMapManager.Instance().zodiacCnt10++; } else if (SelectDB.Instance().zodiacName == "Sagittarius") { WorldMapManager.Instance().zodiacCnt11++; } else if (SelectDB.Instance().zodiacName == "Capricornus") { WorldMapManager.Instance().zodiacCnt12++; } GameObject.Find(SelectDB.Instance().zodiacID).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find(SelectDB.Instance().zodiacID).gameObject.GetComponent <MeshRenderer>().enabled = false; } if (zodiacCnt1 == 6 && cnt1 == false) { for (int cnt = 7; cnt < 17; cnt++) { Debug.Log(GameObject.Find("Aquarius").transform.FindChild("aqua_" + cnt).name); GameObject.Find("Aquarius").transform.FindChild("aqua_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Aquarius").transform.FindChild("aqua_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt1 = true; } if (zodiacCnt2 == 5 && cnt2 == false) { for (int cnt = 6; cnt < 22; cnt++) { GameObject.Find("Pisces").transform.FindChild("pis_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Pisces").transform.FindChild("pis_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt2 = true; } //if (zodiacCnt3 == 4 && cnt3 == false) //{ // //작은별없음 Aries // cnt3 == true; //} if (zodiacCnt4 == 6 && cnt4 == false) { for (int cnt = 7; cnt < 20; cnt++) { GameObject.Find("Taurus").transform.FindChild("tau_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Taurus").transform.FindChild("tau_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt4 = true; } if (zodiacCnt5 == 5 && cnt5 == false) { for (int cnt = 6; cnt < 18; cnt++) { GameObject.Find("Gemini").transform.FindChild("gem_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Gemini").transform.FindChild("gem_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt5 = true; } if (zodiacCnt6 == 5 && cnt6 == false) { for (int cnt = 6; cnt < 8; cnt++) { GameObject.Find("Cancer").transform.FindChild("can_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Cancer").transform.FindChild("can_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt6 = true; } if (zodiacCnt7 == 4 && cnt7 == false) { for (int cnt = 5; cnt < 17; cnt++) { GameObject.Find("Leo").transform.FindChild("leo_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Leo").transform.FindChild("leo_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt7 = true; } if (zodiacCnt8 == 5 && cnt8 == false) { for (int cnt = 6; cnt < 16; cnt++) { GameObject.Find("Virgo").transform.FindChild("vir_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Virgo").transform.FindChild("vir_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt8 = true; } if (zodiacCnt9 == 5 && cnt9 == false) { for (int cnt = 6; cnt < 7; cnt++) { GameObject.Find("Libra").transform.FindChild("lib_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Libra").transform.FindChild("lib_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt9 = true; } if (zodiacCnt10 == 6 && cnt10 == false) { for (int cnt = 7; cnt < 13; cnt++) { GameObject.Find("Scorpius").transform.FindChild("sco_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Scorpius").transform.FindChild("sco_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt10 = true; } if (zodiacCnt11 == 6 && cnt11 == false) { for (int cnt = 7; cnt < 22; cnt++) { GameObject.Find("Sagittarius").transform.FindChild("sag_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Sagittarius").transform.FindChild("sag_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt11 = true; } if (zodiacCnt12 == 6 && cnt12 == false) { for (int cnt = 7; cnt < 13; cnt++) { GameObject.Find("Capricornus").transform.FindChild("cap_" + cnt).gameObject.GetComponent <SphereCollider>().enabled = false; GameObject.Find("Capricornus").transform.FindChild("cap_" + cnt).gameObject.GetComponent <MeshRenderer>().enabled = false; } cnt12 = true; } } }
void loadPlanet() { //마지막에 추가된 rowid 조회 SelectDB.Instance().table = "managePlanetTable"; SelectDB.Instance().column = "rowid, Count(*)"; SelectDB.Instance().Select(0); Debug.Log(SelectDB.Instance().planetCount); SelectDB.Instance().table = "userTable"; SelectDB.Instance().column = "cfood, shipNum"; SelectDB.Instance().Select(2); SelectDB.Instance().table = "managePlanetTable"; SelectDB.Instance().column = "rowid, name, size, color, mat, locationX, locationY, locationZ, tree1, tree2, tree3, tree4, tree5, tree6"; Debug.Log(planetLoadCnt + "," + SelectDB.Instance().planetCount); for (; planetLoadCnt <= SelectDB.Instance().planetCount; planetLoadCnt++) { Debug.Log(planetLoadCnt); SelectDB.Instance().where = "WHERE rowid =" + planetLoadCnt; SelectDB.Instance().Select(3); if (SelectDB.Instance().planetIndex != 0) { int planetShape = (SelectDB.Instance().planetSize * 100) + (SelectDB.Instance().planetColor * 10) + SelectDB.Instance().planetMat; //쿼리 결과로 변수 초기화 Debug.Log(planetShape); // 행성 오브젝트 생성 및 배치 GameObject obj = Instantiate(GameObject.Find("PlanetManager").gameObject.GetComponent <RandPlanet>().D_PlanetList[planetShape]); obj.transform.position = SelectDB.Instance().starPosition; obj.name = SelectDB.Instance().planetName; obj.tag = "Planet"; //obj.GetComponent<SphereCollider>().isTrigger = false; obj.transform.FindChild("PC").gameObject.SetActive(false); obj.transform.FindChild("Neighbor").gameObject.SetActive(false); obj.transform.FindChild("Ship").gameObject.SetActive(false); obj.transform.FindChild("Ship_Neighbor").gameObject.SetActive(false); obj.transform.FindChild("Zoo").gameObject.SetActive(false); //수비 씬을 위한 설정 obj.gameObject.AddComponent <PlanetRowid>(); obj.gameObject.GetComponent <PlanetRowid>().rowid = SelectDB.Instance().planetIndex; loadedPlanets[loadedCnt] = obj.gameObject; loadedCnt++; //나무 표시 처리 for (int treeCnt = 1; treeCnt <= 6; treeCnt++) { string treeObj = "Tree_" + treeCnt; if (obj.transform.FindChild(treeObj) != null) { string treeCntStr = "tree" + treeCnt; switch (treeCheck(treeCntStr)) { case 1: obj.transform.FindChild(treeObj).FindChild("Pinetree_" + treeCnt).gameObject.SetActive(true); obj.transform.FindChild(treeObj).FindChild("Springtree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Mapletree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Wintertree_" + treeCnt).gameObject.SetActive(false); break; case 2: obj.transform.FindChild(treeObj).FindChild("Pinetree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Springtree_" + treeCnt).gameObject.SetActive(true); obj.transform.FindChild(treeObj).FindChild("Mapletree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Wintertree_" + treeCnt).gameObject.SetActive(false); break; case 3: obj.transform.FindChild(treeObj).FindChild("Pinetree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Springtree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Mapletree_" + treeCnt).gameObject.SetActive(true); obj.transform.FindChild(treeObj).FindChild("Wintertree_" + treeCnt).gameObject.SetActive(false); break; case 4: obj.transform.FindChild(treeObj).FindChild("Pinetree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Springtree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Mapletree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Wintertree_" + treeCnt).gameObject.SetActive(true); break; default: obj.transform.FindChild(treeObj).FindChild("Pinetree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Springtree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Mapletree_" + treeCnt).gameObject.SetActive(false); obj.transform.FindChild(treeObj).FindChild("Wintertree_" + treeCnt).gameObject.SetActive(false); break; } } } } } //로드된 행성 배열 사이즈 조정 Array.Resize(ref loadedPlanets, loadedCnt); planetLoadCnt = 1; //휴식 행성 로드 SelectDB.Instance().table = "garbageTable"; SelectDB.Instance().column = "rowid, Count(*)"; SelectDB.Instance().Select(0); SelectDB.Instance().table = "garbageTable"; SelectDB.Instance().column = "rowid, name, size, color, mat, locationX, locationY, locationZ"; for (; planetLoadCnt <= SelectDB.Instance().planetCount; planetLoadCnt++) { SelectDB.Instance().where = "WHERE rowid =" + planetLoadCnt; SelectDB.Instance().Select(3); SelectDB.Instance().where = " "; if (SelectDB.Instance().planetIndex != 0) { int planetShape = (SelectDB.Instance().planetSize * 100) + (SelectDB.Instance().planetColor * 10) + SelectDB.Instance().planetMat; //쿼리 결과로 변수 초기화 Debug.Log(planetShape); // 행성 오브젝트 생성 및 배치 GameObject obj = Instantiate(GameObject.Find("PlanetManager").gameObject.GetComponent <RandPlanet>().D_PlanetList[planetShape]); obj.transform.position = SelectDB.Instance().starPosition; obj.name = SelectDB.Instance().planetName; obj.tag = "Planet"; //obj.GetComponent<SphereCollider>().isTrigger = false; obj.transform.FindChild("PC").gameObject.SetActive(false); obj.transform.FindChild("Neighbor").gameObject.SetActive(false); obj.transform.FindChild("Ship").gameObject.SetActive(false); obj.transform.FindChild("Ship_Neighbor").gameObject.SetActive(false); obj.transform.FindChild("Zoo").gameObject.SetActive(false); obj.transform.FindChild("Postbox").gameObject.SetActive(false); obj.transform.FindChild("Spacestation").gameObject.SetActive(false); for (int treeCnt = 1; treeCnt <= 6; treeCnt++) { string treeObj = "Tree_" + treeCnt; if (obj.transform.FindChild(treeObj) != null) { obj.transform.FindChild(treeObj).gameObject.SetActive(false); } } } } planetLoadCnt = 1; }