本文整理汇总了C#中ControlScheme类的典型用法代码示例。如果您正苦于以下问题:C# ControlScheme类的具体用法?C# ControlScheme怎么用?C# ControlScheme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ControlScheme类属于命名空间,在下文中一共展示了ControlScheme类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Action
public List<ControlKey> Keys;// = new List<ControlKey>();
public Action(ControlScheme scheme, string name = "defaultAction")//:base(scheme, name)
{
Keys = new List<ControlKey>();
this.scheme = scheme;
this.Name = name;
}
开发者ID:Bahamutho,项目名称:GJ04-ST.-STELF-EALTH,代码行数:9,代码来源:Action.cs
示例2: Axis
public Axis(ControlScheme scheme, string name = "defaultAxis")
//: base(scheme, name)
{
AxisKeys = new List<AxisKey>();
this.scheme = scheme;
this.Name = name;
}
开发者ID:Bahamutho,项目名称:GJ04-ST.-STELF-EALTH,代码行数:8,代码来源:Axis.cs
示例3: PlayerData
public PlayerData(int id, int carType, ControlScheme ctrlScheme, PlayerType playerType)
{
_carType = carType;
_ctrlScheme = ctrlScheme;
_playerType = playerType;
_lives = 10;
ID = id;
}
开发者ID:JeanPascalEvette,项目名称:DodgeThisRacing,代码行数:8,代码来源:PlayerData.cs
示例4: Start
// Use this for initialization
void Start()
{
controlScheme = ControlManager.Instance.ControlSchemes[0];
InstrumentInHand = ((GameObject)GameObject.Instantiate(InstrumentsInCollection.First().gameObject)).GetComponent<Instrument>();
InstrumentInHand.gameObject.SetActive(true);
InstrumentInHand.transform.position = transform.position;
InstrumentInHand.transform.parent = transform;
player = transform.parent.Find("PlayerCharacter");
}
开发者ID:Bahamutho,项目名称:GJ01-Jazz-Climbing,代码行数:10,代码来源:InstrumentManager.cs
示例5: Start
// Use this for initialization
void Start()
{
movPhysics = this.GetComponent<DirectMovementPhysics>();
spellController = this.GetComponent<SpellController>();
stats = this.GetComponent<Stats>();
controlScheme = ControlManager.GetControlScheme(1);
//Spells = new List<ISpellBase>();
//Actions = new List<Action>();
}
开发者ID:Bahamutho,项目名称:GJ03-ParagonShmup,代码行数:11,代码来源:PlayerController.cs
示例6: GetDirection
public static Vector2 GetDirection(ControlScheme controlScheme)
{
if (!controlsEnabled)
return Vector2.zero;
Vector2 direction = Vector2.zero;
switch (controlScheme)
{
case ControlScheme.KeyboardZQSD:
if (Input.GetKey(KeyCode.Z))
direction.y = 1;
else if (Input.GetKey(KeyCode.S))
direction.y = -1;
if (Input.GetKey(KeyCode.Q))
direction.x = -1;
else if (Input.GetKey(KeyCode.D))
direction.x = 1;
break;
case ControlScheme.KeyboardOKLM:
if (Input.GetKey(KeyCode.O))
direction.y = 1;
else if (Input.GetKey(KeyCode.L))
direction.y = -1;
if (Input.GetKey(KeyCode.K))
direction.x = -1;
else if (Input.GetKey(KeyCode.M))
direction.x = 1;
break;
case ControlScheme.Keyboard5123:
if (Input.GetKey(KeyCode.Keypad5))
direction.y = 1;
else if (Input.GetKey(KeyCode.Keypad2))
direction.y = -1;
if (Input.GetKey(KeyCode.Keypad1))
direction.x = -1;
else if (Input.GetKey(KeyCode.Keypad3))
direction.x = 1;
break;
case ControlScheme.Gamepad1:
direction = GetJoystickAxis(1);
break;
case ControlScheme.Gamepad2:
direction = GetJoystickAxis(2);
break;
case ControlScheme.Gamepad3:
direction = GetJoystickAxis(3);
break;
default:
break;
}
return direction;
}
开发者ID:julesbriquet,项目名称:Almarach,代码行数:54,代码来源:Controls.cs
示例7: changeControlScheme
//Cycle through control schemes.
public void changeControlScheme()
{
if ((int)controlScheme == 5)
{
controlScheme = ControlScheme.Unspecified;
}
else
{
controlScheme = (ControlScheme)((int)controlScheme + 1);
}
}
开发者ID:EnigmaBADGER,项目名称:DropTheGoat,代码行数:12,代码来源:Player.cs
示例8: Update
public void Update(ControlScheme inputScheme = null)
{
if (scheme == null && inputScheme != null)
scheme = inputScheme;
foreach (ControlKey key in Keys)
{
key.LastState = key.CurState;
key.CurState = IsCKDown(key);
if(key.LastState && scheme != null)
scheme.InputType = key.Type;
}
}
开发者ID:Bahamutho,项目名称:GJ04-ST.-STELF-EALTH,代码行数:14,代码来源:Action.cs
示例9: Start
// Use this for initialization
void Start ()
{
cc = gameObject.GetComponent<Iso2DCharacterController>();
if (ControlScheme == null)
{
ControlScheme = ControlScheme.CreateScheme<PlayerActions>();
ControlScheme.Actions[(int)PlayerActions.PickPocket].Keys.Add(ControlKey.PCKey(KeyCode.Space));
ControlScheme.Actions[(int)PlayerActions.PickPocket].Keys.Add(ControlKey.XboxButton(XboxCtrlrInput.XboxButton.A));
ControlScheme.Actions[(int)PlayerActions.Dance].Keys.Add(ControlKey.PCKey(KeyCode.Q));
ControlScheme.Actions[(int)PlayerActions.Dance].Keys.Add(ControlKey.XboxButton(XboxCtrlrInput.XboxButton.B));
ScriptableObjectHelper.SaveAssetAutoNaming(ControlScheme);
//ControlScheme.hideFlags = HideFlags.DontSave;
}
}
开发者ID:Bahamutho,项目名称:GJ04-ST.-STELF-EALTH,代码行数:17,代码来源:Iso2DPlayerController.cs
示例10: CheckInPlayer
void CheckInPlayer(ControlScheme scheme)
{
var newPlayer = new Player() { id = players.Count + 1, controls = scheme };
players.Add(newPlayer);
bool isPad = scheme.ToString().StartsWith("Gamepad");
// show his key mapping :
schemeSelection[newPlayer.id - 1].GetComponent<Image>().overrideSprite =
buttonConfigs[(newPlayer.id - 1) * 4 + GetMappingIndex(scheme)];
//if (isPad)
// playerGamepadMappings[newPlayer.id - 1].gameObject.SetActive(true);
//else
// playerKeyMappings[newPlayer.id - 1].gameObject.SetActive(true);
playerOverlays[newPlayer.id - 1].gameObject.SetActive(true);
}
开发者ID:julesbriquet,项目名称:Almarach,代码行数:17,代码来源:ControlsSelection.cs
示例11: Start
// Use this for initialization
void Start ()
{
cc = gameObject.GetComponent<SimpleIsoCharacterController>();
pp = gameObject.GetComponent<PickPocket>();
anim = new AnimationSwapAnimatorWrapper(gameObject);
if(ControlScheme == null)
{
ControlScheme = ControlScheme.CreateScheme<PlayerActions>();
ControlScheme.Actions[(int)PlayerActions.PickPocket].Keys.Add(ControlKey.PCKey(KeyCode.Space));
ControlScheme.Actions[(int)PlayerActions.PickPocket].Keys.Add(ControlKey.XboxButton(XboxCtrlrInput.XboxButton.A));
ScriptableObjectHelper.SaveAssetAutoNaming(ControlScheme);
//ControlScheme.hideFlags = HideFlags.DontSave;
}
}
开发者ID:Bahamutho,项目名称:GJ04-ST.-STELF-EALTH,代码行数:19,代码来源:PlayerControl.cs
示例12: SelectControlsCoroutine
private IEnumerator SelectControlsCoroutine()
{
while (true)
{
if (Input.GetKeyDown(KeyCode.Space))
{
_selectedControl = ControlScheme.Keyboard;
StartCoroutine(FadeOutTitleCoroutine());
yield break;
}
if (STMReceiver.Instance.Buttons.BreakButtonDown)
{
_selectedControl = ControlScheme.Stm;
StartCoroutine(FadeOutTitleCoroutine());
yield break;
}
yield return null;
}
}
开发者ID:ksanu,项目名称:SuperTrackMayhem,代码行数:19,代码来源:StartingSequence.cs
示例13: ChooseCharacter
void ChooseCharacter(ControlScheme scheme, float leftRight)
{
var player = players.First(p => p.controls == scheme);
var rect = playerOverlays[player.id - 1].gameObject.GetComponent<RectTransform>();
var currentPos = rect.anchorMax;
if (leftRight < 0)
{
//move left
_audioSource.PlayOneShot(moveSound);
currentPos.x = currentPos.x == 0f ? 1f : currentPos.x - 0.5f;
}
else
{
//move right
_audioSource.PlayOneShot(moveSound);
currentPos.x = currentPos.x == 1f ? 0f : currentPos.x + 0.5f;
}
rect.anchorMax = currentPos;
rect.anchorMin = currentPos;
}
开发者ID:julesbriquet,项目名称:Almarach,代码行数:21,代码来源:ControlsSelection.cs
示例14: UsePowerUp
public static bool UsePowerUp(ControlScheme controlScheme)
{
if (!controlsEnabled)
return false;
switch (controlScheme)
{
case ControlScheme.KeyboardZQSD:
return Input.GetKey(KeyCode.LeftShift);
case ControlScheme.KeyboardOKLM:
return Input.GetKey(KeyCode.Return);
case ControlScheme.Keyboard5123:
return Input.GetKey(KeyCode.KeypadEnter);
case ControlScheme.Gamepad1:
return GetJoystickButton(1);
case ControlScheme.Gamepad2:
return GetJoystickButton(2);
case ControlScheme.Gamepad3:
return GetJoystickButton(3);
}
return false;
}
开发者ID:julesbriquet,项目名称:Almarach,代码行数:22,代码来源:Controls.cs
示例15: Tank
public Tank(int playerIndex, Vector2 position, int team, ControlScheme controlScheme, Rectangle screenBounds)
: base("Sprites", position, Map.TileSize, Map.TileSize, true, SpriteHelper.GetDefaultDepth(SpriteHelper.SpriteDepth.Middle))
{
_playerIndex = playerIndex;
_team = team;
_screenBounds = screenBounds;
_usedControlScheme = controlScheme;
if ((int)_usedControlScheme > 2)
{
_gamePadIndex = (PlayerIndex)_usedControlScheme - 3;
}
//Cannon
SetOrigin(16, 16);
cannon = new Sprite("Sprites", position, 26, 16, false, SpriteHelper.GetDefaultDepth(SpriteHelper.SpriteDepth.Middle) + 0.1f);
cannon.SetTextureRectangle(new Rectangle(96 + (32 * _team), 64, 26, 16));
cannon.SetOrigin(8f, 8f);
cannon.position = position;
_spriteOverlays.Add(cannon);
//Animation
AddAnimationState(new SpriteState("MovingHorizontal", SpriteHelper.GetSpriteRectangleStrip(32, 32, 0, 3 + _team, 3 + _team, 0, 2), _animationSpeed));
_orientation = new Vector2(1, 0);
_currentAnimationState = "MovingHorizontal";
SetCurrentAnimationState(_currentAnimationState);
InitiateAnimationStates();
//Statbar
statsBarPosition = new Vector2(20 + (playerIndex * 290), 24);
if (playerIndex > 1)
{
statsBarPosition.X -= 90;
}
tankSprite = new Sprite("Sprites", (int)statsBarPosition.X, (int)statsBarPosition.Y, new Rectangle(96 + (32 * team), 112, 32, 32), 1);
_healthBar = new HealthBar((int)statsBarPosition.X + 42, (int)statsBarPosition.Y, 116, 30, Color.Green, Color.Red, Color.Black);
powerupRectangle = new Sprite("Sprites", _healthBar.x+100+32,21, 1);
powerupRectangle.SetTextureRectangle(new Rectangle(0, 176, 36, 36));
}
开发者ID:kralle333,项目名称:TankGame,代码行数:38,代码来源:Tank.cs
示例16: Awake
// Use this for initialization
void Awake()
{
platformer = GetComponent<PlatformerPhysics>();
#region Controls
if (ControlScheme == null)
{
ControlScheme = ControlScheme.CreateScheme<JazzClimbingPlayerActions>();
// Make this into a nice function
ControlScheme.Actions[(int)JazzClimbingPlayerActions.Jump].Keys.Add(ControlKey.PCKey(KeyCode.Space));
ControlScheme.Actions[(int)JazzClimbingPlayerActions.Jump].Keys.Add(ControlKey.XboxButton(XboxCtrlrInput.XboxButton.A));
ControlScheme.Actions[(int)JazzClimbingPlayerActions.PlayInstrument].Keys.Add(ControlKey.PCKey(KeyCode.E));
ControlScheme.Actions[(int)JazzClimbingPlayerActions.PlayInstrument].Keys.Add(ControlKey.XboxButton(XboxCtrlrInput.XboxButton.B));
}
ControlManager.Instance.ControlSchemes[0] = ControlScheme;
DontDestroyOnLoad(ControlManager.Instance);
#endregion
}
开发者ID:Bahamutho,项目名称:GJ01-Jazz-Climbing,代码行数:25,代码来源:PlayerController.cs
示例17: ProcessOthers
/// <summary>
/// Process keyboard and joystick events.
/// </summary>
public void ProcessOthers ()
{
currentTouchID = -100;
currentTouch = controller;
bool submitKeyDown = false;
bool submitKeyUp = false;
if (submitKey0 != KeyCode.None && Input.GetKeyDown(submitKey0))
{
currentKey = submitKey0;
submitKeyDown = true;
}
if (submitKey1 != KeyCode.None && Input.GetKeyDown(submitKey1))
{
currentKey = submitKey1;
submitKeyDown = true;
}
if (submitKey0 != KeyCode.None && Input.GetKeyUp(submitKey0))
{
currentKey = submitKey0;
submitKeyUp = true;
}
if (submitKey1 != KeyCode.None && Input.GetKeyUp(submitKey1))
{
currentKey = submitKey1;
submitKeyUp = true;
}
if (submitKeyDown || submitKeyUp)
{
currentScheme = ControlScheme.Controller;
currentTouch.last = currentTouch.current;
currentTouch.current = mCurrentSelection;
ProcessTouch(submitKeyDown, submitKeyUp);
currentTouch.last = null;
}
int vertical = 0;
int horizontal = 0;
if (useKeyboard)
{
if (inputHasFocus)
{
vertical += GetDirection(KeyCode.UpArrow, KeyCode.DownArrow);
horizontal += GetDirection(KeyCode.RightArrow, KeyCode.LeftArrow);
}
else
{
vertical += GetDirection(KeyCode.W, KeyCode.UpArrow, KeyCode.S, KeyCode.DownArrow);
horizontal += GetDirection(KeyCode.D, KeyCode.RightArrow, KeyCode.A, KeyCode.LeftArrow);
}
}
if (useController)
{
if (!string.IsNullOrEmpty(verticalAxisName)) vertical += GetDirection(verticalAxisName);
if (!string.IsNullOrEmpty(horizontalAxisName)) horizontal += GetDirection(horizontalAxisName);
}
// Send out key notifications
if (vertical != 0)
{
currentScheme = ControlScheme.Controller;
Notify(mCurrentSelection, "OnKey", vertical > 0 ? KeyCode.UpArrow : KeyCode.DownArrow);
}
if (horizontal != 0)
{
currentScheme = ControlScheme.Controller;
Notify(mCurrentSelection, "OnKey", horizontal > 0 ? KeyCode.RightArrow : KeyCode.LeftArrow);
}
if (useKeyboard && Input.GetKeyDown(KeyCode.Tab))
{
currentKey = KeyCode.Tab;
currentScheme = ControlScheme.Controller;
Notify(mCurrentSelection, "OnKey", KeyCode.Tab);
}
// Send out the cancel key notification
if (cancelKey0 != KeyCode.None && Input.GetKeyDown(cancelKey0))
{
currentKey = cancelKey0;
currentScheme = ControlScheme.Controller;
Notify(mCurrentSelection, "OnKey", KeyCode.Escape);
}
if (cancelKey1 != KeyCode.None && Input.GetKeyDown(cancelKey1))
{
currentKey = cancelKey1;
currentScheme = ControlScheme.Controller;
//.........这里部分代码省略.........
开发者ID:satela,项目名称:xjhU3d,代码行数:101,代码来源:UICamera.cs
示例18: ProcessTouches
/// <summary>
/// Update touch-based events.
/// </summary>
public void ProcessTouches ()
{
currentScheme = ControlScheme.Touch;
for (int i = 0; i < Input.touchCount; ++i)
{
Touch touch = Input.GetTouch(i);
currentTouchID = allowMultiTouch ? touch.fingerId : 1;
currentTouch = GetTouch(currentTouchID);
bool pressed = (touch.phase == TouchPhase.Began) || currentTouch.touchBegan;
bool unpressed = (touch.phase == TouchPhase.Canceled) || (touch.phase == TouchPhase.Ended);
currentTouch.touchBegan = false;
// Although input.deltaPosition can be used, calculating it manually is safer (just in case)
currentTouch.delta = pressed ? Vector2.zero : touch.position - currentTouch.pos;
currentTouch.pos = touch.position;
// Raycast into the screen
if (!Raycast(currentTouch.pos)) hoveredObject = fallThrough;
if (hoveredObject == null) hoveredObject = genericEventHandler;
currentTouch.last = currentTouch.current;
currentTouch.current = hoveredObject;
lastTouchPosition = currentTouch.pos;
// We don't want to update the last camera while there is a touch happening
if (pressed) currentTouch.pressedCam = currentCamera;
else if (currentTouch.pressed != null) currentCamera = currentTouch.pressedCam;
// Double-tap support
if (touch.tapCount > 1) currentTouch.clickTime = RealTime.time;
// Process the events from this touch
ProcessTouch(pressed, unpressed);
// If the touch has ended, remove it from the list
if (unpressed) RemoveTouch(currentTouchID);
currentTouch.last = null;
currentTouch = null;
// Don't consider other touches
if (!allowMultiTouch) break;
}
if (Input.touchCount == 0)
{
if (useMouse) ProcessMouse();
#if UNITY_EDITOR
else ProcessFakeTouches();
#endif
}
}
开发者ID:satela,项目名称:xjhU3d,代码行数:57,代码来源:UICamera.cs
示例19: ProcessMouse
/// <summary>
/// Update mouse input.
/// </summary>
public void ProcessMouse ()
{
// Update the position and delta
lastTouchPosition = Input.mousePosition;
mMouse[0].delta = lastTouchPosition - mMouse[0].pos;
mMouse[0].pos = lastTouchPosition;
bool posChanged = mMouse[0].delta.sqrMagnitude > 0.001f;
// Propagate the updates to the other mouse buttons
for (int i = 1; i < 3; ++i)
{
mMouse[i].pos = mMouse[0].pos;
mMouse[i].delta = mMouse[0].delta;
}
// Is any button currently pressed?
bool isPressed = false;
bool justPressed = false;
for (int i = 0; i < 3; ++i)
{
if (Input.GetMouseButtonDown(i))
{
currentScheme = ControlScheme.Mouse;
justPressed = true;
isPressed = true;
}
else if (Input.GetMouseButton(i))
{
currentScheme = ControlScheme.Mouse;
isPressed = true;
}
}
// No need to perform raycasts every frame
if (isPressed || posChanged || mNextRaycast < RealTime.time)
{
mNextRaycast = RealTime.time + 0.02f;
if (!Raycast(Input.mousePosition)) hoveredObject = fallThrough;
if (hoveredObject == null) hoveredObject = genericEventHandler;
for (int i = 0; i < 3; ++i) mMouse[i].current = hoveredObject;
}
bool highlightChanged = (mMouse[0].last != mMouse[0].current);
if (highlightChanged) currentScheme = ControlScheme.Mouse;
if (isPressed)
{
// A button was pressed -- cancel the tooltip
mTooltipTime = 0f;
}
else if (posChanged && (!stickyTooltip || highlightChanged))
{
if (mTooltipTime != 0f)
{
// Delay the tooltip
mTooltipTime = RealTime.time + tooltipDelay;
}
else if (mTooltip != null)
{
// Hide the tooltip
ShowTooltip(false);
}
}
// The button was released over a different object -- remove the highlight from the previous
if ((justPressed || !isPressed) && mHover != null && highlightChanged)
{
currentScheme = ControlScheme.Mouse;
if (mTooltip != null) ShowTooltip(false);
Notify(mHover, "OnHover", false);
mHover = null;
}
// Process all 3 mouse buttons as individual touches
for (int i = 0; i < 3; ++i)
{
bool pressed = Input.GetMouseButtonDown(i);
bool unpressed = Input.GetMouseButtonUp(i);
if (pressed || unpressed) currentScheme = ControlScheme.Mouse;
currentTouch = mMouse[i];
currentTouchID = -1 - i;
currentKey = KeyCode.Mouse0 + i;
// We don't want to update the last camera while there is a touch happening
if (pressed) currentTouch.pressedCam = currentCamera;
else if (currentTouch.pressed != null) currentCamera = currentTouch.pressedCam;
// Process the mouse events
ProcessTouch(pressed, unpressed);
currentKey = KeyCode.None;
}
currentTouch = null;
//.........这里部分代码省略.........
开发者ID:satela,项目名称:xjhU3d,代码行数:101,代码来源:UICamera.cs
示例20: Update
/// <summary>
/// Check the input and send out appropriate events.
/// </summary>
void Update ()
{
// Only the first UI layer should be processing events
#if UNITY_EDITOR
if (!Application.isPlaying || !handlesEvents) return;
#else
if (!handlesEvents) return;
#endif
current = this;
// Process touch events first
if (useTouch) ProcessTouches ();
else if (useMouse) ProcessMouse();
// Custom input processing
if (onCustomInput != null) onCustomInput();
// Clear the selection on the cancel key, but only if mouse input is allowed
if (useMouse && mCurrentSelection != null)
{
if (cancelKey0 != KeyCode.None && Input.GetKeyDown(cancelKey0))
{
currentScheme = ControlScheme.Controller;
currentKey = cancelKey0;
selectedObject = null;
}
else if (cancelKey1 != KeyCode.None && Input.GetKeyDown(cancelKey1))
{
currentScheme = ControlScheme.Controller;
currentKey = cancelKey1;
selectedObject = null;
}
}
// If nothing is selected, input focus is lost
if (mCurrentSelection == null) inputHasFocus = false;
// Update the keyboard and joystick events
if (mCurrentSelection != null) ProcessOthers();
// If it's time to show a tooltip, inform the object we're hovering over
if (useMouse && mHover != null)
{
float scroll = !string.IsNullOrEmpty(scrollAxisName) ? Input.GetAxis(scrollAxisName) : 0f;
if (scroll != 0f) Notify(mHover, "OnScroll", scroll);
if (showTooltips && mTooltipTime != 0f && (mTooltipTime < RealTime.time ||
Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)))
{
mTooltip = mHover;
ShowTooltip(true);
}
}
current = null;
}
开发者ID:satela,项目名称:xjhU3d,代码行数:59,代码来源:UICamera.cs
注:本文中的ControlScheme类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论