//===================================================== private void ShowInteractionPopup(eDoorType doorType, int numKeysRequired, eFairy fairyRequired) { if (_guiDoorInteraction != null) { _guiDoorInteraction.ShowBubble(doorType, numKeysRequired, fairyRequired); } }
public DoorComponent CreateDoor(eDoorType type, Vector3 size) { GameObject obj = new GameObject(); obj.name = "door"; obj.layer = LayerMask.NameToLayer("door"); BoxCollider collider = obj.AddComponent <BoxCollider> (); collider.size = size; DoorComponent door = obj.AddComponent <DoorComponent> (); door.mDoorType = type; return(door); }
//===================================================== private static string GetModelPath(eDoorType type, int index) { var path = new StringBuilder(); path.Append("Prefabs/Doors/"); switch (type) { case eDoorType.BASIC: SetModelPathLocation(ref path, _doorsBasic, "Basic", index); break; case eDoorType.BASIC_DOUBLE: SetModelPathLocation(ref path, _doorsBasicDouble, "BasicDouble", index); break; case eDoorType.CRAWL: SetModelPathLocation(ref path, _doorsCrawl, "Crawl", index); break; case eDoorType.OBLIVION_PORTAL: SetModelPathLocation(ref path, _doorsOblivionPortal, "OblivionPortal", index); break; case eDoorType.PUZZLE_LOCKED: SetModelPathLocation(ref path, _doorsPuzzleLocked, "PuzzleLocked", index); break; case eDoorType.PUZZLE_ENTRANCE: SetModelPathLocation(ref path, _doorsPuzzleEntrance, "PuzzleEntrance", index); break; case eDoorType.PLAYER_HUB: SetModelPathLocation(ref path, _doorsPlayerHub, "PlayerHub", index); break; case eDoorType.BOSS: SetModelPathLocation(ref path, _doorsBoss, "Boss", index); break; } return(string.IsNullOrEmpty(path.ToString()) == false ? path.ToString() : string.Empty); }
//===================================================== public static Object GetModel(eDoorType type, int index) { Init(); var path = GetModelPath(type, index); if (string.IsNullOrEmpty(path) == false) { var model = Resources.Load(path); if (model != null) { return(model); } } Debug.Log("Door not found in resources: " + type + " [" + index + "]"); return(null); }
//===================================================== private static void AddDoorOfType(eDoorType type) { var pfb = ResourcesDoors.GetPrefab(); var mdl = ResourcesDoors.GetModel(type, 0); if (pfb == null) { return; } var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject; if (prefab == null) { return; } var script = prefab.GetComponent <Door>(); switch (type) { case eDoorType.BASIC: prefab.name = "BasicDoor"; break; case eDoorType.BASIC_DOUBLE: prefab.name = "DoubleDoor"; break; case eDoorType.CRAWL: prefab.name = "CrawlDoor"; break; case eDoorType.OBLIVION_PORTAL: prefab.name = "OblivionPortal"; break; case eDoorType.PUZZLE_LOCKED: prefab.name = "LockedPuzzleDoor"; break; case eDoorType.PUZZLE_ENTRANCE: prefab.name = "PuzzleRoomDoor"; break; case eDoorType.PLAYER_HUB: prefab.name = "MainHallDoor"; break; case eDoorType.BOSS: prefab.name = "BossRoomDoor"; break; } if (script != null) { script.Type = type; if (mdl != null) { //var model = PrefabUtility.InstantiatePrefab( mdl ) as GameObject; //script.Init( model ); script.Init(); } } PositionObjectAndSelect(prefab); }
//===================================================== public void ShowBubble(eDoorType doorType, int numKeysRequired, eFairy fairyRequired) { if (_isEnabled == true) { return; } var showBubble = false; if (_icon != null && _text != null) { if (numKeysRequired > 0) { // Num keys _icon.sprite = _spriteIcons[_spriteIcons.Length - 3]; _text.text = TextManager.GetText("DOOR_INTERACT_KEY") + " " + numKeysRequired + " :"; showBubble = true; } else if (fairyRequired != eFairy.NULL) { // Fairy _icon.sprite = _spriteIcons[(int)fairyRequired]; _text.text = TextManager.GetText("DOOR_INTERACT_FAIRY") + " :"; showBubble = true; } else { switch (doorType) { case eDoorType.BOSS: _icon.sprite = _spriteIcons[_spriteIcons.Length - 1]; _text.text = TextManager.GetText("DOOR_INTERACT_BOSS") + " " + (int)eFairy.NUM_FAIRIES + " :"; showBubble = true; break; default: // Lever / switch / pushable block _icon.sprite = _spriteIcons[_spriteIcons.Length - 2]; _text.text = TextManager.GetText("DOOR_INTERACT_SWITCH") + " :"; showBubble = true; break; } } } if (showBubble == false) { return; } _isEnabled = true; if (_animator != null && _animator.GetBool(HashIDs.IsEnabled) == false) { _animator.SetBool(HashIDs.IsEnabled, true); } StartCoroutine(AutoHideBubble()); // Face bubble towards player-camera if (_billboardController != null) { _billboardController.enabled = true; } }