private void InstantiateMonsters() { GameObject obj = (GameObject)Instantiate(kingMonster); // Invoke ("InstantiateKingMonster", kingMonsterAppear); SoldierPosition[] soldier1Pos = new SoldierPosition[] { new SoldierPosition(new Vector3(-7.262046f, -3.47f, -3.735428f), new Vector2(-10.8f, 10.8f)), new SoldierPosition(new Vector3(-0.23f, 0.21f, -3.735428f), new Vector2(-10.8f, 10.8f)), new SoldierPosition(new Vector3(5.01f, 4.63f, -3.96f), new Vector2(-10.8f, 10.8f)) }; SoldierPosition[] soldier2Pos = new SoldierPosition[] { new SoldierPosition(new Vector3(-13.09f, -0.64f, -5.01f), new Vector2(-13f, 10f)), new SoldierPosition(new Vector3(-2.56f, 3.68f, -5.01f), new Vector2(-13f, 13f)), new SoldierPosition(new Vector3(-6.7f, 8.12f, -5.01f), new Vector2(-13f, 0f)) }; int level = sceneManager.GetLevel(); int difficulty = sceneManager.getDifficulty(); print(level); for (int i = 0; i < difficulty + 1; i++) { GameObject newMonster = new GameObject(); if (level == 1) { newMonster = (GameObject)Instantiate(soldierMonster, soldier1Pos [i].instPos, soldierMonster.transform.rotation); } else if (level == 2) { newMonster = (GameObject)Instantiate(soldierMonster, soldier2Pos [i].instPos, soldierMonster.transform.rotation); } } Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Player"), LayerMask.NameToLayer("KingMonster")); Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Player"), LayerMask.NameToLayer("SoldierMonster")); }
// Update is called once per frame void Update() { if (gameObject && player && sceneManager.isNightmare) { float y = player.transform.position.y - gameObject.transform.position.y; if (sceneManager.GetLevel() == 1) { if (Vector3.Distance(player.transform.position, gameObject.transform.position) < 4.0f && Mathf.Abs(y) < 3.5f) { gameObject.GetComponent <SpriteRenderer>().color = Color.white; } else { gameObject.GetComponent <SpriteRenderer>().color = new Color(0.3f, 0.3f, 0.3f, 1); } } else { if (Vector3.Distance(player.transform.position, gameObject.transform.position) < 3.7f && Mathf.Abs(y) < 2.5f) { gameObject.GetComponent <SpriteRenderer>().color = Color.white; } else { gameObject.GetComponent <SpriteRenderer>().color = new Color(0.3f, 0.3f, 0.3f, 1); } } } }
private void InstantiateMonsters() { Invoke("InstantiateKingMonster", kingMonsterAppear); SoldierPosition[] soldier1Pos = new SoldierPosition[] { new SoldierPosition(new Vector3(-7.262046f, -3.47f, -3.735428f), new Vector2(-10.8f, 10.8f)), new SoldierPosition(new Vector3(-0.23f, 0.21f, -3.735428f), new Vector2(-10.8f, 10.8f)), new SoldierPosition(new Vector3(5.01f, 4.63f, -3.96f), new Vector2(-10.8f, 10.8f)) }; SoldierPosition[] soldier2Pos = new SoldierPosition[] { new SoldierPosition(new Vector3(-13.09f, -0.64f, -4.01f), new Vector2(-13f, 10f)), new SoldierPosition(new Vector3(-2.56f, 3.68f, -4.01f), new Vector2(-13f, 12f)), new SoldierPosition(new Vector3(-6.7f, 8.12f, -4.01f), new Vector2(-13f, 0f)) }; int level = sceneManager.GetLevel(); int difficulty = sceneManager.getDifficulty(); for (int i = 0; i < difficulty + 1; i++) { GameObject newMonster = new GameObject(); if (level == 1) { newMonster = (GameObject)Instantiate(soldierMonster, soldier1Pos [i].instPos, soldierMonster.transform.rotation); newMonster.GetComponentInChildren <AIInformation> ().floor = i + 1; newMonster.GetComponentInChildren <SoldierProperties>().InitiateValues(soldier1Pos[i].bound.x, soldier1Pos[i].bound.y, soldier1Pos[i].instPos.y, soldier1Pos[i].instPos.z); //StartCoroutine(newMonster.GetComponent<SoldierProperties>().InitiateValues(soldier1Pos[i].bound.x, soldier1Pos[i].bound.y)); //newMonster.GetComponent<SoldierProperties> ().leftBound = soldier1Pos [i].bound.x; //newMonster.GetComponent<SoldierProperties> ().rightBound = soldier1Pos [i].bound.y; //newMonster.GetComponent<SoldierProperties> ().heading = newMonster.GetComponent<SoldierProperties> ().rightBound; } else if (level == 2) { newMonster = (GameObject)Instantiate(soldierMonster, soldier2Pos [i].instPos, soldierMonster.transform.rotation); newMonster.GetComponentInChildren <AIInformation>().floor = i + 1; //StartCoroutine(newMonster.GetComponent<SoldierProperties>().InitiateValues(soldier2Pos[i].bound.x, soldier2Pos[i].bound.y)); newMonster.GetComponentInChildren <SoldierProperties>().InitiateValues(soldier2Pos[i].bound.x, soldier2Pos[i].bound.y, soldier2Pos[i].instPos.y, soldier2Pos[i].instPos.z); //newMonster.GetComponent<SoldierProperties> ().leftBound = soldier2Pos [i].bound.x; //newMonster.GetComponent<SoldierProperties> ().rightBound = soldier2Pos [i].bound.y; //newMonster.GetComponent<SoldierProperties> ().heading = newMonster.GetComponent<SoldierProperties> ().rightBound; } } Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Player"), LayerMask.NameToLayer("KingMonster"), false); Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Player"), LayerMask.NameToLayer("SoldierMonster"), false); }
void Update() { for (int i = 0; i < slotsInTotal; i++) { if (Input.GetKeyDown(keyCodesForSlots [i])) { if (transform.GetChild(1).GetChild(i).childCount != 0 && transform.GetChild(1).GetChild(i).GetChild(0).GetComponent <ItemOnObject> ().item.itemType != ItemType.UFPS_Ammo) { if (selectedItem) { selectedItem.GetComponentInParent <Outline> ().enabled = false; } selectedItem = transform.GetChild(1).GetChild(i).GetChild(0); transform.GetChild(1).GetChild(i).gameObject.GetComponent <Outline> ().enabled = true; // if (transform.GetChild(1).GetChild(i).GetChild(0).GetComponent<ConsumeItem>().duplication != null && transform.GetChild(1).GetChild(i).GetChild(0).GetComponent<ItemOnObject>().item.maxStack == 1) // { // Destroy(transform.GetChild(1).GetChild(i).GetChild(0).GetComponent<ConsumeItem>().duplication); // } // transform.GetChild(1).GetChild(i).GetChild(0).GetComponent<ConsumeItem>().consumeIt(); } } } if (Input.GetKeyDown(KeyCode.R) && selectedItem) { float y = 0; string tag = selectedItem.GetComponent <ItemOnObject> ().item.itemModel.tag; switch (tag) { case "Ladder": y = 1.02f; break; case "Door": y = -1.2f; break; case "Refrigerator": y = 0.37f; break; case "BoundDoor": y = 0.8f; break; case "BananaPeel": y = -0.7f; break; case "Seed": y = 0.1f; break; default: break; } putItem(selectedItem, y, Vector3.zero); } if (UserControl.PutAllGears) { if (sceneManager.GetLevel() == 1) { if (transform.GetChild(1).GetChild(0).childCount != 0) { selectedItem = transform.GetChild(1).GetChild(0).GetChild(0); //Door putItem(selectedItem, 0, new Vector3(-9.5f, -0.4f, -3.1f)); putItem(selectedItem, 0, new Vector3(7.2f, -4.8f, -3.1f)); } if (transform.GetChild(1).GetChild(2).childCount != 0) { selectedItem = transform.GetChild(1).GetChild(2).GetChild(0); //Ladder putItem(selectedItem, 0, new Vector3(-5.9f, 1.8f, -3.1f)); putItem(selectedItem, 0, new Vector3(-9.4f, -2.6f, -3.1f)); } } else { if (transform.GetChild(1).GetChild(0).childCount != 0) { selectedItem = transform.GetChild(1).GetChild(0).GetChild(0); //Door putItem(selectedItem, 0, new Vector3(11.2f, 3.1f, -3.5f)); putItem(selectedItem, 0, new Vector3(-13.0f, 2.9f, -3.5f)); } if (transform.GetChild(1).GetChild(2).childCount != 0) { selectedItem = transform.GetChild(1).GetChild(2).GetChild(0); //Ladder putItem(selectedItem, 0, new Vector3(6.3f, 1.1f, -3.5f)); putItem(selectedItem, 0, new Vector3(-12.8f, 1.1f, -3.5f)); } } } }