Esempio n. 1
0
    private void Move(Vector2 dir)
    {
        animationMesg.Change(localAcc, "Walk", true);
        Dispatch(AreaCode.ANIMATION, AnimationEvent.ANIMATION_SET_BOOL, animationMesg);
        float angle = Mathf.Atan2(dir.x, dir.y) * Mathf.Rad2Deg;

        this.euler.y       = angle;
        transform.rotation = Quaternion.Euler(euler);

        float speedX    = Mathf.Abs(dir.x);
        float speedY    = Mathf.Abs(dir.y);
        float tempSpeed = Mathf.Sqrt(speedY * speedY + speedX * speedX);

        move.x = dir.x;
        move.y = 0;
        move.z = dir.y;
        characterController.SimpleMove(move * tempSpeed * speed);

        float[] pos  = new float[3];
        float[] rota = new float[3];
        pos[0] = this.transform.position.x;
        pos[1] = this.transform.position.y;
        pos[2] = this.transform.position.z;
        Vector3 v3 = this.transform.rotation.eulerAngles;

        rota[0] = v3.x;
        rota[1] = v3.y;
        rota[2] = v3.z;
        transformDto.Change(null, pos, rota);
        Dispatch(AreaCode.GAME, GameEvent.GAME_UPLOAD_TRANS, transformDto);
    }
Esempio n. 2
0
    /// <summary>
    /// 处理传来的其他玩家的方位信息
    /// </summary>
    /// <param name="dto"></param>
    private void SyncTrans(TransformDto dto)
    {
        string     acc   = dto.Account;
        GameObject obj   = userGameObjDict[acc];
        Vector3    pos   = new Vector3(dto.pos[0], dto.pos[1], dto.pos[2]);
        Vector3    rota  = new Vector3(dto.rota[0], dto.rota[1], dto.rota[2]);
        Quaternion qRota = Quaternion.Euler(rota);

        obj.transform.position = pos;
        //obj.transform.position = Vector3.Lerp(obj.transform.position, pos, 0.5f);
        obj.transform.rotation = qRota;
        //播放行走动画
        animationMesg.Change(acc, "Walk", true);
        Dispatch(AreaCode.ANIMATION, AnimationEvent.ANIMATION_SET_BOOL, animationMesg);
    }