Control prompts, character reactions
This commit is contained in:
parent
71e6308f60
commit
177889a1e0
24 changed files with 2328 additions and 34 deletions
|
@ -13,21 +13,21 @@ using EntityNetwork;
|
|||
public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize {
|
||||
public const int COLUMN = 6, ROW = 12;
|
||||
|
||||
public GameBoardRender render;
|
||||
public GameBoardRender render;
|
||||
|
||||
[System.NonSerialized]
|
||||
public BoardState board;
|
||||
private BoardState lastSentBoard;
|
||||
|
||||
public bool active;
|
||||
public bool active;
|
||||
|
||||
public enum DelayState { None, Collapse, Combo, Loss }
|
||||
public DelayState delayState = DelayState.None;
|
||||
|
||||
// TIL I need to always have an update timer or the dispatcher doesn't get created
|
||||
[NetVar('n',true,true,100)]
|
||||
[NetVar('n', true, true, 100)]
|
||||
public int NextDrop;
|
||||
[NetVar('c',true,true)]
|
||||
[NetVar('c', true, true)]
|
||||
public int CurrentDrop;
|
||||
|
||||
public (TileInfo left, TileInfo right) currentPair {
|
||||
|
@ -66,7 +66,7 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize {
|
|||
activator = TileInfo.CreateRandomActivatorTile();
|
||||
|
||||
lastActivatorColor = activator.color;
|
||||
|
||||
|
||||
if (++nextSpecial >= ActivatorsUntilSpecial) {
|
||||
nextSpecial = 0;
|
||||
activator.kind = TileKind.Special;
|
||||
|
@ -87,19 +87,26 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize {
|
|||
public int dropHeight = 12; // Y value to drop from
|
||||
|
||||
[Header("Scoring")]
|
||||
[NetVar('C',true,true)]
|
||||
[NetVar('C', true, true)]
|
||||
public int Combo; // Increments on successively chained combos
|
||||
[NetVar('S',true,true)]
|
||||
[NetVar('S', true, true)]
|
||||
public int score = 0;
|
||||
|
||||
|
||||
|
||||
#region GameLogic
|
||||
// Time without moving that the game will kill you if you have lethal trash
|
||||
public float AutoDeathTime = 10f;
|
||||
public float AutoDeathTime = 10f;
|
||||
|
||||
public enum AnimationName { Idle, Happy, Sad }
|
||||
public AnimationName desiredAnimation;
|
||||
|
||||
public float timeInState = 0;
|
||||
public DelayState lastState = DelayState.None;
|
||||
void GameLogic() {
|
||||
desiredAnimation = AnimationName.Idle; // Start off assuming idle
|
||||
if (HighestStack(board) > 9)
|
||||
desiredAnimation = AnimationName.Sad;
|
||||
|
||||
if (delayState != lastState) {
|
||||
timeInState = 0;
|
||||
}
|
||||
|
@ -130,6 +137,7 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize {
|
|||
}
|
||||
return;
|
||||
case DelayState.Combo:
|
||||
desiredAnimation = AnimationName.Happy; // Look happy when we're combo the shit out of them
|
||||
if (timeInState > activationSpreadTime) {
|
||||
board = ActivateOnce(board, out bool didActivate);
|
||||
if (didActivate) {
|
||||
|
@ -171,6 +179,9 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize {
|
|||
}
|
||||
}
|
||||
return;
|
||||
case DelayState.Loss:
|
||||
desiredAnimation = AnimationName.Sad;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -647,7 +658,9 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize {
|
|||
|
||||
render.RebuildStack(board);
|
||||
GameLogic();
|
||||
|
||||
|
||||
render.SetAnimation();
|
||||
|
||||
if (Time.time >= nextNetworkTick && NetworkManager.inRoom){
|
||||
UpdateNow();
|
||||
nextNetworkTick = Time.time + networkTick;
|
||||
|
|
|
@ -25,6 +25,32 @@ public class GameBoardRender : MonoBehaviour {
|
|||
public TileRender place2;
|
||||
public TileRender place3, place4; // Next tile display
|
||||
|
||||
public GameObject Happy, Sad, Idle;
|
||||
private float soonestChangeTime = 0f;
|
||||
public void SetAnimation() {
|
||||
bool enableHappy = false, enableSad = false, enableIdle = false;
|
||||
|
||||
if (Time.time < soonestChangeTime) return;
|
||||
|
||||
switch(board.desiredAnimation) {
|
||||
case GameBoard.AnimationName.Happy:
|
||||
soonestChangeTime = Time.time + 3f;
|
||||
enableHappy = true;
|
||||
break;
|
||||
case GameBoard.AnimationName.Sad:
|
||||
soonestChangeTime = Time.time + 2f;
|
||||
enableSad = true;
|
||||
break;
|
||||
case GameBoard.AnimationName.Idle:
|
||||
enableIdle = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Happy) Happy.SetActive(enableHappy);
|
||||
if (Sad) Sad.SetActive(enableSad);
|
||||
if (Idle) Idle.SetActive(enableIdle);
|
||||
}
|
||||
|
||||
// Dramatically slow falls in combo mode
|
||||
public float tileSpeed => board.Combo > 0 ? 15 : 20;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue