Exemplo n.º 1
0
    // 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);
            }
        }
    }
Exemplo n.º 2
0
 void Update()
 {
     if (LevelScreen.gameObject.activeSelf)
     {
         if (DadaInput.GetJoystick(0).GetButtonDown(VirtualKey.BACK))
         {
             ShowTitle();
         }
     }
 }
Exemplo n.º 3
0
    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();
    }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 5
0
    // 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;
    }
Exemplo n.º 6
0
    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);
    }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
    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);
        }
    }