示例#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);
 }