// Use this for initialization void Start() { defaultIngredient = (GameObject)(Resources.Load("Ingredient")); defaultPotion = (GameObject)(Resources.Load("Potion")); recipePages = GameObject.FindGameObjectWithTag("recipePage"); ingredientPages = GameObject.FindGameObjectWithTag("ingredientPage"); mixingInventory = GameObject.FindGameObjectsWithTag("mixingInventory"); playerInventory = GameObject.FindGameObjectsWithTag("playerInventory").OrderBy(go => go.name).ToArray(); m_slots = new GameObject[mixingInventory.Length]; m_ingredients = new ArrayList(); p_ingredients = new ArrayList(); mixButton = GameObject.Find("mixButton"); mixArea = GameObject.Find("mixInventory"); mixArea.SetActive(false); mixButton.SetActive(false); mixState = false; modal = GameObject.Find("pickUpModal"); modal.SetActive(false); book = GameObject.Find("Book").GetComponent <bookScript>(); scavenging = GameObject.Find("Scavenger Hunt").GetComponent <scavengeScript>(); player.toggleItem(); bubbles = GameObject.Find("cauldronSound").GetComponent <AudioSource>(); stir = GameObject.Find("mixAreaSound").GetComponent <AudioSource>(); }
void Update() { // Check if the player has pressed the fire button and if enough time has elapsed since they last fired if (Input.GetButtonDown("Fire1") && Time.time > nextFire) { // Update the time when our player can fire next nextFire = Time.time + fireRate; // Start our ShotEffect coroutine to turn our laser line on and off StartCoroutine(ShotEffect()); // Create a vector at the center of our camera's viewport Vector3 rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f)); // Declare a raycast hit to store information about what our raycast has hit RaycastHit hit; // Set the start position for our visual effect for our laser to the position of gunEnd laserLine.SetPosition(0, gunEnd.position); // Check if our raycast has hit anything if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, weaponRange)) { // Set the end position for our laser line laserLine.SetPosition(1, hit.point); // Get a reference to a health script attached to the collider we hit bookScript health = hit.collider.GetComponent <bookScript>(); // If there was a health script attached if (health != null) { // Call the damage function of that script, passing in our gunDamage variable health.Damage(gunDamage); count = count + 1; countText.text = "Punkty: " + count.ToString(); } // Check if the object we hit has a rigidbody attached //if (hit.rigidbody != null) // { // Add force to the rigidbody we hit, in the direction from which it was hit // hit.rigidbody.AddForce(-hit.normal * hitForce); // } } else { // If we did not hit anything, set the end of the line to a position directly in front of the camera at the distance of weaponRange laserLine.SetPosition(1, rayOrigin + (fpsCam.transform.forward * weaponRange)); } } }
// Use this for initialization void Start() { actions = 3; act = true; actionPoints = GameObject.FindGameObjectsWithTag("action"); areas = GameObject.FindGameObjectsWithTag("area").OrderBy(go => go.name).ToArray(); book = GameObject.Find("Book").GetComponent <bookScript>(); rustle = GameObject.Find("scavengeSound").GetComponent <AudioSource>(); }
// Use this for initialization void Start() { book = GameObject.Find("Book").GetComponent <bookScript>(); bubbleLeft = GameObject.Find("bubbleLeft"); bubbleRight = GameObject.Find("bubbleRight"); dialogText = GameObject.Find("DialogText").GetComponent <Text>(); charaName = GameObject.Find("CharaName").GetComponent <Text>(); requestSlot = GameObject.FindGameObjectWithTag("requestSlot"); player = GameObject.Find("player sprite").GetComponent <playerScript>(); list = GameObject.FindGameObjectWithTag("prepArea").GetComponent <ingredientScript>(); list.setupDictionary(); request = list.potions["Potion of Healing"]; requestAtt = "Soothing"; requestSpecial = null; charaState = 1; stars = GameObject.FindGameObjectsWithTag("stars").OrderBy(go => go.name).ToArray(); for (int i = 0; i < stars.Length; i++) { stars[i].SetActive(false); } playerInventory = GameObject.FindGameObjectsWithTag("playerInventory"); back = GameObject.Find("textBack"); forward = GameObject.Find("textForward"); nextChara = GameObject.Find("nextCustomer"); endButton = GameObject.Find("endGame"); nextChara.SetActive(false); endButton.SetActive(false); dia = new List <string>(); //list.test(); charaNum = 0; place = 0; enter = GameObject.Find("enterSound").GetComponent <AudioSource>(); success = GameObject.Find("successSound").GetComponent <AudioSource>(); }