void Walk(PlayerBlackboard PBB) { moveSpeed = PBB.walkSpeed; PBB.Player.GetComponent <Animator>().SetBool("Run", false); PBB.Player.GetComponent <Animator>().SetBool("Walk", true); PBB.ifRecovering = true; }
// Use this for initialization void Start() { totalScore = 0; UpdateScore(); blackBoard = GameObject.FindGameObjectWithTag(Tags.MainCamera).GetComponent<PlayerBlackboard>(); fruitsToWin = 50; }
// Use this for initialization void Start() { PBB = new PlayerBlackboard(); Actions = new Actions(); Player = new Player(); Move = new move(); PBB.Player = GameObject.FindGameObjectWithTag("Player"); PBB.Boss = GameObject.FindGameObjectWithTag("Boss"); PBB.TwoHandWeap = GameObject.FindGameObjectWithTag("TwoHand"); PBB.maxValHealth = 100f; PBB.maxValTwoHealth = 100f; PBB.currentValHealth = 100f; PBB.currentValTwoHealth = 100f; PBB.maxValStamina = 100f; PBB.currentValStamina = 100f; PBB.Dimension = 100f; PBB.setRollSpeed = 7f; PBB.rollDistance = 7f; PBB.terminalRotationSpeed = 25f; PBB.runSpeed = 6f; PBB.walkSpeed = 3f; PBB.fillAmountHealth = 1f; PBB.fillAmountTwoHealth = 1f; PBB.fillAmountStamina = 1f; PBB.ifRecovering = false; PBB.recoveringTimer = 0; Move.InitStart(PBB); Player.Init(); Actions.InitActions(); }
protected override void Awake() { base.Awake(); _blackboard = GetComponent <PlayerBlackboard>(); _cameraManager = GetComponent <CameraManager>(); _hitbox = GetComponentInChildren <HitBox>(); _hitboxController = GetComponent <PlayerHitboxController>(); }
// Use this for initialization public void InitStart(PlayerBlackboard PBB) { //Activate Rigidbody PBB.Player.GetComponent <Rigidbody>().maxAngularVelocity = PBB.terminalRotationSpeed; //Activate animator isRunning = false; moveSpeed = PBB.walkSpeed; }
void Block(PlayerBlackboard PBB, move moveScript) { //Block with weapon moveScript.SetRun(false, PBB); PBB.Player.GetComponent <Animator>().SetBool("Block", true); PBB.Player.GetComponent <Animator>().SetBool("IsAttacking", true); isBlock = true; }
private void waitAndDecreaseHealth(PlayerBlackboard PBB) { Timer -= Time.deltaTime; if (Timer < 0f) { PBB.currentValTwoHealth -= 40 * Time.deltaTime; } }
private float m_ElapsedTimeFire; // Time elapsed since last weapon shoot // Start is called before the first frame update void Awake() { // Get player blackboard if (m_PlayerBlackboard == null) { m_PlayerBlackboard = GetComponent <PlayerBlackboard>(); } }
void Run(PlayerBlackboard PBB) { //attri.CurrentValStamina -= 2.0f * Time.fixedDeltaTime; PBB.recoveringTimer = 0; PBB.currentValStamina -= 10f * Time.deltaTime; moveSpeed = PBB.runSpeed; PBB.Player.GetComponent <Animator>().SetBool("Run", true); PBB.ifRecovering = false; }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { blackboard = animator.GetComponent <PlayerBlackboard>(); if (blackboard) { blackboard.animator.ResetTrigger("HeavyAttack"); blackboard.animator.ResetTrigger("LightAttack"); } }
private void RotatePlayer(PlayerBlackboard PBB, float hor, float ver, Vector3 dir) { Vector3 facingrotation = Vector3.Normalize(dir); // facingrotation = Vector3.Lerp(transform.eulerAngles, facingrotation, 0.5f); if (facingrotation != Vector3.zero) { PBB.Player.transform.forward = facingrotation; } }
public void StatUpdate(PlayerBlackboard PBB) { maxValHealth = PBB.maxValHealth; maxValTwoHealth = PBB.maxValTwoHealth; currentValHealth = PBB.currentValHealth; currentValTwoHealth = PBB.currentValHealth; maxValStamina = PBB.maxValStamina; currentValStamina = PBB.currentValStamina; checkIfRecovering(PBB); }
void HeavyAttack(PlayerBlackboard PBB) { //Heavy attack if (!PBB.Player.GetComponent <Animator>().GetAnimatorTransitionInfo(0).IsName("HeavyAttack")) { hAttack = true; PBB.Player.GetComponent <Animator>().SetBool("HeavyAttack", true); PBB.Player.GetComponent <Animator>().SetBool("IsAttacking", true); } }
private void Move(PlayerBlackboard PBB) { if (PBB.Player.GetComponent <Rigidbody>().velocity.magnitude > moveSpeed) { PBB.Player.GetComponent <Rigidbody>().velocity = PBB.Player.GetComponent <Rigidbody>().velocity.normalized *moveSpeed; } else { PBB.Player.GetComponent <Rigidbody>().AddForce(moveVector * moveSpeed, ForceMode.VelocityChange); } }
public void SetRun(bool b, PlayerBlackboard PBB) { if (PBB.currentValStamina > 0) { isRunning = b; } else { isRunning = false; } }
void SendBehaviourRequest(PlayerBlackboard request, bool immediateAction = false) { if (request == null || request.IsEmpty) { return; } _tree.WriteOnBlackboard(request); if (request.action != null && immediateAction) { StopPlayingAction(); } }
public void TestFalllingDeadStatus() { var snapshot = new PlayerBlackboard() { posture = PlayerPosture.Dead, isOnGround = false, isGravityEnabled = true, }; var result = BT.TestUpdate(rootNode, snapshot, null); Assert.AreEqual(NodeState.Running, result.State); Assert.AreEqual(NodeState.Running, FindNodeStatus("Falling Dead", result)); }
private Vector3 m_PlayerCameraStartPosition; // Camera start position void Start() { // If player blackboard is null get it if (m_PlayerBlackboard == null) { m_PlayerBlackboard = GetComponent <PlayerBlackboard>(); } else { Debug.LogError("PlayerBlackboard isn't attached to GameObject"); } // Set camera start position m_PlayerCameraStartPosition = m_PlayerCameraTransform.localPosition; }
public void TestAttackActionAndIdleStatus() { var snapshot = new PlayerBlackboard() { action = new PlayerAction(PlayerActionType.Cast, null, null, () => true), posture = PlayerPosture.Idle, isOnGround = true, }; var result = BT.TestUpdate(rootNode, snapshot, null); Assert.AreEqual(NodeState.Running, result.State); Assert.AreEqual(NodeState.Running, FindNodeStatus("Attack", result)); Assert.AreEqual(NodeState.Running, FindNodeStatus("Idle", result)); }
public void ActivateRoll(PlayerBlackboard PBB) { if (!PBB.isroll && PBB.Player.GetComponent <Animator>().GetBool("IsAttacking") == false) { if (PBB.currentValStamina >= 20f) { PBB.Player.GetComponent <Animator>().SetBool("Roll", true); PBB.isroll = true; targetpos = PBB.Player.transform.position + PBB.Player.transform.forward.normalized * PBB.rollDistance; PBB.currentValStamina -= 20; PBB.ifRecovering = false; PBB.recoveringTimer = 0; } } }
void Awake() { bb = new PlayerBlackboard(); bb.Init(this); bb.shield = shield; shieldRend = shield.GetComponent <Renderer>(); voxelization = GetComponentInChildren <VoxelizationClient>(); ctrl = GetComponent <CharacterController>(); trail = GetComponentInChildren <TrailRenderer>(); noShootPSGO = noShootPS.gameObject; init = true; //Debug.Log("Player " + playerId + " created."); }
public void checkIfRecovering(PlayerBlackboard PBB) { if (PBB.ifRecovering == true) { PBB.recoveringTimer += Time.deltaTime; if (PBB.recoveringTimer > 1) { PBB.currentValStamina += 10f * Time.deltaTime; } } if (PBB.currentValStamina >= 100) { PBB.currentValStamina = PBB.maxValStamina; } }
private void CheckRollStop(PlayerBlackboard PBB) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("Roll")) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime > 0.9) { PBB.Player.GetComponent <Animator>().SetBool("Roll", false); PBB.isroll = false; } } else if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1).IsName("Roll")) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1).normalizedTime > 0.9) { PBB.Player.GetComponent <Animator>().SetBool("Roll", false); PBB.isroll = false; } } }
public void OnCollisionUpdate(PlayerBlackboard PBB, Actions actions) { if (actions.hAttack == true) { HeavyAttack = true; } if (actions.hAttack == false) { HeavyAttack = false; } if (actions.lAttack == true) { LightAttack = true; } if (actions.lAttack == false) { LightAttack = false; } }
// Update is called once per frame public void MoveUpdate(PlayerBlackboard PBB) { //Get Axis from Horizontal and Vertical from left stick PBB.horizontalForce = Input.GetAxisRaw("Horizontal"); PBB.verticalForce = Input.GetAxisRaw("Vertical"); if (!PBB.isroll) { //Check if Horizontal and vertical isn't zero. if (PBB.verticalForce != 0 || PBB.horizontalForce != 0) { if (PBB.Player.GetComponent <Animator>().GetBool("IsAttacking") == false) { //Move if (isRunning) { Run(PBB); } else { Walk(PBB); } //Get the original input moveVector = PoolInput(PBB.horizontalForce, PBB.verticalForce); //Rotate our moveVector moveVector = RotateWithView(); //Send in rotated moveVector to rotate player RotatePlayer(PBB, PBB.horizontalForce, PBB.verticalForce, moveVector); //Move Move(PBB); } } else { Idle(PBB); } } }
void StopAttacking(PlayerBlackboard PBB) { if (hAttack) { //for (int i = 0; i < PBB.Player.GetComponent<Animator>(); i++) //{ //} if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("HeavyAttack")) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime > 1) { PBB.Player.GetComponent <Animator>().SetBool("HeavyAttack", false); PBB.Player.GetComponent <Animator>().SetBool("IsAttacking", false); hAttack = false; } } else if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1).IsName("HeavyAttack")) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1).normalizedTime > 1) { PBB.Player.GetComponent <Animator>().SetBool("HeavyAttack", false); PBB.Player.GetComponent <Animator>().SetBool("IsAttacking", false); hAttack = false; } } } else if (lAttack) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("LightAttack")) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime > 1) { PBB.Player.GetComponent <Animator>().SetBool("LightAttack", false); PBB.Player.GetComponent <Animator>().SetBool("IsAttacking", false); lAttack = false; } } else if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1).IsName("LightAttack")) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1).normalizedTime > 1) { PBB.Player.GetComponent <Animator>().SetBool("LightAttack", false); PBB.Player.GetComponent <Animator>().SetBool("IsAttacking", false); lAttack = false; } } } else if (isBlock) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("Block")) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime > 1) { PBB.Player.GetComponent <Animator>().SetBool("Block", false); PBB.Player.GetComponent <Animator>().SetBool("IsAttacking", false); isBlock = false; } } else if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1).IsName("Block")) { if (PBB.Player.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1).normalizedTime > 1) { PBB.Player.GetComponent <Animator>().SetBool("Block", false); PBB.Player.GetComponent <Animator>().SetBool("IsAttacking", false); isBlock = false; } } } }
private void Awake() { _blackboard = GetComponent <PlayerBlackboard>(); }
protected override void Awake() { base.Awake(); blackboard = GetComponent <PlayerBlackboard>(); }
void Awake() { //See line 18,19 // all good now npcSight = GetComponent<npcSight>(); nav = GetComponent<NavMeshAgent>(); // abstract all tags into a class and call it Tags so Tags.OVR = "MainCamera" player = GameObject.FindGameObjectWithTag("MainCamera"); playerTransform = player.transform; // see line 22,23 // all good now lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<lastPlayerSighting>(); //f**k still need player blackboard //see line 29,30 //made but needs work playerBlackboard = player.GetComponent<PlayerBlackboard>(); }
public virtual void Init(PlayerBlackboard bb) { this.bb = bb; coloredObjMng = rsc.coloredObjectsMng; }
private void Roll(PlayerBlackboard PBB) { currentpos = PBB.Player.transform.position; updatepos = Vector3.MoveTowards(currentpos, targetpos, PBB.setRollSpeed * Time.fixedDeltaTime); PBB.Player.transform.position = updatepos; }
public void Inputs(PlayerBlackboard PBB, move moveScript) { if (PBB.isroll) { Roll(PBB); CheckRollStop(PBB); } StopAttacking(PBB); { if (Input.GetButton("A Button")) { //Select moveScript.SetRun(true, PBB); } else { moveScript.SetRun(false, PBB); } if (Input.GetButtonDown("X Button")) { //Sprint/Dash } if (Input.GetButtonDown("B Button")) { //Roll ActivateRoll(PBB); } if (Input.GetButtonDown("Y Button")) { //No Action yet. } if (Input.GetButtonDown("RB Button")) { //Heavy Attack HeavyAttack(PBB); } if (Input.GetButtonDown("LB Button")) { //No Action yet. } if (Input.GetButtonDown("View Button")) { //No Action yet. } if (Input.GetButtonDown("Menu Button")) { //No Action yet. } if (Input.GetAxis("RT Button") != 0) { //Light Attack LightAttack(PBB); } if (Input.GetAxis("LT Button") != 0) { //Block Block(PBB, moveScript); } }//Collapsable inputs }