added game manager along with scoring zones for item to be thrown in

This commit is contained in:
Glence 2022-11-17 12:54:08 +08:00
parent e4f23dc6c3
commit 7d2435131f
5 changed files with 152 additions and 31 deletions

View File

@ -1,5 +1,5 @@
- EID: 0
Name: Default
Name: ScoreZone
IsActive: true
NumberOfChildren: 0
Components:
@ -68,7 +68,7 @@
NumberOfChildren: 3
Components:
Transform Component:
Translate: {x: -17.1017113, y: -3.67369723, z: -6.04142666}
Translate: {x: -18.9007454, y: -3.67369723, z: -5.23871422}
Rotate: {x: -0, y: 0, z: 0}
Scale: {x: 2, y: 2, z: 2}
IsActive: true
@ -134,13 +134,13 @@
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0}
Rotate: {x: -0.78538686, y: 1.26529622, z: 0}
Rotate: {x: -0.785401046, y: 1.65799224, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Camera Component:
Position: {x: -17.1017113, y: -3.67369723, z: -6.04142666}
Pitch: -44.9993515
Yaw: 72.4961319
Position: {x: -18.9007454, y: -3.67369723, z: -5.23871422}
Pitch: -45.000164
Yaw: 94.9959564
Roll: 0
Width: 1920
Height: 1080
@ -262,20 +262,16 @@
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: true
Type: Box
Half Extents: {x: 3.5999999, y: 8, z: 7.19999981}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: -24.3999996, y: -3.0999999, z: -5.0999999}
Colliders: ~
IsActive: true
Scripts:
- Type: GameManager
itemPool: 12
totalItemCount: 0
Score: 1
zonePool: 51000
currGameState: 0
totalItemCount: -202
Score: 204
timer: 0
- EID: 12
Name: ItemPool
IsActive: true
@ -337,14 +333,14 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -3.09096575, y: -2.43732405, z: -6.98679876}
Rotate: {x: -0, y: 0, z: -0}
Translate: {x: -20.6163979, y: -0.0419634879, z: -5.08873653}
Rotate: {x: -0, y: 0, z: 0}
Scale: {x: 2, y: 2, z: 2}
IsActive: true
IsActive: false
Renderable Component:
Mesh: 144838771
Material: 123745521
IsActive: true
IsActive: false
RigidBody Component:
Type: Dynamic
Mass: 1
@ -358,7 +354,7 @@
Freeze Rotation X: true
Freeze Rotation Y: true
Freeze Rotation Z: true
IsActive: true
IsActive: false
Collider Component:
Colliders:
- Is Trigger: false
@ -375,8 +371,84 @@
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0.5, z: 0}
IsActive: true
IsActive: false
Scripts:
- Type: Item
Score: 1
currCategory: 0
- EID: 15
Name: ScoreZonePool
IsActive: true
NumberOfChildren: 2
Components: ~
Scripts: ~
- EID: 13
Name: ScoreZone
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -24.5947151, y: -3.15127993, z: -3.29243231}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
RigidBody Component:
Type: Static
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Interpolate: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: true
Type: Box
Half Extents: {x: 1, y: 20, z: 20}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 14
Name: ScoreZone
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -6.64785767, y: 0, z: -14.217104}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
RigidBody Component:
Type: Static
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Interpolate: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: true
Type: Box
Half Extents: {x: 20, y: 20, z: 1}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~

View File

@ -4,19 +4,33 @@ using System.Collections.Generic;
public class GameManager : Script
{
enum GameState
public enum GameState
{
MAINMENU,
WIN,
LOSE,
TOTAL
}
public GameObject itemPool;
public GameObject zonePool;
public GameState currGameState;
[NonSerialized]
public int totalItemCount;
[NonSerialized]
public int Score;
[NonSerialized]
public float timer;
private IEnumerable<Item> listOfItems;
private IEnumerable<ScoringZone> listOfZone;
protected override void awake()
{
totalItemCount = 0;
Score = 0;
currGameState = GameState.MAINMENU;
if (itemPool)
{
@ -24,20 +38,25 @@ public class GameManager : Script
foreach (Item i in listOfItems)
totalItemCount += 1;
}
if (zonePool)
{
listOfZone = itemPool.GetScriptsInChildren<ScoringZone>();
foreach (ScoringZone i in listOfZone)
i.gameManger = Owner.GetScript<GameManager>();
}
}
protected override void update()
{
if (timer > 0)
timer -= Time.DeltaTimeF;
else
currGameState = GameState.LOSE;
}
protected override void onTriggerEnter(CollisionInfo info)
{
if (info.GameObject.GetScript<Item>())
{
totalItemCount -= 1;
Score = info.GameObject.GetScript<Item>().Score;
info.GameObject.SetActive(false);
}
}
}

View File

@ -8,6 +8,7 @@ public class Item : Script
MEDIUM,
HEAVY
}
public int Score = 10;
public ItemCategory currCategory;
@ -15,4 +16,9 @@ public class Item : Script
protected override void awake()
{
}
protected override void onTriggerEnter(CollisionInfo info)
{
}
}

View File

@ -0,0 +1,21 @@
using SHADE;
using System;
public class ScoringZone : Script
{
public GameManager gameManger { get; set; }
protected override void awake()
{
}
protected override void onTriggerEnter(CollisionInfo info)
{
if (gameManger && info.GameObject.GetScript<Item>())
{
gameManger.Score += info.GameObject.GetScript<Item>().Score;
gameManger.totalItemCount -= 1;
info.GameObject.SetActive(false);
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_ScoringZone
ID: 153171688
Type: 9