Ejemplo n.º 1
0
        public void Init(string[] primaryWeapons = null)
        {
            weaponList = FindObjectOfType<WeaponConfigModel>().GetData(); // WeaponModel.Instance.GetData ();

            _gameController = transform.root.gameObject;
            PlayerObjectReferences playerObjects = _gameController.GetComponent<PlayerObjectReferences>();

            character = playerObjects.character;
            characterWeight = character.weight;
            //get default weapon
            foreach (Transform child in transform) {
                if (child.gameObject.tag == "Weapon") {
                    GameObject weapon = child.gameObject;
                    _weapon = weapon.GetComponent<Weapon> ();
                    UpdateConfiguration ();
                }
            }

            _isOffline = GameObject.FindObjectOfType<PlayersManager> ().isOffline;
            if (_isOffline) {
                // offline
                _isLocalPlayer = true;

                //_combatOffline = _gameController.GetComponent<CombatOffline> ();
                _OfflinePlayerController = _gameController.GetComponent<OfflinePlayerController> ();
                ID = _OfflinePlayerController.ID;
            } else {
                // online
                _MultiplayerPlayerController = _gameController.GetComponent<MultiplayerPlayerController> ();
                _isLocalPlayer = _MultiplayerPlayerController.isLocalPlayer;
                ID = _MultiplayerPlayerController.ID;
                _combat = _gameController.GetComponent<Combat> ();
                _combat.OnGotSpecialWeapon += GotSpecialWeapon;
                _CombatAmmoSync = _gameController.GetComponent<CombatAmmoSync> ();
                _combat.OnRevive += SetInitialWeapons;
            }

            if (_isLocalPlayer) {
                weaponsHud = FindObjectOfType<WeaponsHud> ();

                if (primaryWeapons != null) {
                    equippedPrimaryWeapons = primaryWeapons;
                    SetInitialWeapons();
                }

                hud = FindObjectOfType<HudController> ();
                hud.OnWeaponChanged += SetWeapon;

                weaponsHud.SetWeapon (currentPrimary, WeaponSlots.Primary);
                //weaponsHud.SetWeapon (currentSpecial, WeaponSlots.Special);
                weaponsHud.SetWeapon (currentTossable, WeaponSlots.Tossable);

                weaponsHud.UpdateWeaponInfo (1 , _combat.grenadesAmmo , _combat.maxGrenadesAmmo , WeaponSlots.Tossable);
                weaponsHud.SelectWeapon(WeaponSlots.Primary);

                _combat.OnHoldingDelivery += HoldingDelivery;
            }
        }
Ejemplo n.º 2
0
		//at start
		void GetObjects ()
		{
			_weaponHolder = transform.parent.gameObject.GetComponent<WeaponHolder> ();

			foreach (Transform child in transform) {
				if (child.gameObject.name == "shootFrom") {
					_shootFrom = child.gameObject;
				}
			}

			GameObject gameController = transform.root.gameObject;

			var playerObjectsRef = gameController.GetComponent<PlayerObjectReferences> ();
			character = playerObjectsRef.character;

			_jetPackController = character.jetPack;
			_edgeAnimator = GameObject.FindObjectOfType<edgeIndicator> ().gameObject.GetComponent<Animator> ();

			_characterAnimator = character.animator;

			_isOffline = GameObject.FindObjectOfType<PlayersManager> ().isOffline;
			if (_isOffline) {
				// offline
				_isLocalPlayer = true;
				_OfflinePlayerController = gameController.GetComponent<OfflinePlayerController> ();
				ID = _OfflinePlayerController.ID;
				//_combatOffline = gameController.GetComponent<CombatOffline> ();
			} else {
				// online
				_MultiplayerPlayerController = gameController.GetComponent<MultiplayerPlayerController> ();
				_isLocalPlayer = _MultiplayerPlayerController.isLocalPlayer;
				ID = _MultiplayerPlayerController.ID;
				combat = gameController.GetComponent<Combat> ();
				_CombatAmmoSync = transform.root.gameObject.GetComponent<CombatAmmoSync> ();
			}
			_audioPlayer = gameController.GetComponent<AudioPlayerCharacter> ();
			_cameraCont = GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<CameraController> ();
			_inputManager = playerObjectsRef.inputManager;

			_fire = transform.FindChild ("Fire").GetComponent<ParticleSystem> ();

			if (weaponType == WeaponType.Shocker) {
				shocker = GetComponent<Shocker> ();
				shocker.totalEnergy = damage;
				shocker.range = range;
			}
				

			weaponsHud = FindObjectOfType<WeaponsHud> ();
			statusIndicators = playerObjectsRef.statusIndicators;

		}