Ejemplo n.º 1
0
    public override IEnumerator BuffCoroutine(UnitInfo owner)
    {
        AddBuffAction(owner);
        Rigidbody rigidbody     = owner.GetComponent <Rigidbody>();
        float     buffTimeCount = buffTime;

        do
        {
            if (!owner.GetMovement().isOnGround)
            {
                Vector3 newVelocity = rigidbody.velocity;
                if (newVelocity.y < 0)
                {
                    /*newVelocity.y *= 0.8f;
                     * rigidbody.velocity = newVelocity;*/
                }
            }
            buffTimeCount -= Time.deltaTime;
            yield return(null);
        } while (buffTimeCount > 0);
        ActionBehaviour aBehaviour = owner.GetAction().GetBehaviour("Flying");

        if (aBehaviour)
        {
            owner.GetAction().RemoveAction(aBehaviour);
            GameObject.Destroy(aBehaviour.gameObject);
        }
        owner.RemoveBuff(this);
    }
Ejemplo n.º 2
0
    public override void AddBuffAction(UnitInfo _unit)
    {
        GameObject      buffActionPrefab = Resources.Load <GameObject>("Actions/AFlying");
        Transform       newParent        = _unit.GetAction().GetActionList()[0].transform.parent;
        ActionBehaviour newSkill         = GameObject.Instantiate(buffActionPrefab, newParent).GetComponent <ActionBehaviour>();

        _unit.GetAction().GetActionList().Add(newSkill);
        newSkill.transform.localPosition = Vector3.zero;
    }
Ejemplo n.º 3
0
    void MovementInput()
    {
        Vector3 axis     = GetMovingInput();
        Vector3 downAxis = new Vector3();

        downAxis.x = (Input.GetKeyDown(KeyCode.A)) ? -1 : (Input.GetKeyDown(KeyCode.D)) ? 1 : 0;
        downAxis.z = (Input.GetKeyDown(KeyCode.W)) ? 1 : (Input.GetKeyDown(KeyCode.S)) ? -1 : 0;
        if (dashCheckTime > 0)
        {
            if (downAxis != Vector3.zero)
            {
                if (downAxis == lastAxis)
                {
                    dashCheckTime = 0;
                    if (!myUnit.GetAction().GetBehaviour("WakeUp").IsPlaying() && movement.isOnGround)
                    {
                        myUnit.GetAction().UseSkill("Roll", true);
                    }
                    return;
                }
                else
                {
                    lastAxis      = downAxis;
                    dashCheckTime = dashCheckMaxTime;
                }
            }
            else
            {
                dashCheckTime -= Time.deltaTime;
            }
        }
        else
        {
            lastAxis      = downAxis;
            dashCheckTime = dashCheckMaxTime;
        }
        if (movement.paramaterSet != maxSpeed)
        {
            movement.paramaterSet = maxSpeed;
        }
        bool sprint = !Input.GetKey(KeyCode.LeftShift);

        if (!zoomIn && myUnit.GetState() == UnitInfo.UnitState.idle)
        {
            if (axis != Vector3.zero)
            {
                float speed = (sprint) ? maxSpeed : walkSpeed;
                axis   = Camera.main.transform.TransformVector(axis);
                axis.y = 0;
                axis.Normalize();
                //movement.Move(axis, speed, accelation);
                movement.RotateTo(Quaternion.LookRotation(axis), turnSpeed);
                movement.Move(transform.forward, speed, accelation);
            }
            else
            {
                if (movement.IsMoving())
                {
                    //movement.Stop();
                    movement.StopSmooth(breakAccel);
                }
            }
        }
        else if (zoomIn && myUnit.GetState() != UnitInfo.UnitState.die)
        {
            if (axis != Vector3.zero)
            {
                float speed = (sprint) ? maxSpeed : walkSpeed;
                axis   = Camera.main.transform.TransformVector(axis);
                axis.y = 0;
                axis.Normalize();
                movement.Move(axis, speed, accelation);
            }
            else if (myUnit.GetState() == UnitInfo.UnitState.idle)
            {
                if (movement.IsMoving())
                {
                    //movement.Stop();
                    movement.StopSmooth(breakAccel);
                }
            }
            Vector3 forward = Camera.main.transform.forward;
            forward.y = 0;
            if (forward == Vector3.zero)
            {
                movement.RotateTo(forward, 90);
            }
            else
            {
                movement.RotateTo(Quaternion.LookRotation(forward), 90);
            }
        }
    }