Skip to content

Commit

Permalink
修改细节,增加Mac和ios的库
Browse files Browse the repository at this point in the history
  • Loading branch information
imengyu committed May 1, 2022
1 parent e58883b commit b4a7437
Show file tree
Hide file tree
Showing 21 changed files with 184 additions and 76 deletions.
2 changes: 1 addition & 1 deletion Assets/BallancePhysics/Api/ApiStruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ internal void initAll(IntPtr apiArrayPtr, int len)
try {
get_version = Marshal.GetDelegateForFunctionPointer<fn_get_version>(apiArray[i++]);
} catch(Exception e) {
throw new Exception("[BallancePhysics] Failed to get native function, Maybe you choose the wrong way to use it. \nException: " + e.ToString());
throw new Exception("[BallancePhysics] Failed to get native function, Maybe system does not support it. \nException: " + e.ToString());
}

var v = get_version();
Expand Down
4 changes: 3 additions & 1 deletion Assets/BallancePhysics/PhysicsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ public static class PhysicsApi
{
#region 基础定义

#if UNITY_EDITOR
#if UNITY_EDITOR && UNITY_EDITOR_WIN
private const string DLL_NNAME = "bphysics_unity";
#elif UNITY_EDITOR
private const string DLL_NNAME = "bphysics";
#elif UNITY_IPHONE
private const string DLL_NNAME = "_Internal";
#else
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Assets/BallancePhysics/Plugins/x86_64/libbphysics.so
Binary file not shown.
8 changes: 4 additions & 4 deletions Assets/Game/Scripts/Data/GamePhysBall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ GamePhysBall = {
LinearDamp = 0.3,
RotDamp = 0.2,
},
PiecesMinForce = 1.0 * 2,
PiecesMaxForce = 1.9 * 2,
PiecesMinForce = 1.5,
PiecesMaxForce = 2.7,
UpForce = 0.6,
DownForce = 0.3,
BallRadius = 2,
Expand All @@ -78,8 +78,8 @@ GamePhysBall = {
LinearDamp = 0.3,
RotDamp = 0.2,
},
PiecesMinForce = 5,
PiecesMaxForce = 10,
PiecesMinForce = 8,
PiecesMaxForce = 15,
UpForce = 3,
DownForce = 0.05,
BallRadius = 2,
Expand Down
9 changes: 5 additions & 4 deletions Assets/Game/Scripts/GamePlay/BallManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function BallManager:Awake()
self._private.CommandId = Game.Manager.GameDebugCommandServer:RegisterCommand('balls', function (eyword, fullCmd, argsCount, args)
local type = args[1]
if type == 'play-lighting' then
self:PlayLighting(self._private.nextRecoverPos)
self:PlayLighting(self._private.nextRecoverPos, true, true, nil)
elseif type == 'set-recover-pos' then
local ox, nx = DebugUtils.CheckIntDebugParam(1, args, Slua.out, true, 0)
if not ox then return false end
Expand Down Expand Up @@ -367,6 +367,7 @@ function BallManager:SetCurrentBall(name, status)
local ball = self:GetRegisterBall(name)
if(ball == nil) then
GameErrorChecker.SetLastErrorAndLog(GameError.NotRegister, TAG, 'Ball {0} not register', { name })
return
end
if(self._private.currentBall ~= ball) then
self:_DeactiveCurrentBall()
Expand Down Expand Up @@ -421,7 +422,7 @@ end
---恢复摄像机相关移动
function BallManager:StartCamMove()
if GamePlay.CamManager.Target == nil then
GamePlay.CamManager:SetTarget(self._private.currentBall.ball.transform)
GamePlay.CamManager:SetTarget(self._private.currentBall.ball.transform, true)
end
end
---停止摄像机相关移动
Expand Down Expand Up @@ -518,9 +519,9 @@ function BallManager:_DeactiveCurrentBall()
end
end
function BallManager:_ActiveCurrentBall()
local current = self._private.currentActiveBall
local current = self._private.currentActiveBall ---@type BallRegStorage
if current == nil and self._private.currentBall ~= nil then
current = self._private.currentBall
current = self._private.currentBall---@type BallRegStorage
local currentTransform = current.ball.transform
self._private.currentActiveBall = self._private.currentBall
--设置阴影位置与父级约束
Expand Down
1 change: 1 addition & 0 deletions Assets/Game/Scripts/GamePlay/Balls/BallPaper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function BallPaper:new()
self._PaperPiecesSound = nil
self._HitSound.Names.All = 'core.sounds:Hit_Paper.wav'
self._RollSound.Names.All = 'core.sounds:Roll_Paper.wav'
self._RollSound.VolumeFactor = 0.1
self._RollSound.TimeDelayStart = 0.8
self._RollSound.TimeDelayEnd = 0.1
---自定义物理化碎片
Expand Down
2 changes: 1 addition & 1 deletion Assets/Game/Scripts/GamePlay/Balls/BallStone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function BallStone:new()
Stone = 'core.sounds:Roll_Stone_Stone.wav',
Wood = 'core.sounds:Roll_Stone_Wood.wav',
}
self._RollSound.VolumeFactor = 0.07
self._RollSound.VolumeFactor = 0.11
end

function CreateClass:BallStone()
Expand Down
2 changes: 1 addition & 1 deletion Assets/Game/Scripts/GamePlay/Balls/BallWood.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function BallWood:new()
Stone = 'core.sounds:Roll_Wood_Stone.wav',
Wood = 'core.sounds:Roll_Wood_Wood.wav',
}
self._RollSound.VolumeFactor = 0.06
self._RollSound.VolumeFactor = 0.09
end

function CreateClass:BallWood()
Expand Down
11 changes: 8 additions & 3 deletions Assets/Game/Scripts/GamePlay/CamManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,14 @@ function CamManager:SetCamLook(enable)
return self
end
---指定当前摄像机跟踪的目标
---@param target Transform
function CamManager:SetTarget(target)
self.Target = target
---@param target Transform 目标
---@param noUpdatePos boolean|nil 禁止设置目标时的位置同步
function CamManager:SetTarget(target, noUpdatePos)
if noUpdatePos then
self.CamFollow:SetTargetWithoutUpdatePos(target)
else
self.Target = target
end
self.CamFollow.Target = target
self.EventCamFollowTargetChanged:Emit(target)
return self
Expand Down
6 changes: 3 additions & 3 deletions Assets/Game/Scripts/GamePlay/GamePlayManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function GamePlayManager:_Start(isStartBySector, customerFn)
self._FirstStart = false
end

if type(customerFn) == 'function' then
if customerFn ~= nil and type(customerFn) == 'function' then
customerFn()
else
GamePlay.BallManager:SetControllingStatus(BallControlStatus.Control)
Expand Down Expand Up @@ -403,7 +403,7 @@ function GamePlayManager:QuitLevel()
self:_QuitOrLoadNextLevel(false)
end
---暂停关卡
---@param showPauseUI boolean 是否显示暂停界面
---@param showPauseUI boolean|nil 是否显示暂停界面
function GamePlayManager:PauseLevel(showPauseUI)
self:_Stop(BallControlStatus.FreeMode)

Expand All @@ -423,7 +423,7 @@ function GamePlayManager:PauseLevel(showPauseUI)
self.EventPause:Emit(nil)
end
---继续关卡
---@param forceRestart boolean 是否强制重置,会造成当前小节重置,默认false
---@param forceRestart boolean|nil 是否强制重置,会造成当前小节重置,默认false
function GamePlayManager:ResumeLevel(forceRestart)

Log.D(TAG, 'Resume')
Expand Down
2 changes: 1 addition & 1 deletion Assets/Game/Scripts/GamePlay/MusicManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function MusicManager:EnableBackgroundMusic()
end
end
---暂停音乐
---@param fast boolean 是否快速停止(没有渐变)
---@param fast boolean|nil 是否快速停止(没有渐变)
function MusicManager:DisableBackgroundMusic(fast)
self.CurrentAudioEnabled = false
if fast then
Expand Down
10 changes: 5 additions & 5 deletions Assets/Game/Scripts/LevelBuilder/LevelBuilder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function LevelBuilder:Start()
end)

self._LevelLoaderNative = self.gameObject:GetComponent(Ballance2.Game.GameLevelLoaderNative) ---@type GameLevelLoaderNative
self:UpdateErrStatus(false, nil)
self:UpdateErrStatus(false, nil, nil)
return false
end)
end
Expand Down Expand Up @@ -156,7 +156,7 @@ end

---开始加载关卡序列
---@param name string 关卡文件名
---@param preview boolean 是否是预览模式
---@param preview boolean|nil 是否是预览模式
function LevelBuilder:LoadLevel(name, preview)

if self._IsLoading then
Expand All @@ -175,7 +175,7 @@ function LevelBuilder:LoadLevel(name, preview)
---设置UI为初始状态
self._LevelBuilderUI.gameObject:SetActive(true)
self:UpdateLoadProgress(0)
self:UpdateErrStatus(false, nil)
self:UpdateErrStatus(false, nil, nil)
Game.UIManager:MaskBlackSet(true)

--加载内置模块
Expand Down Expand Up @@ -219,7 +219,7 @@ function LevelBuilder:LoadLevel(name, preview)
local requiredPackages = self._CurrentLevelJson.requiredPackages
if type(requiredPackages) == "table" and #requiredPackages > 0 then
for k, v in pairs(requiredPackages) do
if v.name ~= nil and not Game.PackageManager.CheckRequiredPackage(v.name. v.minVersion or 0) then
if v.name ~= nil and not Game.PackageManager:CheckRequiredPackage(v.name, v.minVersion or 0) then
missedPackages = missedPackages + '\nName: '..v.name..' Version:'..v.minVersion
end
end
Expand Down Expand Up @@ -992,7 +992,7 @@ function LevelBuilder:UnLoadLevel(endCallback)

self._IsLoading = false

if type(endCallback) == 'function' then
if endCallback ~= nil and type(endCallback) == 'function' then
endCallback()
else
--通知回到menulevel
Expand Down
7 changes: 4 additions & 3 deletions Assets/Game/Scripts/Moduls/P_Modul_18.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local Vector3 = UnityEngine.Vector3
local Time = UnityEngine.Time

---@class P_Modul_18 : ModulBase
---@field P_Modul_18_Kollisionsquader TiggerTester
Expand All @@ -22,16 +21,18 @@ end
function P_Modul_18:Start()
ModulBase.Start(self)
if not self.IsPreviewMode then
---球进入时给一个方向向上的恒力
---@param other GameObject
self.P_Modul_18_Kollisionsquader.onTriggerEnter = function (_, other)
if self._CurrentInRangeBall == nil and other.tag == 'Ball' and other.name == 'BallPaper' then
if self._CurrentInRangeBall == nil and other.tag == 'Ball' then
self._CurrentInRangeBall = GamePlay.BallManager.CurrentBall._Rigidbody
self.CurrentBallForce = self._CurrentInRangeBall:AddConstantForceLocalCenter(self.P_Modul_18_Force, self.transform:TransformVector(Vector3.up))
end
end
---球离开时去除恒力
---@param other GameObject
self.P_Modul_18_Kollisionsquader.onTriggerExit = function (_, other)
if self._CurrentInRangeBall ~= nil and other.tag == 'Ball' and other.name == 'BallPaper' then
if self._CurrentInRangeBall ~= nil and other.tag == 'Ball' then
if self.CurrentBallForce then
self.CurrentBallForce:Delete()
self.CurrentBallForceID = nil
Expand Down
4 changes: 4 additions & 0 deletions Assets/Game/Scripts/Native/Small/CamFollow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public Transform Target {
}
}

[LuaApiDescription("设置跟踪的目标,不更新位置")]
public void SetTargetWithoutUpdatePos(Transform t) {
_Target = t;
}

[Tooltip("指定当前跟踪的目标")]
[SerializeField]
Expand Down
94 changes: 94 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Ballance

[Chinese Readmre](./README.md);

## Introduction

This is an open source unity remake version of ballance game.

![image](/Assets/System/Textures/splash_app.bmp)

---

## Features

* Original game content
* Level 1-13
* Custom level (魔脓空间站 as an example)
* Level previewer
* Mod manager
* **Using Lua to make custom mod**

## Document

[Full Document](https://imengyu.github.io/Ballance/#/readme)

[API documentation](https://imengyu.github.io/Ballance/#/LuaApi/readme)

## System requirements

||Minimum|Recommended|
|---|---|---|
|Operating system|Windows 7|Windows 7-11|
|Processor|Quad core 3Ghz+|Dual core 3Ghz+|
|Memory|1 GB RAM|2 GB RAM|
|Graphics card|DirectX 10.1 capable GPU with 512 MB VRAM - GeForce GTX 260, Radeon HD 4850 or Intel HD Graphics 5500|DirectX 11 capable GPU with 2 GB VRAM - GeForce GTX 750 Ti, Radeon R7 360|
|DirectX|11|11|
|Storage space|60 MB free space|100 MB free space|

## Installation steps

1. Goto [Releases](https://github.com/imengyu/Ballance/releases) find the latest version。
2. Download the corresponding zip installation package。
3. After decompression, run `ballance.exe` to start the game。

## Turn on debugging mode

When running in unity editor, it is always debug mode.

### If you need to turn on the debugging mode of standalone version, you can

1. Go to the about menu, click the version number several times until the prompt pops up.
2. Then restart the game, you enter the debugging mode.
3. You can press F12 to open the console.

In the debugging mode, you can press the Q key to raise the ball and the e key to lower the ball.

Enter the 'quit dev' command on the console to turn off the debugging mode.

### Open all original levels

After entering the debugging mode, you can enter `highscore open-all` command in the console to open all levels.

## Game album

Original levels

![Demo](docs/DemoImages/11.jpg)
![Demo](docs/DemoImages/12.jpg)
![Demo](docs/DemoImages/13.jpg)
![Demo](docs/DemoImages/14.jpg)
![Demo](docs/DemoImages/18.jpg)
![Demo](docs/DemoImages/9.jpg)
![Demo](docs/DemoImages/6.jpg)
![Demo](docs/DemoImages/7.jpg)
![Demo](docs/DemoImages/15.jpg)
![Demo](docs/DemoImages/16.jpg)
![Demo](docs/DemoImages/17.jpg)

Level 13

![Demo](docs/DemoImages/9.gif)
![Demo](docs/DemoImages/10.png)

Self made level (魔脓空间站)

![Demo](docs/DemoImages/3.jpg)
![Demo](docs/DemoImages/4.jpg)
![Demo](docs/DemoImages/5.jpg)

Level previewer

![Demo](docs/DemoImages/8.jpg)
![Demo](docs/DemoImages/1.jpg)
![Demo](docs/DemoImages/2.jpg)
Loading

0 comments on commit b4a7437

Please sign in to comment.