-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cs
More file actions
48 lines (42 loc) · 1.31 KB
/
Copy pathGame.cs
File metadata and controls
48 lines (42 loc) · 1.31 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
using Godot;
using System;
public class Game : Spatial
{
// Declare member variables here. Examples:
// private int a = 2;
// private string b = "text";
// Called when the node enters the scene tree for the first time.
Camera PlayerCam;
PackedScene PolarBearScene;
public override void _Ready()
{
PolarBearScene = (PackedScene)ResourceLoader.Load("res://PolarBear.tscn");
PlayerCam = GetNode<Camera>("PolarBear/Camera");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(float delta)
{
if (Input.IsActionJustReleased("camSwitch"))
{
PlayerCam.Current = !PlayerCam.Current;
}
}
public void _on_BearChecker_timeout()
{
var bear = 0;
for (int i = 0; i < GetChildCount(); i++)
{
if (GetChild(i).Name.Contains("PolarBear"))
{
bear++;
}
}
if (bear < 1)
{
GD.Print("Bear spawned");
var polarBearInstance = PolarBearScene.Instance<PolarBear>();
polarBearInstance.Translation = new Vector3(polarBearInstance.Translation.x, 20, polarBearInstance.Translation.y);
CallDeferred("add_child", polarBearInstance);
}
}
}