-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSceneManager.cs
More file actions
36 lines (32 loc) · 875 Bytes
/
SceneManager.cs
File metadata and controls
36 lines (32 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Godot;
using Godot.Collections;
using System;
using System.Linq;
public partial class SceneManager : Node2D
{
[Export]
public PackedScene PlayerScene;
private Array<Node> spawnPoints;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
spawnPoints = GetTree().GetNodesInGroup("SpawnPoint");
int index = 0;
// 1 2
// 2 1
foreach (var key in NakamaClient.Players.Keys.OrderBy(k => k))
{
var player = PlayerScene.Instantiate<CharacterController>();
player.Name = NakamaClient.Players[key].Id;
if(spawnPoints[index] is Node2D spawnpoint){
player.SetupPlayer(NakamaClient.Players[key].Id, spawnpoint.GlobalPosition);
}
AddChild(player);
index++;
}
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}