FlashbackPickup AddFlashbackPickupToLevel(TiledObject flashData) { string objUniqueName = flashData.Name.Trim(); flashData.Name = flashData.Name.Replace("Pickup ", "").Trim().ToLower(); int counter = 0; while (_flashPickupsMap.ContainsKey(objUniqueName.ToLower())) { objUniqueName = flashData.Name.Trim().ToLower() + "_" + counter; counter++; } int flashNum = int.TryParse(flashData.Name.Replace("flashback ", ""), out flashNum) ? flashNum : 6; var flashPickup = new FlashbackPickup($"data/flashback_pick_up_{flashNum}.png", flashData, 1, 1) { name = objUniqueName }; _level.AddChild(flashPickup); flashPickup.Enabled = false; flashPickup.width = Mathf.Round(flashData.Width); flashPickup.height = Mathf.Round(flashData.Height); flashPickup.SetOrigin(0, flashPickup.texture.height); //Tmx use origin left,bottom :/ flashPickup.rotation = flashData.rotation; flashPickup.SetXY(flashData.X, flashData.Y); return(flashPickup); }
//object is made from it's hitbox (since it is 2.5D) public Enemy(TiledObject tiledObject) : base("hitbox.png") { Console.WriteLine("-------Enemy created--------"); Console.WriteLine("X: " + tiledObject.X + " Y: " + tiledObject.Y); //process TiledObject properties x = tiledObject.X; y = tiledObject.Y; if (tiledObject.Properties == null) { Console.WriteLine("Error: properties missing!"); } else { for (int i = 0; i < tiledObject.Properties.Property.Length; i++) { if (tiledObject.Properties.Property[i].Name == "image") { addGfx(tiledObject.GID, tiledObject.Properties.Property[i].Value); } } } if (tiledObject.Properties != null) { for (int i = 0; i < tiledObject.Properties.Property.Length; i++) { properties[tiledObject.Properties.Property[i].Name] = Convert.ToString(tiledObject.Properties.Property[i].Value); } Console.WriteLine("Dictionary count: " + properties.Count + " " + tiledObject.Properties.Property.Length); } Console.WriteLine("\n"); }
IEnumerator FlashbackHudRoutine(string flashbackDataName) { bool speedUp = true; TiledObject flashData = null; bool allowSkipByKey = true; if (FlashBackTriggersManager.Instance.FlashTriggersMap.TryGetValue(flashbackDataName.ToLower(), out var flashTrigger)) { flashData = flashTrigger.FlashbackTriggerData; } //For the final flahback scene, its not a trigger so needs a different load else if (flashbackDataName == "final flashback") { flashData = FlashbackPickupsManager.Instance.FinalPickup.FlashbackData; allowSkipByKey = false; speedUp = false; } if (flashData != null) { var flashHud = GameHud.Instance.LoadFlashbackHud(flashData, speedUp, allowSkipByKey); while (flashHud != null && flashHud.toDestroy == false) { yield return(null); } } }
private void SpawnAirplane(TiledObject airData) { float airSpeed = airData.GetFloatProperty("speed", 200); int lifeTime = (int)(airData.GetFloatProperty("life_time", 12) * 1000); int spawnFrequency = (int)(airData.GetFloatProperty("spawn_frequency_time", 0) * 1000); var airplane = GetAirplaneFromPool(); airplane.LoadStartupData(airData.X, airData.Y, airData.Width, airData.Height, _level, _level.Stork, airSpeed, airData.rotation, lifeTime); airplane.SetActive(true); if (lifeTime > 0) { CoroutineManager.StartCoroutine(DespawnAirplaneAfterLifeTime(airplane, lifeTime), this); } if (spawnFrequency > 0) { CoroutineManager.StartCoroutine(SpawnAirplaneAfterDelay(airData, spawnFrequency), this); } _airplanesMap.Add(airplane, airData); }
public FlashbackPickup(string filename, TiledObject pFlashbackData, int cols, int rows, int frames = -1, bool keepInCache = false, bool addCollider = true) : base(filename, cols, rows, frames, keepInCache, addCollider) { _flashbackData = pFlashbackData; _trigger = new TriggerBehavior(this); }
//read a single Tiled Object private void interpretObject(TiledObject tiledObject) { //create an enemy Enemy enemy = new Enemy(tiledObject); AddChild(enemy); }
FlashBackTrigger AddFlashbackTriggerToLevel(TiledObject flashData) { string objUniqueName = flashData.Name.Trim().ToLower(); int counter = 0; while (_flashTriggersMap.ContainsKey(objUniqueName)) { objUniqueName = flashData.Name.Trim() + "_" + counter; counter++; } flashData.Name = objUniqueName; var flashTrigger = new FlashBackTrigger("data/Flashback Pickup.png", flashData) { name = objUniqueName }; _level.AddChild(flashTrigger); flashTrigger.width = Mathf.Round(flashData.Width); flashTrigger.height = Mathf.Round(flashData.Height); flashTrigger.SetOrigin(0, flashTrigger.texture.height); //Tmx use origin left,bottom :/ flashTrigger.rotation = flashData.rotation; flashTrigger.SetXY(flashData.X, flashData.Y); return(flashTrigger); }
//object is made from it's hitbox (since it is 2.5D) public Enemy(TiledObject tiledObject) : base ("hitbox.png") { Console.WriteLine("-------Enemy created--------"); Console.WriteLine("X: "+tiledObject.X+ " Y: "+tiledObject.Y); //process TiledObject properties x = tiledObject.X; y = tiledObject.Y; if (tiledObject.Properties == null) Console.WriteLine("Error: properties missing!"); else { for (int i = 0; i < tiledObject.Properties.Property.Length; i++) { if (tiledObject.Properties.Property[i].Name == "image") { addGfx(tiledObject.GID, tiledObject.Properties.Property[i].Value); } } } if (tiledObject.Properties != null) { for (int i = 0; i < tiledObject.Properties.Property.Length; i++) { properties[tiledObject.Properties.Property[i].Name] = Convert.ToString(tiledObject.Properties.Property[i].Value); } Console.WriteLine("Dictionary count: "+properties.Count + " "+ tiledObject.Properties.Property.Length); } Console.WriteLine("\n"); }
private IEnumerator SpawnAirplaneAfterDelay(TiledObject airData, int spawnFrequency) { if (spawnFrequency > 0) { yield return(new WaitForMilliSeconds(spawnFrequency)); SpawnAirplane(airData); } }
public DoorTile(string filename, int cols, int rows, TiledObject obj) : base(filename, cols, rows) { width = (int)obj.Width; height = (int)obj.Height; visible = false; SetOrigin(width / 2, height / 8); Goto = obj.GetStringProperty("GoTo"); }
public ActivityTile(string filename, int cols, int rows, TiledObject obj) : base(filename, cols, rows) { width = (int)obj.Width; height = (int)obj.Height; visible = false; SetOrigin(width / 2, height / 2); Activity = obj.GetStringProperty("Activity"); }
private IEnumerator WaitForFlashPanelHudBeDestroyed(FlashBackHud01 flashHud, TiledObject flashbackData) { while (flashHud != null && flashHud.toDestroy == false) { yield return(null); } _level.Player.InputEnabled = true; //Fadein Music if has one and a property to closeit var closeMusicBool = flashbackData.GetBoolProperty("close_music", false); if (closeMusicBool) { GameSoundManager.Instance.FadeOutCurrentMusic(Settings.Flashbacks_Music_Fadein_Duration); GameSoundManager.Instance.FadeInMusic(Settings.Base_Music, Settings.Background_Music_Volume, Settings.Flashbacks_Music_Fadein_Duration); } if (_collectedFlashBacksTriggersNames.Count >= _totalFlashbacks) { //All found //Show message to user _level.Player.InputEnabled = false; yield return(new WaitForMilliSeconds(1000)); var textBox = new TextBox(Settings.Message_To_Player_After_Collect_Flashbacks, game.width - 120, 30); textBox.CenterOnBottom(); GameHud.Instance.AddChild(textBox); yield return(textBox.TweenTextRoutine(0, Settings.Flashbacks_TextBoxTweenSpeed, true)); textBox.Destroy(); //Change FlashbackPanel yield return(GameHud.Instance.ShowFlashbackDetectivePanel()); //Show Flashbacks pickups FlashbackPickupsManager.Instance.EnableFlashbackPickups(); _level.Player.InputEnabled = true; } }
/// <summary> /// Returns true if a flashback was added, false if the flashback already exists /// </summary> /// <param name="flashName"></param> /// <returns></returns> public void PlayerPickedupFlashblackTrigger(TiledObject flashbackData) { bool flashbackExists = _collectedFlashBacksTriggersNames.Contains(flashbackData.Name); if (!flashbackExists) { _collectedFlashBacksTriggersNames.Add(flashbackData.Name); GameHud.Instance.SetFlashbackHudCounterText( string.Format(Settings.HUD_Flashback_Counter_Format, _collectedFlashBacksTriggersNames.Count, _totalFlashbacks) ); var flashHud = GameHud.Instance.LoadFlashbackHud(flashbackData, false, Settings.Flashback_Triggers_Allow_Skip_With_Esc_Key); CoroutineManager.StartCoroutine(WaitForFlashPanelHudBeDestroyed(flashHud, flashbackData), this); } }
public void SpawnTornado(TiledObject tornadoData) { int throwAngleMin = tornadoData.GetIntProperty("throw_angle_min", 0); int throwAngleMax = tornadoData.GetIntProperty("throw_angle_max", 359); float throwDistance = tornadoData.GetFloatProperty("throw_distance", 512); var tornado = new TornadoGameObject(tornadoData.X, tornadoData.Y, tornadoData.Width, tornadoData.Height, throwAngleMin, throwAngleMax, throwDistance); tornado.OnUpdateListeners = tornado.OnUpdateListeners.Concat(new IOnUpdateListener[] { _enemiesSoundManager }) .ToArray(); CoroutineManager.StartCoroutine(WaitForTargetBeenSetInLevel(tornado), this); string idString = tornadoData.Name.Replace("tornado ", ""); if (int.TryParse(idString, NumberStyles.Integer, CultureInfo.InvariantCulture, out var id)) { //Check if has path var pathObj = _level.Map.ObjectGroup.Objects.FirstOrDefault(ob => ob.Name == $"path tornado {id}"); if (pathObj != null && pathObj.polygons?.Length == 1) { var pathPos = new Vector2(pathObj.X, pathObj.Y); //Get points var pts = pathObj.polygons[0].points.Select(pt => pt + pathPos).ToArray(); if (pts.Length > 0) { tornado.Path = pts; } } } _level.AddChild(tornado); _tornadosList.Add(tornado); }
public FlashBackTrigger(string filename, TiledObject pFlashbackData) : base(filename, false, true) { _trigger = new TriggerBehavior(this); _flashbackData = pFlashbackData; }