public Scene(string path, CurrencySystem currency, Level level, int scene, int price = 400, Tutorial tutorial = null) : base() { // _tutorial = tutorial; this.scene = scene; _currency = currency; visible = false; this.level = level; isActive = false; canMakeFood = true; tank = new Sprite(path); downArrow = new Sprite("downarrow.png"); downArrow.SetXY(game.width / 2, game.height - 200); downArrow.SetScaleXY(0.2f); foodList = new List <Food>(); AddChildAt(tank, 0); AddChild(downArrow); priceOfAquarium = price; fishListPerScene = new List <Fish>(); DisplayFishInScene fishes = new DisplayFishInScene(scene, foodList, fishListPerScene); sponge = new Sponge(this); shop = new Shop(fishListPerScene, level); inv = new Inventory(); clickToBuy = new Sprite("checkers.png"); clickToBuy.width = 200; clickToBuy.height = 200; clickToBuy.y += 300; AddChild(clickToBuy); foodCan = new Sprite("fish_food.png"); foodCan.SetOrigin(foodCan.width / 4, 0); foodCan.width /= 5; foodCan.height /= 5; for (int i = 0; i < 30; i++) { Dirt dirt = new Dirt(ref cleanMeter); sponge.addDirt(dirt); AddChild(dirt); } AddChild(shop); shop.visible = false; cleanDirtWithSponge = new Sound("sponge_use_sound.wav", true, true); //spongeClean = cleanDirtWithSponge.Play(); //spongeClean.Stop(); repairAquarium = new Sound("repair_aquarium_sound.wav", false, true); makeFoodSound = new Sound("fish_food_pick_sound.wav", false, true); openShop = new Sound("opening_journal_shop_sound.wav", false, true); // openShopSoundChannel = openShop.Play(); }
private static IEnumerator TweenScaleRoutine(Sprite sprite, float from, float to, int duration, int delay, OnTweenComplete onComplete, Easing.Equation equation) { //TODO: remove this call to WaitForMilliSeconds and implement it in the while loop to prevent another instantiation of a yield if (delay > 0) { yield return(new WaitForMilliSeconds(delay)); } int time = 0; sprite.SetScaleXY(from, from); float fromDir = from > to ? from : 0; float toDir = from > to ? 0 : from; float scale = sprite.scale; while (time < duration) { scale = toDir + Easing.Ease(equation, time, fromDir, to - from, duration); sprite.SetScaleXY(scale, scale); time += Time.deltaTime; yield return(null); } sprite.SetScaleXY(to, to); if (onComplete != null) { onComplete.Invoke(sprite); } }
public Tutorial(Vec2 position, Level level) : base() { canvas = new Canvas(500, 400); canvas.SetXY(position.x, position.y); image = new Sprite("tutorial_background.png"); image.SetScaleXY(0.4f); image.SetXY(canvas.x, canvas.y); isVisible = true; skip = new Button(new Vec2(canvas.x + 50, canvas.y + canvas.height - 50), 100, 50, "SKIP"); next = new Button(new Vec2(canvas.x + canvas.width - 200, canvas.y + canvas.height - 50), 100, 500, "NEXT"); count = 0; font = new Font("MV Boli", 18); AddChild(image); AddChild(canvas); AddChild(skip); AddChild(next); this.level = level; }
public HUD(Camera camera, GameObject player) { Instance = this; _mapData = TiledMapParserExtended.MapParser.ReadMap("HUD.tmx"); var objectsDepth0 = _mapData.ObjectGroups.FirstOrDefault(og => og.Name == "Depth 0"); //Hud Score set var hudData = objectsDepth0.Objects.FirstOrDefault(o => o.Name == "Score Bg"); var hudScoreImage = _mapData.TileSets.FirstOrDefault(ts => ts.FirstGId == hudData.GID).Image.FileName; _hudScore = new HudScore(hudScoreImage); AddChild(_hudScore); _hudScore.SetScaleXY(hudData.Width / _hudScore.width, hudData.Height / _hudScore.height); _hudScore.SetXY(hudData.X, hudData.Y - hudData.Height); //Pizza life set var pizzasHudData = objectsDepth0.Objects.Where(o => o.Name.Trim().StartsWith("Hud Pizza")) .OrderBy(o => o.Name) .ToArray(); var pizzaHudBitmapMap = new Dictionary <string, Bitmap>(); var pizzaLostImageFileName = _mapData.TileSets.FirstOrDefault(ts => ts.Name == "Pizza Lost").Image.FileName; pizzaHudBitmapMap.Add(pizzaLostImageFileName, new Bitmap(pizzaLostImageFileName)); _pizzaLives = new Sprite[pizzasHudData.Length]; _pizzaLostLives = new Sprite[pizzasHudData.Length]; for (int i = 0; i < pizzasHudData.Length; i++) { var pizzaHudData = pizzasHudData[i]; var imageFile = _mapData.TileSets.FirstOrDefault(ts => ts.FirstGId == pizzaHudData.GID).Image.FileName; Bitmap bitMap; if (!pizzaHudBitmapMap.ContainsKey(imageFile)) { bitMap = new Bitmap(imageFile); pizzaHudBitmapMap.Add(imageFile, bitMap); } else { bitMap = pizzaHudBitmapMap[imageFile]; } var pizzaHud = new Sprite(bitMap, false); AddChild(pizzaHud); int pizzaHudOriginalW = pizzaHud.width; int pizzaHudOriginalH = pizzaHud.height; pizzaHud.SetScaleXY(pizzaHudData.Width / pizzaHudOriginalW, pizzaHudData.Height / pizzaHudOriginalH); pizzaHud.SetXY(pizzaHudData.X, pizzaHudData.Y - pizzaHudData.Height); _pizzaLives[i] = pizzaHud; var pizzaLostHud = new Sprite(pizzaHudBitmapMap[pizzaLostImageFileName], false); AddChild(pizzaLostHud); pizzaLostHud.SetScaleXY(pizzaHudData.Width / pizzaHudOriginalW, pizzaHudData.Height / pizzaHudOriginalH); pizzaLostHud.SetXY(pizzaHudData.X, pizzaHudData.Y - pizzaHudData.Height); pizzaLostHud.SetActive(false); _pizzaLostLives[i] = pizzaLostHud; } _hudPointsPopUp = new HudPointsPopUp(); AddChild(_hudPointsPopUp); _hudPointsPopUp.Target = player; _camera = camera; _camera.AddChild(this); this.x = -MyGame.HALF_SCREEN_WIDTH; this.y = -MyGame.HALF_SCREEN_HEIGHT; var centerText = $@"<= and => arrows to flap wings Turn is weird flapping one wing while the other is static"; _centerTextBoard = new HudTextBoard(centerText, 312, 32, 20, CenterMode.Center, CenterMode.Center); _centerTextBoard.SetText(centerText); _centerTextBoard.visible = false; _centerTextBoard.Centralize(); _centerTextBoard.y = Game.main.height - _centerTextBoard.Height; AddChild(_centerTextBoard); _slider00 = new HudSlider(200, 22); AddChild(_slider00); _slider00.x = 50; _slider00.y = 50; _slider00.OnValueChanged += ChangeDroneWaitingSpeed; _slider01 = new HudSlider(200, 22); AddChild(_slider01); _slider01.x = 50; _slider01.y = 50 + 34; //_slider01.OnValueChanged += ChangeDroneDetectRange; //_slider01.OnValueChanged += DebugChangeThermometerValue; _slider01.OnValueChanged += ChangeDroneFrameSpeed; _hudThermometer = new HudThermometer(); AddChild(_hudThermometer); _hudThermometer.SetXY(game.width - (1920 - 1731), 85); _hudThermometer.SetOriginToCenter(); _hudArrowToObjective = new HudArrowToObjective(); AddChild(_hudArrowToObjective); _hudArrowToObjective.SetScaleXY(0.4f, 0.4f); _hudArrowToObjective.SetXY(game.width * 0.5f, game.height * 0.5f); _hudArrowToObjective.SetActive(false); _debugTimer = new HudTextBoard(60, 60, 12); _debugTimer.x = game.width - 60; _debugTimer.y = 60; AddChild(_debugTimer); }