Documentation
¶
Index ¶
- Constants
- Variables
- func GetBulletImg(btType BulletType, diameter int) *ebiten.Image
- func GetImgWidth(btName string, btType BulletType, diameter int) int
- func GetShipCost(name string) (fundsCost int64, timeCost int64)
- func GetShipDesc(name string) []string
- func GetShipDisplayName(name string) string
- type BattleShip
- func (s *BattleShip) CanOnLand() bool
- func (s *BattleShip) DisableWeapon(t WeaponType)
- func (s *BattleShip) EnableWeapon(t WeaponType)
- func (s *BattleShip) Fire(enemy *BattleShip) []*Bullet
- func (s *BattleShip) GenTrails() []*Trail
- func (s *BattleShip) HurtBy(bullet *Bullet)
- func (s *BattleShip) MoveTo(mapCfg *mapcfg.MapCfg, targetPos MapPos, nearGoal bool) (arrive bool)
- type Bullet
- type BulletShotType
- type BulletType
- type CriticalType
- type FiringArc
- type GroupID
- type Gun
- type HitObjectType
- type LoadingOilShip
- type MapPos
- func (p *MapPos) AddMx(mx int)
- func (p *MapPos) AddMy(my int)
- func (p *MapPos) AddRx(rx float64)
- func (p *MapPos) AddRy(ry float64)
- func (p *MapPos) AssignMxy(mx, my int)
- func (p *MapPos) AssignRxy(rx, ry float64)
- func (p *MapPos) Copy() MapPos
- func (p *MapPos) EnsureBorder(borderX, borderY float64)
- func (p *MapPos) MEqual(other MapPos) bool
- func (p *MapPos) Near(other MapPos, distance float64) bool
- func (p *MapPos) OnBorder(borderX, borderY float64) bool
- func (p *MapPos) String() string
- func (p *MapPos) SubMx(mx int)
- func (p *MapPos) SubMy(my int)
- func (p *MapPos) SubRx(rx float64)
- func (p *MapPos) SubRy(ry float64)
- type Mark
- type MarkID
- type OilPlatform
- type OncomingShip
- type ReinforcePoint
- type ShipType
- type ShipUidGenerator
- type TorpedoLauncher
- type Trail
- type Weapon
- type WeaponMetadata
- type WeaponType
Constants ¶
View Source
const ( GroupID0 = iota GroupID1 GroupID2 GroupID3 GroupID4 GroupID5 GroupID6 GroupID7 GroupID8 GroupID9 GroupIDNone )
View Source
const ( // 顺时针 RotateFlagClockwise = 1 // 逆时针 RotateFlagAnticlockwise = -1 )
Variables ¶
View Source
var BulletImgWidthMap = map[string]int{}
Functions ¶
func GetBulletImg ¶
func GetBulletImg(btType BulletType, diameter int) *ebiten.Image
GetBulletImg 获取弹药图片
func GetImgWidth ¶
func GetImgWidth(btName string, btType BulletType, diameter int) int
GetImgWidth 获取弹药图片宽度(虽然可能价值不大,总之先加一点缓存 :)
func GetShipCost ¶
GetShipCost 获取战舰成本
Types ¶
type BattleShip ¶
type BattleShip struct { // 名称 Name string `json:"name"` // 展示用名称 DisplayName string `json:"displayName"` // 类别 Type ShipType `json:"type"` // 类别缩写 TypeAbbr string `json:"typeAbbr"` // 描述 Description []string `json:"description"` // 初始生命值 TotalHP float64 `json:"totalHP"` // 水平伤害减免(0.7 -> 仅受到击中的 70% 伤害) HorizontalDamageReduction float64 `json:"horizontalDamageReduction"` // 垂直伤害减免 VerticalDamageReduction float64 `json:"verticalDamageReduction"` // 最大速度 MaxSpeed float64 `json:"maxSpeed"` // 加速度 Acceleration float64 `json:"acceleration"` // 转向速度(度) RotateSpeed float64 `json:"rotateSpeed"` // 战舰长度 Length float64 `json:"length"` // 战舰宽度 Width float64 `json:"width"` // 造价 FundsCost int64 `json:"fundsCost"` // 耗时 TimeCost int64 `json:"timeCost"` // 吨位 Tonnage float64 `json:"tonnage"` // 武器 Weapon Weapon `json:"weapon"` // 唯一标识 Uid string // 当前生命值 CurHP float64 // 当前位置 CurPos MapPos // 旋转角度 CurRotation float64 // 当前速度 CurSpeed float64 // 分组ID GroupID GroupID // 所属阵营(玩家) BelongPlayer faction.Player }
BattleShip 战舰
func NewShip ¶
func NewShip( uidGenerator *ShipUidGenerator, name string, pos MapPos, rotation float64, player faction.Player, ) *BattleShip
NewShip 新建战舰
func (*BattleShip) DisableWeapon ¶
func (s *BattleShip) DisableWeapon(t WeaponType)
DisableWeapon 禁用武器
type Bullet ¶
type Bullet struct { // 弹药名称 Name string `json:"name"` // 弹药类型 Type BulletType `json:"type"` // 口径 Diameter int `json:"diameter"` // 伤害数值 Damage float64 `json:"damage"` // 暴击概率(理论上口径越大越容易被暴击,但是暴击率不应该太高) CriticalRate float64 `json:"criticalRate"` // 生命(前进太多要消亡) Life int // 唯一标识 Uid string // 当前位置 CurPos MapPos // 目标位置 TargetPos MapPos // 旋转角度 Rotation float64 // 速度 Speed float64 // 射击方式 ShotType BulletShotType // 前进周期数 ForwardAge int // 所属战舰 BelongShip string // 所属阵营(玩家) BelongPlayer faction.Player // 实际造成的伤害 RealDamage float64 // 造成暴击类型 CriticalType CriticalType // 击中的对象类型 HitObjectType HitObjectType }
火炮 / 鱼雷弹药
type BulletShotType ¶
type BulletShotType int
const ( // BulletShotTypeDirect 直射 BulletShotTypeDirect BulletShotType = iota // BulletShotTypeArcing 曲射(抛物线射击) BulletShotTypeArcing )
type BulletType ¶
type BulletType string
const ( // BulletTypeShell 火炮炮弹 BulletTypeShell BulletType = "shell" // BulletTypeTorpedo 鱼雷 BulletTypeTorpedo BulletType = "torpedo" )
type CriticalType ¶
type CriticalType int
const ( // CriticalTypeNone 没有暴击 CriticalTypeNone CriticalType = iota // CriticalTypeThreeTimes 三倍暴击 CriticalTypeThreeTimes // CriticalTypeTenTimes 十倍暴击 CriticalTypeTenTimes )
type Gun ¶
type Gun struct { // 火炮名称 Name string `json:"name"` // 炮弹类型 BulletName string `json:"bulletName"` // 单次抛射炮弹数量 BulletCount int `json:"bulletCount"` // 装填时间(单位: s) ReloadTime float64 `json:"reloadTime"` // 射程 Range float64 `json:"range"` // 炮弹散布 BulletSpread int `json:"bulletSpread"` // 炮弹速度 BulletSpeed float64 `json:"bulletSpeed"` // 相对位置 // 0.35 -> 从中心往舰首 35% 舰体长度 // -0.3 -> 从中心往舰尾 30% 舰体长度 PosPercent float64 // 左射界 (180, 360] LeftFiringArc FiringArc // 右射界 (0, 180] RightFiringArc FiringArc // 当前火炮是否可用(如战损 / 禁用) Disable bool // 装填开始时间(毫秒时间戳) ReloadStartAt int64 }
Gun 火炮
type HitObjectType ¶
type HitObjectType int
const ( // HitObjectTypeNone 无 HitObjectTypeNone HitObjectType = iota // HitObjectTypeShip 战舰 HitObjectTypeShip // HitObjectTypeWater 水面 HitObjectTypeWater // HitObjectTypeLand 陆地 HitObjectTypeLand )
type LoadingOilShip ¶
type LoadingOilShip struct { CurPos MapPos // 资金产量 FundYield int // 装载耗时 TimeCost int64 // 开始的时间戳 StartedAt int64 // 进度 Progress float64 }
LoadingOilShip 装载石油的货轮
type MapPos ¶
MapPos 位置
func (*MapPos) EnsureBorder ¶
EnsureBorder 边界检查
type OilPlatform ¶
type OilPlatform struct { Uid string Pos MapPos Radius int Yield int LoadingOilShips map[string]*LoadingOilShip }
OilPlatform 油井
func NewOilPlatform ¶
func NewOilPlatform(pos MapPos, radius int, yield int) *OilPlatform
NewOilPlatform ...
type OncomingShip ¶
type OncomingShip struct { Name string FundsCost int64 TimeCost int64 // 开始的时间戳 StartedAt int64 // 进度 Progress float64 }
OncomingShip 增援中的战舰
type ReinforcePoint ¶
type ReinforcePoint struct { Uid string Pos MapPos Rotation float64 // 集结点 FIXME 支持自定义集结点 RallyPos MapPos // 所属阵营(玩家) BelongPlayer faction.Player // 当前被选中的战舰索引 CurSelectedShipIndex int // 提供的战舰类型 ProvidedShipNames []string // 最大增援进度数量 MaxOncomingShip int // 增援进度 OncomingShips []*OncomingShip }
ReinforcePoint 增援点
func NewReinforcePoint ¶
func NewReinforcePoint( pos MapPos, rotation float64, rallyPos MapPos, belongPlayer faction.Player, maxOncomingShip int, providedShipNames []string, ) *ReinforcePoint
NewReinforcePoint ...
func (*ReinforcePoint) Update ¶
func (p *ReinforcePoint) Update( shipUidGenerator *ShipUidGenerator, curFunds int64, ) *BattleShip
Update ...
type ShipType ¶
type ShipType string
const ( // ShipTypeDefault 默认 ShipTypeDefault ShipType = "default" // ShipTypeBattleShip 战列舰 ShipTypeBattleShip ShipType = "battleship" // ShipTypeCruiser 巡洋舰 ShipTypeCruiser ShipType = "cruiser" // ShipTypeDestroyer 驱逐舰 ShipTypeDestroyer ShipType = "destroyer" // ShipTypeTorpedoBoat 鱼雷艇 ShipTypeTorpedoBoat ShipType = "torpedo_boat" // ShipTypeCargo 货轮 ShipTypeCargo ShipType = "cargo" )
type ShipUidGenerator ¶
type ShipUidGenerator struct {
// contains filtered or unexported fields
}
ShipUidGenerator 战舰 Uid 生成器
func NewShipUidGenerator ¶
func NewShipUidGenerator(player faction.Player) *ShipUidGenerator
NewShipUidGenerator ...
type TorpedoLauncher ¶
type TorpedoLauncher struct { // 发射器名称 Name string `json:"name"` // 鱼雷类型 BulletName string `json:"bulletName"` // 鱼雷数量 BulletCount int `json:"bulletCount"` // 发射间隔(单位: s) ShotInterval float64 `json:"shotInterval"` // 装填时间(单位: s) ReloadTime float64 `json:"reloadTime"` // 射程 Range float64 `json:"range"` // 鱼雷速度 BulletSpeed float64 `json:"bulletSpeed"` // 相对位置 // 0.35 -> 从中心往舰首 35% 舰体长度 // -0.3 -> 从中心往舰尾 30% 舰体长度 PosPercent float64 // 左射界 (180, 360] LeftFiringArc FiringArc // 右射界 (0, 180] RightFiringArc FiringArc // 动态参数 // 当前鱼雷是否可用(如战损 / 禁用) Disable bool // 开始装填时间(时间戳) ReloadStartAt int64 // 最近发射时间(时间戳) LatestFireAt int64 // 本次装填鱼雷已发射数量 ShotCountBeforeReload int }
func (*TorpedoLauncher) CanFire ¶
func (lc *TorpedoLauncher) CanFire(shipCurRotation float64, curPos, targetPos MapPos) bool
CanFire 是否可发射
func (*TorpedoLauncher) Fire ¶
func (lc *TorpedoLauncher) Fire(ship, enemy *BattleShip) []*Bullet
Fire 发射
func (*TorpedoLauncher) Reloaded ¶
func (lc *TorpedoLauncher) Reloaded() bool
Reloaded 是否在重新装填 / 发射间隔
type Trail ¶
type Trail struct { Pos MapPos Shape textureImg.TrailShape // 当前尺寸 & 尺寸扩散速度 CurSize float64 DiffusionRate float64 // 当前生命值 & 生命值衰减速度 CurLife float64 LifeReductionRate float64 // 延迟时间 Delay float64 // 旋转角度 Rotation float64 // 颜色(nil 为默认白色) Color color.Color }
Trail 尾流(战舰,鱼雷,炮弹)
type Weapon ¶
type Weapon struct { // 主炮元数据 MainGunsMD []WeaponMetadata `json:"mainGuns"` // 副炮元数据 SecondaryGunsMD []WeaponMetadata `json:"secondaryGuns"` // 鱼雷元数据 TorpedoesMD []WeaponMetadata `json:"torpedoes"` // 主炮 MainGuns []*Gun // 副炮 SecondaryGuns []*Gun // 鱼雷 Torpedoes []*TorpedoLauncher // 最大射程(各类武器射程最大值) MaxRange float64 // 拥有的武器情况 HasMainGun bool HasSecondaryGun bool HasTorpedo bool // 武器禁用情况 MainGunDisabled bool SecondaryGunDisabled bool TorpedoDisabled bool }
Weapon 武器系统
func (*Weapon) SecondaryGunReloaded ¶
SecondaryGunReloaded 副炮是否已装填
func (*Weapon) TorpedoLauncherReloaded ¶
TorpedoLauncherReloaded 鱼雷是否已装填
type WeaponMetadata ¶
type WeaponType ¶
type WeaponType string
const ( // 所有 WeaponTypeAll WeaponType = "all" // 主炮 WeaponTypeMainGun WeaponType = "mainGun" // 副炮 WeaponTypeSecondaryGun WeaponType = "secondaryGun" // 鱼雷 WeaponTypeTorpedo WeaponType = "torpedo" // 导弹 WeaponTypeMissile WeaponType = "missile" )
Click to show internal directories.
Click to hide internal directories.