/*static public void SelectStatic(AttachWeaponScript.WeaponTypes weapon) { GameObject.Find("WeaponShop").GetComponent<WeaponShopScript>().Select(weapon); }*/ public void Select(AttachWeaponScript.WeaponTypes weapon) { if (!shoppingDiscovered && (weapon == AttachWeaponScript.WeaponTypes.ShoppingCenter)) return; if (!lieGeneratorDiscovered && (weapon == AttachWeaponScript.WeaponTypes.LieGenerator)) return; if (!brothelDiscovered && (weapon == AttachWeaponScript.WeaponTypes.Brothel)) return; if (AttachWeaponScript.weaponPrices[(int) weapon] > StatsScript.money) return; currentWeapon = weapon; }
// Update is called once per frame void Update() { HealthDrop(); /*Image[] grayed = new Image[](4); * for () * Image[] grayed = weaponShop.Find("Expensive").GetComponents<Image>(); * for (int i = 0; i != grayed.Length; ++i) * { * grayed[i].enabled = AttachWeaponScript.weaponPrices[i+1] >= money; * }*/ /*for (int i = 0; i < weaponShop.transform.childCount; ++i) * { * weaponShop.transform.GetChild(i).Find("Expensive").GetComponent<Image>().enabled * = AttachWeaponScript.weaponPrices[i+1] > money; * }*/ WaveManagerScript wms = waves.GetComponent <WaveManagerScript>(); infoTop.GetComponent <Text>().text = string.Format("Mental Health: {0} Wave {1} of {2}", health, WaveManagerScript.currentWave + 1, wms.WaveCount()); infoBottom.GetComponent <Text>().text = string.Format("Money: ${0}K", money); //GameObject.Find("EventSystem").GetComponent<UnityEventQueueSystem> if ((Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) && !EventSystem.current.IsPointerOverGameObject()) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit rch; // = new RaycastHit(); if (Physics.Raycast(ray, out rch)) { AttachWeaponScript aws = rch.collider.gameObject.GetComponent <AttachWeaponScript>(); if (aws != null) { if (Input.GetMouseButtonDown(0)) { //Debug.Log("Mouse Down hit: "+ rch.collider.name); AttachWeaponScript.WeaponTypes weapon = weaponShop.GetComponent <WeaponShopScript>().SelectedWeapon(); if ((weapon != AttachWeaponScript.WeaponTypes.None) && (weapon != aws.GetWeaponType())) { int cost = AttachWeaponScript.weaponPrices[(int)weapon]; GameObject message = (GameObject)Instantiate(Resources.Load("prefabs/message")); Vector3 pos = rch.collider.bounds.center; pos.y = 0; message.GetComponentInChildren <PopupMessageScript>().pos = pos; //transform.position/* + new Vector3(0,0,10.0f)*/; message.GetComponent <RectTransform>().SetParent(canvas.transform); message.transform.SetSiblingIndex(0); message.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0); message.GetComponentInChildren <Text>().text = "-$" + (cost).ToString() + "K"; money -= cost; aws.SetWeaponType(weapon); } } else { if (aws.GetWeaponType() == AttachWeaponScript.WeaponTypes.LieGenerator) { aws.ActivateLies(); } } } } } }