Exemplo n.º 1
0
 void Start()
 {
     playerMelee = GetComponent <PlayerMelee>();
     rb          = GetComponent <Rigidbody2D>();
     anim        = GetComponent <Animator>();
     canMove     = true;
 }
Exemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Player Weapon")
     {
         PlayerMelee playerWeapon = col.GetComponent <PlayerMelee>();
         Health -= playerWeapon.Damage;
     }
 }
    // Use this for initialization
    void Awake()
    {
        player      = GameObject.FindGameObjectWithTag("Player");
        playerStats = player.GetComponent <PlayerStats> ();
        playerMelee = player.GetComponent <PlayerMelee> ();

        //points.text = currentPointsToUse.ToString();
    }
Exemplo n.º 4
0
 private void Awake()
 {
     anim            = GetComponent <Animator>();
     playerMovement  = GetComponent <PlayerMovement>();
     playerMelee     = GetComponent <PlayerMelee>();
     playerAudio     = GetComponent <AudioSource>();
     currentHealth   = startingHealth;
     healthText.text = "Health: " + startingHealth + "/" + currentHealth;
 }
Exemplo n.º 5
0
 private void Awake()
 {
     m_PlayerController  = GetComponent <PlayerController>();
     m_Rigidbody2D       = GetComponent <Rigidbody2D>();
     m_PlayerFXManager   = GetComponent <PlayerFXManager>();
     m_PlayerMelee       = GetComponent <PlayerMelee>();
     m_PlayerThrow       = GetComponent <PlayerThrow>();
     m_CapsuleCollider2D = GetComponent <CapsuleCollider2D>();
 }
Exemplo n.º 6
0
    void Awake()
    {
        movementController = GetComponent <MoveController>();
        abilityManager     = GetComponent <AbilityCooldown>();
        meleeController    = GetComponent <PlayerMelee>();

        #region controls
        controls = new PlayerInput();

        controls.Gameplay.Move.performed += ctx =>
        {
            //This input only alters the value when the value returned by the control stick is changed
            moveDirection = ctx.ReadValue <Vector2>();
        };

        controls.Gameplay.Move.canceled += ctx =>
        {
            //When the stick is returned back to neutral, moveDirection goes back to (0,0)
            moveDirection = Vector2.zero;
        };

        controls.Gameplay.Jump.performed += ctx =>
        {
            //Jumping can be done in controls since it's a one-off impulse force
            //If adding double jump, jump can be moved to its own method
            if (grounded)
            {
                movementController.Jump(rb, jumpForce);
            }
        };

        controls.Gameplay.Attack.performed += ctx =>
        {
            if (canAttack)
            {
                //Basic melee input will use a method in the melee controller to check whether an attack can be performed
                //If the player is able to run and attack at the same time there may need to be 2 objects, one for the player legs and one for the top half with the attack animation
                meleeController.Attack();
            }
        };

        controls.Gameplay.Ability1.performed += ctx =>
        {
            abilityManager.StartAbility1();
        };

        controls.Gameplay.Ability2.performed += ctx =>
        {
            abilityManager.StartAbility2();
        };

        controls.Gameplay.Parry.performed += ctx =>
        {
            print("Parry");
        };
        #endregion
    }
Exemplo n.º 7
0
 private void Awake()
 {
     _instance                   = this;
     playerObject                = GameObject.Find("Player");
     player                      = GameObject.Find("Player").GetComponent <PlayerController>();
     playerMelee                 = GameObject.Find("PlayerAttack").GetComponent <PlayerMelee>();
     playerTransform             = player.transform;
     Application.targetFrameRate = -1;
 }
Exemplo n.º 8
0
    public void GetScripts() //get script components
    {
        try
        {
            PC = GameObject.FindWithTag("Player").GetComponent <PlayerController>();
        }
        catch
        {
            PC = null;
        }

        try
        {
            PS = GameObject.Find("Pistol").GetComponent <PlayerShooting>();
            if (PS != null)
            {
                PS.CancelReload();
            }
        }
        catch
        {
            PM = null;
        }

        try
        {
            PM = GameObject.Find("Machete").GetComponent <PlayerMelee>();
        }
        catch
        {
            PM = null;
        }

        try
        {
            UCI = GameObject.Find("Player").GetComponent <UseConsumableItem>();
            if (UCI != null && UseConsumableItem.playerIsHealing)
            {
                UCI.StopHeal();
            }
        }
        catch
        {
            UCI = null;
        }

        try
        {
            SS = GameObject.FindWithTag("Player").GetComponent <SlotSelection>();
        }
        catch
        {
            SS = null;
        }
    }
Exemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     if (active)
     {
         transform.localEulerAngles = new Vector3(0f, 0f, PlayerMelee.GetRawRotation(PlayerBaseClass.current.playerMovement.dashDirection));
     }
     else
     {
         transform.localEulerAngles = new Vector3(0f, 0f, PlayerMelee.GetRawRotation(PlayerBaseClass.current.playerMovement.lastValidDirection));
     }
 }
Exemplo n.º 10
0
    protected override float DoOnHit()
    {
        _ = base.DoOnHit();

        PlayerMelee currentPlayerMove = battleManager.CurrentMove as PlayerMelee;

        if (currentPlayerMove != null)
        {
            StartCoroutine(PlayHitParticles(battleManager.GetPlayerHitboxTransform(currentPlayerMove.hitboxID).position,
                                            currentPlayerMove.hitParticles));
        }
        return(0);
    }
    private void finishMeleeWeapon()
    {
        m_AmmoManager.SetActive(false);

        PlayerMelee playerMelee = m_CurWeaponSelected.GetComponentInChildren <PlayerMelee> ();

        playerMelee.m_FirstPersonController = m_Player.GetComponentInChildren <UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ();
        playerMelee.setUpReferences();

        putOnCorrectMeleeAnimator(playerMelee);

        m_CurWeaponSelected.SetActive(true);
    }
    public void turnOffShootingAbility()
    {
        PlayerShooting playerShooting = m_CurWeaponSelected.GetComponentInChildren <PlayerShooting> ();

        if (playerShooting != null)
        {
            playerShooting.m_CanShoot = false;
        }
        else
        {
            PlayerMelee playerMelee = m_CurWeaponSelected.GetComponentInChildren <PlayerMelee> ();
            playerMelee.m_CanAttack = false;
        }
    }
Exemplo n.º 13
0
    private void Awake()
    {
        currentSprite = gameObject.GetComponent <SpriteRenderer>().sprite;
        anim          = GetComponent <Animator>();

        currentController = GetComponent <CharacterController2D>();
        currentMovement   = GetComponent <PlayerMovement>();
        tankContoller     = GetComponent <TankBehavior>();
        weapon            = GetComponent <Weapon>();
        playerMelee       = GetComponent <PlayerMelee>();
        rb = GetComponent <Rigidbody2D>();

        tankContoller.enabled = false;

        tankWeapon         = GetComponent <TankWeapon>();
        tankWeapon.enabled = false;
    }
Exemplo n.º 14
0
    private void Awake()
    {
        cameraShake = GameObject.FindGameObjectWithTag("Camera");
        cam         = cameraShake.GetComponent <CineCameraShake>();

        currentController = GetComponent <CharacterController2D>();
        currentMovement   = GetComponent <PlayerMovement>();
        planeContoller    = GetComponent <PlaneBehavior>();
        weapon            = GetComponent <Weapon>();
        playerMelee       = GetComponent <PlayerMelee>();
        rb = GetComponent <Rigidbody2D>();

        planeContoller.enabled = false;

        planeWeapon         = GetComponent <PlaneWeapon>();
        planeWeapon.enabled = false;
        Debug.Log("Is plane enabled? " + planeContoller.enabled);
    }
    private void putOnCorrectMeleeAnimator(PlayerMelee playerMelee)
    {
        string animatorWanted = playerMelee.returnAnimatorName();

        Debug.Log(animatorWanted);
        Animator animator = m_Arms.GetComponentInChildren <Animator> ();

        if (animatorWanted == "PlayerPunchController")
        {
            animator.runtimeAnimatorController = m_PlayerPunchController.runtimeAnimatorController;
        }
        else if (animatorWanted == "PlayerSwordController")
        {
            animator.runtimeAnimatorController = m_PlayerSwordController.runtimeAnimatorController;
        }

        Debug.Log("Putting the animator on!");
        playerMelee.m_MeleeAnim = animator;
    }
Exemplo n.º 16
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);

        rb          = GetComponent <Rigidbody2D>();
        animator    = GetComponent <Animator>();
        health      = GetComponent <PlayerHealth>();
        melee       = GetComponent <PlayerMelee>();
        projectile  = GetComponent <PlayerProjectile>();
        interact    = GetComponent <PlayerInteract>();
        audioSource = GetComponent <AudioSource>();
    }
Exemplo n.º 17
0
    private void GrabReferences()
    {
        characterMotor = GetComponent <CharacterMotor>();
        dealDamage     = GetComponent <DealDamage>();
        m_player       = GameObject.FindGameObjectWithTag("Player").transform;
        pMelee         = m_player.GetComponentInParent <PlayerMelee>();

        //avoid setup errors
        if (tag != "Enemy")
        {
            tag = "Enemy";
            Debug.LogWarning("'EnemyAI' script attached to object without 'Enemy' tag, it has been assign automatically", transform);
        }

        // Grab sightbounds
        sightTrigger = transform.Find("Sight Bounds").GetComponent <TriggerParent> ();
        if (!sightTrigger)
        {
            Debug.LogError("'TriggerParent' script needs attaching to enemy 'SightBounds'");
        }

        // Grab attack bounds
        attackTrigger = transform.Find("Attack Bounds").GetComponent <TriggerParent> ();
        if (!attackTrigger)
        {
            Debug.LogError("'TriggerParent' script needs attaching to enemy 'attackBounds'");
        }

        health = GetComponent <Health> ();
        if (!health)
        {
            Debug.LogError("This gameoObject needs a 'Health' script");
        }

        // Grab animator controller
        animatorController = GetComponentInChildren <Animator> ();
        if (!animatorController)
        {
            Debug.LogError(gameObject.name + " needs an Animator controller. Attach one or enemy won't be able to animate!");
        }
    }
Exemplo n.º 18
0
        float camRayLength = 75f;          // The length of the ray from the camera into the scene.
#endif

        void Awake()
        {
#if !MOBILE_INPUT
            // Create a layer mask for the floor layer.
            Debug.Log(floorMask = LayerMask.GetMask("Floor"));
#endif

            // Set up references.
            anim                  = GetComponent <Animator> ();
            playerRigidbody       = GetComponent <Rigidbody> ();
            mainCamera            = Camera.main;
            mainCameraTransform   = mainCamera.transform;
            initOffsetToPlayer    = mainCameraTransform.position - playerRigidbody.position;
            cameraOffset          = mainCameraTransform.position - playerRigidbody.position;
            playerMovementPlane   = new Plane(this.transform.up, this.transform.position + this.transform.up * cursorPlaneHeight);
            screenMovementSpace   = Quaternion.Euler(0, mainCameraTransform.eulerAngles.y, 0);
            screenMovementForward = screenMovementSpace * Vector3.forward;
            screenMovementRight   = screenMovementSpace * Vector3.right;

            playerMelee = GetComponent <PlayerMelee>();
        }
Exemplo n.º 19
0
    void Death()
    {
        // Set the death flag so this function won't be called again.
        m_IsDead = true;

        m_GameOverManager.enabled = true;
        m_GameOverManager.lost();
        m_GameOverManager.m_Driving = false;

        // Turn off any remaining shooting effects.

        // Tell the animator that the player is dead.
        // anim.SetTrigger ("Die");

        // Set the audiosource to play the death clip and play it (this will stop the hurt sound from playing).
        m_PlayerAudio.clip = m_DeathClip;
        m_PlayerAudio.Play();


        // Turn off the movement and shooting scripts.
        m_PlayerMovement.enabled = false;

        PlayerShooting playerShooting = GetComponentInChildren <PlayerShooting> ();

        //playerShooting.DisableEffects();

        if (playerShooting != null)
        {
            playerShooting.turnOffReloadScript();
            playerShooting.enabled = false;
        }
        else
        {
            PlayerMelee playerMelee = GetComponentInChildren <PlayerMelee> ();
            playerMelee.enabled = false;
        }
    }
Exemplo n.º 20
0
    protected override IEnumerator Attacking()
    {
        isAttacking = true;
        Vector3    startPos = transform.position;
        Quaternion startRot = transform.rotation;

        animator.SetBool("blocking", false);

        hurtbox.enabled = false;

        yield return(new WaitUntil(() => attackChosen));

        yield return(new WaitUntil(() => TargetChosen()));

        battleManager.CurrentMove = currentMove;

        try
        {
            for (int i = 0; i < currentMove.particleEffects.Length; i++)
            {
                StartCoroutine(PlayParticles(currentMove.particleDelay[i],
                                             currentMove.particleEffects[i], spellSpawnTransforms[currentMove.particleSpawnPositionID[i]],
                                             currentMove.particleDuration[i], currentMove.releaseOnInit[i]));
            }
        }
        catch (NullReferenceException) {
            Debug.Log("particles are null");
        }

        PlayerMelee     melee      = currentMove as PlayerMelee;
        PlayerSpell     spell      = currentMove as PlayerSpell;
        PlayerSelfBuff  selfBuff   = currentMove as PlayerSelfBuff;
        SpellProjectile projectile = null;

        if (melee != null)
        {
            walkingForward = true;
            agent.SetDestination(currentTarget.GetAttackPosition().position);
            agent.stoppingDistance = attackPositionOffset;
            yield return(new WaitUntil(() => !agent.pathPending));

            yield return(new WaitUntil(() => agent.pathStatus == NavMeshPathStatus.PathComplete && agent.remainingDistance <= attackPositionOffset));

            hitboxes[melee.hitboxID].enabled = true;
        }

        animator.SetTrigger(name: currentMove.animationName);

        yield return(new WaitUntil(() => animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains(currentMove.animationName)));

        PayForAttack();

        if (selfBuff != null)
        {
            Debug.Log($"{selfBuff.EnhanceDuration(this, selfBuff.buff.duration)}");
            AddPerk(selfBuff.buff, selfBuff.EnhanceDuration(this, selfBuff.buff.duration));
        }

        if (spell != null)
        {
            if (spell.type == SpellType.Areal)
            {
                yield return(new WaitForSeconds(spell.delay[0]));

                foreach (Enemy enemy in battleManager.GetEnemies())
                {
                    for (int i = 0; i < spell.projectile.Length; i++)
                    {
                        //yield return new WaitForSeconds(spell.delay[i]);
                        projectile = Instantiate(spell.projectile[i], spellSpawnTransforms[0].position,
                                                 transform.rotation, transform.parent);
                        projectile.LockOnTarget(enemy.GetProjectileTarget());
                    }
                }
            }
            else
            {
                bool isMultiple = spell.type == SpellType.Multiple;
                if (!isMultiple)
                {
                    transform.rotation = Quaternion.Lerp(transform.rotation,
                                                         Quaternion.LookRotation(currentTarget.transform.position - transform.position),
                                                         Time.deltaTime);
                }
                Enemy[] aliveEnemies = battleManager.GetEnemies().FindAll(enemy => !enemy.IsDead()).ToArray();
                for (int i = 0; i < spell.projectile.Length; i++)
                {
                    yield return(new WaitForSeconds(spell.delay[i]));

                    projectile = Instantiate(spell.projectile[i], spellSpawnTransforms[spell.spawnTransformID].position,
                                             transform.rotation, transform);
                    projectile.LockOnTarget(isMultiple ? aliveEnemies[Mathf.Min(aliveEnemies.Length - 1, i)].GetProjectileTarget() :
                                            currentTarget.GetProjectileTarget());
                }
            }
        }
        yield return(new WaitUntil(() => !animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains(currentMove.animationName)));

        if (melee != null)
        {
            walkingForward       = false;
            agent.updateRotation = false;
            agent.SetDestination(startPos);
            agent.stoppingDistance           = 0f;
            hitboxes[melee.hitboxID].enabled = false;
            yield return(new WaitUntil(() => !agent.pathPending));

            yield return(new WaitUntil(() => agent.pathStatus == NavMeshPathStatus.PathComplete && agent.remainingDistance == 0));

            agent.updateRotation = true;
            transform.rotation   = startRot;
        }

        yield return(new WaitUntil(() => projectile == null));

        attackChosen = false;
        bool doBlock = attributes.probabilityOfBlock +
                       (currentMove as PlayerMove).probOfBlock > UnityEngine.Random.Range(0, 1f);

        animator.SetBool("blocking", doBlock);

        hurtbox.enabled = true;
        yield return(base.Attacking());
    }
Exemplo n.º 21
0
    public void Awake()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        _playerMelee = player.GetComponent <PlayerMelee>();
    }