public void GetCombatComponent () { if (_combat != null) return; var combats = FindObjectsOfType<Combat> (); _combat = combats.FirstOrDefault (c => c.isLocalPlayer); _multiplayerPlayerController = _combat.gameObject.GetComponent<MultiplayerPlayerController> (); ID = _multiplayerPlayerController.ID; // Attach listener to health changed event if (_combat != null) { _combat.OnHealthChanged += UpdateHealth; _combat.OnYellowMatterUpdated += UpdateYellowMatter; } scoreManager = FindObjectOfType<ScoreManager>().GetComponent<ScoreManager>(); if (scoreAnnouncer != null){ scoreAnnouncer.ID = ID; scoreManager.OnScore += scoreAnnouncer.PostScoreType; } if (messageAnnouncer != null){ messageAnnouncer.ID = ID; scoreManager.OnRoundStart += RoundStart; scoreManager.OnWinner += WinnerDecleration; } }
// Use this for initialization public void Init() { items = transform.GetComponentsInChildren<DestructibleItem>(); scoreManager = FindObjectOfType<ScoreManager>(); if (scoreManager != null) scoreManager.OnRoundRestart += RespawnAllParts; isInitialized = true; }
// Use this for initialization public void Init () { scoreManager = FindObjectOfType<ScoreManager>(); missions = FindObjectsOfType<DeliveryMission>(); SelectNewMission(); if (base.isServer) StartCoroutine (SpawnMission ( Random.Range (spawnEverySec -5f , spawnEverySec + 5f) )); audiosource = GetComponent<AudioSource>(); }
void Start() { _isOffline = GameObject.FindObjectOfType<PlayersManager> ().isOffline; if (_isOffline) { // Offline scoreManagerOffline = GameObject.Find ("Score Manager").GetComponent<ScoreManagerCouch> (); _lastChangeCounter = scoreManagerOffline.GetChangeCounter () - 1; } else { // Online scoreManager = GameObject.Find ("Score Manager").GetComponent<ScoreManager> (); _lastChangeCounter = scoreManager.GetChangeCounter () - 1; } }
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(); }
void GetScoreAndScoreboard (){ scoreManager = FindObjectOfType<ScoreManager>(); playerNamesByScore = scoreManager.GetPlayerNames(ScoreBoardTypes.score); for (int i = 0 ; i < playerNamesByScore.Length; i++) { if (playerNamesByScore[i] == ID ) { GetScore(i); } GameObject itemGo = (GameObject)Instantiate (miniScoreboardItemPref); itemGo.transform.SetParent (miniScoreboardContainer.transform, false); var item = itemGo.GetComponent<MiniScoreBoardItem>(); item.name.text = playerNamesByScore[i]; item.score.text = scoreManager.GetScore (playerNamesByScore[i] , ScoreBoardTypes.score).ToString(); } }
// Use this for initialization void Start() { if (base.isClient){ StartCoroutine(DelayRequestHp ()); } destructible = GetComponentInParent<Destructible>(); //Server do your stuff if (!base.isServer) return; initialPosition = transform.position; initialRotation = transform.rotation; hp = initialHp; smoothTime += Random.Range(0,0.3f); scoreManager = FindObjectOfType<ScoreManager>(); }