protected override void setHealth(int newHealth) { if (_photonView.isMine) { PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_HEALTH, newHealth }, }); } // print ("Archer hit"); if (_health > newHealth) { // print ("Archer damaged"); //Archer falls off when attacked PlayerCombatHandler pch = GetComponent <PlayerCombatHandler> (); if (pch.GetClass() == CHARACTER_CLASS.ARCHER) { foreach (var a in pch.GetAbilities()) { if (a is AbilityCoopRide) { AbilityCoopRide acr = (AbilityCoopRide)a; if (acr.Riding) { acr.FallDown(); // print ("Archer falling down"); } break; } } } } base.setHealth(newHealth); }
// protected override void checkForClassSpecificAbilities () // { // base.checkForClassSpecificAbilities (); // } protected override void checkForCoopInteraction() { base.checkForCoopInteraction(); // print ("checking from : " + name); bool interactableFound = false; PhotonView closestPV = _pv; closestPV = GetClosestPVWithinRange(_interactionDisatance, true); if (closestPV != _pv) { interactableFound = true; } if (interactableFound) { // print ("interactable found"); // found, setup UI if (closestPV.GetComponent <PlayerCombatHandler> ().GetClass() == CHARACTER_CLASS.TANK) { // if (UIController.SINGLETON.PlayerUIInteractInstance.Target == null || UIController.SINGLETON.PlayerUIInteractInstance.Target != closestPV.transform) { foreach (var a in _abilities) { if (a is AbilityCoopRide) { if (a.GetStatus() != ABILITY_STATUS.IN_COOLDOWN && a.GetStatus() != ABILITY_STATUS.IN_USE) { AbilityCoopRide acj = (AbilityCoopRide)a; acj.SetTarget(closestPV.transform); a.SetStatus(ABILITY_STATUS.AVAILABLE); print("not use"); } else { print("in use"); UIController.SINGLETON.PlayerUIInteractInstance.SetEnabled(false); UIController.SINGLETON.PlayerUIInteractInstance.SetTarget(null); return; } } } UIController.SINGLETON.PlayerUIInteractInstance.SetEnabled(true); UIController.SINGLETON.PlayerUIInteractInstance.SetTarget(closestPV.transform); // print ("Set target : " + closestPV.transform.name); // } } else { // print ("condition failed"); //interactable target is found, but not in interactable state //hide UI UIController.SINGLETON.PlayerUIInteractInstance.SetEnabled(false); UIController.SINGLETON.PlayerUIInteractInstance.SetTarget(null); // //no jump is available // foreach (var a in _abilities) { // if (a is AbilityCoopRide) { // a.SetStatus (ABILITY_STATUS.UNAVAILABLE); // } // } } } else { // print ("interactable NOT found"); if (UIController.SINGLETON == null) { return; } //no interaction found, hide UI UIController.SINGLETON.PlayerUIInteractInstance.SetEnabled(false); UIController.SINGLETON.PlayerUIInteractInstance.SetTarget(null); // //no jump is available // foreach (var a in _abilities) { // if (a is AbilityCoopRide) { // a.SetStatus (ABILITY_STATUS.UNAVAILABLE); // } // } } }
// Update is called once per frame void Update() { //dev if (GetComponent <DevPlayerAIBehavior> () != null) { return; } // if (Input.GetButtonDown ("Interact")) { // GetComponent<Rigidbody> ().AddForce (Vector3.up * 300f); // } if (photonView == null || photonView.isMine) { if (!_playerCombatHandler.CheckAbilitiesInUse() && //if no abilities are in use, player can use ability GameController.GC.GetIsControlAllowed()) { foreach (var a in _playerCombatHandler.GetAbilities()) { if (Input.GetButtonDown(a.GetInputName())) { Debug.Log(a.GetInputName() + " Pressed"); if (a.GetStatus() == ABILITY_STATUS.AVAILABLE) { a.Activate(); //use ability } } } } //Deactivate hold abilities when letting go of a button from pressing foreach (var a in _playerCombatHandler.GetAbilities()) { if (a is AbilityHold) { AbilityHold ah = a as AbilityHold; if (ah.GetStatus() == ABILITY_STATUS.IN_USE) { if (Input.GetButtonUp(ah.GetInputName())) { ah.Deactivate(); //use ability } //Check child ability functionality foreach (var cah in ah.ChildAbilities) { if (cah.GetStatus() == ABILITY_STATUS.IN_USE) { if (Input.GetButtonUp(cah.GetInputName())) { ((AbilityHold)cah).Deactivate(); //use ability } } } } } } //abilities that can be used while another is active foreach (var a in _playerCombatHandler.GetAbilities().Where(x => x.GetStatus() == ABILITY_STATUS.IN_USE)) { // print (a.name + " is in use!"); //get all child ability of used abilities foreach (var c in a.ChildAbilities) { // print (c.name + " found!"); //if non of the child abilities are in use, ues it // if (a.ChildAbilities.Where (x => x.GetStatus () == ABILITY_STATUS.IN_USE).Count () < 1) { if (Input.GetButtonDown(c.GetInputName())) { if (c.GetStatus() == ABILITY_STATUS.AVAILABLE) { c.Activate(); //use ability } } // } } } //archer fall down from tank if (GameController.GC.GetIsControlAllowed()) { foreach (var a in _playerCombatHandler.GetAbilities()) { if (a is AbilityCoopRide) { if (Input.GetButtonDown(a.GetInputName())) { AbilityCoopRide acr = (AbilityCoopRide)a; if (acr.Riding) { acr.FallDown(); } } } } } } }