void Update() { //_bg.graphics.CompositingMode = CompositingMode.SourceOver; _bg.Clear(Color.FromArgb(255, Color.Black)); var localPos = _bg.InverseTransformPoint(_mainTarget.x, _mainTarget.y); float localX = localPos.x + MyGame.HALF_SCREEN_WIDTH; float localY = localPos.y + MyGame.HALF_SCREEN_HEIGHT; _bg.graphics.CompositingMode = CompositingMode.SourceCopy; _lightSprite.SetXY(localX, localY); _bg.DrawSprite(_lightSprite); DrawLight(Input.mouseX, Input.mouseY); //DrawLight(localX, localY); localPos = _bg.InverseTransformPoint(2792, 3995); DrawLight(localPos.x + MyGame.HALF_SCREEN_WIDTH, localPos.y + MyGame.HALF_SCREEN_HEIGHT); //_bg.graphics.DrawImage(_lightAlpha, Input.mouseX, Input.mouseY); if (Input.GetKeyDown(Key.V)) { hatchIndex = GeneralTools.GetCircularArrayIndex(hatchIndex - 1, _hatchStyles.Length); SetBrushes(_hatchStyles[hatchIndex]); Console.WriteLine(_hatchStyles[hatchIndex]); } else if (Input.GetKeyDown(Key.B)) { hatchIndex = GeneralTools.GetCircularArrayIndex(hatchIndex + 1, _hatchStyles.Length); SetBrushes(_hatchStyles[hatchIndex]); Console.WriteLine(_hatchStyles[hatchIndex]); } }
public HUD() { //Font PFC = new PrivateFontCollection(); PFC.AddFontFile(@"kenyan_coffee_rg.ttf"); _ownFontClock = new Font(PFC.Families[0], 32); _ownFontText = new Font(PFC.Families[0], 32); //Proximity information _rectProximityInfo = new EasyDraw(1920, 1080, addCollider: false); _rectProximityInfo.alpha = 0.9f; _rectProximityInfo.color = 0x262626; AddChild(_rectProximityInfo); _proximityInfo = new EasyDraw(1920, 1080, addCollider: false); _proximityInfo.color = 0x56b25d; _proximityInfo.TextFont(_ownFontText); _textOnceAdded = false; //Clock Background _clockBackground = new Sprite("timeBackground.png"); _clockBackground.SetXY(5, 15); AddChild(_clockBackground); //Clock _clock = new EasyDraw(1920, 1080, addCollider: false); _clock.color = 0x56b25d; _clock.TextFont(_ownFontClock); AddChild(_clock); //Shopping list _shoppingList = new Sprite("List.png"); _shoppingList.scale = 0.65f; _shoppingList.SetXY(_shoppingList.width / 2.5f, 300); _shoppingList.SetOrigin(_shoppingList.width / 2, _shoppingList.height / 2); AddChild(_shoppingList); //Settings button _settingsButton = new Sprite("settingsButton.png"); _settingsButton.SetXY(225, 13); AddChild(_settingsButton); //Chatbox _chatBox = new Sprite("chatBox.png"); _chatBox.SetOrigin(_chatBox.width / 2, _chatBox.height / 2); _chatBox.SetXY(game.width / 2, game.height - 50); AddChild(_chatBox); //Sound _backgroundMusic = new Sound("backgroundSounds.mp3", true, true); _backgroundSC = _backgroundMusic.Play(); _backgroundSC.Volume = 0.35f; //Tutorial tutorial = new Sprite("Tutorial.png"); tutorial.SetOrigin(tutorial.width / 2, tutorial.height / 2); tutorial.SetXY(game.width / 2, game.height / 2); AddChild(tutorial); }
private void DrawBackgroundLayers() { var backGroundImageLayer = _mapData.ImageLayers.Where(l => l.Name.StartsWith("background image") && l.visible == true); var bitMapReuse = new Dictionary <string, Bitmap>(); foreach (var bgLayer in backGroundImageLayer) { Bitmap bitmap; if (!bitMapReuse.ContainsKey(bgLayer.Image.FileName)) { bitmap = new Bitmap(bgLayer.Image.FileName); bitMapReuse.Add(bgLayer.Image.FileName, bitmap); } else { bitmap = bitMapReuse[bgLayer.Image.FileName]; } ImageAttributes imageAtt = new ImageAttributes(); // int offsetX = SIZE * Mathf.Round(bgLayer.offsetX) / 1920; // int offsetY = SIZE * Mathf.Round(bgLayer.offsetY) / 1920; // // //Get Canvas // int canvasRow = offsetY / SIZE; // int canvasColumn = offsetX / SIZE; var canvas = new Sprite(bitmap, false); AddChild(canvas); canvas.SetXY(bgLayer.offsetX, bgLayer.offsetY); } }
public LevelEndScreen() : base("data/Next level screen.png") { _nextLevelSprite = new Sprite("data/Next Level Text.png", true, false); AddChild(_nextLevelSprite); _nextLevelSprite.SetXY(1225, 743); _nextLevelSprite.SetOrigin(_nextLevelSprite.width * 0.5f, _nextLevelSprite.height * 0.5f); //Wait some time to enable input CoroutineManager.StartCoroutine(WaitSomeTime(), this); //Animate Text SpriteTweener.TweenScalePingPong(_nextLevelSprite, 1, 1.05f, 300); }
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(); }
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); } }
public StartScreen() : base("data/Startscreen Bg.png") { //1260 207 _startText = new Sprite("data/Start Screen - pressstart.png", true, false); AddChild(_startText); _startText.SetOrigin(_startText.width * 0.5f, _startText.height * 0.5f); _startText.SetXY(1260, 207); float mScale = _startText.scale; SpriteTweener.TweenScalePingPong(_startText, mScale, mScale * 1.02f, 300); SoundManager.Instance.PlayMusic(0); }
public MeatStand(float givenX, float givenY, float givenRotation) : base(givenX, givenY, "MeatStand.png", givenRotation) { _buyMenu = new Sprite("buyScreen.png"); _buyMenu2 = new Sprite("buyScreen2.png"); _exitButton = new Sprite("exitCross.png"); _buyMenu.SetOrigin(_buyMenu.width / 2, _buyMenu.height / 2); _buyMenu.SetXY(game.width - _buyMenu.width + 150, game.height - _buyMenu.height + 150); _buyMenu2.SetOrigin(_buyMenu.width / 2, _buyMenu.height / 2); _buyMenu2.SetXY(game.width - _buyMenu.width + 150, game.height - _buyMenu.height + 150); _exitButton.SetXY(_buyMenu.x + 500, _buyMenu.y - 325); _menuShown = false; scale = 0.85f; _boughtItem = new EasyDraw(1920, 1080); _boughtItem.TextSize(16); _boughtItem.SetColor(0, 0, 0); }
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 LevelSelect() : base() { //Set the menu background Sprite background = new Sprite ("Sprites/bg.png"); AddChild (background); //render the game logo Sprite logo = new Sprite ("Sprites/logo.png"); logo.SetOrigin ((logo.width / 2), (logo.height / 2)); logo.SetXY (244, 130); AddChild (logo); //list of the level names _levelList = new LevelLister (); //list of level buttons _levelButtons = new List<DrawString> (); Console.WriteLine ("LevelSelect"); //add the menubuttons to the list int i = 275; foreach (string levelName in _levelList.GetLevels()) { _levelButtons.Add (new DrawString (levelName, 244, i, _font, _defaultColor)); i += 60; } //add menu buttons to an array _levelButtonsArray = _levelButtons.ToArray (); for (int k = 0; k < _levelButtonsArray.Length; k++) { AddChild (_levelButtonsArray [k]); } //draw the back button _backButton = new DrawString ("Back", 244, 615, _font, _defaultColor); AddChild (_backButton); }
public void DrawSprite(Sprite pSprite, PointF pPos) { DrawSprite(pSprite); pSprite.SetXY(pPos.X, pPos.Y); }
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); }
private void drawScreen() { //Background AnimationSprite background = new AnimationSprite("endscreenbg.png", 1, 2); AddChild(background); //Draw credits _credits = new Sprite("credits.png"); AddChild(_credits); _credits.y = game.height; //Draw borders Sprite borders = new Sprite("endscreenborders.png"); AddChild(borders); //Draw YOUWON or YOULOST AnimationSprite wonlost = new AnimationSprite("wonlost.png", 1, 2); wonlost.SetOrigin(wonlost.width / 2, wonlost.height / 2); wonlost.SetXY(_game.width / 2, 100); AddChild(wonlost); //Check if player has won or lost if (CurrentWonTest == LevelTest.Won) { background.SetFrame((int)CurrentWonTest); wonlost.SetFrame((int)CurrentWonTest); } else if (CurrentWonTest == LevelTest.Lost) { background.SetFrame((int)CurrentWonTest); wonlost.SetFrame((int)CurrentWonTest); } //Draw "Throw in a coin to play again" _insertcoin = new Sprite("insertcoin.png"); AddChild(_insertcoin); _insertcoin.SetOrigin(_insertcoin.width / 2, _insertcoin.height / 2); _insertcoin.SetXY(game.width / 2, game.height - _insertcoin.height); }