void OnTriggerEnter(Collider other) { if (other.tag == "Map_Collectable") { countMap++; gameScript.setCountMap(countMap); Destroy(other.gameObject); } if (other.tag == "Key") { KeyScript key = (KeyScript)other.GetComponent(typeof(KeyScript)); listKey.Add(key.getColor()); gameScript.setKey(listKey); Destroy(other.gameObject); } if (other.tag == "Laser" || other.tag == "Spikes") { Time.timeScale = 0; menuGameOver.SetActive(true); Debug.Log("Dead"); } if (other.tag == "Arrival") { Time.timeScale = 0; menuFinished.SetActive(true); GameObject.Find("HUDCanvas").SetActive(false); } }
private void PutDown(KeyScript toPut) { toPut.Put(); carryingKey = KeyCode.None; Destroy(carriedCopy); animator.SetBool("IsCarrying", false); }
// Use this for initialization void Start() { if (instance == null) { instance = this; } }
private void DequeKey() { toPickup = keys.Dequeue(); toPickup.gameObject.SetActive(true); toPickup.transform.position = depotKey.transform.position; UpdateQueueVisualisation(null, toPickup); }
public void PrepareShipForLevelLoad() { Dictionary <GameObject, IList <GameObject> > graph = shipGraph.Graph; foreach (GameObject key in graph.Keys) { foreach (GameObject value in graph[key]) { JointScript.Attach(key, value); } key.collider.isTrigger = false; Destroy(key.GetComponent <ShipEditorScript>()); key.AddComponent <DamageOnCollisionScript>(); key.AddComponent <Enforce2DBehaviourScript>(); DontDestroyOnLoad(key); if (key.tag == "Engine") { key.AddComponent <ThrusterScript>(); ThrusterScript thrusterScript = key.GetComponent <ThrusterScript>(); KeyScript keyScript = key.GetComponent <KeyScript>(); thrusterScript.setKeyCode(keyScript.key); Destroy(keyScript); Destroy(key.transform.Find("EngineKeyText").gameObject); } } }
public KeyObject(Keys keys, bool ignore, KeyScript script) { Key = keys; Ignore = ignore; if (script != null) { Scripts = script; } }
void PlaceKey(Vector2 pos, Color color) { GameObject newKey = Instantiate(keyPrefab, pos, Quaternion.identity) as GameObject; KeyScript keyScript = newKey.GetComponent <KeyScript>(); keyScript.player = player; keyScript.SetColor(color); // keyScript.AdjustSprite(tiles, pos); }
void Start() { myRigid = GetComponent <Rigidbody2D>(); mySpriteRenderer = GetComponent <SpriteRenderer>(); bSprite = mySpriteRenderer.sprite; mySpriteRenderer.sprite = nA; kS = transform.GetComponentInParent <KeyScript>(); missedKeyHOffset = (Random.value * 10f) - 5f; missedKeyROffset = (Random.value * 10f) - 5f; }
public void PlaceInDepot(KeyScript keyScript) { keyScript.ToDepot(); //keyScript.gameObject.SetActive(false); keys.Enqueue(keyScript); if (toPickup) { UpdateQueueVisualisation(keyScript); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Bullet" && !isJumping && !isInvinsible) { health--; isInvinsible = true; } else if (other.gameObject.tag == "Jam" && !isJumping) { Heal(0.3); } else if (other.gameObject.tag == "Door") { DoorScript doorScript = other.transform.parent.gameObject.GetComponent <DoorScript>(); bool hasKey = false; if (doorScript != null) { for (int i = 0; i < foundKeys.Count; i++) { KeyScript keyScript = foundKeys[i].GetComponent <KeyScript>(); if (doorScript.keyColorToOpen == keyScript.color) { hasKey = true; Destroy(keyScript.gameObject); } } if (hasKey) { doorScript.Open(); } else { isStuck = true; } } } if (health == 3) { playerSprite.GetComponent <SpriteRenderer>().sprite = Damage3; } if (health == 2) { playerSprite.GetComponent <SpriteRenderer>().sprite = Damage2; } if (health == 1) { playerSprite.GetComponent <SpriteRenderer>().sprite = Damage1; } if (health == 0) { SceneManager.LoadScene(4, LoadSceneMode.Single); } }
public KeyScript TakeFromDepot() { var temp = toPickup; toPickup = null; if (temp) { temp.FromDepot(); } return(temp); }
public void Start() { access_cutter = GameObject.FindGameObjectWithTag("Cutter").GetComponent <KeyScript>(); access_key = GameObject.FindGameObjectWithTag("FinalKey").GetComponent <KeyScript>(); hud = GameObject.FindGameObjectWithTag("HUD").GetComponent <HUDSystem> (); if (gameObject.name.Equals("MusicaFondo")) { GetComponent <AudioSource>().Play(); } }
void OnTriggerEnter2D(Collider2D otherCollider) { KeyScript star = otherCollider.gameObject.GetComponent <KeyScript> (); if (star != null) { Destroy(star.gameObject); key = true; } //控制声音 musicInstant_eatkey.audio.Play(); }
private void PickUp(KeyScript toTake) { var keyCopy = Instantiate(toTake, keyAttachPoint); carriedCopy = keyCopy.gameObject; Destroy(keyCopy); carriedCopy.transform.position = keyAttachPoint.transform.position; carriedCopy.transform.localScale = Vector3.one * 0.6f; carryingKey = toTake.Take(); animator.SetBool("IsCarrying", true); }
private void OnTriggerEnter(Collider other) { KeyScript key = other.GetComponent <KeyScript>(); //If the hit object does not have a key script, don't pick it up if (key == null) { return; } //Pick it up HeldKeys.Add(key); key.PickUp(); }
void ResetLevel1() { //Reset Player Position PlayerStats.respawnPlayerPos.Set(-75.0f, 0.8f, -94.0f); PlayerStats.respawnCalled = true; //Reset Randomize Key Position KeyScript.keyPosRandomizer(); KeyCheck.respawnCalled = true; //Reset Zombie Animation if (ZombieAttack.triggerOnce == false) { ZombieAttack.triggerOnce = true; GameObject.Find("Animated Zombie").SetActive(false); } }
internal override bool CheckItem(Inventory inv) { if (!base.CheckItem(inv)) { return(false); } else { KeyScript held_key = inv.heldObject.GetComponent <KeyScript>(); if (!held_key) { return(false); } if (held_key.color != color) { return(false); } return(true); } }
// Update is called once per frame void Update() { open = true; foreach (GameObject ele in keys) { KeyScript kScript = (KeyScript)ele.GetComponent("KeyScript"); if (kScript.Active) { open = false; } } if (open) { MeshRenderer doorMesh = (MeshRenderer)GetComponent("MeshRenderer"); BoxCollider col = (BoxCollider)GetComponent("BoxCollider"); col.enabled = false; doorMesh.enabled = false; } }
// Use this for initialization void Start() { if(!instance) //simple singleton { instance = this; } else { Destroy(this.gameObject); } keyList = new bool[numKeys]; for(int i = 0; i < numKeys; i++) { keyList[i] = false; } keyList[2] = true; //REMOVE: For testing only keyList[1] = true; keyList[0] = true; }
// Use this for initialization void Start() { HolderObject = this.gameObject; // Start function WaitAndPrint as a coroutine. keyScrip = GetComponent <KeyScript>(); var list = FindObjectsOfType <KeyPointScript>(); foreach (var kp in list) { if (!kp.occupied) { target = kp; kp.occupied = true; break; } } coroutine = BasicMovement(); //redFlick(); StartCoroutine(coroutine); }
public void UpdateQueueVisualisation(KeyScript newKey = null, KeyScript dequeueKey = null) { int index = 1; foreach (var key in keys) { key.gameObject.SetActive(true); key.transform.position = depotKey.transform.position + (Vector3.right * (0.45f * index)); index++; } if (newKey) { Debug.Log(newKey.transform.position); SpawnParticleEffect(newKey.transform.position); } if (dequeueKey) { Debug.Log(dequeueKey.transform.position); SpawnParticleEffect(dequeueKey.transform.position); } }
private void OnTriggerEnter2D(Collider2D collision) { KeyScript key = collision.GetComponent <KeyScript>(); if (key != null) { AddKey(key.GetKeyType()); SoundManager.PlaySound("Spawn"); Destroy(key.gameObject); } DoorHolder keyDoor = collision.GetComponent <DoorHolder>(); if (keyDoor != null) { if (ContainsKey(keyDoor.GetKeyType())) { RemoveKey(keyDoor.GetKeyType()); keyDoor.OpenDoor(); } } }
// Use this for initialization void Start() { keyScript = gameObject.AddComponent <KeyScript>(); tileManagerScript = gameObject.AddComponent <TileManagerScript>(); mapManagerScript = gameObject.AddComponent <MapManagerScript>(); controllScript = gameObject.AddComponent <ControllScript>(); controllScript.enabled = false; keyScript.LoadKey(); if (!mapManagerScript.IsDataFile("/mapki.dat")) { SaveMapsScript s = gameObject.AddComponent <SaveMapsScript>(); mapManagerScript.LoadMaps(s.PrepareData()); } else { mapManagerScript.LoadMaps("/mapki.dat"); } buttonAction action = SetUpGame; gameMenuScript.SetUpLevelButtons(action); gameMenuScript.UpdateLevelButtons(keyScript.GetKeyValue()); }
// Update is called once per frame void Update() { //Antiquated. Keeping just in case. // Collider2D[] hitColliders = Physics2D.OverlapCircleAll(transform.position, 20); // int i = 0; // while (i < hitColliders.Length) // { // if (hitColliders[i].CompareTag("Player")) // player = hitColliders[i].gameObject; // i++; // } if (lagTime == 0) { Vector3 myPos = new Vector3(transform.position.x, transform.position.y, 0); if (hp <= 0) { KeyScript k = Instantiate(key, myPos, Quaternion.identity); g.k = k; Destroy(this.gameObject); } if (waitTime > 0) { waitTime--; } else { Vector3 playerPos = new Vector3(player.transform.position.x, player.transform.position.y, 0); Vector3 direction = (playerPos - GetComponent <Rigidbody2D>().transform.position); // EnemyBulletScript projectile = Instantiate(obj, myPos, Quaternion.identity); // projectile.setTarget(player); waitTime = interval; float bulletDirection = Mathf.Atan(direction.y / direction.x); if (direction.y >= 0 && direction.x <= 0) { bulletDirection += 3.141f; } if (direction.y <= 0 && direction.x <= 0) { bulletDirection += 3.141f; } LinearBullet sneaky1 = Instantiate(bul, myPos, Quaternion.identity); sneaky1.angle = bulletDirection + Random.Range(0.0f, 0.6f) * mod; } Vector3 playerPoss = new Vector3(player.transform.position.x, player.transform.position.y, 0); Vector3 directions = (playerPoss - GetComponent <Rigidbody2D>().transform.position); GetComponent <Rigidbody2D>().velocity = directions * moveSpeed; LinearBullet bullet1 = Instantiate(bul, myPos, Quaternion.identity); bullet1.angle = angle; angle += (angleChange) * mod; LinearBullet bullet2 = Instantiate(bul, myPos, Quaternion.identity); bullet2.angle = angle; angle += (angleChange) * mod; LinearBullet bullet3 = Instantiate(bul, myPos, Quaternion.identity); bullet3.angle = angle; angle += (angleChange) * mod; LinearBullet bullet4 = Instantiate(bul, myPos, Quaternion.identity); bullet4.angle = angle; angle += (angleChange) * mod; LinearBullet bullet5 = Instantiate(bul, myPos, Quaternion.identity); bullet5.angle = angle; angle += (angleChange) * mod; LinearBullet bullet6 = Instantiate(bul, myPos, Quaternion.identity); bullet6.angle = angle; angle += (angleChange) * mod; modTime--; if (modTime <= 0) { mod = mod * -1.00003f; modTime = Random.Range(200, 1000); } //Mathf.PI / 4.0f) + 0.01f } else { lagTime--; } }
// Start is called before the first frame update void Start() { PkdUp = GameObject.Find("KeyCubeTrigger").GetComponent <KeyScript>(); }
// Update is called once per frame void Update() { //numberOfKeys.text = keys.ToString(); if (Input.GetKeyDown(KeyCode.Mouse0)) { Ray ray = new Ray(transform.position, transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, length)) { if (hit.collider.CompareTag("Door")) { DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>(); if (doorScript == null) { return; } if (Inventory.keys[doorScript.index] == true) { doorScript.ChangeDoorState(); FindObjectOfType <AudioManager>().Play("OpenDoor"); } else { FindObjectOfType <AudioManager>().Play("LockedDoor"); } //Debug.Log("Colidi"); //player.ChangeCameraStateTrue(); } else if (hit.collider.CompareTag("FinalDoor")) { DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>(); if (doorScript == null) { return; } if (Inventory.keys[doorScript.index] == true && soundEmitter >= 4 && imagePuzzle.valorFinal == 5) { doorScript.ChangeDoorState(); FindObjectOfType <AudioManager>().Play("OpenDoor"); } else { FindObjectOfType <AudioManager>().Play("LockedDoor"); if (!textIsOnScreen) { textIsOnScreen = true; finalDoorText.SetActive(true); StartCoroutine(WaitForSec()); } } Debug.Log("Colidi"); //player.ChangeCameraStateTrue(); } else if (hit.collider.CompareTag("Key")) { Inventory.keys[hit.collider.GetComponent <KeyScript>().index] = true; if (!textIsOnScreen) { textIsOnScreen = true; uiObject.SetActive(true); StartCoroutine("WaitForSec"); } //Debug.Log("ColidiCarai"); //Destroy(gameObject); FindObjectOfType <AudioManager>().Play("GetKey"); KeyScript keyScript = hit.collider.transform.GetComponent <KeyScript>(); keyScript.DestroyKey(); keys++; } //Interactable intercactable = hit.collider.GetComponent<Interactable>(); else if (hit.collider.CompareTag("AnimInteractable")) { PlayAnimation animation = hit.collider.transform.GetComponent <PlayAnimation>(); animation.AnimPlay(); Debug.Log("TaFuncionando"); //Não ta funcionando ;-; T-T } else if (hit.collider.CompareTag("Sink") && isCarryingWater == false) { if (waterIsWorking) { isCarryingWater = true; Debug.Log("PEGUEI A AGUA"); if (!textIsOnScreen) { textIsOnScreen = true; uiObject2.SetActive(true); StartCoroutine("WaitForSec"); } glassIcon.SetActive(true); trigger2.SetActive(true); } else { if (!textIsOnScreen) { textIsOnScreen = true; uiObject3.SetActive(true); StartCoroutine("WaitForSec"); } } } else if (hit.collider.CompareTag("Fire")) { if (isCarryingWater == true) { FireScript fireParticles = hit.collider.transform.GetComponent <FireScript>(); fireParticles.DestroyFire(); Debug.Log("APAGUEI O FOGO"); glassIcon.SetActive(false); xGlassIcon.SetActive(true); fireplaceKey.SetActive(true); isCarryingWater = false; } else { if (!textIsOnScreen) { textIsOnScreen = true; text3.SetActive(true); StartCoroutine("WaitForSec"); } } } else if (hit.collider.CompareTag("Regulator") && waterIsWorking == false) { waterIsWorking = true; Debug.Log("LIGUEI O REGISTRO"); if (!textIsOnScreen) { textIsOnScreen = true; text.SetActive(true); StartCoroutine("WaitForSec"); } kitchenTable.SetActive(true); normalTable.SetActive(false); kitchenWater.SetActive(true); //PoisonedWaterScript blackWater = hit.collider.transform.GetComponent<PoisonedWaterScript>(); //blackWater.DestroyWater(); //Debug.Log("RIP AGUA DA MORTE"); //waterTankKey.SetActive(true); //normalWater.SetActive(true); //fallingWater.SetActive(true); } else if (hit.collider.CompareTag("PoisonedWater")) { if (waterIsWorking) { PoisonedWaterScript blackWater = hit.collider.transform.GetComponent <PoisonedWaterScript>(); blackWater.DestroyWater(); Debug.Log("RIP AGUA DA MORTE"); waterTankKey.SetActive(true); normalWater.SetActive(true); fallingWater.SetActive(true); } else { if (!textIsOnScreen) { textIsOnScreen = true; text2.SetActive(true); StartCoroutine("WaitForSec"); } } } else if (hit.collider.CompareTag("MovableFloor")) { FloorScript floor = hit.collider.transform.GetComponent <FloorScript>(); floor.DestroyFloor(); //secretCompartmentKey.SetActive(true); } else if (hit.collider.CompareTag("Text")) { PrintMessage text = hit.collider.transform.GetComponent <PrintMessage>(); if (!textIsOnScreen) { textIsOnScreen = true; text.ShowText(); StartCoroutine(WaitForSec()); } //text.TextOnScreen(); } // if (hit.collider.gameObject.name == "Boiler") // { // boiler.SetActive(false); //} else if (hit.collider.CompareTag("RightDoor")) { DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>(); if (doorScript == null) { return; } else { doorScript.PuzzleDoor(); pm.canMove = false; StartCoroutine(WrongDoorEvent()); FindObjectOfType <AudioManager>().Play("OpenDoor"); FindObjectOfType <AudioManager>().Play("Right"); doorScript.ChangeGroup(); } //player.ChangeCameraStateTrue(); } else if (hit.collider.CompareTag("WrongDoor")) { DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>(); if (doorScript == null) { return; } else { Debug.Log(pm.transform.position); doorScript.PuzzleDoor(); pm.canMove = false; StartCoroutine(WrongDoorEvent()); FindObjectOfType <AudioManager>().Play("OpenDoor"); FindObjectOfType <AudioManager>().Play("Wrong"); //pm.SetPlayerSpeed(5); } //player.ChangeCameraStateTrue(); } else if (hit.collider.CompareTag("SoundPuzzle")) { Inventory.soundPuzzleObjects[hit.collider.GetComponent <SoundPuzzleScript>().index] = true; SoundPuzzleScript soundPuzzle = hit.collider.transform.GetComponent <SoundPuzzleScript>(); soundPuzzle.ActivateIcon(); soundPuzzle.AddIndex(); soundPuzzle.DestroyObject(); uiObject4.SetActive(true); FindObjectOfType <AudioManager>().Play("GetKey"); StartCoroutine("WaitForSec"); // soundEmitter++; } else if (hit.collider.CompareTag("NoiseEmitter")) { NoiseEmitterScript noiseEmitterScript = hit.collider.transform.GetComponent <NoiseEmitterScript>(); if (noiseEmitterScript == null) { return; } if (Inventory.soundPuzzleObjects[noiseEmitterScript.index] == true) { soundEmitter++; noiseEmitterScript.ActivateObject(); print(soundEmitter); FindObjectOfType <AudioManager>().Play("Right"); } } // =======================Xylophone======================== if (hit.collider.name == "XyloA") { FindObjectOfType <AudioManager>().Play("XyloA"); } if (hit.collider.name == "XyloB") { FindObjectOfType <AudioManager>().Play("XyloB"); } if (hit.collider.name == "XyloC") { FindObjectOfType <AudioManager>().Play("XyloC"); } if (hit.collider.name == "XyloD") { FindObjectOfType <AudioManager>().Play("XyloD"); } if (hit.collider.name == "XyloE") { FindObjectOfType <AudioManager>().Play("XyloE"); } if (hit.collider.name == "XyloF") { FindObjectOfType <AudioManager>().Play("XyloF"); } if (hit.collider.name == "XyloG") { FindObjectOfType <AudioManager>().Play("XyloG"); } } } if (soundEmitter == 4) { painting.SetActive(true); } }
// Start is called before the first frame update void Start() { getKeyHandler = GameObject.FindWithTag("Key").GetComponent <KeyScript>(); getKeyHandler.playerGetKey += RemoveObstacle; }
private static bool CheckSampleKey(KeyObject var1, KeyObject var2, bool checkIgnoreVal = false) => var1 != null && var2 != null && KeyScript.Equals(var1.Scripts, var2.Scripts) && (!checkIgnoreVal || var1.Ignore == var2.Ignore);
public void Awake() { Instance = this; }