unit

package
v0.0.0-...-526c457 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Building

type Building struct {
	UnitName     string  `network:"sync"`
	Health       int     `network:"sync"`
	Construction float32 `network:"sync"`
	// contains filtered or unexported fields
}

func NewBuilding

func NewBuilding(name string, cfg *BuildingConfig, res *resource.Resources, pal color.Palette) *Building

func (*Building) Bounds

func (b *Building) Bounds() image.Rectangle

func (*Building) Id

func (b *Building) Id() uint64

func (*Building) Name

func (b *Building) Name() string

func (*Building) Position

func (b *Building) Position() image.Point

func (*Building) Render

func (b *Building) Render(renderer platform.Renderer, cameraPos image.Point) error

func (*Building) SetPosition

func (b *Building) SetPosition(pt image.Point)

func (*Building) SetTilePosition

func (b *Building) SetTilePosition(pt image.Point)

func (*Building) Type

func (b *Building) Type() UnitType

func (*Building) Update

func (b *Building) Update() error

type BuildingConfig

type BuildingConfig struct {
	Size int
	BuildingSprite,
	ConstructionSprite string
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(res *resource.Resources, terrainPal color.Palette) *Manager

func (*Manager) AllUnits

func (mgr *Manager) AllUnits() []Unit

func (*Manager) Render

func (mgr *Manager) Render(renderer platform.Renderer, vp image.Rectangle, cameraPos image.Point) error

func (*Manager) SpawnBuilding

func (mgr *Manager) SpawnBuilding(name string, pos image.Point) Unit

type Unit

type Unit interface {
	Id() uint64
	Type() UnitType
	Name() string
	SetPosition(pt image.Point)
	Position() image.Point
	Bounds() image.Rectangle
	Update() error
	Render(renderer platform.Renderer, cameraPos image.Point) error
}

type UnitConfigs

type UnitConfigs struct {
	Buildings map[string]BuildingConfig
}

type UnitType

type UnitType int
const (
	BuildingType UnitType = iota
	CreatureType
	GoldMineType
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL