void SpawnBall() { ball = (Ball)ballScene.Instance(); mainPath.AddChild(ball); if (ball.colors != spawnBallColor) { spawnBallColor = ball.colors; sameColorCount = 1; } else { sameColorCount++; } if (sameColorCount >= 3 && ball.colors == spawnBallColor) { mainPath.RemoveChild(ball); ball.QueueFree(); SpawnBall(); } else if (sameColorCount < 3) { ball.Offset = 0; ball.Connect("endMainPath", this, nameof(_on_Ball_endMainPath)); ball.Connect("reachEnd", this, nameof(_on_Ball_reachEnd)); GD.Print("ball_color : " + ball.colors); GD.Print("color : " + spawnBallColor); GD.Print("count : " + sameColorCount); } }
private void GenerateAlien1() { now = 0; alienSpeed = 20.0f; for (int i = 0; i < NUM_FOLLOWERS; i++) { var pathFollower = new PathFollow2D { Loop = false, Rotate = false }; var alien = (Alien)alien1.Instance(); alien.Died += OnAlienDied; alien.ReachedHome += OnAlienReachedHome; pathFollower.AddChild(alien); path2d.AddChild(pathFollower); pathFollowers[i] = pathFollower; } }
// Member variables here, example: // private int a = 2; // private string b = "textvar"; public override void _Ready() { _bullet = (Bullet)Bullet.Instance(); _bill = GetNode <Sprite>("Bill"); _ben = GetNode <Sprite>("Ben"); _path = GetNode <Path2D>("Path2D"); _follow = new PathFollow2D(); _follow.AddChild(_bullet); _path.Curve = CreatePath(_ben.GlobalPosition, _bill.GlobalPosition); _path.AddChild(_follow); _path.Visible = true; }
public override void _Pressed() { base._Pressed(); counter++; BeaconControl beaconControlInstance = (BeaconControl)beaconControlScene.Instance(); Beacon beacon = (Beacon)beaconScene.Instance(); sliders.AddChild(beaconControlInstance); beaconTrack.AddChild(beacon); beacon.BeaconId = counter; beaconControlInstance.Link(beacon); }
private void EnemySpawner() //Places an enemy every two seconds { enemyCounter += 1; if (enemyCounter <= maxEnemyNumber) { Path2D enemyPath = (Path2D)GetNode("Path2D"); PackedScene enemy = (PackedScene)ResourceLoader.Load("res://Scenes/Enemy.tscn"); var Enemy = enemy.Instance(); enemyPath.AddChild(Enemy); //GD.Print(enemyCounter); } }
private void _on_Shooter_Shoot(Curve2D curve, PackedScene bullet) { var b = (TestBullet2)bullet.Instance(); _path.Curve = curve; PathFollow2D follow = new PathFollow2D(); follow.SetOffset(10); follow.AddChild(b); b.Position = new Vector2(); _path.AddChild(follow); _path.Visible = true; follow.Show(); GD.Print("shoot"); }
public override void _Pressed() { base._Pressed(); counter++; var batonInstance = (Baton)baton.Instance(); var batonControlInstance = (BatonControl)slider.Instance(); sliders.AddChild(batonControlInstance); track.AddChild(batonInstance); batonInstance.Name = $"Baton{counter}"; batonInstance.SetLabel(counter.ToString()); batonInstance.batonId = counter; GD.Print(batonControlInstance); batonControlInstance.Link(batonInstance); }
void SpawnBall(Sides _side) { ball = (Ball)ballScene.Instance(); sides = _side; if (sides == Sides.Left) { mainPathLeft.AddChild(ball); if (ball.colors != spawnBallColorLeft) { spawnBallColorLeft = ball.colors; sameColorCOuntLeft = 1; } else { sameColorCOuntLeft++; } if (sameColorCOuntLeft >= 3 && ball.colors == spawnBallColorLeft) { mainPathLeft.RemoveChild(ball); ball.QueueFree(); SpawnBall(Sides.Left); } else if (sameColorCOuntLeft < 3) { ball.Connect("endMainPathLeft", this, nameof(_on_Ball_endMainPathLeft)); ball.Connect("reachEnd", this, nameof(_on_Ball_reachEnd)); ball.Offset = 0; } } else { mainPathRight.AddChild(ball); if (ball.colors != spawnBallColorRight) { spawnBallColorRight = ball.colors; sameColorCOuntRight = 1; } else { sameColorCOuntRight++; } if (sameColorCOuntRight >= 3 && ball.colors == spawnBallColorRight) { mainPathRight.RemoveChild(ball); ball.QueueFree(); SpawnBall(Sides.Right); } else if (sameColorCOuntRight < 3) { ball.Connect("endMainPathRight", this, nameof(_on_Ball_endMainPathRight)); ball.Connect("reachEnd", this, nameof(_on_Ball_reachEnd)); ball.Offset = 0; } } // ball.Connect("reachEnd", this, nameof(_on_Ball_reachEnd)); // ball.Offset = 0; // GD.Print("ball_color : " + ball.colors); // GD.Print("color : " + spawnBallColor); // GD.Print("count : " + sameColorCount); }