Esempio n. 1
0
 public void StartGame()
 {
     LoadHighScore();
     _waveTimer.Start();
     GUI.InGame();
     GUI.UpdateHighScore(highScore);
     GUI.ShowGetReady(score);
     _world = (World)_worldScene.Instance();
     AddChild(_world);
     _world.Connect("OnGameOver", this, nameof(GameOver));
     _world.Connect("OnWaveWon", this, nameof(WaveWon));
     _world.Hide();
     _victoryAudio.Play();
     GetTree().Paused = true;
 }
        public override void _Ready()
        {
            var size = GetViewportRect().Size;

            viewport = new Viewport()
            {
                Size  = size,
                Usage = Viewport.UsageEnum.Usage2d,
                RenderTargetUpdateMode = Viewport.UpdateMode.Always,
                RenderTargetClearMode  = Viewport.ClearMode.OnlyNextFrame,
                RenderTargetVFlip      = true
            };
            AddChild(viewport);

            pen = new Node2D();
            pen.Connect("draw", this, nameof(OnPenDraw));
            viewport.AddChild(pen);

            var texture = viewport.GetTexture();

            board = new TextureRect()
            {
                AnchorBottom = 1.0f,
                AnchorRight  = 1.0f,
                Texture      = texture
            };
            AddChild(board);

            // First clear on ready
            QueueClearDrawing(clearColor);
        }
Esempio n. 3
0
    public void CreateConnection()
    {
        _player.Connect("OnShoot", this, nameof(OnPlayerShoot));
        _player.Connect("OnHit", this, nameof(PlayerHit));
        _player.Connect("OnGameOver", this, nameof(GameOver));
        Node2D walls = GetNode <Node2D>("Walls");

        walls.Connect("OnRightCollision", _wave, "OnCollideRight");
        walls.Connect("OnLeftCollision", _wave, "OnCollideLeft");
        _wave.Connect("OnDefeat", this, nameof(WaveWon));
        foreach (Node child in _wave.GetChildren())
        {
            if (child is Enemy)
            {
                child.Connect("OnShoot", this, nameof(OnEnemyShoot));
            }
        }
    }
Esempio n. 4
0
    ///////////////////////////////////////////////////
    // Callback Functions
    ///////////////////////////////////////////////////
    private void PlayerConnected(int Id)
    {
        PackedScene scene = ResourceLoader.Load("res://pong.tscn") as PackedScene;
        Node2D      Pong  = scene.Instance() as Node2D;

        Pong.Connect("GameFinished", this, "EndGame", null, (int)ConnectFlags.Deferred);

        GetTree().Root.AddChild(Pong);
        Hide();
    }
Esempio n. 5
0
    public override void _Ready()
    {
        Dice = GetNode("Dice") as Control;
        Dice.Connect("pressed", this, "GetDIceRoll");

        G2         = (Global_I)GetNode("/root/GlobalI");
        Board      = GetNode("Board") as Node2D;
        GameEngine = GetNode("GameEngine") as Node2D;
        GameEngine.Connect("MovePiece", this, "MovePiece_M");

        InitPlayers();
    }
Esempio n. 6
0
    public override void _Ready()
    {
        // Called every time the node is added to the scene.
        // Initialization here
        ScoreBarrel = (Label)GetNode("/root/Main/GameOver/BarrelScore/ScoreBarrel");
        ScoreMeteor = (Label)GetNode("/root/Main/GameOver/MeteorScore/ScoreMeteor");

        EnemySpawn = (Node2D)GetNode("/root/Main/EnemySpawn");
        EnemySpawn.Connect("BarrelAddScoreToLabel", this, "ScoreBarrelConnect");

        MainRoot = (Node2D)GetNode("/root/Main");
        MainRoot.Connect("DataScoreMeteorData", this, "ScoreMeteorConnect");
    }
Esempio n. 7
0
    public void SelectNode(Node2D node)
    {
        if (_currentSelectedNode != null && _currentSelectedNode.IsConnected("FinishedMovement", this, "_on_Player_FinishedMovement"))
        {
            _currentSelectedNode.Disconnect("FinishedMovement", this, "_on_Player_FinishedMovement");
        }

        _currentSelectedNode = node;

        _currentSelectedNode.Connect("FinishedMovement", this, "_on_Player_FinishedMovement");

        if (node is Player player)
        {
            var position = player.GetGridPosition();
            _on_Player_FinishedMovement(position.Column, position.Row, player.GetDirection());
        }
    }
        /// <summary>
        /// Handle new instances
        /// </summary>
        /// <param name="node"></param>
        private void OnInstanceCreated(Node node)
        {
            Node2D target = node as Node2D;

            target.Position        = Position;
            target.RotationDegrees = RotationDegrees;
            target.Scale           = Scale;

            Instances.Add(target);
            target.Connect(nameof(EnemyController.NodeDeleted), this, nameof(OnNodeDeleted));

            if (TargetInstance == null)
            {
                GetParent().CallDeferred("add_child", target);
            }
            else
            {
                GetNode(TargetInstance).CallDeferred("add_child", target);
            }
        }