예제 #1
0
 void Walk(PlayerBlackboard PBB)
 {
     moveSpeed = PBB.walkSpeed;
     PBB.Player.GetComponent <Animator>().SetBool("Run", false);
     PBB.Player.GetComponent <Animator>().SetBool("Walk", true);
     PBB.ifRecovering = true;
 }
예제 #2
0
 // Use this for initialization
 void Start()
 {
     totalScore = 0;
     UpdateScore();
     blackBoard = GameObject.FindGameObjectWithTag(Tags.MainCamera).GetComponent<PlayerBlackboard>();
     fruitsToWin = 50;
 }
예제 #3
0
    // 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();
    }
예제 #4
0
 protected override void Awake()
 {
     base.Awake();
     _blackboard       = GetComponent <PlayerBlackboard>();
     _cameraManager    = GetComponent <CameraManager>();
     _hitbox           = GetComponentInChildren <HitBox>();
     _hitboxController = GetComponent <PlayerHitboxController>();
 }
예제 #5
0
 // 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;
 }
예제 #6
0
 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;
 }
예제 #7
0
 private void waitAndDecreaseHealth(PlayerBlackboard PBB)
 {
     Timer -= Time.deltaTime;
     if (Timer < 0f)
     {
         PBB.currentValTwoHealth -= 40 * Time.deltaTime;
     }
 }
예제 #8
0
    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>();
        }
    }
예제 #9
0
 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;
 }
예제 #10
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     blackboard = animator.GetComponent <PlayerBlackboard>();
     if (blackboard)
     {
         blackboard.animator.ResetTrigger("HeavyAttack");
         blackboard.animator.ResetTrigger("LightAttack");
     }
 }
예제 #11
0
    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;
        }
    }
예제 #12
0
 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);
 }
예제 #13
0
 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);
     }
 }
예제 #14
0
 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);
     }
 }
예제 #15
0
 public void SetRun(bool b, PlayerBlackboard PBB)
 {
     if (PBB.currentValStamina > 0)
     {
         isRunning = b;
     }
     else
     {
         isRunning = false;
     }
 }
예제 #16
0
 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));
        }
예제 #18
0
    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));
        }
예제 #20
0
 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;
         }
     }
 }
예제 #21
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.");
    }
예제 #22
0
    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;
        }
    }
예제 #23
0
 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;
         }
     }
 }
예제 #24
0
    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;
        }
    }
예제 #25
0
    // 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);
            }
        }
    }
예제 #26
0
    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;
                }
            }
        }
    }
예제 #27
0
 private void Awake()
 {
     _blackboard = GetComponent <PlayerBlackboard>();
 }
예제 #28
0
 protected override void Awake()
 {
     base.Awake();
     blackboard = GetComponent <PlayerBlackboard>();
 }
예제 #29
0
    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>();
    }
예제 #30
0
    public virtual void Init(PlayerBlackboard bb)
    {
        this.bb = bb;

        coloredObjMng = rsc.coloredObjectsMng;
    }
예제 #31
0
 private void Roll(PlayerBlackboard PBB)
 {
     currentpos = PBB.Player.transform.position;
     updatepos  = Vector3.MoveTowards(currentpos, targetpos, PBB.setRollSpeed * Time.fixedDeltaTime);
     PBB.Player.transform.position = updatepos;
 }
예제 #32
0
    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
    }