// Update is called once per frame void Update() { if (!initmon) { if (Lists.IsActive() && MonInit.IsActive() && BattleMain3.IsActive()) { //MonInv.AddMonster(MonInit.MakeFromPrefab(test)); //MonInv.AddMonster(MonInit.MakeFromPrefab(test)); initmon = true; randopon = Lists.RandMon(); randopon = MonInit.RandomFromPrefab(randopon); //randopon = MonInit.RandomFromPrefab(testopon); BattleMain3.SetMon(randopon); //you = MonInv.FirstActive(); //you = MonInit.MakeFromPrefab(test); //you = new Monster.SubMonster(MonInv.FirstActive()); //BattleMain3.SetYou(you); BattleMain3.TurnSet(true); } } else if (initmon) { gameObject.SetActive(false); //animation, activate BattleMain3, close this } }
void Start() { if (curInstance == null) { curInstance = this; } //i = 0; }
public static Monster.SubMonster RandMon() { Random.InitState((int)System.DateTime.Now.Ticks); int i = Random.Range(0, instance.allmonsters.Length); Monster.SubMonster temp = new Monster.SubMonster();//instance.allmonsters[i].themonster); temp = MonInit.MakeFromPrefab(instance.allmonsters[i]); //temp = return(temp); }
void OnEnable() { Events.SetActive(false); temp = Lists.RandMon(); temp = MonInit.RandomFromPrefab(temp); disp.sprite = Resources.Load("MonsterSprites/" + temp.imagepath, typeof(Sprite)) as Sprite; text.text = "Aw! You've found a lonely " + temp.Name + "\nwho wants to join your team\n\nDo you want to keep it?"; //SaveLoad.Save(SaveCallBack); }
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 Update() { 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) { if (hit.transform.gameObject.GetComponent <InvSlot>() != null) { if (hit.transform.gameObject.GetComponent <InvSlot>().curMonster != null) { 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) { if (hit.transform.gameObject.GetComponent <InvSlot>() != null) { if (hit.transform.gameObject.GetComponent <InvSlot>().curMonster != null) { go2 = hit.transform.gameObject; } } } moving = false; if (go == go2) { MonInit.RandomMoves(go.GetComponent <InvSlot>().curMonster); DowntownControl.GetPlayer().iteminv.SubstractCoins(750); Success(); } } } else { go = null; go2 = null; onehit = true; } }