public override void Init()
        {
            weaponController       = GetComponent <PlayerWeaponController>();
            playerHealthController = GetComponent <HealthControllerPlayer>();
            reloadController       = GetComponent <PlayerReloadController>();

            playerMeleeWeaponLayerMask = Resources.Load("LayerMasks/LayerMask_Player Melee Weapon") as ScriptableLayerMask;
            throwWeaponInputAction     = Resources.Load("Input Actions/Input Action Throw Weapon") as ScriptableInputBoolAction;
            toggleWeaponInputAction    = Resources.Load("Input Actions/Input Action Toggle Weapon") as ScriptableInputBoolAction;

            isPlayerReloading = Resources.Load("Player/PlayerIsReloading") as ScriptableBool;

            searcherController          = GetComponent <InteractionSearcherController>();
            worldInteractionParentGroup = FindObjectOfType <WorldInteractionsManager>().transform;
            playerRightHand             = GetComponentInChildren <RightHandIdentifier>().transform;

            inventoryAmmo.rifleAmmo     = playerInventoryData.inventoryAmmo.rifleAmmo;
            inventoryAmmo.pistolAmmo    = playerInventoryData.inventoryAmmo.pistolAmmo;
            inventoryAmmo.shotgunShells = playerInventoryData.inventoryAmmo.shotgunShells;
            inventoryAmmo.arrows        = playerInventoryData.inventoryAmmo.arrows;

            fistsWeaponRuntime.FreshSpawnWeapon();
            fistsWeaponRuntime.PickupWeaponPlayer();
            fistsWeaponRuntime.DisableAttackColliders();

            SpawnInventoryWeapons(playerInventoryData.inventoryWeapons);
        }
Exemple #2
0
        void GetFieldOfViewTargets()
        {
            playerFound = false;

            desiredRayCastPosition = castPoint.position;

            for (int i = 0; i < collisionsInSphereCast.Length; i++)
            {
                Transform target = collisionsInSphereCast[i].transform;

                Vector3 dirToTarget = Vector3.zero;

                bool isInViewAngle = CheckIsTargetInFov(target, out dirToTarget);

                if (!isInViewAngle)
                {
                    if (useDebugs)
                    {
                        Debug.Log("Not In View Angle");
                    }

                    if (playerFound == false && playerTarget != null)
                    {
                        PlayerLeftFOV();
                    }
                    return;
                }

                if (Physics.Raycast(desiredRayCastPosition, dirToTarget, out fieldOFViewRay, viewDistance, data.obstacleMask.value))
                {
                    if (useDebugs)
                    {
                        Debug.Log("Hitting Obstacle");
                    }

                    if (fieldOFViewRay.collider.GetComponent <HealthControllerPlayer>() != null)
                    {
                        playerTarget = fieldOFViewRay.transform.GetComponent <HealthControllerPlayer>();
                        playerFound  = true;
                        PlayerEnteredFOV();
                        return;
                    }
                }
                else
                {
                    //Did Not Obstacle

                    if (useDebugs)
                    {
                        Debug.Log("Not Hitting Obstacle");
                    }
                }
            }

            if (collisionsInSphereCast.Length == 0)
            {
                playerFound = false;
            }
        }
Exemple #3
0
        public override void Init()
        {
            base.Init();

            healthControllerPlayer = GetComponentInParent <HealthControllerPlayer>();
            playerWeaponController = GetComponentInParent <PlayerWeaponController>();
            executionController    = GetComponentInParent <PlayerExecutionController>();
        }
        public void OnStateEnter()
        {
            target = Object.FindObjectOfType <HealthControllerPlayer>();

            if (target == null)
            {
                return;
            }

            //Snap To Target
            Vector3 lookat = (new Vector3(target.transform.position.x, stateController.transform.position.y, target.transform.position.z) - stateController.transform.position).normalized;

            stateController.transform.rotation = Quaternion.LookRotation(lookat);
        }
Exemple #5
0
        public override void Init()
        {
            viewMeshFilter      = GetComponent <MeshFilter>();
            aiController        = GetComponentInParent <AIController>();
            playerTarget        = FindObjectOfType <HealthControllerPlayer>();
            inventoryController = aiController.GetComponent <AIInventoryController>();
            alertController     = aiController.GetComponent <AIAlertController>();
            aiHealthController  = aiController.GetComponent <HealthControllerAI>();
            stateController     = aiController.GetComponent <AIStateController>();
            knockdownController = aiController.GetComponent <AIKnockDownController>();

            viewMesh            = new Mesh();
            viewMesh.name       = "View Mesh";
            viewMeshFilter.mesh = viewMesh;

            if (drawFieldOfViewMesh.value)
            {
                DrawFieldOfView();
            }
        }
Exemple #6
0
 void PlayerLeftFOV()
 {
     playerTarget = null;
 }
Exemple #7
0
 private void Awake()
 {
     player = transform.GetComponentInParent <Player>();
     health = GetComponent <HealthControllerPlayer>();
 }