-
Notifications
You must be signed in to change notification settings - Fork 0
/
level.go
47 lines (36 loc) · 1.03 KB
/
level.go
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
package main
import (
"github.com/autovelop/playthos"
"github.com/autovelop/playthos/std"
)
type Level struct {
completed bool
cameraPos *std.Vector3
enemies []*engine.Entity
}
func (l *Level) SetCameraPosition(c *std.Vector3) {
l.cameraPos = c
}
func (l *Level) Completed() bool {
return l.completed
}
func (l *Level) SetCompleted(c bool) {
l.completed = c
if c {
for _, e := range l.enemies {
es := e.Component(&EnemyState{}).(*EnemyState)
es.StopPatrol()
}
}
}
func (l *Level) AddEnemies(e ...*engine.Entity) {
l.enemies = append(l.enemies, e...)
}
func (l *Level) Load(p *PlayerState) {
cTransform := p.Camera().Component(&std.Transform{}).(*std.Transform)
pTransform := p.Player().Component(&std.Transform{}).(*std.Transform)
pTransform.SetPosition(l.cameraPos.X-120, pTransform.Position().Y, pTransform.Position().Z)
cTransform.SetPosition(l.cameraPos.X, l.cameraPos.Y, 3)
cTransform.SetRotation(l.cameraPos.X, l.cameraPos.Y, 0)
// tMaterial := p.Terrain().Component(&render.Material{}).(*render.Material)
}