Пример #1
0
    // Update is called once per frame
    void Update()
    {
        moveDirectionX = 0f;

        // Player character actions
        if (playerHealth.GetCanAct())
        {
            moveDirectionX = Input.GetAxisRaw("Horizontal");

            if (Input.GetButtonDown("Jump"))
            {
                playerMovement.Jump();
            }
            if (Input.GetButtonUp("Jump"))
            {
                playerMovement.CutJumpHeight();
            }

            if (Input.GetButtonDown("Transform"))
            {
                //playerMovement.StopiAllMovement();
                transformationController.Transform();
            }

            if (Input.GetButtonDown("LightAttack"))
            {
                if (transformationController.GetIsInNormalForm())
                {
                    meleeAttack.Attack(ActionType.lightMelee);
                }
                else
                {
                    rangedAttack.Attack(ActionType.lightRanged);
                }
            }
            if (Input.GetButtonDown("HeavyAttack"))
            {
                if (transformationController.GetIsInNormalForm())
                {
                    meleeAttack.Attack(ActionType.heavyMelee);
                }
            }
        }

        playerMovement.MoveInDirection(moveDirectionX);

        // Interface controls
        if (Input.GetButtonDown("Cancel"))
        {
            screenManager.SetPauseMenuActive();
        }
    }
Пример #2
0
    public override void UseSkill()
    {
        base.UseSkill();

        if (m_attack != null)
        {
            m_attack.Attack(m_nowDirection);
        }
    }
Пример #3
0
    public void MeleeAttack()
    {
        if (!isPlaying)
        {
            return;
        }

        if (allowMeleeAttack && meleeAttack != null)
        {
            if (meleeAttack.Attack())
            {
                anim.SetTrigger("melee_attack");
                SoundManager.PlaySfx(meleeAttackSound, meleeAttackSoundVolume);
            }
        }
    }
    private IEnumerator DoAttack()
    {
        //playerChaseDetector.gameObject.SetActive(false);
        attackDetector.gameObject.SetActive(false);
        entityMovement.StopWalking();
        canChangeState = false;

        yield return(new WaitForSeconds(0.8f));

        attackController.Attack(ActionType.lightMelee);
        yield return(new WaitForSeconds(0.3f));

        canChangeState = true;
        playerChaseDetector.gameObject.SetActive(true);
        ChangeState(BehaviourState.Chasing);
        attacking = null;
    }
Пример #5
0
    public void AnimAttack(bool randomize = true)
    {
        if (!hasAuthority)
        {
            Debug.LogError("No authority to call animation with this weapon!");
            return;
        }
        if (IsAttacking)
        {
            Debug.LogError("Already attacking!");
            return;
        }
        int random = 0;

        if (randomize)
        {
            random = Randomize(Animation.RequireNewRandom);
        }

        // This takes place on the local client...
        Animation.Animator.SetInteger(Animation.Random, random);
        Animation.Animator.SetTrigger(Animation.Attack);

        // Deal damage using the MeleeAttack class:
        Attack.Attack(); // Attack any Creatures in the area.

        // Tell other clients what animations we are doing...
        // On their end, animations will play but the authoritive version of events (animation speed, cancelling etc.)
        // will happen here on the client. May be a bad idea. Oh well. This is because if the local client plays the animation
        // when the RPC is recieved, then attack speed will vary depending on ping. Not gud.
        // On the other hand, this will mean that if there is a high ping then attacks will seem irregular and desynchronised
        // for other clients. Bloody multiplayer :)
        CmdRandomizeAnims(random);
        CmdAnimAttack();

        // Flag as attacking
        IsAttacking = true;

        // TODO FIXME
        // DO real attack here, in CMD
    }
Пример #6
0
 private void FixedUpdate()
 {
     if (Time.timeScale != 0)
     {
         RaycastHit2D hit = Physics2D.Raycast(transform.position, player.transform.position - transform.position, Mathf.Infinity, layersToIgnore);
         if (hit.collider != null)
         {
             if (hit.collider.transform.tag == "Player")
             {
                 if (hit.distance <= enemyStats.range)
                 {
                     mA.Attack();
                 }
                 else
                 {
                     MoveTowardsPlayer();
                 }
             }
         }
     }
 }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Q))
        {
            Debug.Log("Base attack value: " + baseMeleeAttack.Attack());
        }

        if (Input.GetKeyDown(KeyCode.W))
        {
            Debug.Log("Hard punch value: " + hardPunch.Attack());
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("Ki Punch value: " + kiPunch.Attack());
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            Debug.Log("Super Ki Punch value: " + superKiPunch.Attack());
        }
    }
Пример #8
0
 /// <summary>
 /// Method for Attack
 /// </summary>
 private void Attack()
 {
     meleeAttack.Attack();
 }
Пример #9
0
    public override void Move()
    {
        //Stop when ground attacking on ground and when doing the special attack
        if (attacksGround.cooldownCurr > attacksGround.cooldownTolerance ||
            specialAttack.cooldownCurr > specialAttack.cooldownTolerance)
        {
            controller.Move(0, false);
            return;
        }

        //If the player was crouching, it will continue if there's a ceiling above him
        if (inputManager.crouch || (!inputManager.crouch && controller.IsOnCeiling() && keepCrouch))
        {
            keepCrouch = true;
            //Applying crouch speed modifier
            inputManager.horizontalMove *= crouchSpeed;
            //Disabling the stand collider if on ground
            if (standCollider)
            {
                standCollider.enabled = false;
            }
            //Setting animator to crouch
            animator.SetBool("IsCrouching", true);
        }
        else
        {
            keepCrouch = false;
            //Enabling the stand collider
            if (standCollider)
            {
                standCollider.enabled = true;
            }
            //Setting animator to not crouch
            animator.SetBool("IsCrouching", false);
        }

        // Attack only if not crouching
        if (!keepCrouch)
        {
            if (inputManager.attack)
            {
                if (controller.IsOnGround())
                {
                    attacksGround.Attack();
                }
                else
                {
                    attacksAir.Attack();
                }
            }
            else if (controller.IsOnGround() && inputManager.specialAttack)
            {
                specialAttack.Attack();
                inputManager.specialAttack = false;
            }
        }

        //Can't jump when there's a ceiling directly above
        if (controller.IsOnCeiling())
        {
            inputManager.jump = false;
        }

        //Filtering the jump input
        if (lastJumpInput && inputManager.jump)
        {
            inputManager.jump = false;
        }
        else
        {
            lastJumpInput = inputManager.jump;
        }

        //If the player isn't grounded, it can't double jump
        if (inputManager.jump && !controller.IsOnGround())
        {
            //Moving it, without double jumping
            inputManager.jump = false;
        }

        // Moving
        controller.Move(inputManager.horizontalMove * Time.fixedDeltaTime, inputManager.jump);

        //Dash if not crouching
        if (!keepCrouch && inputManager.dash != 0)
        {
            controller.Dash(inputManager.dash == 1);
            inputManager.dash = 0;
        }
    }
Пример #10
0
 private void Attack(Vector2 CoordinateDifference)
 {
     RunToHero(CoordinateDifference);
     meleeAtack.Attack();
 }
Пример #11
0
    // Update is called once per frame
    void Update()
    {
        if (currentHpRegen < hpRegenTime)
        {
            currentHpRegen += Time.deltaTime;
        }
        else if (hpRegen && currentHp < hp)
        {
            currentHpRegen = 0;
            currentHp++;
            updateHP();
        }

        if (currentTeleportCoolDown < teleportCoolDown)
        {
            currentTeleportCoolDown += Time.deltaTime;
        }

        rb.velocity = new Vector2(0, 0);

        if (Input.GetKeyDown(KeyCode.E))
        {
            GameObject temp  = attack;
            GameObject temp2 = swapAttack2;

            attack      = swapAttack;
            swapAttack2 = temp;
            swapAttack  = temp2;


            if (attack.tag.Equals("Melee"))
            {
                MeleeAttack mA = attack.GetComponent <MeleeAttack>();
                anim.SetInteger("weapon", mA.weaponId);
            }
            else
            {
                anim.SetInteger("weapon", 2);
            }
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            if (spellSelected == 0)
            {
                spellSelected = 1;
            }
            else
            {
                spellSelected = 0;
            }
        }

        Vector3 mouseScreenPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        Vector3 lookAt = mouseScreenPosition;

        float AngleRad = Mathf.Atan2(lookAt.y - this.transform.position.y, lookAt.x - this.transform.position.x);

        float AngleDeg = (180 / Mathf.PI) * AngleRad;

        transform.rotation = Quaternion.Euler(0, 0, 0);


        if (AngleDeg >= -45 && AngleDeg < 45)
        {
            //  Debug.Log("Right");
            //       transform.rotation = Quaternion.Euler(0, 0, 0);

            transform.localScale = new Vector3(-1 * transform.localScale.y, transform.localScale.y, transform.localScale.z);
        }

        // if (AngleDeg >= 45 && AngleDeg < 135)
        // {
        //     //Debug.Log("Up");

        //     transform.rotation = Quaternion.Euler(0, 0, 90);
        // }


        if (AngleDeg >= 135 || AngleDeg < -135)
        {
            ///  Debug.Log("Left");
            transform.localScale = new Vector3(transform.localScale.y, transform.localScale.y, transform.localScale.z);
            // transform.rotation = Quaternion.Euler(0, 0, 180);
        }


        // if (AngleDeg >= -135 && AngleDeg < -45)
        // {
        //     //    Debug.Log("Down");

        //     transform.rotation = Quaternion.Euler(0, 0, 270);
        // }

        float yMove = Input.GetAxis("Vertical");
        float xMove = Input.GetAxis("Horizontal");

        yMove       = Time.deltaTime * moveSpeed * 50.0f * slowDown * yMove * speedMod;
        xMove       = Time.deltaTime * moveSpeed * 50.0f * slowDown * xMove * speedMod;
        rb.velocity = new Vector2(xMove, yMove);


        if (Input.GetButton("Fire1") && attack != null)
        {
            if (attack.tag.Equals("Melee"))
            {
                MeleeAttack mASpec = attack.GetComponent <MeleeAttack>();
                if (mASpec.Attack(transform.position, AngleDeg))
                {
                    anim.SetTrigger("attacking");
                }
            }
            else if (attack.tag.Equals("Ranged"))
            {
                RangedAttack rASpec = attack.GetComponent <RangedAttack>();

                //rASpec.Shoot(transform.position, AngleDeg);
                rASpec.DrawBow();

                //    Debug.Log("Drawing Arrow " + rASpec.drawAmount);
                slowDown = 0.2f;

                anim.SetBool("bowDrawn", true);
            }
        }

        if (Input.GetButtonDown("Fire2") && spellSelected == 0 && currentTeleportCoolDown > teleportCoolDown && activeSpells[0] == 1)
        {
            mouseScreenPosition.z   = 0;
            transform.position      = mouseScreenPosition;
            currentTeleportCoolDown = 0;
        }

        if (flamethrowerCurrentTotalCoolDown < flamethrowerTotalCoolDown)
        {
            flamethrowerCurrentTotalCoolDown += Time.deltaTime;
        }

        if (flamethrowerCurrentPartCoolDown < flamethrowerPartCoolDown)
        {
            flamethrowerCurrentPartCoolDown += Time.deltaTime;
        }



        if (Input.GetButton("Fire2") && spellSelected == 1 && flamethrowerCurrentTotalCoolDown > flamethrowerTotalCoolDown && activeSpells[1] == 1)
        {
            flamethrowerCurrentTotalCoolDown -= Time.deltaTime * 50;

            GameObject pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            Projectile p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;


            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;
        }

        if (Input.GetButtonUp("Fire1") && attack != null)
        {
            //anim.SetInteger("attacking", 0);
            if (attack.tag.Equals("Ranged"))
            {
                anim.SetBool("bowDrawn", false);
                //    Debug.Log("Firing Arrow");
                RangedAttack rASpec = attack.GetComponent <RangedAttack>();
                rASpec.Shoot(transform.position, AngleDeg);
                slowDown = 1f;
            }
        }

        if (timeSinceLastHit < damageInvulTime)
        {
            //     if (!partySys.isPlaying)
            //   {
            //       partySys.Play();
            //   }
            timeSinceLastHit += Time.deltaTime;
        }
        else
        {
            //        if (partySys.isPlaying)
            //       {
            //           partySys.Stop();
            //       }
        }
    }