Exemplo n.º 1
0
    Sprite AddBoardCell (HexCoord c)
    {
        var texture = Resources.Textures.Tile;
        var textureHeight = texture.GetHeight();
        float scale = 2f / textureHeight;

        var s = new Sprite
        {
            Texture = texture,
            Scale = new Vector2(scale, scale),
            ZIndex = (int)ZLayers.Background,
            Position = c.Position(),
            Modulate = BoardColor
        };
        board.AddChild(s);
        var overlay = new Sprite
        {
            Texture = Resources.Textures.BoardGradient,
            Scale = new Vector2(scale, scale),
            ZIndex = (int)ZLayers.Background+1,
            Position = c.Position()
        };
        board.AddChild(overlay);
        return s;
    }
Exemplo n.º 2
0
    public void loadLastDrawings()
    {
        var img = new Image();
        var err = img.Load("user://lastDraw.png");

        if (err == Error.Ok)
        {
            var imgTex = new ImageTexture();
            imgTex.CreateFromImage(img);
            var spr = new Sprite();
            spr.Centered = false;
            var shader   = (Shader)ResourceLoader.Load("res://shaders/blackFix.shader");
            var material = new ShaderMaterial();
            material.Shader = shader;
            spr.Material    = material;

            spr.Material = material;
            spr.Texture  = imgTex;
            drawContainerNode.AddChild(spr);
        }
        else
        {
            GD.PrintErr(err);
        }
    }
Exemplo n.º 3
0
    private void SetupBlocks()
    {
        PackedScene blockScene = GD.Load <PackedScene>("res://Scenes/Block.tscn");

        Vector2 previousRowPosition = Vector2.Zero;

        for (int i = 0; i < 4; i++)
        {
            Block rowBlock = (Block)blockScene.Instance();
            _blocks.AddChild(rowBlock);

            rowBlock.Position = new Vector2(
                rowBlock.GetCenter().x + _blockPadding,
                rowBlock.GetCenter().y * 2 + _blockPadding + previousRowPosition.y
                );

            Vector2 previousColumnPosition = rowBlock.Position;
            for (int j = 0; j < 9; j++)
            {
                Block columnBlock = (Block)rowBlock.Duplicate();
                _blocks.AddChild(columnBlock);

                columnBlock.Position   = new Vector2(previousColumnPosition.x + columnBlock.GetCenter().x * 2 + _blockPadding, previousColumnPosition.y);
                previousColumnPosition = columnBlock.Position;
            }

            previousRowPosition = rowBlock.Position;
        }
    }
Exemplo n.º 4
0
        private void CreateOrder(Vector2 position)
        {
            var order = _orderCreator.CreateOrder(_foodSpawner.FoodSpawns);

            order.Connect("SpawnOrder", this, nameof(SpawnOrder));
            order.Position = position;
            _orderContainer.AddChild(order);
        }
Exemplo n.º 5
0
    public async void _OnWaveTimerFinished()
    {
        int totalEnemies = 0;
        int num          = GetTree().GetNodesInGroup("EnemySpawnTargets").Count;

        while (num > 0)
        {
            SpawnRadius.GlobalPosition = new Vector2()
            {
                x = Mathf.Clamp((float)GD.RandRange(0, WorldSize) * Globals.TileSize, 256, WorldSize * Globals.TileSize - 256),
                y = Mathf.Clamp((float)GD.RandRange(0, WorldSize) * Globals.TileSize, 256, WorldSize * Globals.TileSize - 256)
            };

            await ToSignal(GetTree().CreateTimer(0.05f), "timeout");

            if (SpawnRadius.GetOverlappingBodies().Count == 0)
            {
                num--;

                for (int i = 0; i < Mathf.FloorToInt(WaveTimer.Wave / 2) + 2; i++)
                {
                    var enemy = (Enemy)EnemySmall.Instance();
                    enemy.GlobalPosition = SpawnRadius.GlobalPosition + new Vector2(0, (float)GD.RandRange(0, 256)).Rotated(Mathf.Deg2Rad((float)GD.RandRange(0, 360)));

                    GroundEntities.AddChild(enemy);
                    totalEnemies++;

                    await ToSignal(GetTree().CreateTimer(0.01f), "timeout");
                }

                for (int i = 0; i < Mathf.FloorToInt(WaveTimer.Wave / 3); i++)
                {
                    var enemy = (FlyingEnemy)EnemyFlying.Instance();
                    enemy.GlobalPosition = SpawnRadius.GlobalPosition + new Vector2(0, (float)GD.RandRange(0, 256)).Rotated(Mathf.Deg2Rad((float)GD.RandRange(0, 360)));

                    FlyingEntities.AddChild(enemy);
                    totalEnemies++;

                    await ToSignal(GetTree().CreateTimer(0.01f), "timeout");
                }

                for (int i = 0; i < Mathf.FloorToInt(WaveTimer.Wave / 5); i++)
                {
                    var enemy = (Enemy)EnemyLarge.Instance();
                    enemy.GlobalPosition = SpawnRadius.GlobalPosition + new Vector2(0, (float)GD.RandRange(0, 256)).Rotated(Mathf.Deg2Rad((float)GD.RandRange(0, 360)));

                    GroundEntities.AddChild(enemy);
                    totalEnemies++;

                    await ToSignal(GetTree().CreateTimer(0.01f), "timeout");
                }
            }
        }

        waveStarted = true;
    }
Exemplo n.º 6
0
        private void CreateChargedAttack()
        {
            // Charged Bullet
            _chargedBullet = (BossBullet)chargedBulletPrefab.Instance();
            _dualArmAttackPosition.AddChild(_chargedBullet);
            _chargedBullet.SetMode(RigidBody2D.ModeEnum.Kinematic);
            _chargedBullet.SetGlobalPosition(_dualArmAttackPosition.GetGlobalPosition());
            _chargedBullet.SetAsStaticBullet();

            // Charged Bullet Effect
            _chargedEffectDestroy = (DestroyNodeForced)chargingEffectPrefab.Instance();
            _dualArmAttackPosition.AddChild(_chargedEffectDestroy);
        }
Exemplo n.º 7
0
    private void OnPlayPressed()                //resetting variables upon pressing, as well as generating the traps
    {
        winingLabel.Visible      = false;
        GameData.paused          = false;
        titleCam.Current         = false;
        titleCam.Visible         = false;
        Player.playerCam.Current = true;
        GameData.minutesLeft     = 1;
        GameData.secondsLeft     = 30;
        GameData.won             = false;
        GameData.dead            = false;
        GameData.gameOver        = false;
        Player.player.Position   = spawnPoint.GlobalPosition;
        for (int i = 0; i < GetChildCount(); i++)
        {
            Node potentialWeaponPoint = GetChild(i);
            if (potentialWeaponPoint.GetType().ToString() == "Godot.Position2D")
            {
                Position2D weaponPoint = potentialWeaponPoint as Position2D;
                if (weaponPoint.Name.Contains("Weapon"))                                //separating player spawn and weapon spawns
                {
                    switch (rand.Next(0, 4))
                    {
                    case 0:
                        Node2D weapon = (Node2D)weaponSet1.Instance();
                        weapon.GlobalPosition = weaponPoint.GlobalPosition;
                        weaponsContainer.AddChild(weapon);
                        break;

                    case 1:
                        Node2D weapon2 = weaponSet2.Instance() as Node2D;
                        weapon2.GlobalPosition = weaponPoint.GlobalPosition;
                        weaponsContainer.AddChild(weapon2);
                        break;

                    case 2:
                        StaticBody2D weapon3 = weaponSet3.Instance() as StaticBody2D;
                        weapon3.GlobalPosition = weaponPoint.GlobalPosition - new Vector2(24f, 0f);
                        weaponsContainer.AddChild(weapon3);
                        break;

                    case 3:
                        StaticBody2D weapon4 = weaponSet4.Instance() as StaticBody2D;
                        weapon4.GlobalPosition = weaponPoint.GlobalPosition - new Vector2(24f, 0f);
                        weaponsContainer.AddChild(weapon4);
                        break;
                    }
                }
            }
        }
    }
Exemplo n.º 8
0
    private void LayoutObjectAtRandom(Godot.Collections.Array <PackedScene> tileArray, int min, int max) //posicionar objeto en lugar aleatorio//array con todos los muros y creame entre una cantidad minima y maxima de muros
    {
        int objectCount = (int)GD.RandRange(min, (double)max + 1);                                       //numero total de objetos que tenemos que crear

        for (int i = 0; i < objectCount; i++)
        {
            Vector2 randomPosition = RandomPosition();            //posición aleatoria que recibo de la lista de bloques libres
            Sprite  tileChoise     = GetRandomInArray(tileArray); //tomamos el nodo que queremos instanciar toma como parametro un arreglo
            board.AddChild(tileChoise);                           //hago que sea hijo del nodo board
            //importante multiplicar el random position por el tamaño de sprite osea 32..En el caso del position estariamos haciendo una multiplicaión de 1 número por 1 vector,osea 32*X/32*Y
            tileChoise.Position        = randomPosition * 32;     //la posicion es la aleatoria que toma en cuenta las posiciones donde pueden estar los obstaculos y evita que se interpongan
            tileChoise.RotationDegrees = 0;                       //la rotacion es 0
        }
    }
Exemplo n.º 9
0
            public override void _Ready()
            {
                var width  = (EndPosition.x - StartPosition.x) / (LinkCount + 1);
                var height = (EndPosition.y - StartPosition.y) / (LinkCount + 1);

                AddChild(linksContainer);
                AddChild(circleContainer);

                startAnchor = new ChainAnchor()
                {
                    Position = StartPosition
                };
                circleContainer.AddChild(startAnchor);

                PhysicsBody2D lastLink = startAnchor;

                for (int i = 0; i < LinkCount; ++i)
                {
                    var link = new ChainLink()
                    {
                        Position = StartPosition + new Vector2(width + (i * width), height + (i * height))
                    };
                    linksContainer.AddChild(link);
                    link.LinkToParent(lastLink, Softness, Bias);
                    links.Add(link);

                    var lineSprite = new SimpleLineSprite();
                    circleContainer.AddChild(lineSprite);
                    lineSprite.PositionA = lastLink.Position;
                    lineSprite.PositionB = link.Position;
                    lineSprites.Add(lineSprite);

                    lastLink = link;
                }

                endAnchor = new ChainAnchor()
                {
                    Position = EndPosition
                };
                circleContainer.AddChild(endAnchor);
                endAnchor.LinkTarget(lastLink, Softness, Bias);

                var lastLineSprite = new SimpleLineSprite();

                linksContainer.AddChild(lastLineSprite);
                lastLineSprite.PositionA = lastLink.Position;
                lastLineSprite.PositionB = endAnchor.Position;
                lineSprites.Add(lastLineSprite);
            }
Exemplo n.º 10
0
        public void SpawnPlateItem(List <FoodItem> foodItems)
        {
            var spawns = GetAvailableSpawns();

            if (!spawns.Any())
            {
                return;
            }

            var spawn = spawns[Global.RNG.Next(0, spawns.Count)];

            var rng      = new [] { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
            var foodItem = rng[Global.RNG.Next(0, rng.Length)] == 0 && foodItems.Count > 0
                ? _foodLoader.RandomItem(foodItems)
                : _foodLoader.Random();

            var plate  = _plates.PlatesList[(int)spawn.x][(int)spawn.y];
            var sprite = FoodLoader.CreateSprite(foodItem.Texture);

            sprite.Position = plate.GlobalPosition;

            var foodSpawn = new FoodSpawn {
                Name = foodItem.Name, Position = spawn, Sprite = sprite
            };

            _spawns.Add(spawn);
            _foodSpawns.Add(foodSpawn);
            _plates.PlateSpawns.Add(spawn);
            _foodContainer.AddChild(sprite);
        }
Exemplo n.º 11
0
    // figure out the placement of the solider
    // called by CombatArmyCreator during the round switch when the vfx are happening
    async public Task PrepArmySoldier(int soliderNum, Enums.ArmyGunTypes gunType)
    {
        CombatArmySoldier newSoldier = armySoldierScene.Instance <CombatArmySoldier>();

        newSoldier.gunType = gunType;

        // hide the soldier and keep trying random positions till it isnt colliding with any of the existing soldiers
        newSoldier.Visible = false;
        armySoldiers.AddChild(newSoldier);

        do
        {
            PlaceSoldierRandomPos(newSoldier);
        }while (await IsSoliderColliding(newSoldier));

        newSoldier.Visible = true;

        // re-calculate the spawn and off-screen spawn positions
        // also set the soldier's position to the off-screen value; prevously it was the final position to check for collisions
        Vector2 spawnPos          = newSoldier.Position;
        Vector2 offScreenSpawnPos = new Vector2(newSoldier.Position.x + spawnOffset, newSoldier.Position.y);

        newSoldier.Position = offScreenSpawnPos;

        preparedSoldiers.Add(newSoldier, spawnPos);
    }
Exemplo n.º 12
0
    public void _addTraversableTiles(Godot.Collections.Array tiles)
    {
        foreach (Vector2 tile in tiles)
        {
            int id = getPointID((int)tile.x, (int)tile.y);

            if (!_aStar.HasPoint(id))
            {
                _aStar.AddPoint(id, tile, 1);
                _tilestoWorld.Add(id, _tileMap.MapToWorld(tile) + _halfCellSize);

                ColorRect colorRect = new ColorRect();
                _grid.AddChild(colorRect);

                colorRect.Color    = _enableColor;
                colorRect.Modulate = new Color(1, 1, 1, 0.5f);

                _gridRects.Add(id, colorRect);

                colorRect.MouseFilter = Control.MouseFilterEnum.Ignore;

                colorRect.SetSize(_tileMap.CellSize);
                // Color Rect's x calculation is lightly different, so need to add 1.5f to position correctly
                colorRect.RectPosition = new Vector2(_tileMap.MapToWorld(tile).x + (_tileMap.CellSize.x * 1.5f), _tileMap.MapToWorld(tile).y);
            }
        }
    }
        private void AddTileMapObject(Vector2 tile, Node2D tmpContainerNode)
        {
            var tileId        = pathfindingTileMap.GetCell((int)tile.x, (int)tile.y);
            var tileUniqueId  = pathfindingTileMap.GetIdForTile(tile);
            var worldPosition = pathfindingTileMap.MapToWorld(tile) + pathfindingTileMap.CellSize / 2;

            tileIdToPackedSceneMapping.TryGetValue(tileId, out var packedScene);

            if (packedScene?.Instance() is TileMapObject tileMapObject)
            {
                if (tileMapObjects.TryGetValue(tileUniqueId, out var tileMapObjectNodeReference))
                {
                    tileMapObjectNodeReference.node = tileMapObject;
                    tmpContainerNode.AddChild(tileMapObjectNodeReference.node);
                    tileMapObjectNodeReference.node.ZIndex = (int)tile.y * 2;
                    tileMapObjectNodeReference.node.SetPosition(worldPosition);
                }
                else
                {
                    throw new Exception("Expected already setup tileMapObjectNodeReference!");
                }
            }

//            else {
//                throw new Exception("Instance is not a tileMapObject");
//            }
        }
Exemplo n.º 14
0
    /**
     * AddWeapon
     * Assign weapon to target weaponOrder and index
     **/
    public bool EquipWeapon(PackedScene weaponScene, Weapon.WeaponOrder weaponOrder, int index)
    {
        Godot.Collections.Array <Weapon> weapons = GetWeapons(weaponOrder);

        if (weapons[index] != null)
        {
            return(false);
        }

        Node2D weaponHolder = GetWeaponsHolder(weaponOrder);
        Weapon weapon       = (Weapon)(weaponScene.Instance());

        weaponHolder.AddChild(weapon);
        weapon.Initialize(_gameWorld, this, weaponOrder);
        weapons[index] = weapon;
        weapon.Hide();

        // If it is current weapon, then perform weapon change
        if (index == CurrentWeaponIndex[weaponOrder])
        {
            changeWeapon(index, weaponOrder);
        }

        return(true);
    }
Exemplo n.º 15
0
    public void AddDamageIndicator(Vector3 ShotFirePosition, float Damage)
    {
        DamageIndicator Indicator = DamageIndicatorScene.Instance() as DamageIndicator;

        Indicator.Setup(ShotFirePosition, Damage * DamageIndicatorLifeMultiplyer);
        DamageIndicatorRoot.AddChild(Indicator);
    }
Exemplo n.º 16
0
        private void LaunchSingleArmAttack(Vector2 attackPosition)
        {
            BossBullet bulletInstance = (BossBullet)singleArmBulletPrefab.Instance();

            _bulletHolder.AddChild(bulletInstance);

            float   xVelocity      = Mathf.Cos(Mathf.Deg2Rad(_attackVariable_1));
            float   yVelocity      = Mathf.Sin(Mathf.Deg2Rad(_attackVariable_1));
            Vector2 launchVelocity = new Vector2(xVelocity, yVelocity);

            bulletInstance.SetGlobalPosition(attackPosition);
            bulletInstance.LaunchBullet(launchVelocity);

            _attackVariable_1 += singeArmAttackAngleDiff;
            _attackVariable_1  = ExtensionFunctions.To360Angle(_attackVariable_1);
        }
Exemplo n.º 17
0
    //Places the rooms and starts the physics simulation. Once the simulation is done
    //("rooms_placed" gets emitted), it continues by assigning tiles in the Level node.
    private async void Generate()
    {
        for (int i = 1; i <= MaxRooms; i++)
        {
            var room = RoomResource.Instance() as Room;

            room.Connect(nameof(Room.SleepingStateChanged), this, nameof(_on_Room_sleeping_state_changed));
            room.Setup(_rng, Level);
            Rooms.AddChild(room);

            _meanRoomSize += room.Size;
        }
        _meanRoomSize /= Rooms.GetChildCount();

        //Wait for all rooms to be positioned in the game world.
        await ToSignal(this, nameof(RoomsPlaced));

        GD.Print("Generate RoomsPlaced Signal Received");

        Rooms.QueueFree();

        //Draws the tiles on the `level` tilemap.
        Level.Clear();

        foreach (var entry in _data)
        {
            Level.SetCellv(entry.Key, 0);
        }
    }
Exemplo n.º 18
0
        private void SetupPlateGrid(out Vector2 size)
        {
            size = new Vector2();
            var keepCount = true;

            for (var r = 0; r < Rows; r++)
            {
                var row = new List <Plate>();
                for (var c = 0; c < Cols; c++)
                {
                    var colPadding = c < Cols ? c * PaddingCol : 0;
                    var rowPadding = r < Rows ? r * PaddingRow : 0;
                    var position   = new Vector2(c * Width + colPadding, r * Height + rowPadding);
                    var sizeData   = new Vector2(Width + colPadding, Height + rowPadding);

                    var plate = _plate.Instance <Plate>();
                    plate.Position = position;
                    row.Add(plate);
                    _container.AddChild(plate);

                    if (keepCount)
                    {
                        size += sizeData;
                    }
                }

                keepCount = false;
                _plates.Add(row);
            }
        }
Exemplo n.º 19
0
    public void DrawGameBoard()
    {
        Random random = new Random();
        int    i      = 0;

        while (i < BRICK_COUNT)
        {
            // instance new brick
            StaticBody2D brickNode = brick.Instance() as StaticBody2D;
            brickArea.AddChild(brickNode);
            //position brick relative to previous
            brickNode.Modulate = new Color(
                (float)random.NextDouble(),
                (float)random.NextDouble(),
                (float)random.NextDouble(),
                1f
                );
            brickNode.Position = new Vector2(
                (i % COL_COUNT * brickSizeVector.x) + INITIAL_OFFSET,
                (i / COL_COUNT) * brickSizeVector.y
                );

            i++;
        }
    }
Exemplo n.º 20
0
        private void HandleWeaponShooting()
        {
            switch (_currentWeaponType)
            {
            case WeaponType.SingleShot:
                float currentRotation = _playerRoot.GetRotation();
                float xVelocity       = Mathf.Cos(currentRotation);
                float yVelocity       = Mathf.Sin(currentRotation);
                ShootSingleShotBullet(new Vector2(xVelocity, yVelocity));
                break;

            case WeaponType.Shotgun:
                ShootShotGunBullet();
                break;

            case WeaponType.ChargeGun:
            {
                _chargeWeaponCurrentScale = 1;

                _chargedShotBullet = (ChargedBullet)playerChargedBulletPrefab.Instance();
                _playerChargedShotShootingPosition.AddChild(_chargedShotBullet);

                _chargedShotBullet.SetGlobalPosition(_playerChargedShotShootingPosition.GetGlobalPosition());
                _chargedShotBullet.SetAsStaticBullet();
                _chargedShotBullet.SetMode(RigidBody2D.ModeEnum.Kinematic);
            }

            break;

            default:
                throw new ArgumentOutOfRangeException(nameof(_currentWeaponType), _currentWeaponType, null);
            }
        }
Exemplo n.º 21
0
    public override void _Process(float delta)
    {
        if (Input.IsActionPressed("move_left"))
        {
            Translate(Vector2.Left * delta * moveSpeed);
        }
        else if (Input.IsActionPressed("move_right"))
        {
            Translate(Vector2.Right * delta * moveSpeed);
        }

        Position = new Vector2(Mathf.Clamp(Position.x, 30, 370), Position.y);

        if (Input.IsActionPressed("fire"))
        {
            if (timePassed >= fireRateSec)
            {
                Laser laser = (Laser)laserScenes[laserIndex].Instance();
                laser.GlobalPosition = muzzle.GlobalPosition;
                space.AddChild(laser);
                sfxShoot.Play();
                timePassed = 0;
            }
        }

        timePassed += delta;
    }
Exemplo n.º 22
0
    private void _on_BuildButton_pressed()
    {
        Index index = new Index((int)Position.x, (int)Position.y);

        if (turretIndexes.ContainsKey(index))
        {
            int    turrentCost = turretIndexes[index].GetCost();
            Turret turret      = turretIndexes[index];
            if (player.GetSpendingMoney() >= turrentCost)
            {
                turret.Upgrade();
                buildSound.Play();
                player.Spend(turrentCost);
            }
        }
        else
        {
            if (player.GetSpendingMoney() >= 150)
            {
                buildSound.Play();
                player.Spend(150);
                Turret turret = (Turret)TurretScene.Instance();
                turret.Position = Position;
                mainNode.AddChild(turret);
                turretIndexes.Add(index, turret);
            }
        }
        Visible = false;
        buildButton.Disabled = false;
    }
Exemplo n.º 23
0
Arquivo: Game.cs Projeto: wsenh/ld47
        private void AssignCamera(Node2D target)
        {
            var parent = Camera.GetParent();

            parent?.RemoveChild(Camera);
            Camera.Position = Vector2.Zero;
            target.AddChild(Camera);
        }
Exemplo n.º 24
0
        private void ShootSingleShotBullet(Vector2 forwardVectorNormalized)
        {
            Bullet bulletInstance = (Bullet)playerBulletPrefab.Instance();

            _playerBulletHolder.AddChild(bulletInstance);

            if (_currentDamageDiffPercent != 0)
            {
                float damageChange = bulletInstance.GetBulletDamage() * _currentDamageDiffPercent / 100;
                _currentDamageDiff       += damageChange;
                _currentDamageDiffPercent = 0;
            }

            bulletInstance.SetBulletDamage(bulletInstance.GetBulletDamage() + _currentDamageDiff);
            bulletInstance.SetGlobalPosition(_playerBulletShootingPosition.GetGlobalPosition());
            bulletInstance.LaunchBullet(forwardVectorNormalized);
            bulletInstance.SetFreezingBulletState(_freezingBulletBought);
        }
Exemplo n.º 25
0
    internal void RegisterLevelRoot(Node2D value)
    {
        LevelRoot = value;

        if (ContextMenuPosition != null)
        {
            LevelRoot.AddChild(ContextMenuPosition);
        }
    }
Exemplo n.º 26
0
    public void add_bunny()
    {
        var bunny = new Sprite();

        bunny.SetTexture(bunnyTexture);
        bunnies.AddChild(bunny);
        bunny.Position = new Vector2(screenSize.x / 2, screenSize.y / 2);
        speeds.Add(new Vector2(random.Next() % 200 + 50, random.Next() % 200 + 50));
    }
Exemplo n.º 27
0
    private void ChangeParent(Node2D child, Node2D newParent)
    {
        Vector2 prevPos   = child.GlobalPosition;
        Vector2 prevScale = GetGlobalScale();

        child.GetParent().RemoveChild(child);
        newParent.AddChild(child);
        child.SetGlobalPosition(prevPos);
        child.SetGlobalScale(prevScale);
    }
Exemplo n.º 28
0
    public void add_bunny()
    {
        var bunny = new Bunny {
            Texture = bunnyTexture
        };

        bunnies.AddChild(bunny);
        bunny.Position = new Vector2(screenSize.x / 2, screenSize.y / 2);
        bunny.Speed    = new Vector2(randomNumberGenerator.Randi() % 200 + 50, randomNumberGenerator.Randi() % 200 + 50);
    }
Exemplo n.º 29
0
        private void LoadLevel(int level)
        {
            var resource = GD.Load <PackedScene>(LevelFactory.GetLevel(level));

            Level          = resource.Instance() as Level;
            Level.Scale    = LevelScale;
            Level.Position = LevePosition;
            LevelContainer.AddChild(Level);
            Level.Connect("GameOver", this, nameof(GameOver));
            Level.Connect("SwitchLevel", this, nameof(SwitchLevel));
        }
Exemplo n.º 30
0
    public void PlaySound(string name, Vector2 position)
    {
        PackedScene sfxScene;

        if (Sounds.TryGetValue(name, out sfxScene))
        {
            var sfx = (Node2D)sfxScene.Instance();
            Level.AddChild(sfx);
            sfx.Position = position;
        }
    }