void Start() { boxCollider2D = GetComponent <BoxCollider2D>(); //furnace needs this as a reference theFurnace = GameObject.Find("Furnace").GetComponent <FurnaceScript>(); //also spawning theSpawning = GameObject.Find("SpawningPoint").GetComponent <SpawningScript>(); //the ingredients should fly towards this, if correct target = null; theChangeScene = GameObject.Find("Canvas").GetComponent <ChangeSceneScript>(); theMoney = GameObject.Find("Money").GetComponent <MoneyScript>(); theSPF = GameObject.Find("SpawningFoodLayer").GetComponent <SpawningFoodLayerScript>(); theSPF.spawnfoodlayer();// foodlayerclone = GameObject.Find("FoodLayer(Clone)"); theNextRecipe = GameObject.Find("NextRecipeButton").GetComponent <NextRecipeScript>(); theGameMaster = GameObject.Find("GameMaster").GetComponent <GameMasterScript>(); }
//獲得金錢 public void GetSomeMoney(int _money) { if (photonView.isMine) { MoneyScript.obtaniResource(_money); } }
//List<GameObject> planten; // Start is called before the first frame update void Start() { //moneyScript = (MoneyScript) GameObject.FindObjectOfType(typeof(MoneyScript)); //planten = new List<GameObject>(); //timings = new List<int>(); //foreach (Transform child in transform) planten.Add(child.gameObject); if (FindObjectsOfType <MoneyScript>().Length != 0) { moneyScript = FindObjectsOfType <MoneyScript>()[0]; } //hide alle planten bij de start for (int i = 0; i < planten.Count; i++) { planten[i].transform.gameObject.SetActive(false); } Quaternion rotation = Quaternion.Euler(new Vector3(0, Random.Range(0, 360), 0)); transform.rotation = rotation; growing = true; change = 0; harvestAble = false; plantTimer = timings[0]; //toon eerste plantje //Debug.Log("antal planten " + planten.Count); //Debug.Log("antal timings " + timings.Count); plantTimer = Random.Range(timings[0], timings[3]); }
// Start is called before the first frame update void Start() { //List<GameObject> lijstGameObjects = new List <GameObject>(); lijstGameObjects.Add(GameObject.Find("Schuur")); lijstGameObjects.Add(GameObject.Find("Huis")); lijstGameObjects.Add(GameObject.Find("Mesthoop")); lijstGameObjects.Add(GameObject.Find("Waterput")); lijstGameObjects.Add(GameObject.Find("Veld")); /* planten = new List<Planten>(); * * for (int i = 0; i < planten.Count; i++) * { * planten[i].transform.gameObject.SetActive(false); * } */ for (int i = 0; i < lijstGameObjects.Count; i++) { lijstGameObjects[i].AddComponent <S_GlitchFruit>(); //lijstGameObjects[i].AddComponent<S_HologramGlitch>(); //lijstGameObjects[i].AddComponent<S_MeshGlitch>(); lijstGameObjects[i].AddComponent <S_WireframeGlitch>(); } if (FindObjectsOfType <MoneyScript>().Length != 0) { money = FindObjectsOfType <MoneyScript>()[0]; } }
protected static TowerScript currentActiveTower; // Variable to store the current selected tower by the player void Start() { // Checking if the there is a reference for the above money, if not assigning it if (moneyMeter == null) { moneyMeter = FindObjectOfType <MoneyScript>(); } }
void OnEnable() { _enemyHealth = GetComponent <Health>(); _enemyHealth.Initialize(); var go = GameObject.Find("GameManager"); _money = go.GetComponent <MoneyScript>(); _manager = go.GetComponent <GameManager>(); }
// Start is called before the first frame update void Start() { SetCurrentTowerType("BASE"); Time.timeScale = 1; M = MoneyHandler.GetComponent <MoneyScript>(); //pausedItems = GameObject.FindGameObjectsWithTag("ShowOnPause"); hidePaused(); }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } }
// Start is called before the first frame update void Start() { if (State.currentTask > 4) { currentTask = State.currentTask; } scene2 = NextScene(2); scene3 = NextScene(1); scene4 = NextScene(3); manager = GameObject.FindWithTag("Manager"); money = manager.GetComponent <MoneyScript>(); uiManagerScript = manager.GetComponent <UIManager>(); }
// Sells a tower and adjusts the player's money accordingly private void SellTower(RaycastHit hit) { // If the raycast is valid if (hit.collider != null) { // If the raycast hits a tower if (hit.collider.gameObject.tag == "Tower") { Destroy(hit.collider.gameObject); MoneyScript M = MoneyHandler.GetComponent <MoneyScript>(); M.Money += 50; } } }
// Start is called before the first frame update void Start() { if (FindObjectsOfType <MoneyScript>().Length != 0) { moneyScript = FindObjectsOfType <MoneyScript>()[0]; } glitching = false; Color red = new Color(1f, 0, 0); Color blue = new Color(0, 0, 1); wireframeMaterialRed = new Material(Shader.Find("FX/Hologram Shader")); wireframeMaterialBlue = new Material(Shader.Find("FX/Hologram Shader")); meshRed = new GameObject(); meshRed.transform.localPosition = gameObject.transform.localPosition; meshRed.transform.localRotation = gameObject.transform.localRotation; meshRed.transform.localScale = gameObject.transform.localScale; meshRed.AddComponent <MeshFilter>(); meshRed.AddComponent <MeshRenderer>(); meshRed.GetComponent <MeshFilter>().mesh = gameObject.GetComponent <MeshFilter>().mesh; meshRed.GetComponent <Renderer>().material = wireframeMaterialRed; meshRed.GetComponent <Renderer>().material.SetColor("_Color", red); meshRed.GetComponent <Renderer>().material.SetFloat("_GlowIntensity", 0.9f); meshBlue = new GameObject(); meshBlue.transform.localPosition = gameObject.transform.localPosition; meshBlue.transform.localRotation = gameObject.transform.localRotation; meshBlue.transform.localScale = gameObject.transform.localScale; meshBlue.AddComponent <MeshFilter>(); meshBlue.AddComponent <MeshRenderer>(); meshBlue.GetComponent <MeshFilter>().mesh = gameObject.GetComponent <MeshFilter>().mesh; meshBlue.GetComponent <Renderer>().material = wireframeMaterialBlue; meshBlue.GetComponent <Renderer>().material.SetColor("_Color", blue); meshBlue.GetComponent <Renderer>().material.SetFloat("_GlowIntensity", 0.9f); meshRed.GetComponents <MeshRenderer>()[0].enabled = false; meshBlue.GetComponents <MeshRenderer>()[0].enabled = false; if (glitchOnSpawn == true) { InvokeRepeating("GlitchFruit", 0, glitchFrequency); } }
// Places a tower in the game world and adjusts the player's monay accordingly private void PlaceTower(RaycastHit hit) { // If the raycast is valid if (hit.collider != null) { // If the raycast hits a wall if (hit.collider.gameObject.tag == "Wall" && hit.collider.gameObject.tag != "Tower") { //If there's money in the bank MoneyScript M = MoneyHandler.GetComponent <MoneyScript>(); if (M.Money >= 100) { // Add a tower and subtract the cost // To be able to place tower types later, we might want to have a type that we check for here Vector3 pos = hit.collider.gameObject.transform.position;// + Vector3.up; pos.y += 0.325f; //Instantiate(TowerPrefab, pos, Quaternion.identity); //M.Money -= 100; } } } }
// Start is called before the first frame update void Start() { savePath = Application.dataPath + "/savedata.json"; rb2d = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); isColliding = false; plowedGround = Resources.Load <GameObject>("Prefabs/PlowedGround_Dry"); moneyScript = GameObject.Find("MoneyAmount").GetComponent <MoneyScript>(); equippedItemScript = GameObject.Find("ItemBackground").GetComponent <EquippedItemScript>(); pauseMenuScript = GameObject.Find("GameUI").GetComponent <PauseMenuScript>(); currentlyEquipped = "none"; money = 100; equippedItemScript.EmptyEquippedItem(); LoadData(); Debug.Log("Game Loaded"); moneyScript.UpdateMoneyText(money); }
private MoneyScript moneyMeter; // Variable to store the money void Start() { // If the reference to the Game Manager is missing, the script gets it if (gameManager == null) { gameManager = FindObjectOfType <GameManagerScript>(); } // Checking if the there is a reference for the above money, if not assigning it if (moneyMeter == null) { moneyMeter = FindObjectOfType <MoneyScript>(); } audioSource = GetComponent <AudioSource>(); animator = GetComponent <Animator>(); // Getting the reference to the Rigidbody2d rb2D = GetComponent <Rigidbody2D>(); // Gtinget the first waypoint from the Game Manager currentWaypoint = gameManager.firstWaypoint; }
// Start is called before the first frame update void Start() { renderer = GetComponent <SpriteRenderer>(); theSPF = GameObject.Find("SpawningFoodLayer").GetComponent <SpawningFoodLayerScript>(); target = GameObject.Find("Furnace"); movetoward = GameObject.Find("SpeechBubble"); //load a base graphic //renderers[3].sprite = SpriteLayerBase(target.GetComponent<FurnaceScript>().recipe.name); theNextRecipe = GameObject.Find("NextRecipeButton").GetComponent <NextRecipeScript>(); gameObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); theChangeScene = GameObject.Find("Canvas").GetComponent <ChangeSceneScript>(); theFurnace = GameObject.Find("Furnace").GetComponent <FurnaceScript>(); theGameMaster = GameObject.Find("GameMaster").GetComponent <GameMasterScript>(); theMoney = GameObject.Find("Money").GetComponent <MoneyScript>(); gameObject.name = "FoodLayer(Clone)"; /*make changes to the food layer for the following specific recipes*/ //change ice cream's position to within the board's surface if (theFurnace.recipe.name.StartsWith("Salad")) { gameObject.transform.position = new Vector3(-0.3f, 0.2f, 0); } else if (theFurnace.recipe.name.StartsWith("IceCream")) { gameObject.transform.position = new Vector3(-0.3f, 0.8f, 0); } else if (theFurnace.recipe.name.StartsWith("Club"))//initialise club sandwich, if needed { int clchldrn; clchldrn = gameObject.transform.childCount; for (int i = 1; i < clchldrn; i++) { //Debug.Log("forloop"); if (theFurnace.recipe.neededIngr.Count < i) { gameObject.transform.GetChild(i - 1).GetComponent <Transform>().localPosition += new Vector3(0f, -0.175f * i + 0.05f * (i) + 0.1f, 0); break; } // Debug.Log("i "+i+" neededingr "+theFurnace.recipe.neededIngr.Count); //Debug.Log(theFurnace.recipe.neededIngr[i-1]); //gameObject.transform.GetChild(i - 1).GetComponent<Transform>().localPosition = new Vector3(0f, 0.05f * (i-1), 0); gameObject.transform.GetChild(i - 1).GetComponent <Transform>().localPosition += new Vector3(0f, -0.175f * i + 0.05f * (i), 0); //Debug.Log("0.05*i-1=" + 0.05 * (i-1)); if (theFurnace.recipe.neededIngr[i - 1] == "Potato") { potatoeson = true; //assign the base's position on potatoes gameObject.transform.GetChild(i - 1).GetComponent <Transform>().localPosition = gameObject.transform.GetChild(clchldrn - 2).GetComponent <Transform>().localPosition; gameObject.transform.GetChild(i - 1).GetComponent <SpriteRenderer>().sortingOrder = 4; } } for (int i = 1; i < clchldrn; i++) { gameObject.transform.GetChild(i - 1).GetComponent <Transform>().localPosition += new Vector3(0f, 0.175f, 0); if (potatoeson) { gameObject.transform.GetChild(i - 1).GetComponent <SpriteRenderer>().sortingOrder++; if (i == clchldrn - 1) { //gameObject.transform.GetChild(i).GetComponent<Transform>().localPosition += new Vector3(0f, -0.700f, 0); gameObject.transform.GetChild(i).GetComponent <Transform>().localPosition = new Vector3(0f, theFurnace.recipe.neededIngr.Count * 0.05f, 0); } } /*if ((i != (clchldrn - 2))) * { * gameObject.transform.GetChild(i).GetComponent<Transform>().localPosition = new Vector3(0f, 0.05f * (i), 0); * if (theFurnace.recipe.neededIngr.Count>=i ) * { * if (theFurnace.recipe.neededIngr[i] == "Potato") * { * Debug.Log("1"); * if (i < clchldrn - 2) * { * Debug.Log("2"); * gameObject.transform.GetChild(i).GetComponent<Transform>().localPosition = new Vector3(0f, 0f, 0); * } * } * } * }*/ /*else * { * gameObject.transform.GetChild(i).GetComponent<Transform>().localPosition = new Vector3(0f, 0, 0); * }*/ //gameObject.transform.GetChild(i - 1).GetComponent<Transform>().localPosition += new Vector3(0f, 0.175f, 0); } gameObject.GetComponent <SpriteRenderer>().sprite = theGameMaster.spriteslayers["Plate"]; gameObject.GetComponent <SpriteRenderer>().sortingOrder = 4; } set_ingredient_distance(); //Debug.Log("k"); }
private void Awake() { ins = this; }