void OnTriggerStay(Collider hit) { if (hit.gameObject.tag == "water" || hit.gameObject.tag == "DeepWater") { if (gameObject.tag != "bear" && gameObject.tag != "bird") { swim = true; // if(gameObject.tag=="turtle") // { // anim.SetBool(swimhash, true); // } } else if (tag == "bear" && !activecharacter) { health = 0; } if (!playingSplash && activecharacter && !Gamepaused) { GameObject.Find("AudioCube").SendMessage("Bubble"); playingSplash = true; } } if (hit.gameObject.tag == "Spike") { if (spikecount < maxcount) { spikecount += 1 * (int)Time.timeScale; } else { spikecount = 0; health -= (1 * (int)Time.timeScale); } } if (gameObject.tag != "parasite" && hit.gameObject.tag == "switch") //hit.gameObject.tag == "switch1" && { int matchnumber; Switch switchscript = (Switch)hit.gameObject.GetComponent(typeof(Switch)); matchnumber = switchscript.switchnumber; GameObject[] doors; doors = GameObject.FindGameObjectsWithTag("door"); foreach (GameObject door in doors) { DoorMove doorscript = (DoorMove)door.GetComponent(typeof(DoorMove)); if (matchnumber == doorscript.numberofdoor) { doorscript.open = true; } } } }
void OnTriggerExit(Collider hit) { if (hit.gameObject.tag == "water" || hit.gameObject.tag == "DeepWater") { if (gameObject.tag != "bear" && gameObject.tag != "bird") { swim = false; // if(gameObject.tag=="turtle") // { // anim.SetBool(swimhash, false); // } } } if (hit.gameObject.tag == "Spike") { spikecount = 0; } if (gameObject.tag != "parasite" && hit.gameObject.tag == "switch") //hit.gameObject.tag == "switch1" && { int matchnumber; Switch switchscript = (Switch)hit.gameObject.GetComponent(typeof(Switch)); matchnumber = switchscript.switchnumber; GameObject[] doors; doors = GameObject.FindGameObjectsWithTag("door"); foreach (GameObject door in doors) { DoorMove doorscript = (DoorMove)door.GetComponent(typeof(DoorMove)); if (matchnumber == doorscript.numberofdoor) { if (doorscript.holddoor) { doorscript.open = false; } } } } }
// Use this for initialization void Start() { pos = transform.position; doorMove = new DoorMove(); //animator = this.GetComponent<Animator> (); }
void OnTriggerEnter(Collider hit) { if (gameObject.tag != "parasite" && hit.gameObject.tag == "switch" && !editormode)//hit.gameObject.tag == "switch1" && { int matchnumber; Switch switchscript = (Switch)hit.gameObject.GetComponent(typeof(Switch)); matchnumber = switchscript.switchnumber; GameObject[] doors; doors = GameObject.FindGameObjectsWithTag("door"); foreach (GameObject door in doors) { DoorMove doorscript = (DoorMove)door.GetComponent(typeof(DoorMove)); if (matchnumber == doorscript.numberofdoor) { doorscript.open = true; } } } if (hit.gameObject.tag == "water" || hit.gameObject.tag == "DeepWater" || hit.gameObject.tag == "turtlewater" && !editormode) { if (gameObject.tag == "bird") { health = 0; } else if (gameObject.tag != "bear") { swim = true; // if(gameObject.tag=="turtle") // { // anim.SetBool(swimhash, true); // } } else if (tag == "bear" && !activecharacter) { health = 0; } } if (hit.gameObject.tag == "Spike") { health -= (1 * (int)Time.timeScale); } if (hit.gameObject.tag == "Bacon" && !editormode) { if (tag == "parasite") { health -= 10; Destroy(hit.gameObject); } else { health += 10; if (health > maxhealth) { health = maxhealth; } Destroy(hit.gameObject); } GameObject.Find("AudioCube").SendMessage("Chime"); } // if(hit.gameObject.tag=="ExtraBacon") // { // if(tag=="parasite") // { // health-=10; // Destroy(hit.gameObject); // } // else // { // health+=10; // if(health>maxhealth) // health=maxhealth; // Destroy(hit.gameObject); // } // } if (hit.gameObject.tag == "end" && activecharacter && !editormode) { //Debug.Log(editormode.ToString()); EndLevel endscript = (EndLevel)hit.gameObject.GetComponent(typeof(EndLevel)); // if(!endscript.BonusLevel) achievement area needs work<<<<<<<<<<<<<<<<<<<<<<<<<================================================= // { // if(Time.timeSinceLevelLoad<endscript.TimetoBeat && !endscript.gettime(Application.loadedLevel-levelminus)) // { // endscript.settime(Application.loadedLevel-levelminus, true); // } // if(!endscript.getcomplete(Application.loadedLevel-levelminus)) // { // endscript.setcomplete(Application.loadedLevel-levelminus, true); // } // if(!endscript.getalive(Application.loadedLevel-levelminus)) // { // bool allalive=true; // int num=0; // while (allalive&&num<=2) // { // GameObject animal=null; // animal = GameObject.FindGameObjectWithTag(animallist[num]); // //Debug.Log(animal.ToString()); // if(animal==null) // allalive=false; // num++; // } // //Debug.Log(allalive.ToString()); // if(allalive) // { // endscript.setalive(Application.loadedLevel-levelminus, true); // //Debug.Log(endscript.getalive(Application.loadedLevel-levelminus).ToString()); // } // } // if(!endscript.getdead(Application.loadedLevel-levelminus)) // { // bool allalivez=false; // int num=0; // while (!allalivez&&num<=2) // { // GameObject animalz=null; // animalz = GameObject.FindGameObjectWithTag(animallist[num]); // //Debug.Log(animalz.ToString()); // if(animalz!=null) // allalivez=true; // num++; // } // if(!allalivez) // { // endscript.setdead(Application.loadedLevel-levelminus, true); // } // } // if(!endscript.getbacon(Application.loadedLevel-levelminus)) // { // GameObject bacon=null; // bacon = GameObject.FindGameObjectWithTag("Bacon"); // if(bacon==null) // endscript.setbacon(Application.loadedLevel-levelminus, true); // } // } // else // { // if(Time.timeSinceLevelLoad<endscript.TimetoBeat && !endscript.getBonustime(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels)) // { // endscript.setBonustime(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels, true); // } // if(!endscript.getBonuscomplete(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels)) // { // endscript.setBonuscomplete(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels, true); // } // if(!endscript.getBonusalive(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels)) // { // bool allalive=true; // int num=0; // while (allalive&&num<=2) // { // GameObject animal=null; // animal = GameObject.FindGameObjectWithTag(animallist[num]); // //Debug.Log(animal.ToString()); // if(animal==null) // allalive=false; // num++; // } // //Debug.Log(allalive.ToString()); // if(allalive) // { // endscript.setBonusalive(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels, true); // //Debug.Log(endscript.getalive(Application.loadedLevel-levelminus).ToString()); // } // } // if(!endscript.getBonusdead(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels)) // { // bool allalivez=false; // int num=0; // while (!allalivez&&num<=2) // { // GameObject animalz=null; // animalz = GameObject.FindGameObjectWithTag(animallist[num]); // //Debug.Log(animalz.ToString()); // if(animalz!=null) // allalivez=true; // num++; // } // if(!allalivez) // { // endscript.setBonusdead(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels, true); // } // } // if(!endscript.getBonusbacon(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels)) // { // GameObject bacon=null; // bacon = GameObject.FindGameObjectWithTag("Bacon"); // if(bacon==null) // endscript.setBonusbacon(Application.loadedLevel-levelminus-endscript.numofnonbonuslevels, true); // } // } if (endscript.UserCreatedLevel) { Application.LoadLevel(0); } else if (endscript.LastLevel) { Application.LoadLevel(endscript.NextIndex); } else { int level = Application.loadedLevel; level++; Application.LoadLevel(level); } } }
void Update() { if (wxml.progress >= 1 && !downloadedlevel) { Debug.Log(gamelist[0].typevar.ToString()); downloadedlevel = true; StopCoroutine("LoadLevel"); foreach (GameType obj in gamelist) { Vector3 spawnposition = Vector3.zero; typeofobj = obj.typevar; if (typeofobj == "Wall") { target = GameObject.CreatePrimitive(PrimitiveType.Cube); } else if (typeofobj == "Turtle" || typeofobj == "Bird") { Quaternion spawn = Quaternion.Euler(0, 90, 0); target = (GameObject)Instantiate(Resources.Load(typeofobj), spawnposition, spawn); } else { target = (GameObject)Instantiate(Resources.Load(obj.typevar), spawnposition, Quaternion.identity); } target.transform.position = obj.positionvar; target.transform.localScale = obj.scalevar; target.name = obj.namevar; if (typeofobj == "Switch") { int switchnum = (int)obj.number1var; Switch switchscript = (Switch)target.GetComponent(typeof(Switch)); switchscript.switchnumber = switchnum; } else if (typeofobj == "Door") { int doornum = (int)obj.number1var; int howfardoor = (int)obj.number2var; DoorMove doorscript = (DoorMove)target.GetComponent(typeof(DoorMove)); doorscript.Vertical = obj.boolean1var; doorscript.positive = obj.boolean2var; doorscript.destroydoor = obj.boolean3var; doorscript.holddoor = obj.boolean4var; doorscript.numberofdoor = doornum; doorscript.howfar = howfardoor; } else if (typeofobj == "Gun") { float timebetween = obj.number1var; float timedelaystart = obj.number2var; float bulletspeed = obj.number3var; Gunscript cannon = (Gunscript)target.GetComponent(typeof(Gunscript)); cannon.timetowait = timebetween; cannon.startDelay = timedelaystart; cannon.bulletspeed = bulletspeed; cannon.shootvertical = obj.boolean1var; cannon.shootpositive = obj.boolean2var; cannon.posion = obj.boolean3var; cannon.water = obj.boolean4var; } else if (typeofobj == "EndFlag") { int timetobeat = (int)obj.number1var; EndLevel end = (EndLevel)target.GetComponent(typeof(EndLevel)); end.BonusLevel = obj.boolean1var; end.UserCreatedLevel = obj.boolean2var; end.LastLevel = obj.boolean3var; end.TimetoBeat = timetobeat; } else if (typeofobj == "Water") { Debug.Log("Y Scale: " + target.transform.localScale.y.ToString()); if (target.transform.localScale.y > 1) { Debug.Log("it should spawn stuff here"); Water wet = (Water)target.GetComponent(typeof(Water)); wet.mainwater = target.gameObject; GameObject turtlewater = (GameObject)Instantiate(Resources.Load("TurtleWater"), spawnposition, Quaternion.identity); Vector3 scale = new Vector3(target.transform.position.x, target.transform.position.y + ((target.transform.localScale.y / 2) - 0.5f), target.transform.position.z); turtlewater.transform.position = scale; scale = new Vector3(target.transform.localScale.x, 1, target.transform.localScale.z * 0.95f); turtlewater.transform.localScale = scale; wet.turtlewater = turtlewater; GameObject deepwater = (GameObject)Instantiate(Resources.Load("DeepWater"), spawnposition, Quaternion.identity); scale = new Vector3(target.transform.position.x, target.transform.position.y - 0.5f, target.transform.position.z); deepwater.transform.position = scale; scale = new Vector3(target.transform.localScale.x, target.transform.localScale.y - 1, target.transform.localScale.z * 0.95f); deepwater.transform.localScale = scale; wet.deepwater = deepwater; } } } Debug.Log("Load Completed"); editormode = false; } }
public void Start() { doorMove = FindObjectOfType <DoorMove>(); EventManager.Instance.Register <DoorMoveEvent>(MoveDoorHandler); EventManager.Instance.Register <DoorResetEvent>(ResetDoorHandler); }
public void Start() { doorVisible = FindObjectOfType <IsDoorVisible>(); control_Move = FindObjectOfType <FPS_Control_Move>(); doorMove = FindObjectOfType <DoorMove>(); }