Exemplo n.º 1
0
 private void Awake()
 {
     anim             = GetComponent <CharacterAnimations>();
     agent            = GetComponent <NavMeshAgent>();
     audioSource      = GetComponent <AudioSource>();
     targetPos        = GameObject.FindGameObjectWithTag(Tags.PLAYER).transform;
     healthController = GetComponent <UniversalHealthController>();
     gameplayManager  = FindObjectOfType <GameplayManager>();
 }
Exemplo n.º 2
0
    private void Start()
    {
        enemies = GameObject.FindGameObjectsWithTag("FinalEnemy");

        foreach (var enemy in enemies)
        {
            healthController = enemy.gameObject.GetComponent <UniversalHealthController>();
        }


        enemyCount = 4;
        Debug.Log(enemyCount);
    }
Exemplo n.º 3
0
    // getting values for position and rotation
    private void Awake()
    {
        thisCharacterPosition_X = PlayerPrefs.GetFloat("myPositionX");
        thisCharacterPosition_Y = PlayerPrefs.GetFloat("mypositionY");
        thisCharacterPosition_Z = PlayerPrefs.GetFloat("myPositionZ");

        thisCharacterRotation_X = PlayerPrefs.GetFloat("myRotationX");
        thisCharacterRotation_Y = PlayerPrefs.GetFloat("myRotationY");
        thisCharacterRotation_Z = PlayerPrefs.GetFloat("myRotationZ");



        healthController = GetComponent <UniversalHealthController>();
    }
 void Awake()
 {
     movement         = GetComponent <CharacterMovement>();
     blocking         = GetComponent <PlayerBlocking>();
     attackAnim       = GetComponent <CharacterAnimations>();
     healthController = FindObjectOfType <UniversalHealthController>();
     animator         = GetComponent <Animator>();
     effectController = SpecialEffectController.instance;
     #region Mobile Buttons
     // attackButton = GameObject.Find("Attack Button").GetComponent<Button>();
     // kickButton = GameObject.Find("Kick Button ").GetComponent<Button>();
     // specialAttack_Button = GameObject.Find("Special Attack Button").GetComponent<Button>();
     //// buttonColor = GameObject.Find("Special Attack Button").GetComponent<Button>().colors;
     #endregion
 }
    private void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;

        player           = GameObject.FindGameObjectWithTag(Tags.PLAYER).transform;
        playerMovement   = player.GetComponent <CharacterMovement>();
        healthController = player.GetComponent <UniversalHealthController>();

        // this makes sure that we inform game manager that we are in gameplay scene
        // so we can enable and disable pause menu
        GameManager.instance.gameState = GameState.RUNNING;
        missionUI = MissionManagerUI.instance;
        restartBtn.onClick.AddListener(() => RestartGameOnCheckPoint());
        quitBtn.onClick.AddListener(() => QuitToMainMenu());
    }
Exemplo n.º 6
0
    private void Shoot()
    {
        agent.isStopped = true;
        anim.Walk(false);

        Ray        shootRay = new Ray(firePoint.position, firePoint.forward);
        RaycastHit infoHit;

        agent.transform.LookAt(targetPos.position);

        Debug.DrawRay(firePoint.position, firePoint.forward * 100f, Color.blue, 2f);

        currentShootTimer += Time.deltaTime;

        float randomFireRate = Random.Range(2f, 4f);

        if (currentShootTimer > randomFireRate + 1)
        {
            currentShootTimer = 0f;
            Invoke("PlayShootAnim", 0.3f);


            var plasmaMuzzle = Instantiate(muzzleEffect, muzzlePoint.position, Quaternion.identity);

            if (Physics.Raycast(shootRay, out infoHit, 100f))
            {
                //Debug.Log("Enemy Shot " + infoHit.collider.name);

                if (infoHit.collider.gameObject.CompareTag(Tags.PLAYER))
                {
                    UniversalHealthController enemyhealth = infoHit.collider.gameObject.GetComponent <UniversalHealthController>();

                    if (enemyhealth != null)
                    {
                        enemyhealth.ApplyDamage(shootDamage);
                    }
                }
            }
        }


        if (Vector3.Distance(transform.position, targetPos.position) > shootRadius)
        {
            enemyAttack = EnemyAttack.CHASE;
        }
    }
Exemplo n.º 7
0
    public PlayerData(UniversalHealthController player)
    {
        if (player.isPlayer)
        {
            health = player.health;

            // storring player position in float array
            // returning this values after saving in universal health controller because it has all values that
            // we need to store

            position = new float[3];

            position[0] = player.transform.position.x;
            position[1] = player.transform.position.y;
            position[2] = player.transform.position.z;
        }
    }
    public void StartShooting()
    {
        _defaultTimer += Time.deltaTime;

        if (_defaultTimer >= fireRate && startShootingAfterWaring == true)
        {
            _defaultTimer = 0f;

            var effect = Instantiate(shootFx, shootPoint.position, Quaternion.identity);
            effect.transform.SetParent(transform);

            _audioSource.clip = shootClip;
            _audioSource.Play();

            Vector3    shootDir = _target.position - transform.position + Vector3.up;
            Ray        ray      = new Ray(transform.position, shootDir);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform.tag == "Player")
                {
                    UniversalHealthController playerHealth = hit.transform.gameObject.GetComponent <UniversalHealthController>();
                    if (playerHealth != null)
                    {
                        if (playerHealth.isPlayer)
                        {
                            playerHealth.ApplyDamage(_damage);
                        }
                        if (playerHealth.health <= 0)
                        {
                            _audioSource.Stop();
                            enabled = false;
                            startShootingAfterWaring = false;
                        }
                    }

                    // Debug.Log("player's health :" + playerHealth.health);
                }
            }
        }
    }
Exemplo n.º 9
0
    private void FireGun()
    {
        Debug.DrawRay(_firePoint.position, _firePoint.forward * 100, Color.red, 2f);

        Ray        ray = new Ray(_firePoint.position, _firePoint.forward);
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo, 100f))
        {
            UniversalHealthController enemyHealth = hitInfo.collider.GetComponent <UniversalHealthController>();

            if (enemyHealth != null)
            {
                if (enemyHealth.isEnemy)
                {
                    enemyHealth.ApplyDamage(_damage);
                    Debug.Log("enemy's health :" + enemyHealth.health + hitInfo.collider.gameObject.name);
                }
            }
        }
    }
Exemplo n.º 10
0
    // save system is storred forever of this game becuase it is static

    public static void SavePlayer(UniversalHealthController player)
    {
        Debug.Log("Saving...");

        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.dat";
        FileStream      file      = new FileStream(path, FileMode.Create);

        try
        {
            PlayerData data = new PlayerData(player);

            formatter.Serialize(file, data);
        }
        catch (SerializationException e)
        {
            Debug.LogError("There was an issue serializing this data" + e.Message);
        }
        finally
        {
            file.Close();
        }
    }
Exemplo n.º 11
0
 private void Awake()
 {
     gameplayManager  = FindObjectOfType <GameplayManager>();
     healthController = GameObject.FindGameObjectWithTag(Tags.PLAYER).GetComponent <UniversalHealthController>();
     gameManager      = FindObjectOfType <GameManager>();
 }
 private void Awake()
 {
     character        = FindObjectOfType <CharacterAttackController>();
     healthController = GameObject.FindGameObjectWithTag(Tags.ENEMY).GetComponent <UniversalHealthController>();
     animations       = GameObject.FindGameObjectWithTag(Tags.ENEMY).GetComponent <CharacterAnimations>();
 }