示例#1
0
        public ActionResult Edit(InputUpdate input)
        {
            if (IsGetRequest)
            {
                return(View());
            }
            var result = new BaseOutput();

            input.Trade.CreatedBy = UserId;
            var now   = DateTime.Now;
            var model = MapTo <Trade>(input.Trade);

            model.ModifiedAt = now;
            var repo = GetRepo <Trade>();

            repo.Update(model);
            model = repo.GetFiltered(f => f.Id == input.Trade.TradeId).First();
            if (model.ModifiedAt == now)
            {
                SetResponse(s => s.Success, input, result);
            }
            else
            {
                SetResponse(s => s.UpdateFailed, input, result);
            }
            return(JsonNet(result));
        }
示例#2
0
        /// <summary>
        /// Event callback when an input packet has been sent to the server from a client.
        /// </summary>
        protected virtual void input_update_event(NetPeer peer, InputUpdate packet)
        {
            var player = players.Find(p => p.Data.CharacterID == packet.ID);

            player.update_input(packet.Keys);
            m_ConnectionManager.set_recent_ack(peer, packet.ACK_Tick);
        }
        /// <summary>
        /// Retrieves the latest input state from this window manager.
        /// </summary>
        /// <returns>The latest input state.</returns>
        public InputUpdate GetInputEvents()
        {
            var thisUpdate = CurrentInputState;

            thisUpdate.FinalizeForReporting();

            CurrentInputState = new InputUpdate(thisUpdate.DownedInputs);

            return(thisUpdate);
        }
示例#4
0
    // Use this for initialization
    void Awake()
    {
        if (!launchData)
        {
            Debug.LogErrorFormat("{0} of type {1} requires a valid reference to a playerdata object", this, this.GetType());
        }

#if UNITY_IOS || UNITY_ANDROID
        isLaunchReady = IsLaunchReadyMobile;
#else
        isLaunchReady = IsLaunchReadyStandalone;
#endif
        ResetInput();
    }
示例#5
0
        public void Connect()
        {
            Log.LogSystem("Connecting to Server...");

            //Put AccountID;
            m_CachedWriter.Put((ulong)0);
            //Put CharacterID;
            m_CachedWriter.Put(LocalCharID);

            m_NetManager.Connect(CrumbShared.Version.Address, CrumbShared.Version.Port, m_CachedWriter);

            CachedInputUpdate    = new InputUpdate();
            CachedInputUpdate.ID = LocalCharID;

            m_CachedWriter.Reset();

            Run();
        }
示例#6
0
        public ActionResult Edit(InputUpdate input)
        {
            if (IsGetRequest)
            {
                return(View());
            }
            var result = new BaseOutput();
            var price  = input.Price;

            price.CreatedBy = UserId;
            var repo  = GetRepo <Price>();
            var model = repo.GetFiltered(f => f.Id == price.PriceId, true).First();

            model.Grain      = price.Grain;
            model.CreatedBy  = price.CreatedBy;
            model.PriceType  = price.PriceType;
            model.Remark     = price.Remarks;
            model.UnitPrice  = price.UnitPrice;
            model.ModifiedAt = DateTime.Now;
            repo.UnitOfWork.SaveChanges();
            SetResponse(s => s.Success, input, result);
            return(JsonNet(result));
        }
示例#7
0
    public void SendInput(InputUpdate input)
    {
        FunMessage message = network.CreateFunMessage(input, MessageType.cs_input);

        network.SendMessage(MessageType.cs_input, message);
    }
 /// <summary>
 /// Initializes a new instance of the RwGlWindowManager class.
 /// </summary>
 public RwGlWindowManager()
 {
     CurrentInputState = new InputUpdate();
     Windows           = new List <RwGlWindow>();
 }
 public void SendInput(InputUpdate input)
 {
     FunMessage message = network.CreateFunMessage(input, MessageType.cs_input);
     network.SendMessage(MessageType.cs_input, message);
 }
示例#10
0
// 以下、メイン処理.リジッドボディと絡めるので、FixedUpdate内で処理を行う.
    void FixedUpdate()
    {
        if (itsMe)
        {
            float h, v;

            if (Application.isEditor)
            {
                h = Input.GetAxis("Horizontal");              // 入力デバイスの水平軸をhで定義
                v = Input.GetAxis("Vertical");                // 入力デバイスの垂直軸をvで定義
            }
            else
            {
                h = CnInputManager.GetAxis("Horizontal");
                v = CnInputManager.GetAxis("Vertical");
            }

            anim.SetFloat("Speed", v);                              // Animator側で設定している"Speed"パラメタにvを渡す
            anim.SetFloat("Direction", h);                          // Animator側で設定している"Direction"パラメタにhを渡す
            anim.speed       = animSpeed;                           // Animatorのモーション再生速度に animSpeedを設定する
            currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // 参照用のステート変数にBase Layer (0)の現在のステートを設定する
            rb.useGravity    = true;                                //ジャンプ中に重力を切るので、それ以外は重力の影響を受けるようにする

            // 以下、キャラクターの移動処理
            velocity = new Vector3(0, 0, v);        // 上下のキー入力からZ軸方向の移動量を取得
            // キャラクターのローカル空間での方向に変換
            velocity = transform.TransformDirection(velocity);
            //以下のvの閾値は、Mecanim側のトランジションと一緒に調整する
            if (v > 0.1)
            {
                velocity *= forwardSpeed;       // 移動速度を掛ける
            }
            else if (v < -0.1)
            {
                velocity *= backwardSpeed;  // 移動速度を掛ける
            }

            if ((Application.isEditor && Input.GetButtonDown("Jump")) ||
                (Application.isMobilePlatform && CnInputManager.GetButtonDown("Jump")))    // スペースキーを入力したら
            {
                last_jump = true;
                //アニメーションのステートがLocomotionの最中のみジャンプできる
                if (currentBaseState.nameHash == locoState)
                {
                    //ステート遷移中でなかったらジャンプできる
                    if (!anim.IsInTransition(0))
                    {
                        rb.AddForce(Vector3.up * jumpPower, ForceMode.VelocityChange);
                        anim.SetBool("Jump", true);     // Animatorにジャンプに切り替えるフラグを送る
                    }
                }
            }


            // 上下のキー入力でキャラクターを移動させる
            transform.localPosition += velocity * Time.fixedDeltaTime;

            // 左右のキー入力でキャラクタをY軸で旋回させる
            transform.Rotate(0, h * rotateSpeed, 0);

            if (last_jump || transform.position != last_position || transform.rotation != last_rotation)
            {
                last_position = transform.position;
                last_rotation = transform.rotation;

                InputUpdate input = new InputUpdate();
                input.a_v  = v;
                input.a_h  = h;
                input.p_x  = transform.position.x;
                input.p_z  = transform.position.z;
                input.r_y  = transform.rotation.y;
                input.r_w  = transform.rotation.w;
                input.jump = last_jump;

                NetworkController.instance.SendInput(input);
            }
        }
        else
        {
            anim.SetFloat("Speed", last_axis_v);                    // Animator側で設定している"Speed"パラメタにvを渡す
            anim.SetFloat("Direction", last_axis_h);                // Animator側で設定している"Direction"パラメタにhを渡す
            anim.speed       = animSpeed;                           // Animatorのモーション再生速度に animSpeedを設定する
            currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // 参照用のステート変数にBase Layer (0)の現在のステートを設定する
            rb.useGravity    = true;                                //ジャンプ中に重力を切るので、それ以外は重力の影響を受けるようにする

            if (last_jump)
            {
                if (currentBaseState.nameHash == locoState)
                {
                    //ステート遷移中でなかったらジャンプできる
                    if (!anim.IsInTransition(0))
                    {
                        rb.AddForce(Vector3.up * jumpPower, ForceMode.VelocityChange);
                        anim.SetBool("Jump", true);     // Animatorにジャンプに切り替えるフラグを送る
                    }
                }
            }

            transform.position = last_position;
            transform.rotation = last_rotation;
        }

        //Debug.Log(string.Format("update - pos:{0} rot:{1}", transform.localPosition, transform.localRotation));


        // 以下、Animatorの各ステート中での処理
        // Locomotion中
        // 現在のベースレイヤーがlocoStateの時
        if (currentBaseState.nameHash == locoState)
        {
            //カーブでコライダ調整をしている時は、念のためにリセットする
            if (useCurves)
            {
                resetCollider();
            }
        }
        // JUMP中の処理
        // 現在のベースレイヤーがjumpStateの時
        else if (currentBaseState.nameHash == jumpState)
        {
            if (itsMe)
            {
                cameraObject.SendMessage("setCameraPositionJumpView");                  // ジャンプ中のカメラに変更
            }

            // ステートがトランジション中でない場合
            if (!anim.IsInTransition(0))
            {
                // 以下、カーブ調整をする場合の処理
                if (useCurves)
                {
                    // 以下JUMP00アニメーションについているカーブJumpHeightとGravityControl
                    // JumpHeight:JUMP00でのジャンプの高さ(0〜1)
                    // GravityControl:1⇒ジャンプ中(重力無効)、0⇒重力有効
                    float jumpHeight     = anim.GetFloat("JumpHeight");
                    float gravityControl = anim.GetFloat("GravityControl");
                    if (gravityControl > 0)
                    {
                        rb.useGravity = false;                          //ジャンプ中の重力の影響を切る
                    }
                    // レイキャストをキャラクターのセンターから落とす
                    Ray        ray     = new Ray(transform.position + Vector3.up, -Vector3.up);
                    RaycastHit hitInfo = new RaycastHit();
                    // 高さが useCurvesHeight 以上ある時のみ、コライダーの高さと中心をJUMP00アニメーションについているカーブで調整する
                    if (Physics.Raycast(ray, out hitInfo))
                    {
                        if (hitInfo.distance > useCurvesHeight)
                        {
                            col.height = orgColHight - jumpHeight;                                      // 調整されたコライダーの高さ
                            float adjCenterY = orgVectColCenter.y + jumpHeight;
                            col.center = new Vector3(0, adjCenterY, 0);                                 // 調整されたコライダーのセンター
                        }
                        else
                        {
                            // 閾値よりも低い時には初期値に戻す(念のため)
                            resetCollider();
                        }
                    }
                }
                // Jump bool値をリセットする(ループしないようにする)
                anim.SetBool("Jump", false);
            }
        }
        // IDLE中の処理
        // 現在のベースレイヤーがidleStateの時
        else if (currentBaseState.nameHash == idleState)
        {
            //カーブでコライダ調整をしている時は、念のためにリセットする
            if (useCurves)
            {
                resetCollider();
            }
            // スペースキーを入力したらRest状態になる
            if (last_jump)
            {
                anim.SetBool("Rest", true);
            }
        }
        // REST中の処理
        // 現在のベースレイヤーがrestStateの時
        else if (currentBaseState.nameHash == restState)
        {
            //cameraObject.SendMessage("setCameraPositionFrontView");		// カメラを正面に切り替える
            // ステートが遷移中でない場合、Rest bool値をリセットする(ループしないようにする)
            if (!anim.IsInTransition(0))
            {
                anim.SetBool("Rest", false);
            }
        }

        last_jump = false;
    }
    // 以下、メイン処理.リジッドボディと絡めるので、FixedUpdate内で処理を行う.
    void FixedUpdate()
    {
        if (itsMe)
        {
            float h, v;

            if (Application.isEditor) {
                h = Input.GetAxis("Horizontal");              // 入力デバイスの水平軸をhで定義
                v = Input.GetAxis("Vertical");                // 入力デバイスの垂直軸をvで定義
            }
            else {
                h = CnInputManager.GetAxis("Horizontal");
                v = CnInputManager.GetAxis("Vertical");
            }

            anim.SetFloat("Speed", v);                          // Animator側で設定している"Speed"パラメタにvを渡す
            anim.SetFloat("Direction", h);                      // Animator側で設定している"Direction"パラメタにhを渡す
            anim.speed = animSpeed;                             // Animatorのモーション再生速度に animSpeedを設定する
            currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // 参照用のステート変数にBase Layer (0)の現在のステートを設定する
            rb.useGravity = true;//ジャンプ中に重力を切るので、それ以外は重力の影響を受けるようにする

            // 以下、キャラクターの移動処理
            velocity = new Vector3(0, 0, v);        // 上下のキー入力からZ軸方向の移動量を取得
            // キャラクターのローカル空間での方向に変換
            velocity = transform.TransformDirection(velocity);
            //以下のvの閾値は、Mecanim側のトランジションと一緒に調整する
            if (v > 0.1) {
                velocity *= forwardSpeed;       // 移動速度を掛ける
            } else if (v < -0.1) {
                velocity *= backwardSpeed;  // 移動速度を掛ける
            }

            if ((Application.isEditor && Input.GetButtonDown("Jump")) ||
                (Application.isMobilePlatform && CnInputManager.GetButtonDown("Jump"))) {  // スペースキーを入力したら
                last_jump = true;
                //アニメーションのステートがLocomotionの最中のみジャンプできる
                if (currentBaseState.nameHash == locoState){
                    //ステート遷移中でなかったらジャンプできる
                    if(!anim.IsInTransition(0))
                    {
                        rb.AddForce(Vector3.up * jumpPower, ForceMode.VelocityChange);
                        anim.SetBool("Jump", true);     // Animatorにジャンプに切り替えるフラグを送る
                    }
                }
            }

            // 上下のキー入力でキャラクターを移動させる
            transform.localPosition += velocity * Time.fixedDeltaTime;

            // 左右のキー入力でキャラクタをY軸で旋回させる
            transform.Rotate(0, h * rotateSpeed, 0);

            if (last_jump || transform.position != last_position || transform.rotation != last_rotation)
            {
                last_position = transform.position;
                last_rotation = transform.rotation;

                InputUpdate input = new InputUpdate();
                input.a_v = v;
                input.a_h = h;
                input.p_x = transform.position.x;
                input.p_z = transform.position.z;
                input.r_y = transform.rotation.y;
                input.r_w = transform.rotation.w;
                input.jump = last_jump;

                NetworkController.instance.SendInput(input);
            }
        }
        else
        {
            anim.SetFloat("Speed", last_axis_v);                          // Animator側で設定している"Speed"パラメタにvを渡す
            anim.SetFloat("Direction", last_axis_h);                      // Animator側で設定している"Direction"パラメタにhを渡す
            anim.speed = animSpeed;                             // Animatorのモーション再生速度に animSpeedを設定する
            currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // 参照用のステート変数にBase Layer (0)の現在のステートを設定する
            rb.useGravity = true;//ジャンプ中に重力を切るので、それ以外は重力の影響を受けるようにする

            if (last_jump)
            {
                if (currentBaseState.nameHash == locoState){
                    //ステート遷移中でなかったらジャンプできる
                    if(!anim.IsInTransition(0))
                    {
                        rb.AddForce(Vector3.up * jumpPower, ForceMode.VelocityChange);
                        anim.SetBool("Jump", true);     // Animatorにジャンプに切り替えるフラグを送る
                    }
                }
            }

            transform.position = last_position;
            transform.rotation = last_rotation;
        }

        //Debug.Log(string.Format("update - pos:{0} rot:{1}", transform.localPosition, transform.localRotation));

        // 以下、Animatorの各ステート中での処理
        // Locomotion中
        // 現在のベースレイヤーがlocoStateの時
        if (currentBaseState.nameHash == locoState){
            //カーブでコライダ調整をしている時は、念のためにリセットする
            if(useCurves){
                resetCollider();
            }
        }
        // JUMP中の処理
        // 現在のベースレイヤーがjumpStateの時
        else if(currentBaseState.nameHash == jumpState)
        {
            if (itsMe) {
                cameraObject.SendMessage("setCameraPositionJumpView");	// ジャンプ中のカメラに変更
            }

            // ステートがトランジション中でない場合
            if(!anim.IsInTransition(0))
            {

                // 以下、カーブ調整をする場合の処理
                if(useCurves){
                    // 以下JUMP00アニメーションについているカーブJumpHeightとGravityControl
                    // JumpHeight:JUMP00でのジャンプの高さ(0〜1)
                    // GravityControl:1⇒ジャンプ中(重力無効)、0⇒重力有効
                    float jumpHeight = anim.GetFloat("JumpHeight");
                    float gravityControl = anim.GetFloat("GravityControl");
                    if(gravityControl > 0)
                        rb.useGravity = false;	//ジャンプ中の重力の影響を切る

                    // レイキャストをキャラクターのセンターから落とす
                    Ray ray = new Ray(transform.position + Vector3.up, -Vector3.up);
                    RaycastHit hitInfo = new RaycastHit();
                    // 高さが useCurvesHeight 以上ある時のみ、コライダーの高さと中心をJUMP00アニメーションについているカーブで調整する
                    if (Physics.Raycast(ray, out hitInfo))
                    {
                        if (hitInfo.distance > useCurvesHeight)
                        {
                            col.height = orgColHight - jumpHeight;			// 調整されたコライダーの高さ
                            float adjCenterY = orgVectColCenter.y + jumpHeight;
                            col.center = new Vector3(0, adjCenterY, 0);	// 調整されたコライダーのセンター
                        }
                        else{
                            // 閾値よりも低い時には初期値に戻す(念のため)
                            resetCollider();
                        }
                    }
                }
                // Jump bool値をリセットする(ループしないようにする)
                anim.SetBool("Jump", false);
            }
        }
        // IDLE中の処理
        // 現在のベースレイヤーがidleStateの時
        else if (currentBaseState.nameHash == idleState)
        {
            //カーブでコライダ調整をしている時は、念のためにリセットする
            if(useCurves){
                resetCollider();
            }
            // スペースキーを入力したらRest状態になる
            if (last_jump) {
                anim.SetBool("Rest", true);
            }
        }
        // REST中の処理
        // 現在のベースレイヤーがrestStateの時
        else if (currentBaseState.nameHash == restState)
        {
            //cameraObject.SendMessage("setCameraPositionFrontView");		// カメラを正面に切り替える
            // ステートが遷移中でない場合、Rest bool値をリセットする(ループしないようにする)
            if(!anim.IsInTransition(0))
            {
                anim.SetBool("Rest", false);
            }
        }

        last_jump = false;
    }
 public static void Update()
 {
     InputUpdate?.Invoke();
 }