当前位置: 首页>>代码示例>>C#>>正文


C# ControlScheme.AddControl方法代码示例

本文整理汇总了C#中ControlScheme.AddControl方法的典型用法代码示例。如果您正苦于以下问题:C# ControlScheme.AddControl方法的具体用法?C# ControlScheme.AddControl怎么用?C# ControlScheme.AddControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ControlScheme的用法示例。


在下文中一共展示了ControlScheme.AddControl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    // Use this for initialization
    void Start()
    {
        m_holdAccum = 0.0f;

        m_LeftTransform  = m_LeftPart.GetComponent<RectTransform>() as RectTransform;
        m_RightTransform = m_RightPart.GetComponent<RectTransform>() as RectTransform;

        float speed = Screen.width / 55.0f;
        float magnetForce = 15.0f;
        Behavior p1Mag   = new MagneticBehavior("player1 magnetic", 	   m_LeftPart, magnetForce);
        Behavior p1Up    = new RectTranslateBehavior("player1 move up",    m_LeftPart, new Vector3( 0,  1, 0) * speed);
        Behavior p1Down  = new RectTranslateBehavior("player1 move down",  m_LeftPart, new Vector3( 0, -1, 0) * speed);
        Behavior p1Left  = new RectTranslateBehavior("player1 move left",  m_LeftPart, new Vector3(-1,  0, 0) * speed);
        Behavior p1Right = new RectTranslateBehavior("player1 move right", m_LeftPart, new Vector3( 1,  0, 0) * speed);
        Behavior p2Mag   = new MagneticBehavior("player2 magnetic", 	   m_RightPart, magnetForce);
        Behavior p2Up    = new RectTranslateBehavior("player2 move up",    m_RightPart, new Vector3( 0,  1, 0) * speed);
        Behavior p2Down  = new RectTranslateBehavior("player2 move down",  m_RightPart, new Vector3( 0, -1, 0) * speed);
        Behavior p2Left  = new RectTranslateBehavior("player2 move left",  m_RightPart, new Vector3(-1,  0, 0) * speed);
        Behavior p2Right = new RectTranslateBehavior("player2 move right", m_RightPart, new Vector3( 1,  0, 0) * speed);

        m_Controls = new ControlScheme();
        m_Controls.AddControl(new TrueSignal(),                                                                     p1Mag  );
        m_Controls.AddControl(new KeyCodeControlSignal(KeyCode.W, new KeyCode[] { KeyCode.A, KeyCode.D }),          p1Up   );
        m_Controls.AddControl(new KeyCodeControlSignal(KeyCode.S, new KeyCode[] { KeyCode.A, KeyCode.D }),          p1Down );
        m_Controls.AddControl(new KeyCodeControlSignal(KeyCode.A, new KeyCode[] { KeyCode.W, KeyCode.S }),          p1Left );
        m_Controls.AddControl(new KeyCodeControlSignal(KeyCode.D, new KeyCode[] { KeyCode.W, KeyCode.S }),          p1Right);
        m_Controls.AddControl(new TrueSignal(),                                                                     p2Mag  );
        m_Controls.AddControl(new KeyCodeControlSignal(KeyCode.UpArrow   , new KeyCode[] { KeyCode.A, KeyCode.D }), p2Up   );
        m_Controls.AddControl(new KeyCodeControlSignal(KeyCode.DownArrow , new KeyCode[] { KeyCode.A, KeyCode.D }), p2Down );
        m_Controls.AddControl(new KeyCodeControlSignal(KeyCode.LeftArrow , new KeyCode[] { KeyCode.W, KeyCode.S }), p2Left );
        m_Controls.AddControl(new KeyCodeControlSignal(KeyCode.RightArrow, new KeyCode[] { KeyCode.W, KeyCode.S }), p2Right);

        m_Controls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y,  1.0f, true), p1Up    );
        m_Controls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y, -1.0f, true), p1Down  );
        m_Controls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X, -1.0f, true), p1Left  );
        m_Controls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X,  1.0f, true), p1Right );
        m_Controls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y,  1.0f, true), p2Up    );
        m_Controls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y, -1.0f, true), p2Down  );
        m_Controls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X, -1.0f, true), p2Left  );
        m_Controls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X,  1.0f, true), p2Right );
    }
开发者ID:Danathus,项目名称:ggj-2015-oj,代码行数:42,代码来源:TitleScreen.cs

示例2: Start

    // Use this for initialization
    void Start()
    {
        // create mock scene with two player objects
        mPlayer1 = GameObject.CreatePrimitive(PrimitiveType.Cube);
        mPlayer2 = GameObject.Find("CubeHand");
        Vector3 scale = new Vector3(0.1f, 0.1f, 0.1f);
        mPlayer1.transform.localScale = scale;
        mPlayer2.transform.localScale = scale;
        // find the camera and man
        mCamera = GameObject.Find("Main Camera");
        mMan = GameObject.Find("Man");
        //RuntimeAnimatorController animCtrl = mMan.AddComponent("RuntimeAnimatorController") as RuntimeAnimatorController;
        //
        //RuntimeAnimatorController anim = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("myAnimation", typeof(RuntimeAnimatorController)));
        AnimatorOverrideController overrideController = new AnimatorOverrideController();
        //Animator manimator = mMan.GetComponent<Animator>();
        //manimator.runtimeAnimatorController = overrideController;
        //
        mLeftHand = GameObject.FindWithTag("LeftHand");
        mRightHand = GameObject.FindWithTag("RightHand");
        mRightShoulder = GameObject.FindWithTag("RightShoulder");
        // hook up the IK
        if (mRightShoulder != null)
        {
            //IKControl ik = mRightShoulder.GetComponent<IKControl>();
            //ik.target = mPlayer2.transform;
            //ik.ikActive = true;

            //IKCtrl ik = mRightShoulder.GetComponent<IKCtrl>();
            //ik.rightHandObj = mPlayer2.transform;
            //ik.ikActive = true;

            //ikLimb2 ik = mRightShoulder.GetComponent<ikLimb2>();
            //IKLimb ik = mRightShoulder.GetComponent<IKLimb>();
            IKScriptNew ik = mRightShoulder.GetComponent<IKScriptNew>();
            //ik.target = mPlayer2.transform;
            ik.IsEnabled = true;
        }
        // restart the scene
        Restart();

        // create the behaviors in this scene
        float speed = 0.025f;
        Behavior p1Up    = new TranslateBehavior("player1 move up",    mPlayer1, new Vector3( 0,  1, 0) * speed);
        Behavior p1Down  = new TranslateBehavior("player1 move down",  mPlayer1, new Vector3( 0, -1, 0) * speed);
        Behavior p1Left  = new TranslateBehavior("player1 move left",  mPlayer1, new Vector3(-1,  0, 0) * speed);
        Behavior p1Right = new TranslateBehavior("player1 move right", mPlayer1, new Vector3( 1,  0, 0) * speed);
        Behavior p2Up    = new TranslateBehavior("player2 move up",    mPlayer2, new Vector3( 0,  1, 0) * speed);
        Behavior p2Down  = new TranslateBehavior("player2 move down",  mPlayer2, new Vector3( 0, -1, 0) * speed);
        Behavior p2Left  = new TranslateBehavior("player2 move left",  mPlayer2, new Vector3(-1,  0, 0) * speed);
        Behavior p2Right = new TranslateBehavior("player2 move right", mPlayer2, new Vector3( 1,  0, 0) * speed);

        // create the control scheme that maps inputs to these behaviors
        mControls = new ControlScheme();
        mControls.AddControl(new KeyCodeControlSignal(KeyCode.W),          p1Up   );
        mControls.AddControl(new KeyCodeControlSignal(KeyCode.S),          p1Down );
        mControls.AddControl(new KeyCodeControlSignal(KeyCode.A),          p1Left );
        mControls.AddControl(new KeyCodeControlSignal(KeyCode.D),          p1Right);
        mControls.AddControl(new KeyCodeControlSignal(KeyCode.UpArrow),    p2Up   );
        mControls.AddControl(new KeyCodeControlSignal(KeyCode.DownArrow),  p2Down );
        mControls.AddControl(new KeyCodeControlSignal(KeyCode.LeftArrow),  p2Left );
        mControls.AddControl(new KeyCodeControlSignal(KeyCode.RightArrow), p2Right);
        //
        mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y,  1.0f), p1Up    );
        mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y, -1.0f), p1Down  );
        mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X, -1.0f), p1Left  );
        mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X,  1.0f), p1Right );
        mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y,  1.0f), p2Up    );
        mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y, -1.0f), p2Down  );
        mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X, -1.0f), p2Left  );
        mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X,  1.0f), p2Right );
    }
开发者ID:Danathus,项目名称:ggj-2015-oj,代码行数:73,代码来源:Main.cs


注:本文中的ControlScheme.AddControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。