Ejemplo n.º 1
0
    void Punch()
    {
        var cols = boxCheck.BoxCheck(enemyMask);

        foreach (Collider c in cols)
        {
            var ec = c.transform.root.GetComponent <EnemyController>();
            if (ec != null)
            {
                ec.GetHit();
            }
        }
        // Punch animation
    }
Ejemplo n.º 2
0
    void Update()
    {
        // Movement
        var moveDir = new Vector3();

        if (Input.GetKey(KeyCode.W))
        {
            moveDir += Vector3.forward;
        }
        if (Input.GetKey(KeyCode.A))
        {
            moveDir += Vector3.left;
        }
        if (Input.GetKey(KeyCode.S))
        {
            moveDir += Vector3.back;
        }
        if (Input.GetKey(KeyCode.D))
        {
            moveDir += Vector3.right;
        }

        // if moving to any direction
        movement.Move(moveDir);

        // Jump
        if (Input.GetKeyDown(KeyCode.Space) && grounded)
        {
            movement.Jump();
            grounded = false;
        }

        // Rotation
        if (attacking.GetHasWeapon())
        {
            rotation.RotateToMousePosition();
        }
        else
        {
            rotation.RotateToDirection(moveDir);
        }

        // Attacking
        if (Input.GetKeyDown(KeyCode.Mouse0) && currentHeldBox == null)
        {
            attacking.Attack();
        }

        // Box holding
        if (Input.GetKeyDown(KeyCode.E))
        {
            var cols = boxCheck.BoxCheck(boxMask);
            foreach (Collider c in cols)
            {
                currentHeldBox = c.transform.root.GetComponentInChildren <BoxBehaviour>();
                if (currentHeldBox != null)
                {
                    currentHeldBox.Hold(transform);
                    break;
                }
            }
        }

        // Box throwing
        if (Input.GetKeyDown(KeyCode.Mouse0) && currentHeldBox != null)
        {
            currentHeldBox.Throw(transform.forward);
            currentHeldBox = null;
        }

        // DEBUG MODESWITCH
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            attacking.hasWeapon = false;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            attacking.hasWeapon = true;
        }
    }