private void OnMouseDown() { if (Bullets_Selector_UI.bullet_No[1] == true) { if (Static_Fields.money >= Static_Fields.AR_ammo_cost && assualt_rifle_script.Assault_rifle.bullet_count <= 0) { assualt_rifle_script.Assault_rifle.Add_Bullets(Add_bullets.ammo_count); money_manager.Deduct_Money(Static_Fields.AR_ammo_cost); Add_bullets.add_ammo_audio.Play(); Change_Color_To_Black(); } else { GameObject.Find("Money Manager").GetComponent <AudioSource>().Play(); } } }
private void OnMouseDown() { if (Bullets_Selector_UI.bullet_No[0] == true) { if (Static_Fields.money >= Static_Fields.HG_ammo_cost && hand_gun_script.Hand_gun.bullet_count <= 0) { hand_gun_script.Hand_gun.Add_Bullets(Add_bullets.ammo_count); bullets_cost_money.Deduct_Money(Static_Fields.HG_ammo_cost); Add_bullets.add_ammo_audio.Play(); Change_Color_To_Black(); } else { GameObject.Find("Money Manager").GetComponent <AudioSource>().Play(); } } }
public void Spawn_Selector(GameObject weapon_prefab) { if (weapon_prefab.name == "Defender_1" && hand_gun_ui.allow_instantiation) { hand_gun_ui.is_selected = false; change_color_to_black_hand_gun = true; Instantiate(weapon_prefab, new Vector3((int)this.touch_pos.x + 1f, (int)this.touch_pos.y + 0.2f, -2f), Quaternion.identity); if (hand_gun_ui.change_weapon_color.a >= 1) { money_manager.Deduct_Money(Static_Fields.gun_cost[(int)Gun_cost.HG]); } } else if (weapon_prefab.name == "Defender_2" && assault_rifle_ui.allow_instantiation) { assault_rifle_ui.is_selected = false; change_color_to_black_assault_rifle = true; Instantiate(weapon_prefab, new Vector3((int)this.touch_pos.x + 0.5f, (int)this.touch_pos.y + 0.7f, -2f), Quaternion.identity); if (assault_rifle_ui.change_weapon_color.a >= 1) { money_manager.Deduct_Money(Static_Fields.gun_cost[(int)Gun_cost.AR]); } } else if (weapon_prefab.name == "Defender_3" && shot_gun_ui.allow_instantiation) { shot_gun_ui.is_selected = false; change_color_to_black_shot_gun = true; Instantiate(weapon_prefab, new Vector3((int)this.touch_pos.x + 1.5f, (int)this.touch_pos.y + 0.5f, -2f), Quaternion.identity); if (shot_gun_ui.change_weapon_color.a >= 1) { money_manager.Deduct_Money(Static_Fields.gun_cost[(int)Gun_cost.SG]); } } else if (weapon_prefab.name == "Defender_4" && burst_gun_ui.allow_instantiation) { burst_gun_ui.is_selected = false; change_color_to_black_burst_gun = true; Instantiate(weapon_prefab, new Vector3((int)this.touch_pos.x + 3.1f, (int)this.touch_pos.y, -2f), Quaternion.identity); if (burst_gun_ui.change_weapon_color.a >= 1) { money_manager.Deduct_Money(Static_Fields.gun_cost[(int)Gun_cost.BG]); } } else if (weapon_prefab.name == "Defender_5" && sniper_rifle_ui.allow_instantiation) { sniper_rifle_ui.is_selected = false; bool allow_instantiation = Physics2D.Raycast(new Vector2((int)this.touch_pos.x, (int)this.touch_pos.y + 0.5f), Vector2.right, 1.2f, layer_mask_sniper_rifle); if ((allow_instantiation == false) || allow_once) { change_color_to_black_sniper_rifle = true; if (sniper_rifle_ui.change_weapon_color.a >= 1) { money_manager.Deduct_Money(Static_Fields.gun_cost[(int)Gun_cost.SR]); } allow_once = false; Instantiate(weapon_prefab, new Vector3((int)this.touch_pos.x + 1f, (int)this.touch_pos.y + 0.7f, -2f), Quaternion.identity); } } }