Skip to content

Commit

Permalink
Merge pull request #105 from 2024FALL-SWPP/feature/bugfix
Browse files Browse the repository at this point in the history
chore
  • Loading branch information
integraldx authored Dec 18, 2024
2 parents 1cffe0c + 73a924a commit 089e997
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 29 deletions.
10 changes: 10 additions & 0 deletions Assets/SWPPT3/Scenes/Stage 2.unity
Original file line number Diff line number Diff line change
Expand Up @@ -6475,6 +6475,16 @@ PrefabInstance:
propertyPath: _cameraTransform
value:
objectReference: {fileID: 2115476442}
- target: {fileID: 5865617930821872791, guid: b63037d539f98bc42a98baf0281987bd,
type: 3}
propertyPath: m_Materials.Array.data[1]
value:
objectReference: {fileID: 2100000, guid: 21165d66baa9949edbc4302d0636e546, type: 2}
- target: {fileID: 5865617930821872791, guid: b63037d539f98bc42a98baf0281987bd,
type: 3}
propertyPath: m_Materials.Array.data[2]
value:
objectReference: {fileID: 2100000, guid: 264f74bf3bd1b48c199dabcbaf507a00, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b63037d539f98bc42a98baf0281987bd, type: 3}
--- !u!4 &1522870392 stripped
Expand Down
2 changes: 1 addition & 1 deletion Assets/SWPPT3/Scripts/Main/AudioLogic/AudioObject.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/SWPPT3/Scripts/Main/AudioLogic/BgmObject.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/SWPPT3/Scripts/Main/AudioLogic/SfxObject.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ private void Awake()
{ PlayerStates.Metal, 0 },
{ PlayerStates.Rubber, 0 },
};
OnItemChanged?.Invoke();
}
OnItemChanged?.Invoke();
TryChangeState(PlayerStates.Slime);

}
Expand Down Expand Up @@ -108,8 +108,8 @@ public void SetItemCounts(int newSlimeCount, int newMetalCount, int newRubberCou
{ PlayerStates.Metal, 0 },
{ PlayerStates.Rubber, 0 },
};
OnItemChanged?.Invoke();
}
OnItemChanged?.Invoke();
Item[PlayerStates.Slime] = newSlimeCount;
Item[PlayerStates.Metal] = newMetalCount;
Item[PlayerStates.Rubber] = newRubberCount;
Expand Down
72 changes: 49 additions & 23 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/State/PlayerState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using System;
using SWPPT3.Main.Manager;
using SWPPT3.Main.Prop;
using SWPPT3.Main.PlayerLogic;
using UnityEngine;
using SWPPT3.Main.UI;

#endregion

Expand All @@ -17,35 +20,58 @@ public enum PlayerStates

public abstract class PlayerState
{
private bool isDirty= false;
public virtual void InteractWithProp(Player player, PropBase obstacle)
{
if (obstacle is ItemBox itemBox)
{
player.SetItemCounts(0,
itemBox.ItemState == PlayerStates.Metal ? player.Item[PlayerStates.Metal] + 1 : player.Item[PlayerStates.Metal],
itemBox.ItemState == PlayerStates.Rubber ? player.Item[PlayerStates.Rubber] + 1 : player.Item[PlayerStates.Rubber]
);
}
else if (obstacle is PoisonPool)
isDirty = true;
if (isDirty)
{
isDirty = false;
if (obstacle is ItemBox itemBox)
{
itemBox.InteractWithPlayer();
player.SetItemCounts(0,
itemBox.ItemState == PlayerStates.Metal ? player.Item[PlayerStates.Metal] + 1 : player.Item[PlayerStates.Metal],
itemBox.ItemState == PlayerStates.Rubber ? player.Item[PlayerStates.Rubber] + 1 : player.Item[PlayerStates.Rubber]
);
}
else if (obstacle is PoisonPool)
{
//Debug.Log("collide with Poison pool");
GameManager.Instance.GameState = GameState.GameOver;
}
else if (obstacle is Gas)
{
foreach(PlayerStates playerState in Enum.GetValues(typeof(PlayerStates)))
GameManager.Instance.GameState = GameState.GameOver;
}
else if (obstacle is Gas)
{
player.SetItemCounts(0,0,0);
foreach(PlayerStates playerState in Enum.GetValues(typeof(PlayerStates)))
{

player.SetItemCounts(0,
itemBox.ItemState == PlayerStates.Metal ? player.Item[PlayerStates.Metal] + 1 : player.Item[PlayerStates.Metal],
itemBox.ItemState == PlayerStates.Rubber ? player.Item[PlayerStates.Rubber] + 1 : player.Item[PlayerStates.Rubber]
);
itemBox.InteractWithPlayer();
}
else if (obstacle is PoisonPool)
{
//Debug.Log("collide with Poison pool");
GameManager.Instance.GameState = GameState.GameOver;
}
else if (obstacle is Gas)
{
foreach(PlayerStates playerState in System.Enum.GetValues(typeof(PlayerStates)))
{
player.SetItemCounts(0,0,0);
}
player.TryChangeState(PlayerStates.Slime);
}
else if (obstacle is MagicCircle)
{
GameManager.Instance.GameState = GameState.StageCleared;
}
else
{
obstacle.InteractWithPlayer(player.CurrentState);
}
player.TryChangeState(PlayerStates.Slime);
}
else if (obstacle is MagicCircle)
{
GameManager.Instance.GameState = GameState.StageCleared;
}
else
{
obstacle.InteractWithPlayer(player.CurrentState);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Assets/SWPPT3/Scripts/Main/UI/InGameScreenBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ public void PlayTimeUpdate(int time){
_playTimeTmp.text = $"{min:D2}:{sec:D2}";
}

private void NumUpdate()
public void NumUpdate()
{
Debug.Log("Numupdate");
_metalNumTmp.text = $"{_player.Item[PlayerStates.Metal]}";
_rubberNumTmp.text = $"{_player.Item[PlayerStates.Rubber]}";
}
Expand Down

0 comments on commit 089e997

Please sign in to comment.