Skip to content

Commit

Permalink
Zs 153 analytic changes Finished with tests passing (#64)
Browse files Browse the repository at this point in the history
* Task implemented with tests passing

* Task implemented with tests passing

* Task implemented with tests passing

* Task finished with tests passings

* Added change for playtesting

* Last change for playtesting

Co-authored-by: Joshua Dunne <44901016+Joshua-Dunne@users.noreply.github.com>
  • Loading branch information
MantasZalnierius and Joshua-Dunne authored Mar 28, 2022
1 parent cc6c35b commit 491378b
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 47 deletions.
29 changes: 22 additions & 7 deletions RWM-P2-TEAM-C/Assets/Scenes/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2157,8 +2157,8 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!61 &1392612451
BoxCollider2D:
--- !u!60 &1392612451
PolygonCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
Expand All @@ -2170,7 +2170,7 @@ BoxCollider2D:
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.05335939, y: -1.0816567}
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
Expand All @@ -2180,9 +2180,21 @@ BoxCollider2D:
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 6.68, y: 0.14668226}
m_EdgeRadius: 0
m_Points:
m_Paths:
- - {x: 3.2092147, y: -1.0621006}
- {x: 2.8078632, y: -0.98591435}
- {x: -2.9109974, y: -1.0156308}
- {x: -3.2213817, y: -1.1928521}
- {x: -3.2612693, y: -1.3018324}
- {x: -3.2785203, y: -1.4855522}
- {x: -2.834473, y: -1.4863421}
- {x: -2.785316, y: -1.3444514}
- {x: 0.85773116, y: -1.3270557}
- {x: 3.01694, y: -1.3211349}
- {x: 3.021416, y: -1.480169}
- {x: 3.38234, y: -1.4727167}
- {x: 3.3739069, y: -1.2045928}
--- !u!61 &1392612452
BoxCollider2D:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2491,8 +2503,11 @@ MonoBehaviour:
deathCount: 0
defeatedEnemies: 0
level: 0
version: week_3
version: week_4
playerID:
killedBy:
defaultBulletsShoot: 0
steamPunkBulletsShoot: 0
--- !u!4 &1482684144
Transform:
m_ObjectHideFlags: 0
Expand Down
4 changes: 4 additions & 0 deletions RWM-P2-TEAM-C/Assets/Scripts/Bomb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ void OnTriggerEnter2D(Collider2D col)
if (!col.gameObject.GetComponent<PlayerController>().getIsInvincible())
{
col.gameObject.GetComponent<PlayerController>().decreseHealth(3, transform.position);
if (col.gameObject.GetComponent<PlayerController>().getHealth() <= 0)
{
AnalyticsManager.instance.data.killedBy = "Bomb";
}
Destroy(this.gameObject);
}
}
Expand Down
4 changes: 4 additions & 0 deletions RWM-P2-TEAM-C/Assets/Scripts/Bomber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ void OnTriggerStay2D(Collider2D col)
if (!col.gameObject.GetComponent<PlayerController>().getIsInvincible())
{
col.gameObject.GetComponent<PlayerController>().decreseHealth(1, transform.position);
if (col.gameObject.GetComponent<PlayerController>().getHealth() <= 0)
{
AnalyticsManager.instance.data.killedBy = "Bomber";
}
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions RWM-P2-TEAM-C/Assets/Scripts/Boss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,24 @@ private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{

if(hit)
{
if (!collision.gameObject.GetComponent<PlayerController>().getIsInvincible())
{
collision.gameObject.GetComponent<PlayerController>().decreseHealth(1, transform.position);

if (collision.gameObject.GetComponent<PlayerController>().getHealth() <= 0)
{
AnalyticsManager.instance.data.killedBy = "Boss";
}

Debug.Log("player detected");
}

}


}
}
}

}
}
}
4 changes: 4 additions & 0 deletions RWM-P2-TEAM-C/Assets/Scripts/BossBullet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ void OnTriggerEnter2D(Collider2D col)

col.gameObject.GetComponent<PlayerController>().decreseHealth(3, transform.position);

if (col.gameObject.GetComponent<PlayerController>().getHealth() <= 0)
{
AnalyticsManager.instance.data.killedBy = "Boss";
}

Destroy(this.gameObject);
}
Expand Down
61 changes: 53 additions & 8 deletions RWM-P2-TEAM-C/Assets/Scripts/Bullet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class Bullet : MonoBehaviour
public float bulletDirection;
public float speed;
public float lifetime;
public int damage;


// Update is called once per frame

Expand All @@ -30,16 +32,59 @@ void Update()
void OnTriggerEnter2D(Collider2D t_other)
{
bool collSuccess = false;

if (t_other.tag != "Player")
{
if (t_other.gameObject.tag == "Bomb") { t_other.gameObject.GetComponent<ItemDrop>().drop(); Destroy(t_other.gameObject); SoundManagerScript.instance.PlaySound("bhit"); collSuccess = true; }
else if(t_other.gameObject.tag == "bossbullet") { Destroy(t_other.gameObject); SoundManagerScript.instance.PlaySound("bhit"); collSuccess = true; }
else if (t_other.gameObject.tag == "Shrapnel") { Destroy(t_other.gameObject); SoundManagerScript.instance.PlaySound("bhit"); collSuccess = true; }
else if (t_other.gameObject.tag == "Bomber") { t_other.gameObject.GetComponent<Bomber>().Damage(1); t_other.gameObject.GetComponent<ItemDrop>().drop(); SoundManagerScript.instance.PlaySound("bhit"); collSuccess = true; }
else if (t_other.gameObject.tag == "Follower" && !t_other.gameObject.GetComponent<FlyingFollower>().invincible) { t_other.gameObject.GetComponent<FlyingFollower>().damage(1); t_other.gameObject.GetComponent<ItemDrop>().drop(); SoundManagerScript.instance.PlaySound("bhit"); collSuccess = true; }
else if (t_other.gameObject.tag == "Follower" && t_other.gameObject.GetComponent<FlyingFollower>().invincible) { SoundManagerScript.instance.PlaySound("dink"); collSuccess = true; }
else if (t_other.gameObject.tag == "Boss") { t_other.gameObject.GetComponent<Boss>().damage(3); t_other.gameObject.GetComponent<ItemDrop>().drop(); SoundManagerScript.instance.PlaySound("bhit"); collSuccess = true; }
if (t_other.gameObject.tag == "Bomb")
{
t_other.gameObject.GetComponent<ItemDrop>().drop();
Destroy(t_other.gameObject);
SoundManagerScript.instance.PlaySound("bhit");
collSuccess = true;
AnalyticsManager.instance.data.defeatedEnemies++;
}
else if(t_other.gameObject.tag == "bossbullet")
{
Destroy(t_other.gameObject);
SoundManagerScript.instance.PlaySound("bhit");
collSuccess = true;
AnalyticsManager.instance.data.defeatedEnemies++;
}
else if (t_other.gameObject.tag == "Shrapnel")
{
Destroy(t_other.gameObject);
SoundManagerScript.instance.PlaySound("bhit");
collSuccess = true;
AnalyticsManager.instance.data.defeatedEnemies++;
}
else if (t_other.gameObject.tag == "Bomber")
{
t_other.gameObject.GetComponent<Bomber>().Damage(damage);
if (t_other.gameObject.GetComponent<Bomber>().getHealth() <= 0){AnalyticsManager.instance.data.defeatedEnemies++;}
t_other.gameObject.GetComponent<ItemDrop>().drop();
SoundManagerScript.instance.PlaySound("bhit");
collSuccess = true;
}
else if (t_other.gameObject.tag == "Follower" && !t_other.gameObject.GetComponent<FlyingFollower>().invincible)
{
t_other.gameObject.GetComponent<FlyingFollower>().damage(damage);
if (t_other.gameObject.GetComponent<FlyingFollower>().getHealth() <= 0) { AnalyticsManager.instance.data.defeatedEnemies++; }
t_other.gameObject.GetComponent<ItemDrop>().drop();
SoundManagerScript.instance.PlaySound("bhit");
collSuccess = true;
}
else if (t_other.gameObject.tag == "Follower" && t_other.gameObject.GetComponent<FlyingFollower>().invincible)
{
SoundManagerScript.instance.PlaySound("dink");
collSuccess = true;
}
else if (t_other.gameObject.tag == "Boss")
{
t_other.gameObject.GetComponent<Boss>().damage(damage);
if (t_other.gameObject.GetComponent<Boss>().getHealth() <= 0) { AnalyticsManager.instance.data.defeatedEnemies++; }
t_other.gameObject.GetComponent<ItemDrop>().drop();
SoundManagerScript.instance.PlaySound("bhit");
collSuccess = true;
}
else if (t_other.gameObject.tag == "dummy") {
if(!t_other.GetComponent<TutorialDummyScript>()._invincible)
{
Expand Down
11 changes: 11 additions & 0 deletions RWM-P2-TEAM-C/Assets/Scripts/BulletManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public class BulletManager : MonoBehaviour
public int steamAmmo = maxSteamAmmo;
public Text steamAmmoText;
public string state = "Normal";
private GunManager _gunManager;

private void Start()
{
_gunManager = this.GetComponent<GunManager>();
}

/// <summary>
/// Decrease the number of active bullets
Expand Down Expand Up @@ -43,25 +49,30 @@ public void shootBullet()
{
if (currentBulletTotal < MAX_BULLETS)
{
int damage = (_gunManager.getCurrentGun() == Gun.SteamPunk) ? 2000 : 1;
if (state == "Normal")
{
bulletPrefab.GetComponent<Bullet>().bulletManager = this;
bulletPrefab.GetComponent<Bullet>().speed = bulletMoveSpeed;
bulletPrefab.GetComponent<Bullet>().lifetime = bulletLifeTime;
bulletPrefab.GetComponent<Bullet>().damage = damage;
Instantiate(bulletPrefab);
SoundManagerScript.instance.PlaySound("buster");
AnalyticsManager.instance.data.bulletsFired++;
AnalyticsManager.instance.data.defaultBulletsShoot++;
}
if(state == "Steam" && steamAmmo > 0)
{
bulletPrefab.GetComponent<Bullet>().bulletManager = this;
bulletPrefab.GetComponent<Bullet>().speed = bulletMoveSpeed;
bulletPrefab.GetComponent<Bullet>().lifetime = bulletLifeTime;
bulletPrefab.GetComponent<Bullet>().damage = damage;
Instantiate(bulletPrefab);
SoundManagerScript.instance.PlaySound("buster");
AnalyticsManager.instance.data.bulletsFired++;
steamAmmo--;
steamAmmoText.text = "STEAM AMMO: " + steamAmmo;
AnalyticsManager.instance.data.steamPunkBulletsShoot++;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions RWM-P2-TEAM-C/Assets/Scripts/FlyingFollwerCollisions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ void OnTriggerStay2D(Collider2D col)
if (!col.gameObject.GetComponent<PlayerController>().getIsInvincible())
{
col.gameObject.GetComponent<PlayerController>().decreseHealth(1, transform.position);
if (col.gameObject.GetComponent<PlayerController>().getHealth() <= 0)
{
AnalyticsManager.instance.data.killedBy = "Flying Follower";
}
}
}
}
Expand Down
19 changes: 4 additions & 15 deletions RWM-P2-TEAM-C/Assets/Scripts/OnDeath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,15 @@ public class OnDeath : MonoBehaviour
{
public GameObject end;
public GameObject deathOrbPrefab;
public bool willRestartLevel;
public float timeToRestart;
public float orbSpeed;
private bool restartLevel;
private bool isDead = false;
private levelover _levelEnd;


public void LateUpdate()
public void Start()
{
if (willRestartLevel)
{
if (restartLevel)
{
SceneManager.LoadScene("Game");

}
}
_levelEnd = GameObject.Find("end").GetComponent<levelover>();
}

public void hasDied()
{
AnalyticsManager.instance.data.deathCount++;
Expand Down Expand Up @@ -104,8 +94,7 @@ IEnumerator deathAnimationPlaying()
// now wait a few seconds in order to restart the level
yield return new WaitForSeconds(timeToRestart);

restartLevel = willRestartLevel; // if this death script will restart the level, let it do it
// this is done because the code will be re-used for our boss, and we don't want the level restarting abruptly.
_levelEnd.levelEnded();

yield break; // stop the co-routine
}
Expand Down
6 changes: 2 additions & 4 deletions RWM-P2-TEAM-C/Assets/Scripts/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ void updatePlayerAnimationStates()
{
getShootInput();
}
if (_2dMovement.getIsMovingLeft() && _2dMovement.getIsGrounded() && !_animator.GetBool("movingLeft"))
if (_rb.velocity.SqrMagnitude() > 0 && _2dMovement.getIsMovingLeft() && _2dMovement.getIsGrounded() && !_animator.GetBool("movingLeft"))
{
handleLeftAnimation();
}
else if (_2dMovement.getIsMovingRight() && _2dMovement.getIsGrounded() && !_animator.GetBool("movingRight"))
else if (_rb.velocity.SqrMagnitude() > 0 && _2dMovement.getIsMovingRight() && _2dMovement.getIsGrounded() && !_animator.GetBool("movingRight"))
{
handleRightAnimation();
}
Expand Down Expand Up @@ -245,11 +245,9 @@ public void decreseHealth(int healthReduction, Vector2 sourcePos)
_rb.velocity += new Vector2(_damagePushback, 0.0f);
this.GetComponent<MovingStateMachine>().movementController.setRigidBodyVelocity(_rb.velocity);
}

StartCoroutine(damagedStateTime());
}
}

}

IEnumerator invincibilityTime()
Expand Down
7 changes: 5 additions & 2 deletions RWM-P2-TEAM-C/Assets/Scripts/Server/AnalyticsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ public class GameState
public int deathCount = 0;
public int defeatedEnemies = 0;
public int level = 0;
public string version = "week_3";
public string version = "week_4";
public string playerID;
public string killedBy = "Nothing";
public int defaultBulletsShoot = 0;
public int steamPunkBulletsShoot = 0;
}

public class AnalyticsManager : MonoBehaviour
Expand Down Expand Up @@ -65,7 +68,7 @@ public IEnumerator PostMethod()
}


Application.OpenURL("https://docs.google.com/forms/d/e/1FAIpQLSckN6E4a-Z5jLL9Yu828BNgmV0mUPzltHn8PFXKqpDgev8LaQ/viewform?usp=pp_url&entry.1212825994=" + data.playerID);
Application.OpenURL("https://docs.google.com/forms/d/e/1FAIpQLSdf28n_147BIOExFTyYBBb9EXV6rbUReaRHwXkwtvN_fK8X0Q/viewform?usp=pp_url&entry.1212825994=" + data.playerID);
}

void Start() { }
Expand Down
4 changes: 4 additions & 0 deletions RWM-P2-TEAM-C/Assets/Scripts/Shrapnel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ void OnTriggerStay2D(Collider2D col)
if (!col.gameObject.GetComponent<PlayerController>().getIsInvincible())
{
col.gameObject.GetComponent<PlayerController>().decreseHealth(1, transform.position);
if (col.gameObject.GetComponent<PlayerController>().getHealth() <= 0)
{
AnalyticsManager.instance.data.killedBy = "Shrapnel";
}
Destroy(this.gameObject);
}
}
Expand Down
13 changes: 8 additions & 5 deletions RWM-P2-TEAM-C/Assets/Scripts/levelover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.name == "Player")
{
Debug.Log("player detected ending");
ended = true;
Debug.Log(AnalyticsManager.instance);
StartCoroutine(AnalyticsManager.instance.PostMethod());
over.SetActive(true);
levelEnded();
}
}

public void levelEnded()
{
ended = true;
StartCoroutine(AnalyticsManager.instance.PostMethod());
over.SetActive(true);
}
}
4 changes: 2 additions & 2 deletions RWM-P2-TEAM-C/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2019.4.31f1
m_EditorVersionWithRevision: 2019.4.31f1 (bd5abf232a62)
m_EditorVersion: 2019.4.34f1
m_EditorVersionWithRevision: 2019.4.34f1 (6a9faed444f2)

0 comments on commit 491378b

Please sign in to comment.