Esempio n. 1
0
		// Use this for initialization
		public void Init (string[] primaryWeapons = null) {
			
			Physics2D.IgnoreCollision (headCollider , bodyCollider);

			if (transform.parent.gameObject.CompareTag(Tags.GameController)) {
				gameController = transform.parent.gameObject;
				playerObjects = gameController.GetComponent<PlayerObjectReferences>();
				playerObjects.character = this;

				jetPack.Init();
				weaponHolder.GetComponent<WeaponHolder>().Init(primaryWeapons);

				gameController.GetComponent<CharacterCustomizationSync>().RegisterObjectsToColor(playerColorObjects);
				combat = gameController.GetComponent<Combat>();
				StatusIndicators statusIndicators = transform.parent.GetComponentInChildren<StatusIndicators>();
				if (statusIndicators != null) {
					statusIndicators.Init();
				}

				audioPlayer = transform.root.GetComponent<AudioPlayerCharacter>();
				deliveryPointInitialLocalPosition = deliveryPoint.transform.localPosition;

				bodyColor = playerColorObjects[0].GetComponent<SpriteRenderer>().color;
			}

		}
Esempio n. 2
0
        // Use this for initialization
        void Start()
        {
            playerObjects = GetComponent<PlayerObjectReferences>();
            combat = GetComponent<Combat>();

            if (playerObjects == null || combat == null)
                isCharacter = false;
        }
Esempio n. 3
0
		// Use this for initialization

		public void Init ()
		{

			isOffline = FindObjectOfType<PlayersManager> ().isOffline;
			globalSounds = FindObjectOfType<GlobalSounds> ().GetComponent<GlobalSounds> ();
			if (isOffline) {
				// Offline
				ID = GetComponent<OfflinePlayerController> ().ID;
			} else {
				// Online
				audioNetworking = GetComponent<AudioNetworking> ();
				audioNetworking.Init();
				ID = GetComponent<MultiplayerPlayerController> ().ID;
			}
			StartCoroutine (PlayJoinSound ());
			playerObjects = GetComponent<PlayerObjectReferences>();
			character = playerObjects.character;

			characterVoiceAudioSource = character.voiceAudioSource;
			meleeAudioSource = character.meleeAttackAudioSource;
			weaponHolderAudioSource = character.weaponHolderAudioSource;
		}
Esempio n. 4
0
		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();

		}
Esempio n. 5
0
        private void CreateBullet(string shooterID, Vector2 shootFromVec, Quaternion rotation, Vector2 velocity, int range, int damage, PlayerObjectReferences opponent)
        {
            // Create bullet, assign attributes
            GameObject bullet = Instantiate (bullet1, shootFromVec, rotation) as GameObject;
            //bullet.SetActive (true);
            bullet.GetComponent<Rigidbody2D> ().velocity = velocity;
            bullet.GetComponent<Bullet> ().shooterID = shooterID;
            bullet.GetComponent<Bullet> ().damage = damage;
            Destroy (bullet, range / velocity.magnitude); // destroy after range pass

            // ignore shooter collision, ignore other bullets

            Physics2D.IgnoreCollision (bullet.GetComponent<CircleCollider2D> (), opponent.character.headCollider);
            Physics2D.IgnoreCollision (bullet.GetComponent<CircleCollider2D> (), opponent.character.bodyCollider);
            Physics2D.IgnoreLayerCollision (8, 8);
        }