/*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() { ; shoppingDiscovered = WaveManagerScript.currentWave >= 2; lieGeneratorDiscovered = WaveManagerScript.currentWave >= 4; brothelDiscovered = WaveManagerScript.currentWave >= 6; int availableCount = 0; for (int i = 0; i < transform.childCount; ++i) { bool expensive = AttachWeaponScript.weaponPrices[i + 1] > StatsScript.money; transform.GetChild(i).Find("Expensive").GetComponent <Image>().enabled = expensive; if (expensive && ((int)currentWeapon == i + 1)) { currentWeapon = AttachWeaponScript.WeaponTypes.None; } transform.GetChild(i).Find("Selected").GetComponent <Image>().enabled = (i + 1 == (int)currentWeapon); bool discovered = true; if (i + 1 == (int)AttachWeaponScript.WeaponTypes.Brothel) { discovered = brothelDiscovered; } if (i + 1 == (int)AttachWeaponScript.WeaponTypes.LieGenerator) { discovered = lieGeneratorDiscovered; } if (i + 1 == (int)AttachWeaponScript.WeaponTypes.ShoppingCenter) { discovered = shoppingDiscovered; } transform.GetChild(i).Find("Undiscovered").GetComponent <Image>().enabled = !discovered; transform.GetChild(i).Find("Undiscovered").GetComponentInChildren <Text>().enabled = !discovered; if (!expensive && discovered) { ++availableCount; } } if (availableCount == 1) { Select(AttachWeaponScript.WeaponTypes.DrinkSpot); } }
// Use this for initialization void Start() { /*Text[] shopPrices = GetComponentsInChildren<Text>(); for (int i = 0; i != shopPrices.Length; ++i) { shopPrices[i].text = "$" + AttachWeaponScript.weaponPrices[i+1].ToString() + "K"; }*/ for (int i = 0; i < transform.childCount; ++i) { transform.GetChild(i).Find("Price").GetComponent<Text>().text = "$" + AttachWeaponScript.weaponPrices[i+1].ToString() + "K"; } currentWeapon = AttachWeaponScript.WeaponTypes.None; }
// Use this for initialization void Start() { /*Text[] shopPrices = GetComponentsInChildren<Text>(); * for (int i = 0; i != shopPrices.Length; ++i) * { * shopPrices[i].text = "$" + AttachWeaponScript.weaponPrices[i+1].ToString() + "K"; * }*/ for (int i = 0; i < transform.childCount; ++i) { transform.GetChild(i).Find("Price").GetComponent <Text>().text = "$" + AttachWeaponScript.weaponPrices[i + 1].ToString() + "K"; } currentWeapon = AttachWeaponScript.WeaponTypes.None; }
/*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() { ; shoppingDiscovered = WaveManagerScript.currentWave >= 2; lieGeneratorDiscovered = WaveManagerScript.currentWave >= 4; brothelDiscovered = WaveManagerScript.currentWave >= 6; int availableCount = 0; for (int i = 0; i < transform.childCount; ++i) { bool expensive = AttachWeaponScript.weaponPrices[i+1] > StatsScript.money; transform.GetChild(i).Find("Expensive").GetComponent<Image>().enabled = expensive; if (expensive && ((int) currentWeapon == i+1)) currentWeapon = AttachWeaponScript.WeaponTypes.None; transform.GetChild(i).Find("Selected").GetComponent<Image>().enabled = (i+1 == (int) currentWeapon); bool discovered = true; if (i+1 == (int) AttachWeaponScript.WeaponTypes.Brothel) discovered = brothelDiscovered; if (i+1 == (int) AttachWeaponScript.WeaponTypes.LieGenerator) discovered = lieGeneratorDiscovered; if (i+1 == (int) AttachWeaponScript.WeaponTypes.ShoppingCenter) discovered = shoppingDiscovered; transform.GetChild(i).Find("Undiscovered").GetComponent<Image>().enabled = !discovered; transform.GetChild(i).Find("Undiscovered").GetComponentInChildren<Text>().enabled = !discovered; if (!expensive && discovered) ++availableCount; } if (availableCount == 1) Select(AttachWeaponScript.WeaponTypes.DrinkSpot); }
// 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(); } } } } } }