public FlashbackManager(BaseLevel pLevel, int pTotalFlashbacks) : base(false) { Instance = this; _level = pLevel; _collectedFlashBacksTriggersNames = new HashSet <string>(); _collectedFlashPickupsNames = new List <string>(); _totalFlashbacks = pTotalFlashbacks; CoroutineManager.StartCoroutine(Start(), this); }
public HiddenRoomCoverManager(BaseLevel pLevel) : base(false) { Instance = this; _level = pLevel; //Load hidden room from tmx var map = _level.LevelMap.MapData; var hiddenRoomData = map.ObjectGroups?.Where(og => og.Name == "Hidden Room Cover").FirstOrDefault()?.Objects .FirstOrDefault(ob => ob.Name == "Hidden Room Cover"); var hiddenRoomColliderData = map.ObjectGroups?.Where(og => og.Name == "Hidden Room Cover").FirstOrDefault() ?.Objects .FirstOrDefault(ob => ob.Name == "Hidden Room Collider"); if (hiddenRoomData == null || hiddenRoomColliderData == null) { Console.WriteLine( $"ERROR: Hidden Room Cover or Collider Tmx objects not found in Hidden Room Cover object layer"); } else { _hiddenRoomCover = new Sprite("data/Hidden Room Cover.png", false, false); _hiddenRoomCover.width = Mathf.Round(hiddenRoomData.Width); _hiddenRoomCover.height = Mathf.Round(hiddenRoomData.Height); _hiddenRoomCover.SetOrigin(0, _hiddenRoomCover.texture.height); _level.AddChild(_hiddenRoomCover); _hiddenRoomCover.rotation = hiddenRoomData.rotation; _hiddenRoomCover.SetXY(hiddenRoomData.X, hiddenRoomData.Y); _hiddenRoomCoverCollider = new Sprite("data/White Texture.png"); _hiddenRoomCoverCollider.width = Mathf.Round(hiddenRoomColliderData.Width); _hiddenRoomCoverCollider.height = Mathf.Round(hiddenRoomColliderData.Height); _hiddenRoomCoverCollider.SetOrigin(0, _hiddenRoomCoverCollider.texture.height); _level.AddChild(_hiddenRoomCoverCollider); _hiddenRoomCoverCollider.rotation = hiddenRoomColliderData.rotation; _hiddenRoomCoverCollider.SetXY(hiddenRoomColliderData.X, hiddenRoomColliderData.Y); _hiddenRoomCoverCollider.visible = false; Console.WriteLine( $"{_hiddenRoomCoverCollider}: {_hiddenRoomCoverCollider.scaleX} | {_hiddenRoomCoverCollider.scaleY}"); CoroutineManager.StartCoroutine(Start(), this); } }
private BaseLevel _level; //the level public DarkHallManager(MapGameObject pMap, BaseLevel pLevel) : base(false) { _darkTriggersMap = new Dictionary <string, DarkHall>(); _map = pMap; _level = pLevel; //Load doors objects from Map var darkTriggersData = _map.ObjectGroups.SelectMany(og => og.Objects) .Where(tileObj => tileObj?.Type.ToLower() == "dark"); //Creates DoorTrigger Game Objects in scene, IGNORE if doesn't exist a door with the same name "NameofTheDoor Trigger" foreach (var memData in darkTriggersData) { AddDarkHall(memData.Name, memData.X, memData.Y, memData.rotation, memData.Width, memData.Height); } }
public FlashBackTriggersManager(MapGameObject pMap, BaseLevel pLevel) : base(false) { Instance = this; _flashTriggersMap = new Dictionary <string, FlashBackTrigger>(); _level = pLevel; _map = pMap; var flashesData = _map.ObjectGroups.SelectMany(og => og.Objects) .Where(tileObj => tileObj?.Type.ToLower() == "flashback"); foreach (var flash in flashesData) { var flashTrigger = AddFlashbackTriggerToLevel(flash); _flashTriggersMap.Add(flashTrigger.name.ToLower(), flashTrigger); } }
public HistoryPickupsManager(MapGameObject pMap, BaseLevel pLevel) : base(false) { _pickupsMap = new Dictionary <string, HistoryPickUp>(); _level = pLevel; _map = pMap; var historicData = _map.ObjectGroups.SelectMany(og => og.Objects) .Where(tileObj => tileObj?.Type.ToLower() == "history"); foreach (var memData in historicData) { string historyImageFileName = memData.GetStringProperty("history_image", "data/No Image.png"); AddHistoryPickupToLevel(memData.Name, historyImageFileName, memData.X, memData.Y, memData.rotation, memData.Width, memData.Height); } CoroutineManager.StartCoroutine(Start(), this); }
public FlashbackPickupsManager(MapGameObject pMap, BaseLevel pLevel) : base(false) { Instance = this; _flashPickupsMap = new Dictionary <string, FlashbackPickup>(); _level = pLevel; _map = pMap; var flashesData = _map.ObjectGroups.SelectMany(og => og.Objects) .Where(tileObj => tileObj?.Type.ToLower() == "flashbackpickup"); //Get from settings to skip some flashbacks _flashesPickupsToSkip = new List <string>(); if (Settings.Flashback_Pickups_Collected != "0") { var flashesStr = Settings.Flashback_Pickups_Collected.Trim().Split(' '); for (int i = 0; i < flashesStr.Length; i++) { string valStr = flashesStr[i].Trim(); if (int.TryParse(valStr, out var val)) { _flashesPickupsToSkip.Add($"Flashback {val}".ToLower()); } } } foreach (var flashData in flashesData) { var flashPickup = AddFlashbackPickupToLevel(flashData); _flashPickupsMap.Add(flashData.Name.ToLower(), flashPickup); } //Final trigger flashback var finalFlashData = _map.ObjectGroups .SelectMany(og => og.Objects) .FirstOrDefault(tileObj => tileObj?.Type.ToLower() == "finalflashbackpickup"); if (finalFlashData != null) { _finalPickup = AddFlashbackPickupToLevel(finalFlashData); } }
private BaseLevel _level; //the level public DoorsManager(MapGameObject pMap, BaseLevel pLevel) : base(false) { _doorsMap = new Dictionary <string, Door>(); _doorsTriggersMap = new Dictionary <string, DoorTrigger>(); _map = pMap; _level = pLevel; //Load doors objects from Map var doorsData = _map.ObjectGroups.SelectMany(og => og.Objects).Where(tileObj => !string.IsNullOrWhiteSpace(tileObj.Name) && !string.IsNullOrWhiteSpace(tileObj.Type) && (tileObj.Type?.ToLower() == "door" || tileObj.Type?.ToLower() == "dooronesided")); var doorsTriggersData = _map.ObjectGroups.SelectMany(og => og.Objects).Where(tileObj => !string.IsNullOrWhiteSpace(tileObj.Name) && !string.IsNullOrWhiteSpace(tileObj.Type) && tileObj.Type?.ToLower() == "doortrigger").ToDictionary(k => k.Name.Trim().ToLower().Replace(" trigger", ""), v => v); //Creates Door Game Objects in scene //Converts names to lowercase to prevent incorrect camelcase input in Tiled object names foreach (var doorData in doorsData) { doorData.Name = doorData.Name.ToLower(); bool isOpenForever = doorData.GetBoolProperty("open forever", true); bool isOneSidedDoor = doorData.Type.Trim().ToLower() == "dooronesided"; AddDoor(doorData.Name, isOpenForever, isOneSidedDoor, doorData.X, doorData.Y, doorData.rotation, doorData.Width, doorData.Height); } //Creates DoorTrigger Game Objects in scene, IGNORE if doesn't exist a door with the same name "NameofTheDoor Trigger" foreach (var kv in doorsTriggersData) { var doorTData = kv.Value; doorTData.Name = doorTData.Name.ToLower(); bool isDarkTrigger = doorTData.GetBoolProperty("dark_trigger", false); if (_doorsMap.TryGetValue(kv.Key, out var door)) { AddDoorTrigger(kv.Key, isDarkTrigger, door, doorTData.X, doorTData.Y, doorTData.rotation, doorTData.Width, doorTData.Height); } } CoroutineManager.StartCoroutine(Start(), this); }