public void ServerCardSwiped(BaseEntity.RPCMessage msg) { if (!this.IsPowered()) { return; } if (Vector3Ex.Distance2D(msg.player.transform.position, base.transform.position) > 1f) { return; } if (base.IsInvoking(new Action(this.GrantCard)) || base.IsInvoking(new Action(this.FailCard))) { return; } uint num = msg.read.UInt32(); Keycard keycard = BaseNetworkable.serverEntities.Find(num) as Keycard; Effect.server.Run(this.swipeEffect.resourcePath, this.audioPosition.position, Vector3.up, msg.player.net.connection, false); if (keycard != null) { Item item = keycard.GetItem(); if (item != null && keycard.accessLevel == this.accessLevel && item.conditionNormalized > 0f) { base.Invoke(new Action(this.GrantCard), 0.5f); item.LoseCondition(1f); return; } base.Invoke(new Action(this.FailCard), 0.5f); } }
public void ServerCardSwiped(BaseEntity.RPCMessage msg) { if (!this.IsPowered() || (double)Vector3Ex.Distance2D(((Component)msg.player).get_transform().get_position(), ((Component)this).get_transform().get_position()) > 1.0 || (this.IsInvoking(new Action(this.GrantCard)) || this.IsInvoking(new Action(this.FailCard)))) { return; } uint uid = msg.read.UInt32(); Keycard keycard = BaseNetworkable.serverEntities.Find(uid) as Keycard; Effect.server.Run(this.swipeEffect.resourcePath, this.audioPosition.get_position(), Vector3.get_up(), msg.player.net.get_connection(), false); if (!Object.op_Inequality((Object)keycard, (Object)null)) { return; } Item obj = keycard.GetItem(); if (obj != null && keycard.accessLevel == this.accessLevel && (double)obj.conditionNormalized > 0.0) { this.Invoke(new Action(this.GrantCard), 0.5f); obj.LoseCondition(1f); } else { this.Invoke(new Action(this.FailCard), 0.5f); } }
// Use this for initialization void Start() { myInventory = GetComponent <Inventory>(); a = new Disguise("Guard"); b = new Disguise("Nurse"); c = new Keycard("Red"); d = new Keycard("blue"); myInventory.AddTo(a); myInventory.AddTo(d); myInventory.AddTo(b); myInventory.AddTo(c); Item randItem = myInventory.getItem((int)UnityEngine.Random.RandomRange(0, 4)); if (randItem is Keycard) { (randItem as Keycard).snapKeyCard(); } if (randItem is Disguise) { (randItem as Disguise).crackle(); } }
private void OnCardEject(Keycard card) { insertedCard = null; foreach (var item in lights) { item.GetComponent <MeshRenderer>().material = off; } }
public void SetKeycard(Keycard keycard) { this.keycard = keycard; var spriteRenderer = GetComponent <SpriteRenderer>(); spriteRenderer.sprite = keycard.doorSprite; //spriteRenderer.color = keycard.keycardColor; }
private void OnCardInsert(Keycard card) { if (insertedCard != null) { throw new System.Exception("Fatal Error"); } insertedCard = card; UpdateLights(); }
public void AddKeycardToUI(Keycard keycards) { var newItem = Instantiate(collectibleUIItem, collectibleParent); newItem.GetComponent <Image>().sprite = keycards.keycardSprite; // TESTING newItem.GetComponent <Image>().color = keycards.keycardColor; }
private void OnTriggerStay(Collider other) { Keycard card = other.GetComponent <Keycard>(); if (card != null && objectInRange == null) { objectInRange = card; meshRenderer.material.color = Color.Lerp(origColor, targetColor, 0.5f); } }
// Use this for initialization void Start() { myInventory = GetComponent <Inventory>(); ic = GetComponent <ItemController>(); k1 = new Keycard("Keycard 1"); k1.setName("Keycard 1"); k2 = new Keycard("Keycard 2"); k2.setName("Keycard 2"); k3 = new Keycard("Keycard 3"); k3.setName("Keycard 3"); k4 = new Keycard("Keycard 4"); k4.setName("Keycard 4"); g = new Grenade("Stun Grenade"); }
private void OnTriggerExit(Collider other) { Keycard card = other.GetComponent <Keycard>(); if (card != null && objectInRange == card) { if (keycardIn != null) { if (keycardEjected != null) { keycardEjected.Invoke(keycardIn); } keycardIn = null; } objectInRange = null; meshRenderer.material.color = origColor; } }
private void Start() { if (randomizeDoor && exitDoor != null) { int rand = Mathf.RoundToInt(Random.Range(0f, (float)keycardCollection.keycards.Count - 1)); keycard = keycardCollection.keycards[rand]; if (exitDoor.GetComponentInParent <Door>() != null) { exitDoor.GetComponentInParent <Door>().SetKeycard(keycard); } } if (checkForKeycard && keycard != null) { SetKeycard(keycard); } }
private void OnControllerDropObject(GameObject obj) { Keycard card = obj.GetComponent <Keycard>(); if (card != null && card == objectInRange) { keycardIn = card; if (keycardInserted != null) { keycardInserted.Invoke(card); card.transform.position = targetTransform.position; card.transform.rotation = targetTransform.rotation; FixedJoint fx = gameObject.AddComponent <FixedJoint>(); fx.breakForce = 5000; fx.breakTorque = 5000; fx.connectedBody = card.GetComponent <Rigidbody>(); } } }
// Sort all of the ForegroundObject children of "parent" into the grid private void populateForegroundGrid(GameObject parent) { ForegroundObject[] fgObjects = parent.GetComponentsInChildren <ForegroundObject>(); for (int i = 0; i < fgObjects.Length; i++) { Vector2Int truePos = pos3dToVect2Int(fgObjects[i].transform.position); updateFgGridForAllPos(fgObjects[i], truePos, fgObjects[i].additionalCoords, true); if (fgObjects[i] is LockedDoor) { lockedDoors.Add((LockedDoor)fgObjects[i]); } else if (fgObjects[i] is Keycard) { Keycard keycard = (Keycard)fgObjects[i]; keycardTotals[keycard.color]++; } } }
public void PickedUp(Keycard keycard) { switch (keycard) { case Keycard.LOCKPICK: lockpick = "Lockpick\n"; StartCoroutine(PickupTextFlash("You pickup some lockpicks")); break; case Keycard.CROWBAR: crowbar = "Crowbar\n"; StartCoroutine(PickupTextFlash("You pickup a crowbar")); break; case Keycard.TNT: tnt = "TNT"; StartCoroutine(PickupTextFlash("You pickup a bundle of dynamite")); break; } KeycardsHeldText.text = lockpick + crowbar + tnt; }
public void PlaceObjectives() { // While there are still objective items to spawn: while (objectiveItemList.Count > 0) { // Select a random spawn point on a random floor: Floor randomFloor = SelectRandomFloor(); ItemSpawnPoint randomSpawnPoint = SelectRandomSpawnPoint(randomFloor); if (randomSpawnPoint != null) { // Spawn the item: ObjectiveItem currentItem = objectiveItemList[Random.Range(0, objectiveItemList.Count)]; Instantiate(currentItem, randomSpawnPoint.transform.position, randomSpawnPoint.transform.rotation, randomSpawnPoint.transform); randomFloor.itemSpawnPoints.Remove(randomSpawnPoint); objectiveItemList.Remove(currentItem); spawnedObjectives.Add(currentItem); } else if (randomSpawnPoint == null) { // Do nothing. The while loop will continue running until it finds an available spawn point. Debug.Log("Floor has no available spawn points. Trying another floor."); } } // Spawn a single keycard somewhere in the level for access to locked rooms: Floor randomFloor2 = SelectRandomFloor(); ItemSpawnPoint randomSpawnPoint2 = SelectRandomSpawnPoint(randomFloor2); Keycard keycard = keycardPrefab; Instantiate(keycardPrefab, randomSpawnPoint2.transform.position, randomSpawnPoint2.transform.rotation, randomSpawnPoint2.transform); randomFloor2.itemSpawnPoints.Remove(randomSpawnPoint2); spawnedKeycards.Add(keycard); }
public void ServerCardSwiped(RPCMessage msg) { if (!IsPowered() || Vector3Ex.Distance2D(msg.player.transform.position, base.transform.position) > 1f || IsInvoking(GrantCard) || IsInvoking(FailCard)) { return; } uint uid = msg.read.UInt32(); Keycard keycard = BaseNetworkable.serverEntities.Find(uid) as Keycard; Effect.server.Run(swipeEffect.resourcePath, audioPosition.position, Vector3.up, msg.player.net.connection); if (keycard != null && Interface.CallHook("OnCardSwipe", this, keycard, msg.player) == null) { Item item = keycard.GetItem(); if (item != null && keycard.accessLevel == accessLevel && item.conditionNormalized > 0f) { Invoke(GrantCard, 0.5f); item.LoseCondition(1f); } else { Invoke(FailCard, 0.5f); } } }
public void AddKeycard(Keycard card) { keycards.Add(card); indicators[card.keycardId].SetActive(true); Debug.Log("Keycard " + card.keycardId + " collected"); }
public void AddKeycard(Keycard keycard) { keycards.Add(keycard); UIManager.Instance.AddKeycardToUI(keycard); }