IEnumerator DelayedInit () { yield return new WaitForSeconds (0.2f); moveJoystick.Init (); aimJoystick.Init (); moveJoystick.OnMove += UpdateMovement; aimJoystick.OnAim += UpdateAim; aimJoystick.OnMelee += DoMelee; var inputManagers = FindObjectsOfType<InputManager> (); inputManager = inputManagers.FirstOrDefault (j => j._isLocalPlayer); var weaponHolders = FindObjectsOfType<WeaponHolder> (); weaponHolder = weaponHolders.FirstOrDefault (w => w.GetId() == inputManager.ID); var statusIndicatorses = FindObjectsOfType<StatusIndicators> (); statusIndicators = statusIndicatorses.FirstOrDefault (s => s.transform.GetComponentInParent<NetworkIdentity> ().isLocalPlayer); animator = GetComponent<Animator> (); if (showTutorial) animator.SetTrigger ("StartTutorial"); initialized = true; }
// Use this for initialization void Start() { _statusIndicators = transform.parent.parent.parent.gameObject.GetComponent<StatusIndicators> (); image = GetComponent<Image> (); }
public void Init () { if (initialized) return; playerObjects = GetComponent<PlayerObjectReferences>(); _scoreManager = FindObjectOfType<ScoreManager> (); if (_scoreManager != null && base.isServer) _scoreManager.OnRoundStart += Revive; killsFeed = FindObjectsOfType<ChatEnterer> ().FirstOrDefault(c => c.feedType == ChatFeederTypes.Kills); chatFeed = FindObjectsOfType<ChatEnterer> ().FirstOrDefault(c => c.feedType == ChatFeederTypes.Chat); characterLoader = playerObjects.transform.GetComponent<CharacterLoader>(); // fill health and ammo health = maxHealth; ammo = maxAmmo; //find start positions _startPositions = GameObject.FindGameObjectsWithTag (Tags.SpawnPoint); _character = playerObjects.character; selfInjury = _character.injurator; //find audio network sync _audioPlayer = GetComponent<AudioPlayerCharacter> (); _playersManager = FindObjectOfType <PlayersManager> (); _hudController = FindObjectOfType<HudController> (); statusIndicators = playerObjects.statusIndicators; if (base.isLocalPlayer) { Cmd_GetPlayers (); if (chatFeed != null) { chatFeed.OnPostChatMessage += PostChatMessage; } } Revive (); StartCoroutine(CleareMessagesCount()); initialized = true; /* events */ JetsonsAnalytics.LogEquipment(); }
//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; }