用lua写的小游戏,主要玩法是点击进行采矿并和怪物搏斗等操作,人物属性有体力,血量,恢复,攻击,防御
采矿可以挖到金币和经验,打怪升级最后决战boss赢取胜利,升级可以获得技能点增加属性,还有老虎机系统等外围系统
首先说下小怪和矿的配置格式和需要用到的参数读取函数:
local sz = CCDirector:sharedDirector():getVisibleSize()
local BonusType = CreateEnumTable({"MINE", "ENEMY", "SYSTEM", "BOSS"})
local KeyType = CreateEnumTable({"IRON", "SILVER", "GOLD"})
local SysType = CreateEnumTable({"AACT", "AATK", "ADEF", "AKEY", "ADOT", "ROCK"})
local gameConfig = {
initBattleData = {
active = 50, -- 体力
hp = 100, -- 生命
recover = 10, -- 恢复
atk = 10, -- 攻击
def = 10, -- 防御
},
bonus = {
{
types = BonusType.MINE,
width = 39,
height = 15,
pos = ccp(10, 269),
curlife = 0,
digged = false,
},
{
types = BonusType.ENEMY,
width = 30,
height = 30,
pos = ccp(10, 235),
curlife = 0,
digged = false,
},
{
types = BonusType.SYSTEM,
width = 48,
height = 48,
pos = ccp(10, 104),
sys = SysType.ADOT,
color = "lightyellow",
cost = {200,400,1000,1600,2400,3600,5000,6400,8000,10000},
curst = 1,
},
{
types = BonusType.SYSTEM,
width = 59,
height = 47,
pos = ccp(174, 252),
sys = SysType.AATK,
color = "lightyellow",
cost = {200,400,1000,1600,2400,3600,5000,6400,8000,10000},
curst = 1,
},
{
types = BonusType.SYSTEM,
width = 80,
height = 81,
pos = ccp(439, 203),
sys = SysType.ROCK,
color = "darkyellow",
cost = {200},
result = {0,0,0},
curst = 0,
},
},
}
function getUserMaxExp(level)
return math.ceil(level/3)*100
end
function getInitBattleData()
return gameConfig.initBattleData
end
function getLevelUpAddSkillDot(level)
return math.ceil(level/5)*5
end
function countBarScaleX(scale, hpAndActivePercent)
if hpAndActivePercent then
return math.min(1, math.max(0.02, scale)) * math.min(1, math.max(0.5, hpAndActivePercent))
else
return math.min(1, math.max(0.01, scale))
end
end
function getBonusListInfo()
return gameConfig.bonus
end
function getMineActivendRecover(width, height)
local area = width*height
local lenght = width+height
local cost = math.floor(area/50)
if cost >= width/3 then cost = math.floor(width/5) end
local cover = math.ceil(height/5) - 2
if cost <= 1.5*cover then cover = cost end
local mineData = {
life = width,
recover = cover,
digMoney = math.floor(area/2),
digExp = math.floor(area/2),
clickMoney = math.floor(area/20),
clickCost = cost,
}
return mineData
end
function getEnemyLifeAndRecover(width, height)
local area = width*height
local lenght = width+height
local enemyData = {
life = width,
atk = math.ceil(lenght/3),
def = math.ceil(lenght/10),
recover = math.ceil(height/5) - 2,
digMoney = math.floor(area/4),
digExp = math.floor(area/1),
}
return enemyData
end
下面的函数主要是不同等级的经验、技能点等属性的计算,和小怪、矿的属性计算,主要根据方块的长宽进行计算
下一节介绍玩家的等级等信息的更新方法