//public GameObject desk; void Awake() { absolutelyAllItems = FindAllDirectChildren(GameObject.FindGameObjectWithTag("ItemsToManage")); List <BasicFurnitureScript> fntb = new List <BasicFurnitureScript>(); for (int i = 0; i < absolutelyAllItems.Length; i++) { if (absolutelyAllItems[i].GetComponent <BasicFurnitureScript>() && absolutelyAllItems[i].GetComponent <BasicFurnitureScript>().isFlammable) { fntb.Add(absolutelyAllItems[i].GetComponent <BasicFurnitureScript>()); furnitureNeededToBurn++; } } allFurnitureToBurn = fntb.ToArray(); winScreen = GameObject.FindGameObjectWithTag("WinScreen"); wbScript = GameObject.FindGameObjectWithTag("WaitButton").GetComponent <WaitButtonScript>(); fMeterScript = GameObject.FindGameObjectWithTag("FineOMeter").GetComponent <FineOMeterScript>(); dog = GameObject.FindGameObjectWithTag("Dog").GetComponent <DogScript>(); fmScript = GetComponent <FireManagerScript>(); mmScript = GetComponent <MoveManager>(); gManager = GameObject.FindGameObjectWithTag("GridManager").GetComponent <GridManager>(); mText = GameObject.FindGameObjectWithTag("MovesText").GetComponent <MovesText>(); movesTextWin = FindGameObjectInChildWithTag(winScreen, "MovesTextWin").GetComponent <Text>(); winScreen.GetComponent <RectTransform>().localPosition = new Vector3(-119, 52, 0.02f); }
private void Awake() { myAgent = GetComponent <NavMeshAgent>(); if (dog == null) { dog = this; } else { Destroy(gameObject); } }
// Start is called before the first frame update void Start() { r1 = GetComponent <Rigidbody2D>(); playerAnimation = GetComponent <Animator>(); isFacingRight = true; respawnPoint = transform.position; gameLevelManager = FindObjectOfType <LevelManager>(); Pstats = FindObjectOfType <PlayerStats>(); Wp = FindObjectOfType <Weapon>(); groundCheckRadius = 0.2f; anim = GetComponent <Animator>(); dog = FindObjectOfType <DogScript>(); }
void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { source.Play(); GetComponent <Renderer>().enabled = false; Object.Destroy(GetComponent <BoxCollider2D>()); DogScript dogScript = collision.gameObject.GetComponent("DogScript") as DogScript; dogScript.gainBarks(3); Object.Destroy(this.gameObject, source.clip.length); } }
private void attack() { // Attack once per second if (Time.time - lastAttacked > attackSpeed) { //Attack logic DogScript player = GameObject.FindGameObjectWithTag("Player").GetComponent("DogScript") as DogScript; if (player.health > 0) { player.health -= damage; } lastAttacked = Time.time; } return; }
public void loseHealth() { health -= 1; // When enemy dies and updates player score if (health <= 0) { source.Play(); GetComponent <Renderer>().enabled = false; Object.Destroy(GetComponent <Rigidbody2D>()); Object.Destroy(GetComponent <BoxCollider2D>()); Object.Destroy(this.gameObject, source.clip.length); DogScript player = GameObject.FindGameObjectWithTag("Player").GetComponent("DogScript") as DogScript; player.addScore(1); } }
void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, 100,dogLayer); if (hit.collider != null) { if (hit.collider.gameObject.tag == "Dog") { currentDog = hit.collider.gameObject.GetComponent<DogScript>(); newPosition = Vector2.zero; } } else TryMoveDog(); } }
public void Start() { GameObject[] allItems = TimeManagerScript.instance.absolutelyAllItems; for (int i = 0; i < allItems.Length; i++) { if (allItems[i].GetComponent <DogScript>()) { dog = allItems[i].GetComponent <DogScript>(); break; } } GameObject[] roombas = GameObject.FindGameObjectsWithTag("Roomba"); allRoombas = new RoombaScript[roombas.Length]; for (int i = 0; i < allRoombas.Length; i++) { allRoombas[i] = roombas[i].GetComponent <RoombaScript>(); } }
public void RandomSummonDog() { if (currentQuest.QuestID >= 3) { GameObject[] allSpawnPoint = GameObject.FindGameObjectsWithTag("SpawnPointDog"); GameObject[] allDog = GameObject.FindGameObjectsWithTag("Dog"); int count = allDog.Length; for (int i = 0; i < allSpawnPoint.Length; i++) { int persentage = allSpawnPoint[i].GetComponent <SpawnScript>().spawnPersentage; string tempID = allSpawnPoint[i].GetComponent <SpawnScript>().ID; bool haveSameID = false; for (int j = 0; j < allDog.Length; j++) { DogScript dogs = allDog[j].GetComponent <DogScript>(); if (dogs.ID == tempID) { haveSameID = true; break; } } if (count > maxDog) { haveSameID = true; } if (!haveSameID) { bool temp = HavetoSummonDog(persentage); if (temp && count < maxDog) { GameObject dog = (GameObject)Instantiate(Resources.Load("Prefabs/dog"), allSpawnPoint[i].transform.position + new Vector3(0, 1, 0), Quaternion.Euler(0, 0, 0)); dog.GetComponent <DogScript>().spawnScreen = Application.loadedLevelName; dog.GetComponent <DogScript>().ID = allSpawnPoint[i].GetComponent <SpawnScript>().ID; //enemy.GetComponent<EnemyScript>().wallLeft = allSpawnPoint[i].GetComponent<SpawnScript>().wallLeft; //enemy.GetComponent<EnemyScript>().wallRight = allSpawnPoint[i].GetComponent<SpawnScript>().wallRight; count++; } } } } }
void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, 100, dogLayer); if (hit.collider != null) { if (hit.collider.gameObject.tag == "Dog") { currentDog = hit.collider.gameObject.GetComponent <DogScript>(); newPosition = Vector2.zero; } } else { TryMoveDog(); } } }
// Update is called once per frame void Update() { if (!gameOver) { TimerText.text = "0:" + (30 - (int)(Time.time - lastLevel)).ToString("D2"); if (Time.time - lastSpawn > spawnRate * (maxLevel - level + 1)) { int val = Random.Range(0, 3); if (val == 0) { spawnKitten(); } else if (val == 1) { spawnCat(); } else { spawnLion(); } lastSpawn = Time.time; } if (Time.time - lastLevel > 30 && level < maxLevel) { level += 1; LevelText.text = "Wave " + level.ToString(); lastLevel = Time.time; } if (Time.time - lastLevel > 30 && level == maxLevel) { makeGameOver(true); DogScript player = GameObject.FindGameObjectWithTag("Player").GetComponent("DogScript") as DogScript; player.makeGameOver(); } } }
// Use this for initialization void Start() { ghostController = GetComponent <CGG_GhostCon_Modified>(); dog = FindObjectOfType <DogScript>(); }
public void Use(DogScript dogScript) { dogScript.currentEmbarrassment += EmbarrassmentLevel * (1.0f + (float)dogScript.currentObserverCount); gameManager.SetMinimumEmbarrassment(dogScript.currentEmbarrassment); UsedTimer = ReUseTime; }