void OnDeviceAttached(InputDevice device) { //print("device attached: " + device.Name); devices.Add(device); var actionz = new CharacterActionz(); actionz.Device = device; actionz.action.AddDefaultBinding(Key.Return); actionz.action.AddDefaultBinding(InputControlType.Action1); Key[] upkeys = { Key.UpArrow, Key.W }; actionz.up.AddDefaultBinding(upkeys); actionz.up.AddDefaultBinding(InputControlType.DPadUp); actionz.up.AddDefaultBinding(InputControlType.LeftStickUp); Key[] downkeys = { Key.DownArrow, Key.S }; actionz.down.AddDefaultBinding(downkeys); actionz.down.AddDefaultBinding(InputControlType.DPadDown); actionz.down.AddDefaultBinding(InputControlType.LeftStickDown); Key[] leftkeys = { Key.LeftArrow, Key.A }; actionz.left.AddDefaultBinding(leftkeys); actionz.left.AddDefaultBinding(InputControlType.DPadLeft); actionz.left.AddDefaultBinding(InputControlType.LeftStickLeft); Key[] rightkeys = { Key.RightArrow, Key.D }; actionz.right.AddDefaultBinding(rightkeys); actionz.right.AddDefaultBinding(InputControlType.DPadRight); actionz.right.AddDefaultBinding(InputControlType.LeftStickRight); deviceMap.Add(device, actionz); }
public bool MapActions(CharacterActionz actions) { if (AreActionsMapped(actions)) { return(false); } if (active_players.Count == 4) { // no more left return(false); } // create and assign a player var player = Instantiate(PlayerPrefab, new Vector3(active_players.Count * 2, 0.5f, 0), Quaternion.identity, transform); player.OnTouchPillar += Magic; player.SetActionsSource(actions); action_mapping.Add(actions, player); active_players.Add(player); return(true); }
public bool AreActionsMapped(CharacterActionz actions) { return(action_mapping.ContainsKey(actions)); }
public Player GetPlayer(CharacterActionz actions) { return(action_mapping[actions]); }
public void SetActionsSource(CharacterActionz actions) { this.actions = actions; }