Example #1
0
        public GameSettings()
        {
            gameName = "NowaGra000";
            gameMap = null;
            gameType = GameType.DeathMatch;
            gamePointLimit = 0;
            gameFragLimit = 10;
            gameTimeLimit = 0;
            gameServerIP = "127.0.0.1";
            gameSlots = new MotorShortDescription[10];
            gameMotors = new Motorek[10];
            for (int i = 0; i < 10; i++)
            {
                gameSlots[i] = null;
                gameMotors[i] = null;
            }
            agentController = null;

            playerName = "Gracz1";
            playerKeys = new Keys[Enum.GetNames(typeof(GameKeyNames)).Count()];
            for (int i = 0; i < Enum.GetNames(typeof(GameKeyNames)).Count(); i++)
            {
                playerKeys[i] = (Keys)Enum.Parse(typeof(Default_playerKeys), Enum.GetNames(typeof(GameKeyNames))[i]);
            }
            playerSteering = PlayerMotor.Steering.Relative;
            playerColor = Color.Yellow;

            videoGraphMode = 0; //default graph mode
            videoFullscreen = false; //windowed by default

            audioEnabled = false;
            audioVolumePercent = 100;
            audioSFXVolumePercent = 75;
            audioMusicVolumePercent = 50;
            audioUIVolumePercent = 75;

            gameoptNames = true;
            gameoptMinimap = true;
            gameoptPointers = true;
        }
Example #2
0
        void FragsPoints_Changed(Motorek m, int old_value)
        {
            string new_text = "";

            int bikesCount = 0; //total number of bikes for demolition
            int aliveBikesCount = 0; //number of alive bikes for demolition
            for (int i = 0; i < GameSettings.gameMotors.Length; i++)
                if (GameSettings.gameMotors[i] != null)
                {
                    bikesCount++;
                    if (GameSettings.gameMotors[i].HP > 0)
                        aliveBikesCount++;
                }

            int teamID = motorID / (GameSettings.gameMotors.Length / 2);

            int teamMembersCount = 0; //number of alive team members for team demolition
            int enemyTeamMembersCount = 0; //number of alive enemy team members for team demolition
            int teamFragsCount = 0; //total count of frags in team
            int enemyTeamFragsCount = 0; //total count of frags in enemy team
            int teamPointsCount = 0; //total count of points in team
            int enemyTeamPointsCount = 0; //total count of points in enemy team
            for (int i = 0; i < GameSettings.gameMotors.Length / 2; i++)
            {
                int testingID = (GameSettings.gameMotors.Length / 2) * teamID + i;
                if (GameSettings.gameMotors[testingID] != null)
                {
                    teamFragsCount += GameSettings.gameMotors[testingID].FragsCount;
                    teamPointsCount += GameSettings.gameMotors[testingID].PointsCount;
                    if (GameSettings.gameMotors[testingID].HP > 0)
                        teamMembersCount++;
                }
                int enemyTestingID = (GameSettings.gameMotors.Length / 2) * (1 - teamID) + i;
                if (GameSettings.gameMotors[enemyTestingID] != null)
                {
                    enemyTeamFragsCount += GameSettings.gameMotors[enemyTestingID].FragsCount;
                    enemyTeamPointsCount += GameSettings.gameMotors[enemyTestingID].PointsCount;
                    if (GameSettings.gameMotors[enemyTestingID].HP > 0)
                        enemyTeamMembersCount++;
                }
            }
            int time_left = (int)(GameSettings.gameTimeLimit * 60 - (GameSettings.gamePlayScreen.currentTime - GameSettings.gamePlayScreen.startTime));

            //some statistics
            int leader_frags = GameSettings.gameMotors[motorID].FragsCount - GameSettings.gameMotors.Max((_) => _ != null && _ != GameSettings.gameMotors[motorID] ? _.FragsCount : 0);
            int leader_points = GameSettings.gameMotors[motorID].PointsCount - GameSettings.gameMotors.Max((_) => _ != null && _ != GameSettings.gameMotors[motorID] ? _.PointsCount : 0);
            int team_leader_frags = teamFragsCount - enemyTeamFragsCount;
            int team_leader_points = teamPointsCount - enemyTeamPointsCount;

            switch (GameSettings.gameType)
            {
                case GameType.DeathMatch: new_text = GameSettings.gameMotors[motorID].FragsCount.ToString("000") + "/" + GameSettings.gameFragLimit.ToString("000") + (leader_frags > 0 ? " (you are leading by +" + leader_frags + ")" : leader_frags == 0 ? " (tie)" : " (you are losing by " + leader_frags + ")"); break;
                case GameType.Demolition: new_text = aliveBikesCount.ToString("00") + " of " + bikesCount.ToString("00") + " alive"; break;
                case GameType.PointMatch: new_text = GameSettings.gameMotors[motorID].PointsCount.ToString("000000") + "/" + GameSettings.gamePointLimit.ToString("000000") + (leader_points > 0 ? " (you are leading by +" + leader_points + ")" : leader_points == 0 ? " (tie)" : " (you are losing by " + leader_points + ")"); break;
                case GameType.TimeMatch: new_text = (time_left / 60).ToString("00") + ":" + (time_left % 60).ToString("00") + (leader_points > 0 ? " (you are leading by +" + leader_points + " points)" : leader_points == 0 ? " (tie)" : " (you are losing by " + leader_points + " points)"); break;
                case GameType.TeamDeathMatch: new_text = teamFragsCount.ToString("000") + " [" + GameSettings.gameMotors[motorID].FragsCount.ToString("000") + " yours]/" + GameSettings.gameFragLimit.ToString("000") + (team_leader_frags > 0 ? " (your team is leading with +" + team_leader_frags + ")" : team_leader_frags == 0 ? " (tie)" : " (your team is losing with " + team_leader_frags + ")"); break;
                case GameType.TeamDemolition: new_text = teamMembersCount.ToString("0") + " alive - " + enemyTeamMembersCount.ToString("0") + " alive" + (teamMembersCount > enemyTeamMembersCount ? " (your team is leading)" : teamMembersCount == enemyTeamMembersCount ? " (tie)" : " (your team is losing)"); break;
                case GameType.TeamPointMatch: new_text = teamPointsCount.ToString("000000") + " [" + GameSettings.gameMotors[motorID].PointsCount.ToString("000000") + " yours]/" + GameSettings.gamePointLimit.ToString("000000") + (team_leader_points > 0 ? " (your team is leading by +" + team_leader_points + ")" : team_leader_points == 0 ? " (tie)" : " (your team is losing by " + team_leader_points + ")"); break;
                case GameType.TeamTimeMatch: new_text = (time_left / 60).ToString("00") + ":" + (time_left % 60).ToString("00") + (team_leader_points > 0 ? " (your team is leading by +" + team_leader_points + " points)" : team_leader_points == 0 ? " (tie)" : " (your team is losing by " + team_leader_points + " points)"); break;
            }
            UIParent.UI["playerCounterShade"].Text = new_text;
            UIParent.UI["playerCounterFront"].Text = new_text;
        }
Example #3
0
        /// <param name="motor">note: motor is passed by ref but is not changed - ref only prevents object copying</param>
        /// <param name="displacementVec">resulting displacement vector</param>
        /// <param name="damage">damage inflicted by collision (if any)</param>
        /// <returns>true if any collision occured</returns>
        public bool TestCollisions(ref Motorek motor, out Vector2 displacementVec, out float damage)
        {
            bool is_collided = false;
            displacementVec = Vector2.Zero;
            damage = 0;

            Vector2 motorDirVec = Utils.CalculateDirectionVector(motor.rotation.ToRadians());
            foreach (MapEdge edge in Edges)
            {
                Vector2 dispVec = Vector2.Zero;

                bool collided = edge.TestCollision(motorDirVec, motor.boundPoints, out dispVec);

                is_collided |= collided;
                if (collided)
                {
                    if (motor.oldCollided.IndexOf(edge.Name) == -1)
                        damage += 1;
                    motor.newCollided.Add(edge.Name);
                    displacementVec += dispVec;
                }
            }
            return is_collided;
        }
Example #4
0
        void FragsPoints_Changed(Motorek m, int old_value)
        {
            string new_text = "";

            int bikesCount = 0; //total number of bikes for demolition
            int aliveBikesCount = 0; //number of alive bikes for demolition
            for (int i = 0; i < GameSettings.gameMotors.Length; i++)
                if (GameSettings.gameMotors[i] != null)
                {
                    bikesCount++;
                    if (GameSettings.gameMotors[i].HP > 0)
                        aliveBikesCount++;
                }

            int teamID = motorID / (GameSettings.gameMotors.Length / 2);

            int teamMembersCount = 0; //number of alive team members for team demolition
            int enemyTeamMembersCount = 0; //number of alive enemy team members for team demolition
            int teamFragsCount = 0; //total count of frags in team
            int teamPointsCount = 0; //total count of points in team
            for (int i = 0; i < GameSettings.gameMotors.Length / 2; i++)
            {
                int testingID = (GameSettings.gameMotors.Length / 2) * teamID + i;
                if (GameSettings.gameMotors[testingID] != null)
                {
                    teamFragsCount += GameSettings.gameMotors[testingID].FragsCount;
                    teamPointsCount += GameSettings.gameMotors[testingID].PointsCount;
                    if (GameSettings.gameMotors[testingID].HP > 0)
                        teamMembersCount++;
                }
                int enemyTestingID = (GameSettings.gameMotors.Length / 2) * (1 - teamID) + i;
                if ((GameSettings.gameMotors[enemyTestingID] != null) && (GameSettings.gameMotors[enemyTestingID].HP > 0))
                    enemyTeamMembersCount++;
            }
            int time_left = (int)(GameSettings.gameTimeLimit * 60 - (GameSettings.gamePlayScreen1.currentTime - GameSettings.gamePlayScreen1.startTime));

            switch (GameSettings.gameType)
            {
                case GameType.DeathMatch: new_text = GameSettings.gameMotors[motorID].FragsCount.ToString("000") + "/" + GameSettings.gameFragLimit.ToString("000"); break;
                case GameType.Demolition: new_text = aliveBikesCount.ToString("00") + "/" + bikesCount.ToString("00"); break;
                case GameType.PointMatch: new_text = GameSettings.gameMotors[motorID].PointsCount.ToString("000000") + "/" + GameSettings.gamePointLimit.ToString("000000"); break;
                case GameType.TimeMatch: new_text = (time_left / 60).ToString("00") + ":" + (time_left % 60).ToString("00"); break;
                case GameType.TeamDeathMatch: new_text = teamFragsCount.ToString("000") + " [" + GameSettings.gameMotors[motorID].FragsCount.ToString("000") + "]/" + GameSettings.gameFragLimit.ToString("000"); break;
                case GameType.TeamDemolition: new_text = teamMembersCount.ToString("0") + " - " + enemyTeamMembersCount.ToString("0"); break;
                case GameType.TeamPointMatch: new_text = teamPointsCount.ToString("000000") + " [" + GameSettings.gameMotors[motorID].PointsCount.ToString("000000") + "]/" + GameSettings.gamePointLimit.ToString("000000"); break;
                case GameType.TeamTimeMatch: new_text = (time_left / 60).ToString("00") + ":" + (time_left % 60).ToString("00"); break;
            }
            UIParent.UI["playerCounterShade"].Text = new_text;
            UIParent.UI["playerCounterFront"].Text = new_text;
        }
Example #5
0
        void menu_InitBackground()
        {
            if (menu_background)
                menu_DestroyBackground();

            motorek = new PlayerMotor(this, 0, new Color(255, 255, 255));
            motorek.name = "";
            menu_bots = new BotMotor[3];
            menu_bots[0] = new BotMotor(this, Color.Red);
            menu_bots[0].name = "";
            menu_bots[1] = new BotMotor(this, Color.Green);
            menu_bots[1].name = "";
            menu_bots[2] = new BotMotor(this, Color.Blue);
            menu_bots[2].name = "";
            motorek.LoadAndInitialize(new Rectangle(0, 0, 800, 600));
            motorek.Spawn(new Vector2(400, 300), 90);
            menu_bots[0].LoadAndInitialize(new Rectangle(0, 0, 900, 700));
            menu_bots[0].Spawn(new Vector2(10, 10), 135);
            menu_bots[1].LoadAndInitialize(new Rectangle(0, 0, 900, 700));
            menu_bots[1].Spawn(new Vector2(10, 600 - 10), 45);
            menu_bots[2].LoadAndInitialize(new Rectangle(0, 0, 900, 700));
            menu_bots[2].Spawn(new Vector2(800 - 10, 600 - 10), -45);
            menu_background = true;
        }
Example #6
0
        void menu_DestroyBackground()
        {
            if (!menu_background)
                return;

            motorek.Destroy();
            motorek = null;
            for (int i = 0; i < 3; i++)
            {
                menu_bots[i].Destroy();
                menu_bots[i] = null;
            }
            menu_background = false;
        }