骑老登游戏开发笔记
  • 介绍
  • 魔兽地图开发笔记
    • 介绍
    • 数据格式
    • 英雄经验值公式
    • 常规制图
      • 修改特效角度
      • 禁止单位攻击物品
      • 多重射击参数设置
      • 修改建筑建造速度
    • 内置Lua制图
      • 黑窗控制台
      • 获取对象物编数据
      • 技能冷却渲染机制
      • 异步计时器
      • UI异步行为转同步
      • UI界面显示与隐藏,菜单按钮的实现
    • 狼魂Lua框架
      • 控制台UI调整
      • 字符串转魔兽ID
      • 创建单位
      • 编辑自定义属性
    • 平台BUG
    • 效率工具
      • 模型批量改名
      • 装饰物物编生成
  • 魔兽Lua
    • 魔兽Lua/UI/基类
  • y3doc/uplib
    • y3doc/uplib/math
    • y3doc/uplib/particle
    • y3doc/uplib/lighting
    • y3doc/uplib/projectiles
    • y3doc/uplib/destructable
    • y3doc/uplib/timer
    • y3doc/uplib/selector
    • y3doc/uplib/ui
    • y3doc/uplib/point
    • y3doc/uplib/player
    • y3doc/uplib/unit
    • y3doc/uplib/item
    • y3doc/uplib/skill
    • y3doc/uplib/buff
  • 代码片段
Powered by GitBook
On this page
  • Code Pieces
  • A
  • Build Game Unit

代码片段

Code Pieces

pieces of code here.

A

Build Game Unit

local MainQuest = {}
MainQuest.Units = {}

local u_enemy = CreateUnit(uid, GetPlayerPoint(player, 'MainEnemyPoint'), 270, 'Enemy')

function GetPlayerPoint(player, label)
    local pid = player:GetID()
    if label == 'MainEnemyPoint' then
        return {{-512,0}, {512,0}, {0,512}, {0,-512}}[pid]
    end
end

function CreateUnit(uid, point, face, type)
    local unit = ... stuffs here ...
    Matrix.SetupUnitPower(u, type)
    return unit
end

function Matrix.CalcUnitPower(u, type)
    local info = {}
    if type == 'Enemy' then
        info.ATK = G_DIFFICULT * G_CHAPTER * 300
        info.DEF = G_DIFFICULT * G_CHAPTER * 50
        info.HP = G_DIFFICULT * 1000 + G_CHAPTER * 200
    end
    return info
end

function Matrix.AssignUnitPower(u, info)
    if info.ATK then u:SetAttr('ATK', info.ATK) end
    if info.DEF then u:SetAttr('DEF', info.DEF) end
    if info.HP then u:SetAttr('HP', info.HP) end
    if info.MP then u:SetAttr('MP', info.MP) end
    if info.SPD then u:SetAttr('SPD', info.SPD) end
    if info.RNG then u:SetAttr('RNG', info.RNG) end
    if info.SIGHT then u:SetAttr('SIGHT', info.SIGHT) end
end

function Matrix.SetupUnitPower(u, type)
    local info = Matrix.CalcUnitPower(u, type)
    Matrix.AssignUnitPower(info)
end
Previousy3doc/uplib/buff

Last updated 2 years ago