//from highest to lowest //battle //money //pickpocket //trap //freemon //nothing IEnumerator Waiting() { while (!stoploading) { //yield return new WaitForSeconds(Random.Range(3.5f, 6f)); yield return(new WaitForSeconds(1f)); //checker = Random.Range((int)0, (int)7); checker = Choose(percents); if (!stoploading) { switch (checker) { case 5: break; case 1: stoploading = true; panel.SetActive(true); money.gameObject.SetActive(true); break; case 2: if (player.GetPlayer().iteminv.Coins() > 0) { stoploading = true; panel.SetActive(true); pickpocket.gameObject.SetActive(true); } break; case 3: stoploading = true; panel.SetActive(true); trap.SetActive(true); break; case 4: if (!player.GetPlayer().moninv.IsFull()) { stoploading = true; panel.SetActive(true); monster.gameObject.SetActive(true); } break; case 0: //scene = "Battle"; //do an animation that leads into it GlobalData.loadGame = true; stoploading = true; StartCoroutine("Fader", "Battle"); break; case 6: break; } } } }
public static void PlayerSet(PlayerMain pm, int i) { if (i == 1) { instance.player1m = pm; instance.player1 = pm.GetPlayer(); instance.p1mon = instance.player1.moninv.FirstActive(); } else if (i == 2) { instance.player2m = pm; instance.player2 = pm.GetPlayer(); instance.p2mon = instance.player2.moninv.FirstActive(); } }
//need ??? void Awake() { if (curInstance == null) { curInstance = this; } UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks); player1 = player1m.GetPlayer(); //player2 = player2m.GetPlayer(); }
void Update() { if (Input.GetKeyDown(KeyCode.Space)) { player.GetPlayer().moninv.AddMonster(MonInit.MakeFromPrefab(acticons[2].GetComponent <InvSlot>().curMonster)); //MonInv.AddMonster(MonInit.MakeFromPrefab(acticons[2].GetComponent<InvSlot>().curMonster)); //MonInv.AddMonster(MonInit.MakeFromPrefab(acticons[2].GetComponent<InvSlot>().curMonster)); picker++; SaveLoad.Save(SaveCallBack); } if (GlobalData.pickstart == false) { //SaveLoad.Save(SaveCallBack); towncontrol.SetActive(true); gameObject.SetActive(false); } else { towncontrol.SetActive(false); } if (picker == 1) { welcome.SetActive(true); for (int i = 0; i < 3; i++) { acticons[i].GetComponent <InvSlot>().curMonster = set1[i].themonster; acticons[i].GetComponent <SpriteRenderer>().sprite = Resources.Load("MonsterSprites/" + set1[i].themonster.imagepath, typeof(Sprite)) as Sprite; } } else if (picker == 2) { welcome.SetActive(false); second.SetActive(true); for (int i = 0; i < 3; i++) { acticons[i].GetComponent <InvSlot>().curMonster = set2[i].themonster; acticons[i].GetComponent <SpriteRenderer>().sprite = Resources.Load("MonsterSprites/" + set2[i].themonster.imagepath, typeof(Sprite)) as Sprite; } } else { towncontrol.SetActive(true); GlobalData.pickstart = false; } if (Input.touchCount == 1 && onehit) { // touch on screen if (Input.GetTouch(0).phase == TouchPhase.Began) { Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit hit = new RaycastHit(); moving = Physics.Raycast(ray, out hit); if (moving) { go = hit.transform.gameObject; //Debug.Log("Touch Detected on : " + go.name); } else { onehit = false; } } // release touch/dragging if ((Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.touchCount != 1) && go != null && onehit) { Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit hit = new RaycastHit(); moving = Physics.Raycast(ray, out hit); if (moving) { go2 = hit.transform.gameObject; moving = false; } //moving = false; //Debug.Log("Touch Released from : " + go.name); if (go == acticons[0] && go == go2) { player.GetPlayer().moninv.AddMonster(MonInit.MakeFromPrefab(acticons[0].GetComponent <InvSlot>().curMonster)); //MonInv.AddMonster(MonInit.MakeFromPrefab(acticons[0].GetComponent<InvSlot>().curMonster)); //MonInv.AddMonster(MonInit.MakeFromPrefab(acticons[0].GetComponent<InvSlot>().curMonster)); picker++; } else if (go == acticons[1] && go == go2) { player.GetPlayer().moninv.AddMonster(MonInit.MakeFromPrefab(acticons[1].GetComponent <InvSlot>().curMonster)); //MonInv.AddMonster(MonInit.MakeFromPrefab(acticons[1].GetComponent<InvSlot>().curMonster)); //MonInv.AddMonster(MonInit.MakeFromPrefab(acticons[1].GetComponent<InvSlot>().curMonster)); picker++; } else if (go == acticons[2] && go == go2) { player.GetPlayer().moninv.AddMonster(MonInit.MakeFromPrefab(acticons[2].GetComponent <InvSlot>().curMonster)); //MonInv.AddMonster(MonInit.MakeFromPrefab(acticons[2].GetComponent<InvSlot>().curMonster)); //MonInv.AddMonster(MonInit.MakeFromPrefab(acticons[2].GetComponent<InvSlot>().curMonster)); picker++; } } } else { go = null; go2 = null; onehit = true; //im pretty sure this is completely f*****g unnecessary } }
private void Awake() { player = playerm.GetPlayer(); }
void Update() { /*if (Input.GetKeyDown("space")) * { * SaveLoad.Save(SaveCallBack); * GlobalData.loadGame = true; * * StartCoroutine("Fader"); * }*/ if (player.GetPlayer().moninv.IsEmpty()) { gameover.SetActive(true); gameObject.SetActive(false); } //use bools to make this section go off only if there's a change? bool shopisactive = (ShopMain.isActive() || MICollider.isActive() || InvCol.isActive() || BookControl.isActive()); shop.GetComponent <BoxCollider>().enabled = !shopisactive; fountain.GetComponent <BoxCollider>().enabled = !shopisactive; book.GetComponent <BoxCollider>().enabled = !shopisactive; adventure.GetComponent <BoxCollider>().enabled = !shopisactive; iteminv.GetComponent <BoxCollider>().enabled = !shopisactive; iteminv.GetComponent <SpriteRenderer>().enabled = !shopisactive; moninv.GetComponent <SpriteRenderer>().enabled = !shopisactive; moninv.GetComponent <BoxCollider>().enabled = !shopisactive; downtown.GetComponent <BoxCollider>().enabled = !shopisactive; menubut.SetActive(!shopisactive); //if (Input.GetKeyDown("space")) //print(go == go2); if (Input.touchCount == 1 && onehit) { if (!shopisactive) { // touch on screen if (Input.GetTouch(0).phase == TouchPhase.Began) { Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit hit = new RaycastHit(); moving = Physics.Raycast(ray, out hit); if (moving) { go = hit.transform.gameObject; //Debug.Log("Touch Detected on : " + go.name); } else { onehit = false; } } // release touch/dragging if ((Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.touchCount != 1) && go != null && onehit) { Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit hit = new RaycastHit(); moving = Physics.Raycast(ray, out hit); if (moving) { go2 = hit.transform.gameObject; } moving = false; //Debug.Log("Touch Released from : " + go.name); if (go == shop && go == go2) { ShopMain.ShopSet(true); } else if (go == fountain && go == go2) { player.GetPlayer().moninv.HealAll(); if (canenter) { StartCoroutine("HealSprite"); } //play sound SaveLoad.Save(SaveCallBack); } else if (go == book && go == go2) { BookControl.BookSet(true); } else if (go == adventure && go == go2) { if (player.GetPlayer().moninv.HasAnActive()) { SaveLoad.Save(SaveCallBack); GlobalData.loadGame = true; //fader.color = Color.clear; //SceneManager.LoadScene("Adventure"); StartCoroutine("Fader", "Adventure"); } else { //you need at least one active monster to adventure! } } else if (go == iteminv && go == go2) { InvCol.SetActive(true); } else if (go == moninv && go == go2) { MICollider.SetActive(true); } else if (go == downtown && go == go2) { SaveLoad.Save(SaveCallBack); GlobalData.loadGame = true; StartCoroutine("Fader", "Downtown"); } } } } else { go = null; go2 = null; onehit = true; } }