_map

package
v0.0.0-...-54eea7a Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anomalies

type Anomalies struct {
	ID     int    `json:"id"`
	X      int    `json:"x"`
	Y      int    `json:"y"`
	Radius int    `json:"radius"`
	Type   string `json:"type"`
	Power  int    `json:"power"`
}

type Beam

type Beam struct {
	ID     int    `json:"id"`
	XStart int    `json:"x_start"`
	YStart int    `json:"y_start"`
	XEnd   int    `json:"x_end"`
	YEnd   int    `json:"y_end"`
	Color  string `json:"color"`
}

type Emitter

type Emitter struct {
	ID            int    `json:"id"`
	X             int    `json:"x"`
	Y             int    `json:"y"`
	MinScale      int    `json:"min_scale"`
	MaxScale      int    `json:"max_scale"`
	MinSpeed      int    `json:"min_speed"`
	MaxSpeed      int    `json:"max_speed"`
	TTL           int    `json:"ttl"`
	Width         int    `json:"width"`
	Height        int    `json:"height"`
	Color         string `json:"color"`
	Frequency     int    `json:"frequency"`
	MinAlpha      int    `json:"min_alpha"`
	MaxAlpha      int    `json:"max_alpha"`
	Animate       bool   `json:"animate"`
	AnimateSpeed  int    `json:"animate_speed"`
	NameParticle  string `json:"name_particle"`
	AlphaLoopTime int    `json:"alpha_loop_time"`
	Yoyo          bool   `json:"yoyo"`
}
type Link struct {
	Zone   *Zone   `json:"zone"`
	Region *Region `json:"region"`
	FromX  int     `json:"from_x"`
	FromY  int     `json:"from_y"`
	ToX    int     `json:"to_x"`
	ToY    int     `json:"to_y"`
}

func (*Link) GetGlobalKey

func (l *Link) GetGlobalKey() string

type Map

type Map struct {
	Id            int `json:"id"`
	Name          string
	XSize         int
	YSize         int
	DefaultLevel  int
	Specification string

	// интерактивные координаты на карте, типо телепорты, выхода с баз, заходы на базы и тд
	OneLayerMap map[int]map[int]*coordinate.Coordinate

	Reservoir map[int]map[int]*resource.Map `json:"-"`
	// текстуры земли
	Flore map[int]map[int]*dynamic_map_object.Flore `json:"flore"`
	// все обьекты у которых нет поведения находятся в карте OneLayerMap, дороги, горы, базы.
	// Игрок видит эти обьекты всегда независимо от радара/обзора
	StaticObjects map[int]map[int]*dynamic_map_object.Object `json:"static_objects"`
	// в матрице DynamicObjects находятся обьекты которые могут передвигатся/уничтожатся/рождатся
	// тоесть это обьекты с поведением, игрок их видит и запоминает последнее их состояние у себя.
	// Игрок не видит если с обьектов что либо произошло вне поле его зрения.
	DynamicObjects      map[int]map[int]*dynamic_map_object.Object `json:"-"`
	DynamicObjectsMX    sync.Mutex                                 `json:"dynamic_objects_mx"`
	Global              bool                                       `json:"global"`
	HandlersCoordinates []*coordinate.Coordinate                   `json:"handlers_coordinates"`
	EntryPoints         []*coordinate.Coordinate                   `json:"entry_points"`
	Beams               []*Beam                                    `json:"beams"`
	Emitters            []*Emitter                                 `json:"emitters"`
	GeoData             []*obstacle_point.ObstaclePoint            `json:"geo_data"`

	// разделяем карту на зоны (DiscreteSize х DiscreteSize) при загрузке сервера,
	// добавляем в зону все поинты которые пересекают данных квадрат и ближайшие к нему
	// когда надо найти колизию с юнитом делем его полизию на 100 и отбрасываем дровь так мы получим зону
	// например положение юнита 55/DiscreteSize:77/DiscreteSize = зона 0:0, 257/DiscreteSize:400/DiscreteSize = 1:1, 1654/DiscreteSize:2340/DiscreteSize = 6:9
	// и смотрим только те точки которые находятся в данной зоне
	GeoZones [][]*Zone `json:"-"`

	Anomalies []*Anomalies `json:"anomalies"`

	// показывает позицию на карте мира, пока используется ради меню карты на фронте
	XGlobal int `json:"x_global"`
	YGlobal int `json:"y_global"`

	Fraction       string `json:"fraction"`
	PossibleBattle bool   `json:"possible_battle"`
}

func (*Map) AddCoordinate

func (mp *Map) AddCoordinate(newCoordinate *coordinate.Coordinate)

func (*Map) AddDynamicObject

func (mp *Map) AddDynamicObject(object *dynamic_map_object.Object)

func (*Map) AddResourceInMap

func (mp *Map) AddResourceInMap(reservoir *resource.Map)

func (*Map) DeleteCoordinate

func (mp *Map) DeleteCoordinate(x, y int)

func (*Map) GetAllEntrySectors

func (mp *Map) GetAllEntrySectors() []*coordinate.Coordinate

func (*Map) GetCoordinate

func (mp *Map) GetCoordinate(x, y int) (*coordinate.Coordinate, bool)

func (*Map) GetCopyMapDynamicObjects

func (mp *Map) GetCopyMapDynamicObjects() map[int]map[int]*dynamic_map_object.Object

func (*Map) GetDynamicObjects

func (mp *Map) GetDynamicObjects(x, y int) *dynamic_map_object.Object

func (*Map) GetDynamicObjectsByID

func (mp *Map) GetDynamicObjectsByID(id int) *dynamic_map_object.Object

func (*Map) GetEntryBase

func (mp *Map) GetEntryBase(baseID int) *coordinate.Coordinate

func (*Map) GetEntryTySector

func (mp *Map) GetEntryTySector(sectorID int) *coordinate.Coordinate

TODO надо переписать на интерфейсы

func (*Map) GetMaxPriorityObject

func (mp *Map) GetMaxPriorityObject() int

func (*Map) GetMaxPriorityTexture

func (mp *Map) GetMaxPriorityTexture() int

TODO GetMaxPriorityTexture, GetMaxPriorityObject близнецы

func (*Map) GetRandomEntryBase

func (mp *Map) GetRandomEntryBase() *coordinate.Coordinate

func (*Map) GetRandomEntrySector

func (mp *Map) GetRandomEntrySector() *coordinate.Coordinate

func (*Map) GetResource

func (mp *Map) GetResource(x, y int) *resource.Map

func (*Map) GetShortInfoMap

func (mp *Map) GetShortInfoMap() *ShortInfoMap

func (*Map) RemoveDynamicObject

func (mp *Map) RemoveDynamicObject(object *dynamic_map_object.Object)

func (*Map) RemoveDynamicObjectByXY

func (mp *Map) RemoveDynamicObjectByXY(x, y int)

func (*Map) SetXYSize

func (mp *Map) SetXYSize(Scale int) (int, int)

type Region

type Region struct {
	Index       int                                    `json:"index"`
	Cells       map[int]map[int]*coordinate.Coordinate `json:"cells"`        // координаты принадлежащие району
	GlobalLinks map[string]*Link                       `json:"global_links"` // уникальные зоны
	Links       []*Link                                `json:"links"`        // зоны в которые можно пройти из этого региона по каждой клетке
	Zone        *Zone                                  `json:"zone"`         // что бы каждый регион знал своего родителя
}

func (*Region) GetKey

func (r *Region) GetKey() string

type ShortInfoMap

type ShortInfoMap struct {
	Id                  int `json:"id"`
	Name                string
	QSize               int
	RSize               int
	Specification       string
	Global              bool                     `json:"global"`
	HandlersCoordinates []*coordinate.Coordinate `json:"handlers_coordinates"`
	XGlobal             int                      `json:"x_global"`
	YGlobal             int                      `json:"y_global"`
	Fraction            string                   `json:"fraction"`
	PossibleBattle      bool                     `json:"possible_battle"`
}

func (*ShortInfoMap) GetAllEntrySectors

func (mp *ShortInfoMap) GetAllEntrySectors() []*coordinate.Coordinate

func (*ShortInfoMap) GetEntryTySector

func (mp *ShortInfoMap) GetEntryTySector(sectorID int) *coordinate.Coordinate

type Zone

type Zone struct {
	Size      int                             `json:"size"`
	DiscreteX int                             `json:"discrete_x"`
	DiscreteY int                             `json:"discrete_y"`
	Obstacle  []*obstacle_point.ObstaclePoint `json:"obstacle"`
	Regions   []*Region                       `json:"regions"`
	Cells     []*coordinate.Coordinate        `json:"cells"` // все координаты в зоне
}

func (*Zone) GetKey

func (z *Zone) GetKey() string

func (*Zone) GetNeighboursZone

func (z *Zone) GetNeighboursZone(mp *Map) []*Zone

func (*Zone) GetRegionsByXY

func (z *Zone) GetRegionsByXY(x, y int) *Region

Jump to

Keyboard shortcuts

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