//***************************************************************************//
    // Actual shoot fucntion
    //***************************************************************************//
    void OnMouseUp()
    {
        //Special checks for 2-player game
        if ((GlobalGameManager.playersTurn && gameObject.tag == "Player_2") || (GlobalGameManager.opponentsTurn && gameObject.tag == "Player"))
        {
            arrowPlane.GetComponent <Renderer>().enabled  = false;
            shootCircle.GetComponent <Renderer>().enabled = false;
            return;
        }

        //give the player a second chance to choose another ball if drag on the unit is too low
        print("currentDistance: " + currentDistance);
        if (currentDistance < 0.75f)
        {
            arrowPlane.GetComponent <Renderer>().enabled  = false;
            shootCircle.GetComponent <Renderer>().enabled = false;
            return;
        }

        //But if player wants to shoot anyway:
        //prevent double shooting in a round
        if (!canShoot)
        {
            return;
        }

        //no more shooting is possible
        canShoot = false;

        //keep track of elapsed time after letting the ball go,
        //so we can findout if ball has stopped and the round should be changed
        //this is the time which user released the button and shooted the ball
        shootTime = Time.time;

        //hide helper arrow object
        arrowPlane.GetComponent <Renderer>().enabled  = false;
        shootCircle.GetComponent <Renderer>().enabled = false;

        //do the physics calculations and shoot the ball
        Vector3 outPower = shootDirectionVector * pwr * -1;

        //add team power bonus
        //print ("OLD outPower: " + outPower.magnitude);
        outPower *= (1 + (TeamsManager.getTeamSettings(PlayerPrefs.GetInt("PlayerFlag")).x / 50));
        //print ("NEW outPower: " + outPower.magnitude);

        //always make the player to move only in x-y plane and not on the z direction
        print("shoot power: " + outPower.magnitude);
        GetComponent <Rigidbody>().AddForce(outPower, ForceMode.Impulse);

        //change the turn
        if (GlobalGameManager.gameMode == 0)
        {
            StartCoroutine(gameController.GetComponent <GlobalGameManager>().managePostShoot("Player"));
        }
        else if (GlobalGameManager.gameMode == 1)
        {
            StartCoroutine(gameController.GetComponent <GlobalGameManager>().managePostShoot(gameObject.tag));
        }
    }
Ejemplo n.º 2
0
        public async Task <ActionResult> AddTeam(CoachModel coachModel)
        {
            var teamsManager = new TeamsManager(ConfigurationManager.ConnectionStrings["WhosOnFirstDb"].ConnectionString);
            var teamExists   = await teamsManager.ExistsAsync(coachModel.TeamName);

            if (!teamExists)
            {
                teamsManager.AddAsync(coachModel.TeamName);
            }
            var personManager = new PersonManager(ConfigurationManager.ConnectionStrings["WhosOnFirstDb"].ConnectionString);
            var person        = new Person();
            var userModel     = Session["userModel"] as UserModel;

            person.PersonId    = userModel.PersonId;
            person.FirstName   = userModel.FirstName;
            person.LastName    = userModel.LastName;
            person.PhoneNumber = userModel.PhoneNumber;
            person.EMail       = userModel.EMail;
            person.IsPlayer    = userModel.IsPlayer;
            person.IsCoach     = userModel.IsCoach;
            person.IsValid     = userModel.IsValid;
            person.IsAdmin     = userModel.IsAdmin;
            var team = await teamsManager.RetrieveAsync(coachModel.TeamName);

            person.TeamId = team.TeamsId;
            personManager.Update(person);
            userModel.TeamId     = team.TeamsId;
            Session["userModel"] = userModel;

            return(View(coachModel));
        }
Ejemplo n.º 3
0
    private int timeCounter        = 0;                         //Actual game-time index

    //*****************************************************************************
    // Init. Updates the 3d texts with saved values fetched from playerprefs.
    //***************************************************************************
    void Awake()
    {
        //check if this config scene is getting used for tournament or normal play mode
        isTournamentMode = PlayerPrefs.GetInt("IsTournament");
        isSinglePlayer   = PlayerPrefs.GetInt("IsSinglePlayer");

        if (isTournamentMode == 1)
        {
            //first of all, check if we are going to continue an unfinished tournament
            if (PlayerPrefs.GetInt("TorunamentLevel") > 0)
            {
                //if so, there is no need for any configuration. load the next scene.
                SceneManager.LoadScene("Tournament-c#");
                return;
            }


            //disable unnecessary options
            p2TeamSel.SetActive(false);
            p2FormationSel.SetActive(false);
            timeSel.SetActive(false);

            p1TeamSel.transform.position      = new Vector3(0, 4.5f, -1);
            p1FormationSel.transform.position = new Vector3(0, -4.3f, -1);
        }

        if (isSinglePlayer == 1)
        {
            p2TeamSel.SetActive(false);
            p2FormationSel.SetActive(false);
            timeSel.SetActive(false);

            p1TeamSel.transform.position      = new Vector3(0, 4.5f, -1);
            p1FormationSel.transform.position = new Vector3(0, -4.3f, -1);

            int team2 = Random.Range(0, availableTeams.Count - 1);
            p2TeamCounter = team2;
        }

        p1FormationLabel.GetComponent <TextMesh>().text = availableFormations[p1FormationCounter];              //loads default formation
        p1PowerBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p1TeamCounter).x / barScaleDivider,
                                                      p1PowerBar.transform.localScale.y,
                                                      p1PowerBar.transform.localScale.z);
        p1TimeBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p1TeamCounter).y / barScaleDivider,
                                                     p1TimeBar.transform.localScale.y,
                                                     p1TimeBar.transform.localScale.z);

        p2FormationLabel.GetComponent <TextMesh>().text = availableFormations[p2FormationCounter];              //loads default formation
        p2PowerBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p2TeamCounter).x / barScaleDivider,
                                                      p2PowerBar.transform.localScale.y,
                                                      p2PowerBar.transform.localScale.z);
        p2TimeBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p2TeamCounter).y / barScaleDivider,
                                                     p2TimeBar.transform.localScale.y,
                                                     p2TimeBar.transform.localScale.z);

        gameTimeLabel.GetComponent <TextMesh>().text = availableTimes[timeCounter];                                     //loads default game-time

        setNewTeams();
    }
Ejemplo n.º 4
0
 void Start()
 {
     gameManager  = GameManager.Instance;
     teamsManager = GameObject.Find("/Managers/TeamsManager").GetComponent <TeamsManager>();
     GetComponent <MeshRenderer>().material.color = shooter.GetComponent <MeshRenderer>().material.color;
     GetComponent <Rigidbody>().AddForce(transform.forward * force);
     StartCoroutine("DestroyBullet");
 }
Ejemplo n.º 5
0
 void Start()
 {
     gameManager  = GameManager.Instance;
     teamsManager = GameObject.Find("/Managers/TeamsManager").GetComponent <TeamsManager>();
     controller   = GetComponent <CharacterController>();
     shoot        = GetComponent <Shoot>();
     indicator    = transform.Find("IndicatorHolder");
     GetComponent <SpriteHolder>().Init();
 }
Ejemplo n.º 6
0
 public void Init()
 {
     teamsManager = GameObject.Find("/Managers/TeamsManager").GetComponent <TeamsManager>();
     agent        = GetComponent <NavMeshAgent>();
     shoot        = GetComponent <Shoot>();
     gameManager  = GameManager.Instance;
     indicator    = transform.Find("IndicatorHolder/Indicator");
     StartCoroutine("setBehaviour");
     GetComponent <SpriteHolder>().Init();
 }
Ejemplo n.º 7
0
        public async Task <ActionResult> ViewAllTeams()
        {
            var userModel    = Session["userModel"] as UserModel;
            var teamsManager = new TeamsManager(ConfigurationManager.ConnectionStrings["WhosOnFirstDb"].ConnectionString);
            var teams        = await teamsManager.GetAllAsync();

            ViewBag.TeamStatus = userModel.TeamId;

            return(View(teams));
        }
Ejemplo n.º 8
0
        private async Task <TeamsManager> CreateTeamsManagerAsync()
        {
            var httpClient = await GetHttpClientAsync();

            var logger          = Substitute.For <ILogger>();
            var oneDriveManager = new OneDriveManager(httpClient);
            var teamsManager    = new TeamsManager(httpClient, logger, oneDriveManager);

            return(teamsManager);
        }
Ejemplo n.º 9
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Ejemplo n.º 10
0
        public TeamsManagerTests()
        {
            var mapper = new MapperConfiguration(cfg =>
            {
                cfg.AddMaps("EMBC.ESS");
            }).CreateMapper();

            teamRepository = new TestTeamRepository();
            var essContextStatusReporter = A.Fake <IEssContextStateReporter>();
            var metadataRepository       = A.Fake <IMetadataRepository>();
            var supplierRepository       = A.Fake <ISupplierRepository>();

            adminManager = new TeamsManager(mapper, teamRepository, supplierRepository);
        }
Ejemplo n.º 11
0
    void Start()
    {
        Time.timeScale    = 0;
        leaderBoardCanvas = GameObject.Find("/LeaderBoardCanvas");
        startCanvas       = GameObject.Find("/StartCanvas");
        teamsManager      = GameObject.Find("/Managers/TeamsManager").GetComponent <TeamsManager>();
        player            = GameObject.Find("/Environment/Character <--|").GetComponent <Player>();
        enemyManager      = GameObject.Find("/Managers/EnemyManager").GetComponent <EnemyManager>();
        soundManager      = GameObject.Find("/Managers/SoundManager").GetComponent <SoundManager>();
        enemiesHolder     = GameObject.Find("Environment/EnemiesHolder");
        bulletsHolder     = GameObject.Find("Environment/BulletHolder");

        leaderBoardCanvas.SetActive(false);
    }
Ejemplo n.º 12
0
        private static void SetPossibleNameIfNeeded(int teamId, Team team)
        {
            var manager      = new TeamsManager();
            var existingTeam = manager.GetById(teamId);

            if (JaroWinklerWrapper.AreSimilar(existingTeam.DisplayName.ToLower(), team.DisplayName.ToLower()))
            {
                manager.AddPossibleName(new TeamPossibleName()
                {
                    TeamId       = teamId,
                    PossibleName = team.DisplayName,
                });
                //existingTeam.PossibleNames.Add();
                //manager.Update(existingTeam);
                manager.Remove(team);
            }
        }
Ejemplo n.º 13
0
        private static Team GetOrAddTeam(string teamName)
        {
            var manager = new TeamsManager();
            var team    = manager.GetByPossibleName(teamName);

            if (team == null)
            {
                team = new Team()
                {
                    DisplayName   = teamName,
                    PossibleNames = new List <TeamPossibleName>()
                };
                manager.Add(team);
            }

            return(team);
        }
Ejemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string idRider = Request["idRider"];
            string idTeam  = Request["idTeam"];

            //if RiderEditScript.js pass teamID and riderID via POST Call method SetTeam()
            //else get all teams serialize to JSON string for RiderEditScript.js to create dropdown list
            if (!string.IsNullOrEmpty(idRider) && !string.IsNullOrEmpty(idTeam))
            {
                RidersManager rm = new RidersManager();
                rm.SetTeam(Convert.ToInt32(idRider), Convert.ToInt32(idTeam));
            }
            else
            {
                TeamsManager tm = new TeamsManager();

                JavaScriptSerializer jss = new JavaScriptSerializer();
                string json = jss.Serialize(tm.PassTeams());

                Response.Write(json);
            }
        }
Ejemplo n.º 15
0
    //***************************************************************************//
    // Actual shoot fucntion
    //***************************************************************************//
    void OnMouseUp()
    {
        //Special checks for 2-player game
        if ((GlobalGameManager.playersTurn && gameObject.tag == "Player_2") || (GlobalGameManager.opponentsTurn && gameObject.tag == "Player"))
        {
            arrowPlane.GetComponent <Renderer>().enabled  = false;
            shootCircle.GetComponent <Renderer>().enabled = false;
            return;
        }

        //give the player a second chance to choose another ball if drag on the unit is too low
        print("currentDistance: " + currentDistance);
        if (currentDistance < 0.75f)
        {
            arrowPlane.GetComponent <Renderer>().enabled  = false;
            shootCircle.GetComponent <Renderer>().enabled = false;
            return;
        }

        //But if player wants to shoot anyway:
        //prevent double shooting in a round
        if (!canShoot)
        {
            return;
        }

        //no more shooting is possible
        canShoot = false;

        //keep track of elapsed time after letting the ball go,
        //so we can findout if ball has stopped and the round should be changed
        //this is the time which user released the button and shooted the ball
        shootTime = Time.time;

        //hide helper arrow object
        arrowPlane.GetComponent <Renderer>().enabled  = false;
        shootCircle.GetComponent <Renderer>().enabled = false;

        //do the physics calculations and shoot the ball
        Vector3 outPower = shootDirectionVector * pwr * -1;

        //add team power bonus
        //print ("OLD outPower: " + outPower.magnitude);
        outPower *= (1 + (TeamsManager.getTeamSettings(PlayerPrefs.GetInt("PlayerFlag")).x / 50));
        //print ("NEW outPower: " + outPower.magnitude);

        //Bug fix. Avoid shoot powers over 40, or the ball might fly off the level bounds.
        //Introduced in version 1.5+
        if (outPower.magnitude >= 40)
        {
            outPower *= 0.85f;
        }

        //always make the player to move only in x-y plane and not on the z direction
        print("shoot power: " + outPower.magnitude);
        GetComponent <Rigidbody>().AddForce(outPower, ForceMode.Impulse);

        //Update game summary
        //Please notice that both player1 and player2 (human players) are using this class to shoot their units.
        //so we need to distinguish each one when we want to monitor their stats
        if (GlobalGameManager.gameMode == 0)
        {
            //for player vs AI mode
            if (outPower.magnitude > 24)
            {
                GlobalGameManager.playerShoots++;
            }
            else
            {
                GlobalGameManager.playerPasses++;
            }
        }
        else if (GlobalGameManager.gameMode == 1)
        {
            //for player1 vs player2 mode
            if (outPower.magnitude > 24)
            {
                if (gameObject.tag == "Player")
                {
                    GlobalGameManager.playerShoots++;
                }
                else if (gameObject.tag == "Player_2")
                {
                    GlobalGameManager.opponentShoots++;
                }
            }
            else
            {
                if (gameObject.tag == "Player")
                {
                    GlobalGameManager.playerPasses++;
                }
                else if (gameObject.tag == "Player_2")
                {
                    GlobalGameManager.opponentPasses++;
                }
            }
        }
        //End - Update game summary

        //change the turn
        if (GlobalGameManager.gameMode == 0)
        {
            StartCoroutine(gameController.GetComponent <GlobalGameManager>().managePostShoot("Player"));
        }
        else if (GlobalGameManager.gameMode == 1)
        {
            StartCoroutine(gameController.GetComponent <GlobalGameManager>().managePostShoot(gameObject.tag));
        }
    }
Ejemplo n.º 16
0
        private void OnTeamChanged(TeamsManager.Team turnOfTeam)
        {
            if(turnOfTeam != team) return;

            foreach (var character in characters)
                character.Refresh();

            CurrentControlled = characters.FirstOrDefault();
        }
Ejemplo n.º 17
0
    public Texture2D[] statusModes;                     //Available status textures

    //*****************************************************************************
    // Init.
    //*****************************************************************************
    void Awake()
    {
        //debug
        //PlayerPrefs.DeleteAll();

        //init
        goalHappened       = false;
        shootHappened      = false;
        gameIsFinished     = false;
        playerGoals        = 0;
        opponentGoals      = 0;
        gameTime           = 0;
        round              = 1;
        seconds            = 0;
        minutes            = 0;
        canPlayCrowdChants = true;

        //Check if this is a penalty game or a normal match
        isPenaltyKick = (PlayerPrefs.GetInt("IsPenalty") == 1) ? true : false;

        //To avoid null reference errors caused by running the penalty scene without opening it from main menu,
        //we need to add the following lines. You should remove this in your live game.
        if (SceneManager.GetActiveScene().name == "Penalty-c#")        //just to avoid null errors
        {
            isPenaltyKick = true;
        }

        setDestinationForPenaltyMode();         //init the positions

        //get additonal time for each player and AI
        p1ShootTime = baseShootTime + TeamsManager.getTeamSettings(PlayerPrefs.GetInt("PlayerFlag")).y;
        p2ShootTime = baseShootTime + TeamsManager.getTeamSettings(PlayerPrefs.GetInt("Player2Flag")).y;
        print("P1 shoot time: " + p1ShootTime + " // " + "P2 shoot time: " + p2ShootTime);

        //hide gameStatusPlane
        gameStatusPlane.SetActive(false);
        continueTournamentBtn.SetActive(false);

        //Translate gameTimer index to actual seconds
        switch (PlayerPrefs.GetInt("GameTime"))
        {
        case 0:
            gameTimer = 180;
            break;

        case 1:
            gameTimer = 300;
            break;

        case 2:
            gameTimer = 480;
            break;

            //You can add more cases and options here.
        }

        //fill player shoot timer to full (only in normal game mode, where these objects are available)
        if (!isPenaltyKick)
        {
            p1TimeBarInitScale             = p1TimeBar.transform.localScale.x;
            p1TimeBarCurrentScale          = p1TimeBar.transform.localScale.x;
            p2TimeBarInitScale             = p2TimeBar.transform.localScale.x;
            p2TimeBarCurrentScale          = p2TimeBar.transform.localScale.x;
            p1TimeBar.transform.localScale = new Vector3(1, 1, 1);
            p2TimeBar.transform.localScale = new Vector3(1, 1, 1);
        }

        //Get Game Mode
        if (PlayerPrefs.HasKey("GameMode"))
        {
            gameMode = PlayerPrefs.GetInt("GameMode");
        }
        else
        {
            gameMode = 0;             // Deafault Mode (Player-1 vs AI)
        }
        playerAIController   = GameObject.FindGameObjectWithTag("playerAI");
        opponentAIController = GameObject.FindGameObjectWithTag("opponentAI");

        ball = GameObject.FindGameObjectWithTag("ball");
        ballStartingPosition = new Vector3(0, -0.81f, -0.7f);           //for normal play mode

        manageGameModes();
    }
Ejemplo n.º 18
0
 public TeamController(TeamsManager.Team team)
 {
     this.team = team;
 }
Ejemplo n.º 19
0
 public override void Execute()
 {
     Program.userInterface.TeamsManager = TeamsManager.Deserialize(FileName);
 }
Ejemplo n.º 20
0
    IEnumerator tapManager()
    {
        //Mouse of touch?
        if (Input.touches.Length > 0 && Input.touches[0].phase == TouchPhase.Ended)
        {
            ray = Camera.main.ScreenPointToRay(Input.touches[0].position);
        }
        else if (Input.GetMouseButtonUp(0))
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        }
        else
        {
            yield break;
        }

        if (Physics.Raycast(ray, out hitInfo))
        {
            GameObject objectHit = hitInfo.transform.gameObject;

            switch (objectHit.name)
            {
            case "p1-TBR":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));                               //button scale-animation to user input
                checkAvailableTeam();
                checkAvailableForm();
                do
                {
                    p1TeamCounter++;                                            //cycle through available team indexs for this player. This is the main index value.
                    fixCounterLengths();                                        //when reached to the last option, start from the first index of the other side.
                } while(!isAvailableTeam [p1TeamCounter]);

                p1Team.GetComponent <Renderer>().material.mainTexture = availableTeams[p1TeamCounter];                        //set the flag on UI
                p1PowerBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p1TeamCounter).x / 10,
                                                              p1PowerBar.transform.localScale.y,
                                                              p1PowerBar.transform.localScale.z);

                p1TimeBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p1TeamCounter).y / 10,
                                                             p1TimeBar.transform.localScale.y,
                                                             p1TimeBar.transform.localScale.z);
                yield return(new WaitForSeconds(0.07f));

                StartCoroutine(animateButton(p1Team));
                break;

            case "p1-TBL":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));                               //button scale-animation to user input
                checkAvailableTeam();
                checkAvailableForm();
                do
                {
                    p1TeamCounter--;                                                                   //cycle through available team indexs for this player. This is the main index value.
                    fixCounterLengths();                                                               //when reached to the last option, start from the first index of the other side.
                } while(!isAvailableTeam [p1TeamCounter]);
                p1Team.GetComponent <Renderer>().material.mainTexture = availableTeams[p1TeamCounter]; //set the flag on UI
                p1PowerBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p1TeamCounter).x / 10,
                                                              p1PowerBar.transform.localScale.y,
                                                              p1PowerBar.transform.localScale.z);

                p1TimeBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p1TeamCounter).y / 10,
                                                             p1TimeBar.transform.localScale.y,
                                                             p1TimeBar.transform.localScale.z);
                yield return(new WaitForSeconds(0.07f));

                StartCoroutine(animateButton(p1Team));
                break;

            case "p2-TBR":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));                               //button scale-animation to user input
                checkAvailableTeam();
                checkAvailableForm();
                do
                {
                    p2TeamCounter++;                                            //cycle through available team indexs for this player. This is the main index value.
                    fixCounterLengths();                                        //when reached to the last option, start from the first index of the other side.
                } while(!isAvailableTeam [p2TeamCounter]);

                p2Team.GetComponent <Renderer>().material.mainTexture = availableTeams[p2TeamCounter];                        //set the flag on UI
                p2PowerBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p2TeamCounter).x / 10,
                                                              p2PowerBar.transform.localScale.y,
                                                              p2PowerBar.transform.localScale.z);

                p2TimeBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p2TeamCounter).y / 10,
                                                             p2TimeBar.transform.localScale.y,
                                                             p2TimeBar.transform.localScale.z);
                yield return(new WaitForSeconds(0.07f));

                StartCoroutine(animateButton(p2Team));
                break;

            case "p2-TBL":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));                               //button scale-animation to user input
                checkAvailableTeam();
                checkAvailableForm();
                do
                {
                    p2TeamCounter--;                                                                   //cycle through available team indexs for this player. This is the main index value.
                    fixCounterLengths();                                                               //when reached to the last option, start from the first index of the other side.
                } while(!isAvailableTeam [p2TeamCounter]);
                p2Team.GetComponent <Renderer>().material.mainTexture = availableTeams[p2TeamCounter]; //set the flag on UI
                p2PowerBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p2TeamCounter).x / 10,
                                                              p2PowerBar.transform.localScale.y,
                                                              p2PowerBar.transform.localScale.z);

                p2TimeBar.transform.localScale = new Vector3(TeamsManager.getTeamSettings(p2TeamCounter).y / 10,
                                                             p2TimeBar.transform.localScale.y,
                                                             p2TimeBar.transform.localScale.z);
                yield return(new WaitForSeconds(0.07f));

                StartCoroutine(animateButton(p2Team));
                break;

            case "p1-FBL":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));                               //button scale-animation to user input
                checkAvailableTeam();
                checkAvailableForm();
                do
                {
                    p1FormationCounter--;                                       //cycle through available formation indexs for this player. This is the main index value.
                    fixCounterLengths();                                        //when reached to the last option, start from the first index of the other side.
                } while(!isAvailableForm [p1FormationCounter]);

                p1FormationLabel.GetComponent <TextMesh>().text = availableFormations[p1FormationCounter];                        //set the string on the UI
                break;

            case "p1-FBR":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));
                checkAvailableTeam();
                checkAvailableForm();
                do
                {
                    p1FormationCounter++;                                       //cycle through available formation indexs for this player. This is the main index value.
                    fixCounterLengths();                                        //when reached to the last option, start from the first index of the other side.
                } while(!isAvailableForm [p1FormationCounter]);

                p1FormationLabel.GetComponent <TextMesh>().text = availableFormations[p1FormationCounter];
                break;

            case "p2-FBL":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));
                checkAvailableTeam();
                checkAvailableForm();
                do
                {
                    p2FormationCounter--;                                       //cycle through available formation indexs for this player. This is the main index value.
                    fixCounterLengths();                                        //when reached to the last option, start from the first index of the other side.
                } while(!isAvailableForm [p2FormationCounter]);

                p2FormationLabel.GetComponent <TextMesh>().text = availableFormations[p2FormationCounter];
                break;

            case "p2-FBR":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));
                checkAvailableTeam();
                checkAvailableForm();
                do
                {
                    p2FormationCounter++;                                       //cycle through available formation indexs for this player. This is the main index value.
                    fixCounterLengths();                                        //when reached to the last option, start from the first index of the other side.
                } while(!isAvailableForm [p2FormationCounter]);
                p2FormationLabel.GetComponent <TextMesh>().text = availableFormations[p2FormationCounter];
                break;

            case "durationBtnLeft":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));
                timeCounter--;
                fixCounterLengths();
                if (pubR.language_option == 0)
                {
                    gameTimeLabel.GetComponent <TextMesh>().text = availableTimes[timeCounter];
                }
                else
                {
                    if (timeCounter == 0)
                    {
                        arab_3_min.SetActive(true);
                        arab_5_min.SetActive(false);
                        arab_8_min.SetActive(false);
                    }
                    else if (timeCounter == 1)
                    {
                        arab_3_min.SetActive(false);
                        arab_5_min.SetActive(true);
                        arab_8_min.SetActive(false);
                    }
                    else if (timeCounter == 2)
                    {
                        arab_3_min.SetActive(false);
                        arab_5_min.SetActive(false);
                        arab_8_min.SetActive(true);
                    }
                }
                break;

            case "durationBtnRight":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));
                timeCounter++;
                fixCounterLengths();
                if (pubR.language_option == 0)
                {
                    gameTimeLabel.GetComponent <TextMesh>().text = availableTimes[timeCounter];
                }
                else
                {
                    if (timeCounter == 0)
                    {
                        arab_3_min.SetActive(true);
                        arab_5_min.SetActive(false);
                        arab_8_min.SetActive(false);
                    }
                    else if (timeCounter == 1)
                    {
                        arab_3_min.SetActive(false);
                        arab_5_min.SetActive(true);
                        arab_8_min.SetActive(false);
                    }
                    else if (timeCounter == 2)
                    {
                        arab_3_min.SetActive(false);
                        arab_5_min.SetActive(false);
                        arab_8_min.SetActive(true);
                    }
                }
                break;

            case "Btn-Back":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));
                yield return(new WaitForSeconds(0.5f));

                //No need to save anything
                SceneManager.LoadScene("Menu-c#");
                break;

            case "Btn-Start":
                playSfx(tapSfx);
                StartCoroutine(animateButton(objectHit));
                //Save configurations
                PlayerPrefs.SetInt("PlayerFormation", p1FormationCounter);                              //save the player-1 formation index
                PlayerPrefs.SetInt("PlayerFlag", p1TeamCounter);                                        //save the player-1 team index

                PlayerPrefs.SetInt("Player2Formation", p2FormationCounter);                             //save the player-2 formation index
                PlayerPrefs.SetInt("Player2Flag", p2TeamCounter);                                       //save the player-2 team index
                //Opponent uses the exact same settings as player-2, so:
                PlayerPrefs.SetInt("OpponentFormation", p2FormationCounter);                            //save the Opponent formation index
                PlayerPrefs.SetInt("OpponentFlag", p2TeamCounter);                                      //save the Opponent team index

                PlayerPrefs.SetInt("GameTime", timeCounter);                                            //save the game-time value
                //** Please note that we just set the indexes here. We fetch the actual index values in the <<Game>> scene.

                yield return(new WaitForSeconds(0.5f));

                //if we are using the config for a tournament, we should load it as the next scene.
                //otherwise we can instantly jump to the Game scene in normal play mode.
                if (isTournamentMode == 1)
                {
                    SceneManager.LoadScene("Tournament-c#");
                }
                else
                {
                    SceneManager.LoadScene("Game-c#");
                }

                break;
            }
        }
    }
    public Texture2D[] statusModes_arab;     //Available status textures

    //*****************************************************************************
    // Init.
    //*****************************************************************************
    void Awake()
    {
        //init
        goalHappened       = false;
        shootHappened      = false;
        gameIsFinished     = false;
        playerGoals        = 0;
        opponentGoals      = 0;
        gameTime           = 0;
        round              = 1;
        seconds            = 0;
        minutes            = 0;
        canPlayCrowdChants = true;

        //get additonal time for each player and AI
        p1ShootTime = baseShootTime + TeamsManager.getTeamSettings(PlayerPrefs.GetInt("PlayerFlag")).y;
        p2ShootTime = baseShootTime + TeamsManager.getTeamSettings(PlayerPrefs.GetInt("Player2Flag")).y;
        print("P1 shoot time: " + p1ShootTime + " // " + "P2 shoot time: " + p2ShootTime);

        //hide gameStatusPlane
        gameStatusPlane.SetActive(false);
        continueTournamentBtn.SetActive(false);

        //Translate gameTimer index to actual seconds
        switch (PlayerPrefs.GetInt("GameTime"))
        {
        case 0:
            gameTimer = 180;
            break;

        case 1:
            gameTimer = 300;
            break;

        case 2:
            gameTimer = 480;
            break;

            //You can add more cases and options here.
        }

        //fill player shoot timer to full
        p1TimeBarInitScale             = p1TimeBar.transform.localScale.x;
        p1TimeBarCurrentScale          = p1TimeBar.transform.localScale.x;
        p2TimeBarInitScale             = p2TimeBar.transform.localScale.x;
        p2TimeBarCurrentScale          = p2TimeBar.transform.localScale.x;
        p1TimeBar.transform.localScale = new Vector3(1, 1, 1);
        p2TimeBar.transform.localScale = new Vector3(1, 1, 1);

        //Get Game Mode
        if (PlayerPrefs.HasKey("GameMode"))
        {
            gameMode = PlayerPrefs.GetInt("GameMode");
        }
        else
        {
            gameMode = 0;             // Deafault Mode (Player-1 vs AI)
        }
        playerAIController   = GameObject.FindGameObjectWithTag("playerAI");
        opponentAIController = GameObject.FindGameObjectWithTag("opponentAI");
        ball = GameObject.FindGameObjectWithTag("ball");

        manageGameModes();
    }
Ejemplo n.º 22
0
 void Start()
 {
     teamsMngr = GameObject.FindGameObjectWithTag("TeamsManager").GetComponent <TeamsManager>();
 }
Ejemplo n.º 23
0
 public TeamController(TeamsManager.Team team, IEnumerable<Character> chars )
     : this(team)
 {
     characters = chars as List<Character>;
 }
Ejemplo n.º 24
0
 public PlayerController()
 {
     _playersManager = new PlayersManager();
     _teamsManager   = new TeamsManager();
 }
Ejemplo n.º 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            TeamsManager teamsManager = new TeamsManager();

            TeamsList = teamsManager.PassTeams();
        }
Ejemplo n.º 26
0
 void Start()
 {
     gameManager  = GameManager.Instance;
     teamsManager = GameObject.Find("/Managers/TeamsManager").GetComponent <TeamsManager>();
 }
Ejemplo n.º 27
0
 void Start()
 {
     timeToFire = fireRate;
     satSelf    = GetComponent <Satellite>();
     teamsMngr  = GameObject.FindGameObjectWithTag("TeamsManager").GetComponent <TeamsManager>();
 }
Ejemplo n.º 28
0
 public override void Execute()
 {
     TeamsManager.Serialize(Program.userInterface.TeamsManager, FileName);
 }
Ejemplo n.º 29
0
 public MatchController()
 {
     _matchesManager = new MatchManager();
     _teamsManager   = new TeamsManager();
 }
Ejemplo n.º 30
0
 public TeamController()
 {
     _teamsManager = new TeamsManager();
 }
Ejemplo n.º 31
0
    private GameObject bestShooter;     //select the best unit to shoot.
    IEnumerator shoot()
    {
        //wait for a while to fake thinking process :)
        yield return(new WaitForSeconds(1.0f));

        //init
        bestShooter = null;

        //1. find units with good position to shoot
        //Units that are in the right hand side of the ball are considered a better options.
        //They can have better angle to the player's gate.
        List <GameObject> shooters        = new List <GameObject>();    //list of all good units
        List <float>      distancesToBall = new List <float>();         //distance of these good units to the ball

        foreach (GameObject shooter in myTeam)
        {
            if (shooter.transform.position.x > target.transform.position.x + 1.5f)
            {
                shooters.Add(shooter);
                distancesToBall.Add(Vector3.Distance(shooter.transform.position, target.transform.position));
            }
        }

        //if we found atleast one good unit...
        float minDistance            = 1000;
        int   minDistancePlayerIndex = 0;

        if (shooters.Count > 0)
        {
            //print("we have " + shooters.Count + " unit(s) in a good shoot position");
            for (int i = 0; i < distancesToBall.Count; i++)
            {
                if (distancesToBall[i] <= minDistance)
                {
                    minDistance            = distancesToBall[i];
                    minDistancePlayerIndex = i;
                }
                //print(shooters[i] + " distance to ball is " + distancesToBall[i]);
            }
            //find the unit which is most closed to ball.
            bestShooter = shooters[minDistancePlayerIndex];
            //print("MinDistance to ball is: " + minDistance + " by opponent " + bestShooter.name);
        }
        else
        {
            //print("no player is availabe for a good shoot!");
            //Select a random unit
            bestShooter = myTeam[Random.Range(0, myTeam.Length)];
        }

        //calculate direction and power and add a little randomness to the shoot (can be used to make the game easy or hard)
        float distanceCoef = 0;

        if (minDistance <= 5 && minDistance >= 0)
        {
            distanceCoef = Random.Range(1.0f, 2.5f);
        }
        else
        {
            distanceCoef = Random.Range(2.0f, 4.0f);
        }
        print("distanceCoef: " + distanceCoef);

        //////////////////////////////////////////////////////////////////////////////////////////////////
        // Detecting the best angle for the shoot
        //////////////////////////////////////////////////////////////////////////////////////////////////
        Vector3 vectorToGate;                                   //direct vector from shooter to gate
        Vector3 vectorToBall;                                   //direct vector from shooter to ball
        float   straightAngleDifferential;                      //angle between "vectorToGate" and "vectorToBall" vectors

        vectorToGate = PlayerBasketCenter.transform.position - bestShooter.transform.position;
        vectorToBall = target.transform.position - bestShooter.transform.position;
        straightAngleDifferential = Vector3.Angle(vectorToGate, vectorToBall);
        //if angle between these two vector is lesser than 10 for example, we have a clean straight shot to gate.
        //but if the angle is more, we have to calculate the correct angle for the shoot.
        print("straightAngleDifferential: " + straightAngleDifferential);
        //////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////////////

        float shootPositionDifferential = bestShooter.transform.position.y - target.transform.position.y;

        print("Y differential for shooter is: " + shootPositionDifferential);

        if (straightAngleDifferential <= 10)
        {
            //direct shoot
            directionToTarget = target.transform.position - bestShooter.transform.position;
        }
        else if (Mathf.Abs(shootPositionDifferential) <= 0.5f)
        {
            //direct shoot
            directionToTarget = target.transform.position - bestShooter.transform.position;
        }
        else if (Mathf.Abs(shootPositionDifferential) > 0.5f && Mathf.Abs(shootPositionDifferential) <= 1)
        {
            if (shootPositionDifferential > 0)
            {
                directionToTarget = (target.transform.position - new Vector3(0, bestShooter.transform.localScale.z / 2.5f, 0)) - bestShooter.transform.position;
            }
            else
            {
                directionToTarget = (target.transform.position + new Vector3(0, bestShooter.transform.localScale.z / 2.5f, 0)) - bestShooter.transform.position;
            }
        }
        else if (Mathf.Abs(shootPositionDifferential) > 1 && Mathf.Abs(shootPositionDifferential) <= 2)
        {
            if (shootPositionDifferential > 0)
            {
                directionToTarget = (target.transform.position - new Vector3(0, bestShooter.transform.localScale.z / 2, 0)) - bestShooter.transform.position;
            }
            else
            {
                directionToTarget = (target.transform.position + new Vector3(0, bestShooter.transform.localScale.z / 2, 0)) - bestShooter.transform.position;
            }
        }
        else if (Mathf.Abs(shootPositionDifferential) > 2 && Mathf.Abs(shootPositionDifferential) <= 3)
        {
            if (shootPositionDifferential > 0)
            {
                directionToTarget = (target.transform.position - new Vector3(0, bestShooter.transform.localScale.z / 1.6f, 0)) - bestShooter.transform.position;
            }
            else
            {
                directionToTarget = (target.transform.position + new Vector3(0, bestShooter.transform.localScale.z / 1.6f, 0)) - bestShooter.transform.position;
            }
        }
        else if (Mathf.Abs(shootPositionDifferential) > 3)
        {
            if (shootPositionDifferential > 0)
            {
                directionToTarget = (target.transform.position - new Vector3(0, bestShooter.transform.localScale.z / 1.25f, 0)) - bestShooter.transform.position;
            }
            else
            {
                directionToTarget = (target.transform.position + new Vector3(0, bestShooter.transform.localScale.z / 1.25f, 0)) - bestShooter.transform.position;
            }
        }

        //set the shoot power based on direction and distance to ball
        Vector3 appliedPower = Vector3.Normalize(directionToTarget) * shootPower;

        //add team power bonus
        //print ("OLD appliedPower: " + appliedPower.magnitude);
        appliedPower *= (1 + (TeamsManager.getTeamSettings(PlayerPrefs.GetInt("Player2Flag")).x / 50));
        //print ("NEW appliedPower: " + appliedPower.magnitude);
        bestShooter.GetComponent <Rigidbody>().AddForce(appliedPower, ForceMode.Impulse);

        print(bestShooter.name + " shot the ball with a power of " + appliedPower.magnitude);
        StartCoroutine(visualDebug());

        StartCoroutine(gameController.GetComponent <GlobalGameManager>().managePostShoot("Opponent"));
    }
Ejemplo n.º 32
0
 public TeamsManagerTests(ITestOutputHelper output, DynamicsWebAppFixture fixture) : base(output, fixture)
 {
     manager = Services.GetRequiredService <TeamsManager>();
 }