private Vector2 GetRawMoveVector() { Vector2 move = Vector2.zero; move.x = _controller.GetAxis(m_HorizontalAxis); move.y = _controller.GetAxis(m_VerticalAxis); if (_controller.GetButtonDown(m_HorizontalAxis)) { if (move.x < 0) { move.x = -1f; } if (move.x > 0) { move.x = 1f; } } if (DadaInput.GetButtonDown(m_VerticalAxis)) { if (move.y < 0) { move.y = -1f; } if (move.y > 0) { move.y = 1f; } } return(move); }
// Use this for initialization void Start() { Canvas canvas = GameObject.FindObjectOfType <Canvas>(); CharacterSelectionView[] views = new CharacterSelectionView[4]; //If you are debugging and you start directly from the character selection screen, //this gives you at least one player to play with if (DadaGame.PlayersNum == 0) { DadaGame.PlayersNum = 1; } //Assign the controllers to specific sub-windows, so players can choose their characer indipendently. //Disable windows without a player for (int i = 0; i < 4; i++) { views[i] = canvas.transform.GetChild(i).GetComponent <CharacterSelectionView>(); if (i < DadaGame.PlayersNum && i < DadaInput.ControllerCount) { views[i].OnPlayerReady = PlayerReady; views[i].SetController(DadaInput.GetJoystick(i)); } else { views[i].gameObject.SetActive(false); } } }
void Update() { if (LevelScreen.gameObject.activeSelf) { if (DadaInput.GetJoystick(0).GetButtonDown(VirtualKey.BACK)) { ShowTitle(); } } }
protected void Start() { Transform canvas = GameObject.Find("Canvas").transform; Transform scoreText = canvas.Find("Scores"); _fin = canvas.transform.FindChild("Fin").GetComponent <Text>(); _restartMenu = canvas.transform.FindChild("RestartMenu").gameObject; _pauseScreen = canvas.transform.FindChild("PauseScreen"); _restartYes = canvas.transform.FindChild("RestartMenu/RestartYes").GetComponent <FadeEffect>(); _restartNo = canvas.transform.FindChild("RestartMenu/RestartNo").GetComponent <FadeEffect>(); _controller1 = DadaInput.GetJoystick(0); _camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollow>(); _teams = DadaGame.Teams; //********** FOR DEBUG ONLY!! ************** if (_teams == null || _teams.Count == 0) { for (int i = 0; i < (int)testPlayers; i++) { DadaGame.RegisterPlayer(CreateDebugPlayers(i)); } _teams = DadaGame.Teams; } //find all respawn points _spawnPoints = Object.FindObjectsOfType <SpawnPoint>(); //shuffle the order of spawnpoints, so the players will spawn to different places ShuffleSpawnPoints(); //find the scores UI and give them the same color of the player _scoreThing = new List <GameObject>(); for (int i = 0; i < scoreText.childCount; i++) { //there is no team for this score: hide the text if (i >= _teams.Count) { scoreText.GetChild(i).gameObject.SetActive(false); } else { _scoreThing.Add(scoreText.GetChild(i).gameObject); //GameObject frame = scoreText.GetChild(i).FindChild("Frame").gameObject; //frame.GetComponent<Image>().color = _teams[i].TeamColor; scoreText.GetChild(i).GetComponent <UIScore>().ScoresBg.GetComponent <Image>().color = _teams[DadaGame.Players[i].InTeam.Number].TeamColor; } } InitLevel(); }
public static void AutoInit() { if (_inst == null) { TextAsset txt = (TextAsset)Resources.Load("_Core/keymap", typeof(TextAsset)); string json = txt.text; Dictionary <string, KeyMap> keyMapConfig = KeyMap.JsonToKeyConfiguration(json); DadaInput.Initialize(keyMapConfig); } }
private void BeginGame() { _levelName = LevelsName[_levelNum]; DadaGame.PlayersNum = Mathf.Clamp(_playerNum, 0, DadaInput.ControllerCount); DadaGame.IsTeamPlay = _isTeamMode; if (DadaGame.PlayersNum >= 1) { Player p = new Player(DadaInput.GetJoystick(0)); p.Hero = Resource.FISH_HERO; p.FirstWeapon = Resource.PHOENIX; p.SecondWeapon = Resource.KATANA_MELEE; p.InTeam = Team.TEAM_1; DadaGame.RegisterPlayer(p); } if (DadaGame.PlayersNum >= 2) { Player p = new Player(DadaInput.GetJoystick(1)); p.Hero = Resource.FEZ_HERO; p.FirstWeapon = Resource.PHOENIX; p.SecondWeapon = Resource.KATANA_MELEE; p.InTeam = Team.TEAM_2; DadaGame.RegisterPlayer(p); } if (DadaGame.PlayersNum >= 3) { Player p = new Player(DadaInput.GetJoystick(2)); p.Hero = Resource.RACCOON_HERO; p.FirstWeapon = Resource.PHOENIX; p.SecondWeapon = Resource.KATANA_MELEE; p.InTeam = _isTeamMode ? Team.TEAM_1 : Team.TEAM_3; DadaGame.RegisterPlayer(p); } if (DadaGame.PlayersNum >= 4) { Player p = new Player(DadaInput.GetJoystick(3)); p.Hero = Resource.POOP_HERO; p.FirstWeapon = Resource.PHOENIX; p.SecondWeapon = Resource.KATANA_MELEE; p.InTeam = _isTeamMode ? Team.TEAM_2 : Team.TEAM_4; DadaGame.RegisterPlayer(p); } Application.LoadLevel(_levelName); }
// Use this for initialization void Start() { Time.timeScale = 1f; DadaGame.Reset(); _startFadeText = StartGameText.GetComponent <FadeEffect>(); _creditsFadeText = CreditsText.GetComponent <FadeEffect>(); _teamFadeText = TeamModeText.GetComponent <FadeEffect>(); _allvsFadeText = AllVsAllModeText.GetComponent <FadeEffect>(); _startFadeText.Fade(); StartGameText.color = Color.yellow; _controller = DadaInput.GetJoystick(0); _currentScreen = Screen.START; }
private Player CreateDebugPlayers(int controller) { Player p1 = new Player(DadaInput.GetJoystick(controller)); p1.Hero = Resource.FISH_HERO; p1.FirstWeapon = Resource.PHOENIX; p1.SecondWeapon = Resource.KATANA_MELEE; if (controller == 0) { p1.InTeam = Team.TEAM_1; } else { p1.InTeam = Team.TEAM_2; } return(p1); }
public override bool ShouldActivateModule() { if (!base.ShouldActivateModule()) { return(false); } _controller = DadaInput.GetJoystick(0); var shouldActivate = _controller.GetButtonDown(m_SubmitButton); shouldActivate |= _controller.GetButtonDown(m_CancelButton); shouldActivate |= !Mathf.Approximately(_controller.GetAxis(m_HorizontalAxis), 0.0f); shouldActivate |= !Mathf.Approximately(_controller.GetAxis(m_VerticalAxis), 0.0f); shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f; shouldActivate |= Input.GetMouseButtonDown(0); return(shouldActivate); }
private void SetupPlayers(bool isTeam) { DadaGame.IsTeamPlay = isTeam; if (DadaGame.PlayersNum >= 1) { Player p = new Player(DadaInput.GetJoystick(0)); p.Hero = Resource.FISH_HERO; p.FirstWeapon = Resource.PHOENIX; p.SecondWeapon = Resource.LAYBOMB_MELEE; p.InTeam = Team.TEAM_1; DadaGame.RegisterPlayer(p); } if (DadaGame.PlayersNum >= 2) { Player p = new Player(DadaInput.GetJoystick(1)); p.Hero = Resource.FEZ_HERO; p.FirstWeapon = Resource.PHOENIX; p.SecondWeapon = Resource.LAYBOMB_MELEE; p.InTeam = Team.TEAM_2; DadaGame.RegisterPlayer(p); } if (DadaGame.PlayersNum >= 3) { Player p = new Player(DadaInput.GetJoystick(2)); p.Hero = Resource.RACCOON_HERO; p.FirstWeapon = Resource.PHOENIX; p.SecondWeapon = Resource.LAYBOMB_MELEE; p.InTeam = isTeam ? Team.TEAM_1 : Team.TEAM_3; DadaGame.RegisterPlayer(p); } if (DadaGame.PlayersNum >= 4) { Player p = new Player(DadaInput.GetJoystick(3)); p.Hero = Resource.POOP_HERO; p.FirstWeapon = Resource.PHOENIX; p.SecondWeapon = Resource.LAYBOMB_MELEE; p.InTeam = isTeam ? Team.TEAM_2 : Team.TEAM_4; DadaGame.RegisterPlayer(p); } }
public static void Initialize(Dictionary <string, KeyMap> map, KeyMap customMap, InputMethod method) { if (_inst == null) { _inst = new DadaInput(); } if (map == null) { Instance._rawKeyMaps = new Dictionary <string, KeyMap>(); } else { Instance._rawKeyMaps = map; } Instance._customKeyMap = customMap; CheckJoysticks(method); }
void Update() { bool startPressed = DadaInput.GetButtonDown(VirtualKey.START); //Pause game if (!_isPaused && startPressed && !_gameEnded) { Time.timeScale = 0.0000001f; _isPaused = true; _pauseScreen.gameObject.SetActive(true); } else if (_isPaused) { //resume game if (startPressed) { Time.timeScale = 1; _isPaused = false; _pauseScreen.gameObject.SetActive(false); } else if (DadaInput.GetButtonDown(VirtualKey.SELECT)) { Time.timeScale = 1; _isPaused = false; DadaGame.Reset(); Application.LoadLevel("MainScreen"); } } //game ended. if (_gameEnded) { if (_controller1.GetButtonDown(VirtualKey.LEFT) && !_restartYes.IsFading) { _restartYes.Fade(); _restartNo.Stop(1, 0); _restartYes.GetComponent <Text>().color = _teams[_winningTeam].TeamColor; _restartNo.GetComponent <Text>().color = Color.white; } if (_controller1.GetButtonDown(VirtualKey.RIGHT) && !_restartNo.IsFading) { _restartNo.Fade(); _restartYes.Stop(1, 0); _restartNo.GetComponent <Text>().color = _teams[_winningTeam].TeamColor; _restartYes.GetComponent <Text>().color = Color.white; } if (_controller1.GetButtonDown(VirtualKey.SUBMIT)) { if (_restartYes.IsFading) { Application.LoadLevel(Application.loadedLevelName); } else { Application.LoadLevel("MainScreen"); } } } }