Scripting changes for item and added level 1 scene #330
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1,10 @@
|
||||||
|
Name: MD_CarRed
|
||||||
|
ID: 76808537
|
||||||
|
Type: 4
|
||||||
|
Sub Assets:
|
||||||
|
Name: CarBody
|
||||||
|
ID: 135736753
|
||||||
|
Type: 8
|
||||||
|
Name: CarWindows
|
||||||
|
ID: 139618182
|
||||||
|
Type: 8
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1,19 @@
|
||||||
|
Name: MD_TutorialGarageProps01
|
||||||
|
ID: 75936469
|
||||||
|
Type: 4
|
||||||
|
Sub Assets:
|
||||||
|
Name: MetalShelf
|
||||||
|
ID: 141619727
|
||||||
|
Type: 8
|
||||||
|
Name: Chair01.001
|
||||||
|
ID: 139750047
|
||||||
|
Type: 8
|
||||||
|
Name: Cube.002
|
||||||
|
ID: 137072050
|
||||||
|
Type: 8
|
||||||
|
Name: Cube.003
|
||||||
|
ID: 149524108
|
||||||
|
Type: 8
|
||||||
|
Name: GarageDoor
|
||||||
|
ID: 148373587
|
||||||
|
Type: 8
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1,10 @@
|
||||||
|
Name: MD_TutorialGarageProps02
|
||||||
|
ID: 79889545
|
||||||
|
Type: 4
|
||||||
|
Sub Assets:
|
||||||
|
Name: CupboardSolidBlock.001
|
||||||
|
ID: 141180771
|
||||||
|
Type: 8
|
||||||
|
Name: CupboardSinkPiece.002
|
||||||
|
ID: 141816633
|
||||||
|
Type: 8
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1,10 @@
|
||||||
|
Name: MD_WashingMachine
|
||||||
|
ID: 67614549
|
||||||
|
Type: 4
|
||||||
|
Sub Assets:
|
||||||
|
Name: WashingMachine
|
||||||
|
ID: 138744683
|
||||||
|
Type: 8
|
||||||
|
Name: WashingMachineDoor
|
||||||
|
ID: 139502794
|
||||||
|
Type: 8
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,3 @@
|
||||||
|
Name: Level1Scene
|
||||||
|
ID: 96668835
|
||||||
|
Type: 5
|
File diff suppressed because it is too large
Load Diff
|
@ -10,9 +10,10 @@ public class Breakable : Script
|
||||||
public bool ignoreRaccoon = false;
|
public bool ignoreRaccoon = false;
|
||||||
private RigidBody rb;
|
private RigidBody rb;
|
||||||
private Transform trans;
|
private Transform trans;
|
||||||
private bool isBreak = false;
|
public bool isBreak { get; set; }
|
||||||
private List<GameObject> itemPieces = new List<GameObject>();
|
private List<GameObject> itemPieces = new List<GameObject>();
|
||||||
private Random ran = new Random();
|
private Random ran = new Random();
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
rb = GetComponent<RigidBody>();
|
rb = GetComponent<RigidBody>();
|
||||||
|
@ -28,6 +29,8 @@ public class Breakable : Script
|
||||||
itemPieces.Add(pieces);
|
itemPieces.Add(pieces);
|
||||||
pieces.SetActive(false);
|
pieces.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isBreak = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
|
@ -44,6 +47,7 @@ public class Breakable : Script
|
||||||
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold)
|
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold)
|
||||||
{
|
{
|
||||||
isBreak = true;
|
isBreak = true;
|
||||||
|
GameManager.Instance.totalItemCount -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void onTriggerEnter(CollisionInfo info)
|
protected override void onTriggerEnter(CollisionInfo info)
|
||||||
|
|
|
@ -16,17 +16,29 @@ public class Item : Script
|
||||||
private Transform transform;
|
private Transform transform;
|
||||||
private bool playSound = false;
|
private bool playSound = false;
|
||||||
private bool caputurePos = false;
|
private bool caputurePos = false;
|
||||||
public Vector3 firstPostion;
|
private Vector3 firstPostion;
|
||||||
|
private Collider collider;
|
||||||
|
public float density = 1.0f;
|
||||||
|
public bool dontReturn = false;
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
transform = GetComponent<Transform>();
|
transform = GetComponent<Transform>();
|
||||||
|
collider = GetComponent<Collider>();
|
||||||
|
if(collider)
|
||||||
|
collider.GetCollisionShape(0).Density = density;
|
||||||
|
|
||||||
returnBack = false;
|
returnBack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void start()
|
||||||
|
{
|
||||||
|
GameManager.Instance.totalItemCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
if (returnBack)
|
if (returnBack && !dontReturn)
|
||||||
{
|
{
|
||||||
transform.LocalPosition = firstPostion;
|
transform.LocalPosition = firstPostion;
|
||||||
returnBack = false;
|
returnBack = false;
|
||||||
|
|
|
@ -11,9 +11,6 @@ public class GameManager : Script
|
||||||
LOSE
|
LOSE
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject itemPool;
|
|
||||||
public GameObject zonePool;
|
|
||||||
|
|
||||||
public uint winScene = 92009475;
|
public uint winScene = 92009475;
|
||||||
public uint loseScene = 91685359;
|
public uint loseScene = 91685359;
|
||||||
|
|
||||||
|
@ -26,49 +23,29 @@ public class GameManager : Script
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public float timer;
|
public float timer;
|
||||||
|
|
||||||
private IEnumerable<Item> listOfItems;
|
|
||||||
private IEnumerable<ScoringZone> listOfZone;
|
|
||||||
|
|
||||||
public GameObject scoreText;
|
public GameObject scoreText;
|
||||||
public GameObject timeText;
|
public GameObject timeText;
|
||||||
|
|
||||||
private bool once = true;
|
public static GameManager Instance { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
|
if (Instance != null && Instance != this)
|
||||||
|
RemoveScript<GameManager>();
|
||||||
|
else
|
||||||
|
Instance = this;
|
||||||
|
|
||||||
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
|
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
|
||||||
Audio.PlayBGMOnce2D("event:/Ambience/roomtone_kitchen");
|
Audio.PlayBGMOnce2D("event:/Ambience/roomtone_kitchen");
|
||||||
totalItemCount = 0;
|
totalItemCount = 0;
|
||||||
Score = 0;
|
Score = 0;
|
||||||
currGameState = GameState.START;
|
currGameState = GameState.START;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
Cheats();
|
Cheats();
|
||||||
|
|
||||||
if (once)
|
|
||||||
{
|
|
||||||
if (itemPool)
|
|
||||||
{
|
|
||||||
listOfItems = itemPool.GetScriptsInChildren<Item>();
|
|
||||||
if (listOfItems != null)
|
|
||||||
foreach (Item i in listOfItems)
|
|
||||||
totalItemCount += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zonePool)
|
|
||||||
{
|
|
||||||
listOfZone = zonePool.GetScriptsInChildren<ScoringZone>();
|
|
||||||
if (listOfZone != null)
|
|
||||||
foreach (ScoringZone sz in listOfZone)
|
|
||||||
sz.gameManger = Owner.GetScript<GameManager>();
|
|
||||||
}
|
|
||||||
once = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currGameState == GameState.START)
|
if (currGameState == GameState.START)
|
||||||
{
|
{
|
||||||
timer -= Time.DeltaTimeF;
|
timer -= Time.DeltaTimeF;
|
||||||
|
@ -77,7 +54,7 @@ public class GameManager : Script
|
||||||
if(timeText)
|
if(timeText)
|
||||||
timeText.GetComponent<TextRenderable>().Text = $"Time Left: {timer.ToString("0.00")}";
|
timeText.GetComponent<TextRenderable>().Text = $"Time Left: {timer.ToString("0.00")}";
|
||||||
|
|
||||||
if ((timer > 0 && totalItemCount <= 0) || Input.GetKeyDown(Input.KeyCode.F1))
|
if ((timer > 0 && totalItemCount < 0) || Input.GetKeyDown(Input.KeyCode.F1))
|
||||||
{
|
{
|
||||||
currGameState = GameState.WIN;
|
currGameState = GameState.WIN;
|
||||||
Audio.StopAllSounds();
|
Audio.StopAllSounds();
|
||||||
|
@ -94,6 +71,12 @@ public class GameManager : Script
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void onDestroy()
|
||||||
|
{
|
||||||
|
if (Instance == this)
|
||||||
|
Instance = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void Cheats()
|
private void Cheats()
|
||||||
{
|
{
|
||||||
if (Input.GetKeyDown(Input.KeyCode.Escape))
|
if (Input.GetKeyDown(Input.KeyCode.Escape))
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System;
|
using System;
|
||||||
public class ScoringZone : Script
|
public class ScoringZone : Script
|
||||||
{
|
{
|
||||||
public GameManager gameManger { get; set; }
|
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
|
@ -10,11 +9,11 @@ public class ScoringZone : Script
|
||||||
|
|
||||||
protected override void onTriggerEnter(CollisionInfo info)
|
protected override void onTriggerEnter(CollisionInfo info)
|
||||||
{
|
{
|
||||||
if (gameManger && info.GameObject.GetScript<Item>())
|
if (GameManager.Instance && info.GameObject.GetScript<Item>())
|
||||||
{
|
{
|
||||||
Audio.PlaySFXOnce2D("event:/Music/stingers/item_scored");
|
Audio.PlaySFXOnce2D("event:/Music/stingers/item_scored");
|
||||||
gameManger.Score += info.GameObject.GetScript<Item>().Score;
|
GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score;
|
||||||
gameManger.totalItemCount -= 1;
|
GameManager.Instance.totalItemCount -= 1;
|
||||||
info.GameObject.SetActive(false);
|
info.GameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue