예제 #1
0
    private void Awake()
    {
        camera = GetComponent <Camera>();

        PlayerEvents.Instance().SpawnPlayer   += SetTarget;
        PlayerEvents.Instance().TouchPlatform += SetHeight;
    }
예제 #2
0
 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);
     }
 }
예제 #3
0
    private void TakeDamage(int d)
    {
        health--;
        health = Mathf.Max(0, health);
        PlayerEvents.Instance().InvokeUpdateHealth(health, maxHealth);

        if (health == 0)
        {
            PlayerEvents.Instance().InvokeDeath();
        }
    }
예제 #4
0
    // 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();
    }
예제 #5
0
    // 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);
        }
    }
예제 #6
0
    // 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);
        }
    }
예제 #7
0
 private void OnBecameInvisible()
 {
     PlayerEvents.Instance().InvokeDeath();
 }
예제 #8
0
 private void SpawnPlayer()
 {
     player.transform.position = currentCheckpoint.position;
     player.transform.rotation = Quaternion.identity;
     PlayerEvents.Instance().InvokeSpawnPlayer(player.transform);
 }
예제 #9
0
 void Start()
 {
     // Register listeners
     PlayerEvents.Instance().UpdateHealth += UpdateHealth;
 }
예제 #10
0
 private void OnBecameInvisible()
 {
     PlayerEvents.Instance().InvokeDespawnShot(gameObject);
 }