private void Awake() { camera = GetComponent <Camera>(); PlayerEvents.Instance().SpawnPlayer += SetTarget; PlayerEvents.Instance().TouchPlatform += SetHeight; }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Platform") { Transform trans = collision.gameObject.transform; float offset = 0.5f * collision.collider.bounds.size.y; PlayerEvents.Instance().InvokeTouchPlatform(trans, offset); } }
private void TakeDamage(int d) { health--; health = Mathf.Max(0, health); PlayerEvents.Instance().InvokeUpdateHealth(health, maxHealth); if (health == 0) { PlayerEvents.Instance().InvokeDeath(); } }
// Use this for initialization void Start() { // Register listeners PlayerEvents.Instance().DespawnPlayer += SpawnPlayer; LevelEvents.Instance().SetCheckpoint += SetCheckpoint; LevelEvents.Instance().ReachGoal += WinLevel; // Level Manager logic currentCheckpoint = startPoint; player = Instantiate(PlayerPrefab); SpawnPlayer(); }
// Update is called once per frame void Update() { if (Input.GetButtonDown("Shoot")) { animator.SetBool("Shooting", true); Vector3 pos = shootPoint.position; Quaternion rot = shootPoint.rotation * Quaternion.Euler(0F, 0F, transform.localScale.x < 0F ? 180F : 0F); PlayerEvents.Instance().InvokeSpawnShot(pos, rot); } else { animator.SetBool("Shooting", false); } }
// Use this for initialization void Start() { PlayerEvents.Instance().SpawnShot += SpawnBullet; PlayerEvents.Instance().DespawnShot += DespawnBullet; instances = new List <GameObject>(); instances.Capacity = startSize; for (int i = 0; i < startSize; i++) { GameObject instance = Instantiate(Prefab); instance.SetActive(false); instances.Add(instance); } }
private void OnBecameInvisible() { PlayerEvents.Instance().InvokeDeath(); }
private void SpawnPlayer() { player.transform.position = currentCheckpoint.position; player.transform.rotation = Quaternion.identity; PlayerEvents.Instance().InvokeSpawnPlayer(player.transform); }
void Start() { // Register listeners PlayerEvents.Instance().UpdateHealth += UpdateHealth; }
private void OnBecameInvisible() { PlayerEvents.Instance().InvokeDespawnShot(gameObject); }