Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance "Game Over"-outro #740

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions source/game.game.base.bmx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ Type TGameBase {_exposeToLua="selected"}
End Method


Method EndGame:Int()
'stub
End Method


Method Update(deltaTime:Float=1.0)
'stub
End Method
Expand Down
46 changes: 46 additions & 0 deletions source/game.game.bmx
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,52 @@ Type TGame Extends TGameBase {_exposeToLua="selected"}
Next

End Method


Method SetGameOver()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wäre es sinnvoll, hier den visitBoss-Parameter mitzugeben? Schließlich sollte beim Aufruf klar sein, ob der Chef einen rauswerfen will oder man selbst heimlich abhaut.

Super.SetGameOver()

' Method SetPlayerGameOver()
Local player:TPlayer = GetPlayer() 'current player

'needs an event?
'TriggerBaseEvent(GameEventKeys.Game_SetPlayerGameOver, New TData.AddInt("playerID", playerID), Self, player)

'inform all AI players about the game over (maybe they want to
'have a laugh in the chat
For Local p:TPlayer = EachIn GetPlayerCollection().players
If Not p.IsLocalAI() Or Not p.PlayerAI Then Continue

'p.PlayerAI.AddEventObj( New TAIEvent.SetID(TAIEvent.OnPlayerGameOver).AddInt(playerID))
Next

Local figure:TFigure = player.GetFigure()
If figure
local visitBossFirst:int = False

'send figure to boss, then offscreen (figure got fired)
If visitBossFirst
'goto boss variant 1
'If figure.inRoom Then figure.LeaveRoom(True)
'figure.SetTarget( new TFigureTarget.Init(GetRoomDoorCollection().GetFirstByDetails("boss", player.playerID)) )

'goto boss variant 2
local moveToPos:SVec2I = new TFigureTarget.Init(GetRoomDoorCollection().GetFirstByDetails("boss", player.playerID) ).GetMoveToPosition()
figure.ForceChangeTarget(moveToPos.x, moveToPos.y)

'afterwards leave building
figure.AddTarget( new TFigureTarget.Init( New TVec2D(GetBuildingBase().figureOffscreenX, TBuildingBase.GetFloorY2(0) - 5)) )

Else
figure.SendToOffscreen(True)
EndIf

'disable figure control (disable changetarget)
figure._controllable = False
EndIf

End Method



Method SetPlayerBankrupt(playerID:Int)
Expand Down
58 changes: 41 additions & 17 deletions source/game.screen.base.bmx
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ End Type

'of this type only one instance can exist
Type TInGameScreen_World Extends TInGameScreen
Field gameOverFader:TScreenChangeEffect
Global instance:TInGameScreen_World
Global _eventListeners:TEventListenerBase[]

Expand All @@ -370,7 +371,7 @@ Type TInGameScreen_World Extends TInGameScreen

Method Initialize:int()
Super.Initialize()

'=== remove all registered event listeners
EventManager.UnregisterListenersArray(_eventListeners)
_eventListeners = new TEventListenerBase[0]
Expand All @@ -379,7 +380,7 @@ Type TInGameScreen_World Extends TInGameScreen
_eventListeners :+ [ EventManager.registerListenerFunction(GameEventKeys.Figure_OnBeginLeaveRoom, onBeginLeaveRoom, "TFigure") ]
_eventListeners :+ [ EventManager.registerListenerFunction(GameEventKeys.Figure_OnFinishLeaveRoom, onFinishLeaveRoom, "TFigure") ]
End Method


Method ToString:String()
Return "TInGameScreen_World: group="+group+" name="+name
Expand Down Expand Up @@ -419,23 +420,38 @@ Type TInGameScreen_World Extends TInGameScreen
GetWorld().Update()
GetBuildingBase().Update()

'handle player target changes
local fig:TFigureBase = GetPlayerBase().GetFigure()
If Not fig.IsInRoom()
If MOUSEMANAGER.isClicked(1) And Not GUIManager._ignoreMouse
If Not fig.isChangingRoom()
If THelper.MouseIn(0, 0, 800, 385)
'convert mouse position to building-coordinates
Local x:Int = MouseManager.x - GetBuildingBase().buildingInner.GetScreenRect().GetX()
Local y:Int = MouseManager.y - GetBuildingBase().buildingInner.GetScreenRect().GetY()
fig.ChangeTarget(x, y)

'handled left click
MouseManager.SetClickHandled(1)
If Not GetGameBase().IsGameOver()
'handle player target changes
local fig:TFigureBase = GetPlayerBase().GetFigure()
If Not fig.IsInRoom()
If MOUSEMANAGER.isClicked(1) And Not GUIManager._ignoreMouse
If Not fig.isChangingRoom()
If THelper.MouseIn(0, 0, 800, 385)
'convert mouse position to building-coordinates
Local x:Int = MouseManager.x - GetBuildingBase().buildingInner.GetScreenRect().GetX()
Local y:Int = MouseManager.y - GetBuildingBase().buildingInner.GetScreenRect().GetY()
fig.ChangeTarget(x, y)

'handled left click
MouseManager.SetClickHandled(1)
EndIf
EndIf
EndIf
EndIf
EndIf
Else
local fig:TFigureBase = GetPlayerBase().GetFigure()
If fig.IsOffscreen()
if not gameOverFader
gameOverFader = New TIngameScreenChangeEffect_ClosingRects.Create(TScreenChangeEffect.DIRECTION_CLOSE, _contentArea)
gameOverFader.Initialize()
endif

gameOverFader.Update()
EndIf
If KeyManager.IsHit(KEY_ESCAPE) or (MOUSEMANAGER.isClicked(1) And Not GUIManager._ignoreMouse)
GetGameBase().EndGame()
EndIf
Endif
End Method


Expand All @@ -446,10 +462,18 @@ Type TInGameScreen_World Extends TInGameScreen
GetBuildingBase().Render()

if GetGameBase().IsGameOver()
if gameOverFader
local fig:TFigureBase = GetPlayerBase().GetFigure()
If fig.IsOffscreen()
gameOverFader.Draw()
EndIf
EndIf

local oldA:float = GetAlpha()
SetAlpha oldA * 0.85
GetBitmapFont("default", 72, BOLDFONT).DrawBox("GAME OVER", 0,0, GetGraphicsManager().GetWidth(), 380, sALIGN_CENTER_CENTER, new SColor8(255,155,125), EDrawTextEffect.Shadow, -1.0)
Setalpha oldA
SetAlpha oldA
GetBitmapFont("default", 18, BOLDFONT).DrawBox("hit ESCAPE or a mouse button to return to main menu", 0,0, GetGraphicsManager().GetWidth(), 480, sALIGN_CENTER_CENTER, new SColor8(225,225,225), EDrawTextEffect.Shadow, -1.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich finde jeden Mausklick ziemlich rigoros (nochmal im Fernseher rumzappen, Hilfe aufmachen) - vielleicht nur außerhalb des Interfaces?

endif
End Method
End Type
Expand Down