Ejemplo n.º 1
0
    public override void doAction(LChatacterInterface character, LChatacterInformationInterface information)
    {
        int targetId = character.GetTargetId();

        if (targetId != -1)
        {
            LChatacterInterface target = information.GetCharacter(targetId);

            if (null == target || target.IsDead())
            {
                return;
            }
            var     selPos    = character.GetCurPosition();
            var     targetPos = target.GetCurPosition();
            Vector3 MoveDir   = targetPos - selPos;
            MoveDir.y = 0f;


            MoveDir.Normalize();
            Vector3 pos0 = MoveDir * Time.deltaTime * speed;
            Vector3 pos  = information.tryMove(character.GetCurPosition(), pos0, true);
            character.SetCurPosition(pos);
            character.SetCurForward(MoveDir);
        }
    }
Ejemplo n.º 2
0
    public override void doAction(LChatacterInterface character, LChatacterInformationInterface information)
    {
        Vector3 pos  = character.GetCurPosition();
        Vector3 pos0 = pos;
        float   J2   = JumpTime * 2;

        if (curTime < 0)
        {
            return;
        }
        float t = curTime / JumpTime;
        float b = t - 1;
        float y = -b * b + 1;

        float h = jumpHeight * y;

        pos.y = beginPositon.y + h;

        pos += MoveDir * jumpSpeed * Time.deltaTime;

        /*if (curTime > JumpTime * 2)
         * {
         *  Vector3 gh = information.getGroundHight(pos);
         *  //Debug.LogError("pos.y =  " + pos.y + " g "+gh.y + " " + (gh.y <= pos.y));
         *
         * }*/
        pos = information.tryMove(pos0, pos - pos0, false);


        character.SetCurPosition(pos);
    }
Ejemplo n.º 3
0
    public override void endAction(LChatacterInterface character, LChatacterInformationInterface information)
    {
        var pos = information.getGroundHight(character.GetCurPosition());

        character.SetCurPosition(pos);

        //Debug.LogError("end fall");
    }
Ejemplo n.º 4
0
    public override void doAction(LChatacterInterface character, LChatacterInformationInterface information)
    {
        var  pos0  = character.GetCurPosition();
        var  pos   = information.getGroundHight(pos0);
        bool inAir = pos0.y - pos.y > 0.01f;

        if (inAir)
        {
            pos0.y -= fallSpeed * Time.deltaTime;
            pos0.y  = pos0.y > pos.y ? pos0.y : pos.y;
            character.SetCurPosition(pos0);
        }
    }
Ejemplo n.º 5
0
 public override void doAction(LChatacterInterface character, LChatacterInformationInterface information)
 {
     if (curTime <= hit_back_time)
     {
         Vector3 dir = MoveDir * Time.deltaTime * hit_back_speed;
         Vector3 pos = information.tryMove(character.GetCurPosition(), dir, true);
         character.SetCurPosition(pos);
     }
     else
     {
         endPoition.y = character.GetCurPosition().y;;
         Vector3 pos = information.tryMove(endPoition, Vector3.zero, true);
     }
 }
Ejemplo n.º 6
0
    public override void doAction(LChatacterInterface character, LChatacterInformationInterface information)
    {
        Vector3 pos  = character.GetCurPosition();
        Vector3 pos0 = pos;
        float   t    = curTime / JumpTime;
        float   b    = t - 1;
        float   y    = -b * b + 1;

        float h = jumpHeight * y;


        pos  = Vector3.Lerp(beginPositon, endPositoin, t * 0.5f);
        pos += new Vector3(0f, h, 0f);
        character.SetCurPosition(pos);
    }
Ejemplo n.º 7
0
    public override void doAction(LChatacterInterface character, LChatacterInformationInterface information)
    {
        Vector3 forward;

        character.GetForward(out forward);
        Vector3 left    = Vector3.Cross(forward, Vector3.up);
        Vector3 MoveDir = (left * VirtualInput.dir.x + forward * VirtualInput.dir.y).normalized;
        Vector3 dir     = MoveDir * Time.deltaTime * speed;
        Vector3 basePos = character.GetCurPosition();
        Vector3 pos     = information.tryMove(basePos, dir, true);

        if (basePos.y - pos.y > 0.5f)
        {
            pos = information.tryMove(basePos, dir, true);
        }
        character.SetCurPosition(pos);
        character.SetCurForward(MoveDir);
    }
Ejemplo n.º 8
0
    public override void doAction(LChatacterInterface character, LChatacterInformationInterface information)
    {
        if (!firFrame && jumpCount < maxJumpCount && VirtualInput.IsButtonDown(button))
        {
            jumpCount++;
            initJump(character, information);
        }
        firFrame = false;


        Vector3 pos  = character.GetCurPosition();
        Vector3 pos0 = pos;
        float   t    = curTime / JumpTime;
        float   b    = t - 1;
        float   y    = -b * b + 1;

        float h = jumpHeight * y;

        pos.y = beginPositon.y + h;

        pos += MoveDir * jumpSpeed * Time.deltaTime;
        pos  = information.tryMove(pos0, pos - pos0, false);
        character.SetCurPosition(pos);
    }
Ejemplo n.º 9
0
 public override void endAction(LChatacterInterface character, LChatacterInformationInterface information)
 {
     isJumpping = false;
     character.SetCurPosition(information.getGroundHight(endPositoin + Vector3.up));
 }