// initialization public void init (string playerId , Transform characterTransform) { if (_initiated) return; _isOffline = GameObject.FindObjectOfType<PlayersManager> ().isOffline; if (!_isOffline) { // Online _twirl = GetComponent<Twirl> (); var combats = FindObjectsOfType<Combat> (); _combat = combats.FirstOrDefault (c => c.isLocalPlayer); var weaponHolderControllers = FindObjectsOfType<WeaponHolder> (); _weaponHolder = weaponHolderControllers.FirstOrDefault (w => w.transform.GetComponentInParent<Combat> ().isLocalPlayer); _character = characterTransform; _cam = GetComponent<Camera> (); //minZDist = _cam.transform.position.z; } else { // Offline _startPosition = transform.position; } bloom = GetComponent<Bloom>(); _initiated = true; }
public void Init() { _combat = transform.root.GetComponent<Combat> (); _multiplayerPlayerController = GetComponentInParent<MultiplayerPlayerController> (); PlayerObjectReferences playerObjects = GetComponentInParent<PlayerObjectReferences>(); character = playerObjects.character.gameObject; if (_combat.isLocalPlayer) { enemyContainer.SetActive (false); container.SetActive (true); // set to 0 to fill niceley when starting _healthBarNewFill = 0.0f; } else { enemyContainer.SetActive (true); container.SetActive (false); } animator = GetComponent<Animator>(); missions = FindObjectOfType<Missions>(); missions.OnMissionStart += SetMissionDirector; missions.OnMissionEnd += DestroyMissionDirector; isInitialized = true; }
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 void Start() { playerObjects = GetComponent<PlayerObjectReferences>(); combat = GetComponent<Combat>(); if (playerObjects == null || combat == null) isCharacter = false; }
void OnParticleCollision(GameObject shooter) { //print ( "OnParticleCollision " + other.transform.root.name + " ME : " + transform.root.name); shooterCombat = shooter.transform.root.GetComponent<Combat>(); if (shooterCombat != myCombat && shooterCombat.isLocalPlayer) { shooterCombat.GiveDamage ( shooter.GetComponentInParent<Weapon>().damage , transform.root.name , DamageType.Smell , Vector3.zero , Vector2.zero ); //myCombat.TakeDamage ( shooter.GetComponentInParent<Weapon>().damage , transform.root.name , DamageType.Smell , Vector3.zero , Vector2.zero ); } }
// Use this for initialization void Start () { animator = GetComponent<Animator>(); localCombat = FindObjectsOfType<Combat>().FirstOrDefault(c => c.isLocalPlayer); if (localCombat == null){ print ("Did not find local combat, f****r"); } UpdateSign (); localCombat.OnYellowMatterUpdated += UpdateSign; priceText.text = spinPrice.ToString(); audioSource = GetComponent<AudioSource>(); }
public void Spin () { if (inSpin) return; audioSource.clip = spinSound; audioSource.Play(); animator.SetTrigger("spin"); inSpin = true; if (localCombat == null){ localCombat = FindObjectsOfType<Combat>().FirstOrDefault(c => c.isLocalPlayer); } }
void ApplyDamage(Collider2D col , int damage) { if (col.gameObject.CompareTag(Tags.Character) ) { //Debug.Log("Boom " + grenadeDamage + " Shooter ID: " + shooterID); enemy = col.gameObject.transform.root.GetComponent<Combat> (); if (enemy != null) { //enemy.TakeDamage (Mathf.RoundToInt(damage / 2), shooterID, DamageType.Grenade, Vector3.zero, Vector3.zero ); if (isDecider) shooterCombat.GiveDamage(Mathf.RoundToInt(damage / 2), enemy.gameObject.name , DamageType.Grenade, Vector3.zero, -(transform.position - col.gameObject.transform.position) * damage * 5); } var colliderRb = col.gameObject.GetComponent<Rigidbody2D> (); if (colliderRb != null) { colliderRb.AddForce (-(transform.position - col.gameObject.transform.position) * damage * 16); } } else if (col.gameObject.CompareTag (Tags.Destructible)){ Vector3 damageVel = -(transform.position - col.gameObject.transform.position) * damage * 0.5f; var destructibleItem = col.gameObject.GetComponent<Jetsons.DestructibleItem>(); destructibleItem.TakeDamage(Mathf.RoundToInt (damage) , damageVel , shooterID); } else if (col.gameObject.CompareTag (Tags.Leaves)) { BunchOfLeaves leaves = col.gameObject.GetComponent<BunchOfLeaves>(); if (leaves != null) { leaves.Movement((-(transform.position - col.gameObject.transform.position) * damage * 7).magnitude); } } else { var rb = col.gameObject.GetComponent<Rigidbody2D>(); if (rb != null && !rb.isKinematic) { rb.AddForce (-(transform.position - col.gameObject.transform.position) * damage * 7f); } } }
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; } }
// 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; } }
void Start() { isOffline = GameObject.FindObjectOfType<PlayersManager> ().isOffline; collidersBehingHit = new Collider2D[0]; if (isDecider) shooterCombat = FindObjectsOfType<Combat>().FirstOrDefault ( c => c.ID == shooterID); }
void Start() { CreateSmokeLine(); rb = GetComponent<Rigidbody2D>(); Quaternion rotation = Quaternion.LookRotation(rb.velocity , Vector3.back); rotation.x = 0f; rotation.y = 0f; transform.rotation = rotation; if (isDecider && shooterCombat == null) shooterCombat = FindObjectsOfType<Combat>().FirstOrDefault ( c => c.ID == shooterID); }
//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; }
// Use this for initialization void Start () { myCombat = transform.root.GetComponent<Combat>(); }