Ejemplo n.º 1
0
    private void Start()
    {
        curWeaponRight           = Instantiate(weaponList[0], DummyRight.transform.position, DummyRight.transform.rotation, transform);
        currentWeaponIdx         = 0;
        curWeaponControllerRight = curWeaponRight.GetComponent <WeaponControllerComponent>();
        if (curWeaponControllerRight)
        {
            curWeaponControllerRight.SetOwner(gameObject);
        }

        EventManager.Instance.AddListener <ChangeWeaponEvent>(OnChangeWeapon);
        EventManager.Instance.AddListener <ShootEvent>(OnShoot);
    }
Ejemplo n.º 2
0
 private void OnChangeWeapon(ChangeWeaponEvent e)
 {
     if (currentWeaponIdx != e.weaponId)
     {
         Destroy(curWeaponRight.gameObject);
         curWeaponRight           = Instantiate(weaponList[(int)e.weaponId], DummyRight.transform.position, DummyRight.transform.rotation, transform);
         curWeaponControllerRight = curWeaponRight.GetComponent <WeaponControllerComponent>();
         if (curWeaponControllerRight)
         {
             curWeaponControllerRight.SetOwner(gameObject);
         }
         currentWeaponIdx = e.weaponId;
     }
 }