예제 #1
0
    //Initialize
    private void Initialize()
    {
        //Set instance to this if null, otherwise destroy this
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        gamestate = GameState.titleScreen;

        //Create Item spawner, set prefabs
        ItemSpawner.getInstance().setPrefabs(ammoPickupPrefab, healthPickupPrefab);
    }
예제 #2
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.name == "Bullet(Clone)")
     {
         foreach (GameObject go in GameObject.FindObjectsOfType(typeof(GameObject)))
         {
             if (go.name == "PlayerUi(Clone)")
             {
                 if (go.GetComponent <PlayerUi>().ID == collision.gameObject.GetComponent <BulletController>().PlayerID)
                 {
                     int newScore = int.Parse(go.transform.GetChild(0).gameObject.GetComponent <TextMeshProUGUI>().text) + 5;
                     go.transform.GetChild(0).gameObject.GetComponent <TextMeshProUGUI>().text = newScore.ToString();
                 }
             }
         }
         AgentManager.GetInstance().KillZombie(this.gameObject);
         Object bloodPrefab = Resources.Load("Prefabs/blood2");
         var    blood       = (GameObject)Instantiate(bloodPrefab, this.gameObject.transform.position, this.gameObject.transform.rotation);
         Destroy(blood, 5f);
         Vector3 pos = this.gameObject.transform.position;
         ItemSpawner.getInstance().spawnItem(pos);
         Destroy(this.gameObject);
     }
 }