public async Task ToggleNotifications()
    {
        Team team = TeamUtils.GetTeam(Context.User.Id);

        //If the user isn't in a team or isn't the team leader, display an error message
        if (team == null)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_No_Team, Context.User)); return;
        }
        if (team.TeamLeader != Context.User.Id)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_Not_Leader, Context.User)); return;
        }

        //Create a new team based on the original and update the notification status
        Team updatedTeam = team;

        if (team.Notifications)
        {
            updatedTeam.Notifications = false;
        }
        else
        {
            updatedTeam.Notifications = true;
        }

        //Delete the team file, write the new team file, and update the teams list with the new team
        File.Delete($"Users/Teams/{team.TeamLeader}.json");
        Utilities.WriteToJsonFile <Team>($"Users/Teams/{team.TeamLeader}.json", updatedTeam);
        TeamUtils.teamData.Remove(team);
        TeamUtils.teamData.Add(updatedTeam);

        await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Updated", $"Team Notifications Enabled: {updatedTeam.Notifications.ToString()}", Context.User)); return;
    }
Exemple #2
0
        public async Task MainAsync()
        {
            _client   = new DiscordSocketClient();
            _commands = new CommandService();
            _services = ConfigureServices();

            //Add all required EventHandlers
            _client.Log               += Log;
            _client.JoinedGuild       += GuildJoinedHandler;
            _client.LeftGuild         += GuildLeftHandler;
            _client.Ready             += _client_Ready;
            _commands.CommandExecuted += _commands_CommandExecuted;

            //Installs all command modules
            await InstallCommandsAsync();

            //Loads the bot token from the token config file
            var token = File.ReadAllText("Config/token.cfg");

            //Logs in to the bot account and starts the client
            await _client.LoginAsync(TokenType.Bot, token);

            await _client.StartAsync();

            //Loads various stored data
            PremiumUtils.LoadRanks();
            TeamUtils.teamData     = TeamUtils.LoadTeams();
            TeamUtils.userSettings = TeamUtils.LoadSettings();
            GuildUtils.guildData   = GuildUtils.LoadSettings();

            //Loads the Top.GG API key from the topggToken config file
            LoggingUtils.apiKey = File.ReadAllText("Config/topggToken.cfg");

            await Task.Delay(-1);
        }
Exemple #3
0
    public async Task RaidNotifier()
    {
        Team team = TeamUtils.GetTeam(Context.User.Id);

        if (team == null)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_No_Team, Context.User)); return;
        }
        if (!team.Notifications)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_Notifications_Disabled, Context.User)); return;
        }
        if (Context.Guild != Program._client.GetGuild(team.GuildID))
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_Wrong_Guild, Context.User)); return;
        }

        StringBuilder mentions = new StringBuilder();

        foreach (ulong member in team.Members)
        {
            mentions.Append($"<@!{member}>, ");
        }

        await ReplyAsync($"<@!{team.TeamLeader}>, {mentions.ToString()}", false, Utilities.GetEmbedMessage("Team Notifications", "Raid", $"Attention, we are currently being raided. Base Coords: {team.BaseCoords}, Server IP: {team.Server.IP}:{team.Server.Port}", Context.User));
    }
Exemple #4
0
    private void OnTriggerEnter(Collider other)
    {
        Ball ball = other.gameObject.GetComponent <Ball>();

        if (ball != null)
        {
            if (ball.teamAllegiance != ETeam.None && GameManager.Instance.rules.scoreIfBallFalls && ball.teamAllegiance == TeamUtils.GetOppositeTeam(team))
            {
                GameManager.Instance.IncrementScore(ball.teamAllegiance);
            }
            Destroy(ball.gameObject);
            return;
        }

        PlayerController player = other.gameObject.GetComponent <PlayerController>();

        if (player != null && destroyPlayer)
        {
            if (player.team != ETeam.None && GameManager.Instance.rules.scoreIfPlayerFalls)
            {
                GameManager.Instance.IncrementScore(TeamUtils.GetOppositeTeam(player.team));
            }
            GameManager.Instance.ReplacePlayer(player);
            return;
        }
    }
Exemple #5
0
    public async Task SetBaseCoords(string coords)
    {
        Team team = TeamUtils.GetTeam(Context.User.Id);

        //If the input is not a valid coordinate, display an error and return.
        if (!Regex.Match(coords, @"^[a-zA-Z]{1,2}\d{1,2}$").Success)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Coordinates", "Error", Language.Team_Coordinates_Error_Invalid, Context.User)); return;
        }

        //If the user isn't in a team or isn't the team leader, display an error message
        if (team == null)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Coordinates", "Error", Language.Team_Error_No_Team, Context.User)); return;
        }
        if (team.TeamLeader != Context.User.Id)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_Not_Leader, Context.User)); return;
        }

        //Create a new team based on the original and update the base coordinates
        Team updatedTeam = team;

        updatedTeam.BaseCoords = coords.ToUpper();

        //Delete the team file, write the new team file, and update the teams list with the new team
        File.Delete($"Users/Teams/{team.TeamLeader}.json");
        Utilities.WriteToJsonFile <Team>($"Users/Teams/{team.TeamLeader}.json", updatedTeam);
        TeamUtils.teamData.Remove(team);
        TeamUtils.teamData.Add(updatedTeam);

        await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Coordinates", "Updated", $"Coordinates Updated: {updatedTeam.BaseCoords}", Context.User)); return;
    }
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (ColliderUtils.HasBallCollided(collision))
        {
            GameObject             player                       = this.gameObject.transform.parent.parent.parent.gameObject;
            GameObject             ballGameObject               = collision.gameObject;
            BallController         ballControlerScript          = BallUtils.FetchBallControllerScript(ballGameObject);
            PlayerStatus           currentPlayerStatus          = PlayerUtils.FetchPlayerStatusScript(player);
            GenericPlayerBehaviour genericPlayerBehaviourScript = PlayerUtils.FetchCorrespondingPlayerBehaviourScript(player, currentPlayerStatus);

            if (ballControlerScript.IsMoving && ballControlerScript.IsHit && !ballControlerScript.IsPitched)
            {
                if (PlayerUtils.HasPitcherPosition(player) && !ballControlerScript.IsTargetedByFielder && !ballControlerScript.IsInFoulState)
                {
                    ballControlerScript.IsTargetedByPitcher = true;
                    ((PitcherBehaviour)genericPlayerBehaviourScript).CalculatePitcherTriggerInterraction(ballGameObject, genericPlayerBehaviourScript, currentPlayerStatus);
                }


                if (PlayerUtils.HasFielderPosition(player) && !ballControlerScript.IsTargetedByFielder && !ballControlerScript.IsTargetedByPitcher && !ballControlerScript.IsInFoulState)
                {
                    GameObject   nearestFielder       = TeamUtils.GetNearestFielderFromGameObject(ballGameObject);
                    PlayerStatus nearestFielderStatus = PlayerUtils.FetchPlayerStatusScript(nearestFielder);

                    if (nearestFielderStatus.PlayerFieldPosition == currentPlayerStatus.PlayerFieldPosition)
                    {
                        ((FielderBehaviour)genericPlayerBehaviourScript).CalculateFielderTriggerInterraction(genericPlayerBehaviourScript);
                    }
                }
            }
        }
    }
    public async Task TeamInvite([Remainder] string mention)
    {
        Team team = TeamUtils.GetTeam(Context.User.Id);

        if (team == null)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Invitation", "Error", Language.Team_Error_No_Team, Context.User)); return;
        }
        if (TeamUtils.CheckIfInTeam(Context.Message.MentionedUsers.First().Id))
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Invitation", "Error", Language.Team_Error_Has_Team, Context.User)); return;
        }
        if (!TeamUtils.GetSettings(Context.Message.MentionedUsers.First().Id).InvitesEnabled)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Invitation", "Error", Language.Team_Invite_Disabled, Context.User)); return;
        }
        if (TeamUtils.pendingInvites.ContainsKey(Context.Message.MentionedUsers.First().Id))
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Invitation", "Error", Language.Team_Invite_Pending, Context.User)); return;
        }

        try
        {
            await Context.Message.MentionedUsers.First().SendMessageAsync("", false, Utilities.GetEmbedMessage("Team Invite", $"{Context.User.Username}'s Team", $"You have been invited to {Context.User.Username}'s Team. Reply with r!accept to join this team.", Context.User));
        }
        catch (HttpException)
        {
            await ReplyAsync($"<@!{Context.Message.MentionedUsers.First().Id}>", false, Utilities.GetEmbedMessage("Team Invite", $"{Context.User.Username}'s Team", $"You have been invited to {Context.User.Username}'s Team. Reply with r!accept to join this team.", Context.User));
        }

        TeamUtils.pendingInvites.Add(Context.Message.MentionedUsers.First().Id, team);
    }
Exemple #8
0
        private Mech CreatePathFinderMech()
        {
            GameInstance    game        = UnityGameInstance.BattleTechGame;
            CombatGameState combatState = game.Combat;
            string          spawnerId   = Guid.NewGuid().ToString();
            string          uniqueId    = $"{spawnerId}.9999999999";

            HeraldryDef heraldryDef = null;

            combatState.DataManager.Heraldries.TryGet(HeraldryDef.HeraldyrDef_SinglePlayerSkirmishPlayer1, out heraldryDef);

            MechDef mechDef = null;

            combatState.DataManager.MechDefs.TryGet("mechdef_spider_SDR-5V", out mechDef);

            PilotDef pilotDef = null;

            combatState.DataManager.PilotDefs.TryGet("pilot_default", out pilotDef);
            Mech mech = new Mech(mechDef, pilotDef, new TagSet(), uniqueId, combatState, spawnerId, heraldryDef);

            string teamId = TeamUtils.GetTeamGuid("NeutralToAll");
            Team   team   = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(teamId);

            AccessTools.Field(typeof(AbstractActor), "_team").SetValue(mech, team);
            AccessTools.Field(typeof(AbstractActor), "_teamId").SetValue(mech, teamId);

            return(mech);
        }
Exemple #9
0
        private Vehicle CreatePathFindingVehicle()
        {
            GameInstance    game        = UnityGameInstance.BattleTechGame;
            CombatGameState combatState = game.Combat;
            string          spawnerId   = Guid.NewGuid().ToString();
            string          uniqueId    = $"{spawnerId}.9999999998";

            HeraldryDef heraldryDef = null;

            combatState.DataManager.Heraldries.TryGet(HeraldryDef.HeraldyrDef_SinglePlayerSkirmishPlayer1, out heraldryDef);

            VehicleDef vehicleDef = null;

            combatState.DataManager.VehicleDefs.TryGet("vehicledef_DEMOLISHER", out vehicleDef);

            PilotDef pilotDef = null;

            combatState.DataManager.PilotDefs.TryGet("pilot_default", out pilotDef);
            Vehicle vehicle = new Vehicle(vehicleDef, pilotDef, new TagSet(), uniqueId, combatState, spawnerId, heraldryDef);

            string teamId = TeamUtils.GetTeamGuid("NeutralToAll");
            Team   team   = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(teamId);

            AccessTools.Field(typeof(AbstractActor), "_team").SetValue(vehicle, team);
            AccessTools.Field(typeof(AbstractActor), "_teamId").SetValue(vehicle, teamId);

            return(vehicle);
        }
Exemple #10
0
    public async Task TeamAlert([Remainder] string message)
    {
        Team team = TeamUtils.GetTeam(Context.User.Id);

        //If the user isn't in a team or isn't the team leader, display an error message
        if (team == null)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_No_Team, Context.User)); return;
        }
        if (team.TeamLeader != Context.User.Id)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_Not_Leader, Context.User)); return;
        }
        if (!team.Notifications)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_Notifications_Disabled, Context.User)); return;
        }

        foreach (ulong u in team.Members)
        {
            try
            {
                //If the user has notifications disabled, the message won't be sent
                if (TeamUtils.GetSettings(u).NotificationsEnabled)
                {
                    await Program._client.GetUser(u).SendMessageAsync($"<@!{u}>", false, Utilities.GetEmbedMessage("Team Notifications", "Team Alert", $"{message}", Context.User));
                }
            }
            catch (HttpException)
            {
            }
        }
    }
Exemple #11
0
        public bool usageReportItem(Player player, int counter, bool inMinors)
        {
            string bgColor = getBackgroundColor(player.Actual, player.TargetUsage, player.Replay, player.IsHitter);

            if (bgColor.Length == 0) //Skip line if player does not fall within boundry
            {
                return(false);
            }

            if (counter == 1)
            {
                this.emptyUsageRow();
            }

            lines.Add("<table style='margin-left:50px;' border=0 cellspacing=0 cellpadding=0 style='border-collapse:collapse;border:none'><tr>");

            addTableCell(counter, "#5B9BD5", "#F8CBAD", 30, false);
            addTableCell(player.Name, bgColor, "#000000", 100, false);
            addTableCell(TeamUtils.prettyTeamName(player.Team.Abrv), bgColor, "#000000", 60, false);
            addTableCell(player.IsHitter?"B":"P", bgColor, "#000000", 60);
            addTableCell(player.Actual, bgColor, "#000000", 75);
            addTableCell(player.Replay, bgColor, "#000000", 75);
            addTableCell(player.TargetUsage, bgColor, "#000000", 75);
            if (inMinors)
            {
                addTableCell(player.TargetUsage - player.Replay, bgColor, "#000000", 30);
            }
            else
            {
                addTableCell((player.TargetUsage - player.Replay) + " (M)", bgColor, "#000000", 30);
            }

            lines.Add("</tr></table>");
            return(true);
        }
Exemple #12
0
    public bool HandleHit(ETeam ballTeam)
    {
        if (ballTeam == TeamUtils.GetOppositeTeam(team))
        {
            if (GameManager.Instance.rules.hitsToDestroyTiles > 0)
            {
                hit++;
                if (hit >= GameManager.Instance.rules.hitsToDestroyTiles)
                {
                    if (GameManager.Instance.rules.scoreIfDestroyTile)
                    {
                        GameManager.Instance.IncrementScore(ballTeam);
                    }
                    DisableTile();
                }
                else
                {
                    renderer.material = hitMaterial;
                }
            }
            else if (GameManager.Instance.rules.scoreIfDestroyTile)
            {
                GameManager.Instance.IncrementScore(ballTeam);
            }

            return(true);
        }
        else //Ball hit tile of same team
        {
            return(false);
            //Start glow effect
        }
    }
Exemple #13
0
    public async Task SendRoll()
    {
        bool notifications;

        //Asks the user whether or not to enable notifications
        await ReplyAndDeleteAsync("", false, Utilities.GetEmbedMessage("Team Creation", "Notifications", Language.Team_Creation_Notifications, Context.User));

        var notifResponse = await NextMessageAsync();

        if (notifResponse.Content == "1")
        {
            notifications = true;
        }
        else if (notifResponse.Content == "2")
        {
            notifications = false;
        }
        else
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Creation", "Error", Language.Team_Creation_Error_Invalid, Context.User)); return;
        }

        //Creates the team role
        IRole teamRole = await Context.Guild.CreateRoleAsync($"{Context.User.Username}'s Team", null, null, false, null);

        if (!TeamUtils.CreateTeam(Context.User.Id, new ulong[] { }, teamRole, Context.Guild, notifications))
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Creation", "Unsuccessful", Language.Team_Error_Has_Team, Context.User)); await Context.Guild.GetRole(teamRole.Id).DeleteAsync(); return;
        }

        await(Context.User as IGuildUser).AddRoleAsync(teamRole);
        await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Creation", "Success", $"Team successfully created (<#{teamRole.Id}>). Invite people using r!teaminvite", Context.User));
    }
        public void process(IOutput output)
        {
            List <Player> players = teamComparisonReport.getPlayers();

            output.usageHeader(players.Count);
            int counter = 1;

            Team currentTeam = null;

            foreach (Player player in players)
            {
                if (currentTeam == null || !currentTeam.Equals(player.Team))
                {
                    counter = 1;
                }
                currentTeam = player.Team;
                int previousReplay = checkForPreviousStorageInfo(player);
                if (previousReplay > 0)
                {
                    player.PreviousReplay = previousReplay;
                }
                bool inMinors = teamPrimaryStatsReport.getTeamByAbbreviation(TeamUtils.prettyTeamNoDiceName(currentTeam.Abrv)).isPlayerInMinors(player);
                if (output.usageReportItem(player, counter, inMinors))
                {
                    Report.DATABASE.addPlayerUsage(player);
                    counter++;
                }
            }

            output.usageFooter();
        }
Exemple #15
0
    public async Task SendMembers()
    {
        Team team = TeamUtils.GetTeam(Context.User.Id);

        //If the user isn't in a team, display an error message
        if (team == null)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_No_Team, Context.User)); return;
        }

        StringBuilder sb = new StringBuilder();

        if (team.Members.Length == 0)
        {
            sb.Append("No members.");
        }
        else
        {
            foreach (ulong member in team.Members)
            {
                sb.Append($"{Program._client.GetUser(member).Username}\n");
            }
        }

        await ReplyAsync("", false, Utilities.GetEmbedMessage("Team List", $"{Program._client.GetUser(team.TeamLeader).Username}'s Team", $"{sb.ToString()}", Context.User));
    }
Exemple #16
0
    private void OnCollisionEnter(Collision collision)
    {
        if (isDestroying)
        {
            return;
        }

        GroundTile       tile   = collision.gameObject.GetComponent <GroundTile>();
        PlayerController player = collision.gameObject.GetComponent <PlayerController>();
        Ramp             ramp   = collision.gameObject.GetComponent <Ramp>();

        if (tile != null)
        {
            if (tile.HandleHit(teamAllegiance))
            {
                Disintegrate();
            }
        }
        else if (player != null && player.team == TeamUtils.GetOppositeTeam(teamAllegiance))
        {
            if (GameManager.Instance.rules.scoreIfHitPlayer)
            {
                GameManager.Instance.IncrementScore(teamAllegiance);
                Disintegrate();
            }
        }
        else if (ramp != null)
        {
            if (GameManager.Instance.rules.rampChangeAlliegance)
            {
                ChangeAllegiance(ramp.team);
            }
        }
    }
    private void SetUpNewBatter(GameManager gameManager)
    {
        GameObject newBatter = gameManager.AttackTeamBatterListClone.First();

        TeamUtils.AddPlayerTeamMember(PlayerFieldPositionEnum.BATTER, newBatter, TeamUtils.GetBaseballPlayerOwner(newBatter));
        newBatter.SetActive(true);
        gameManager.EquipBatToPlayer(newBatter);
    }
Exemple #18
0
    public void CatchBallAction(GameObject actionUser)
    {
        //CATCHER TURN
        GameObject       catcher                       = TeamUtils.GetPlayerTeamMember(PlayerFieldPositionEnum.CATCHER, TeamUtils.GetPlayerIdFromPlayerFieldPosition(PlayerFieldPositionEnum.CATCHER));
        PlayerStatus     catcherStatusScript           = PlayerUtils.FetchPlayerStatusScript(catcher);
        CatcherBehaviour genericCatcherBehaviourScript = ((CatcherBehaviour)PlayerUtils.FetchCorrespondingPlayerBehaviourScript(catcher, catcherStatusScript));

        genericCatcherBehaviourScript.CalculateCatcherColliderInterraction(PitcherGameObject, ballGameObject, ballControllerScript);
    }
Exemple #19
0
    public async Task LeaveCurrentTeam()
    {
        if (!TeamUtils.LeaveTeam(Context.User.Id))
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_No_Team, Context.User)); return;
        }

        await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Left Team", Language.Team_Leave, Context.User));
    }
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug($"[SetTeamByLanceSpawnerGuid] Setting Team '{Team}' with Spawner Guid '{LanceSpawnerGuid}'");
            LanceSpawnerGameLogic spawnerGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <LanceSpawnerGameLogic>(LanceSpawnerGuid);
            Lance lance = spawnerGameLogic.GetLance();
            List <AbstractActor> lanceUnits = spawnerGameLogic.GetLance().GetLanceUnits();

            Main.LogDebug($"[SetTeamByLanceSpawnerGuid] Found '{lanceUnits.Count}' lance units");
            Team oldTeam = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(spawnerGameLogic.teamDefinitionGuid);
            Team newTeam = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <Team>(TeamUtils.GetTeamGuid(Team));

            spawnerGameLogic.teamDefinitionGuid = TeamUtils.GetTeamGuid(Team);
            spawnerGameLogic.encounterTags.Remove(oldTeam.Name);
            spawnerGameLogic.encounterTags.Add(newTeam.Name);

            oldTeam.lances.Remove(lance);
            newTeam.lances.Add(lance);

            foreach (AbstractActor actor in lanceUnits)
            {
                oldTeam.RemoveUnit(actor);
                actor.AddToTeam(newTeam);
                newTeam.AddUnit(actor);

                actor.EncounterTags.Remove(oldTeam.Name);
                actor.EncounterTags.Add(newTeam.Name);

                if (ApplyTags != null)
                {
                    actor.EncounterTags.AddRange(ApplyTags);
                }

                CombatHUDInWorldElementMgr inworldElementManager = GameObject.Find("uixPrfPanl_HUD(Clone)").GetComponent <CombatHUDInWorldElementMgr>();
                if (oldTeam.GUID == TeamUtils.NEUTRAL_TO_ALL_TEAM_ID)
                {
                    AccessTools.Method(typeof(CombatHUDInWorldElementMgr), "AddInWorldActorElements").Invoke(inworldElementManager, new object[] { actor });
                }
                else if (newTeam.GUID == TeamUtils.NEUTRAL_TO_ALL_TEAM_ID)
                {
                    AccessTools.Method(typeof(CombatHUDInWorldElementMgr), "RemoveInWorldUI").Invoke(inworldElementManager, new object[] { actor.GUID });
                }

                CombatantSwitchedTeams message = new CombatantSwitchedTeams(actor.GUID, newTeam.GUID);
                this.combat.MessageCenter.PublishMessage(message);

                LazySingletonBehavior <FogOfWarView> .Instance.FowSystem.Rebuild();
            }

            if (this.AlertLance)
            {
                lance.BroadcastAlert();
            }
        }
    public async Task Accept()
    {
        if (TeamUtils.pendingInvites.ContainsKey(Context.User.Id))
        {
            TeamUtils.AddToTeam(TeamUtils.pendingInvites[Context.User.Id], Context.User.Id);
            await ReplyAsync($"<@!{Context.Message.MentionedUsers.First().Id}>", false, Utilities.GetEmbedMessage("Team Invite", $"{Context.User.Username}'s Team", Language.Team_Join, Context.User));

            TeamUtils.pendingInvites.Remove(Context.User.Id);
        }
        else
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Invite", $"{Context.User.Username}'s Team", Language.Team_Invite_None, Context.User));
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (CommandMenuManager.isMenuDisplayEnabled && !TargetSelectionManager.IsActivated)
        {
            PlayerAbilities playerAbilitiesScript = null;

            switch (this.TurnState)
            {
            case TurnStateEnum.STANDBY:
                break;

            case TurnStateEnum.PITCHER_TURN:
                GameObject pitcher = TeamUtils.GetPlayerTeamMember(PlayerFieldPositionEnum.PITCHER, TeamUtils.GetPlayerIdFromPlayerFieldPosition(PlayerFieldPositionEnum.PITCHER));
                playerAbilitiesScript = PlayerUtils.FetchPlayerAbilitiesScript(pitcher);
                break;

            case TurnStateEnum.BATTER_TURN:
                GameObject batter = TeamUtils.GetPlayerTeamMember(PlayerFieldPositionEnum.BATTER, TeamUtils.GetPlayerIdFromPlayerFieldPosition(PlayerFieldPositionEnum.BATTER));
                playerAbilitiesScript = PlayerUtils.FetchPlayerAbilitiesScript(batter);
                break;

            case TurnStateEnum.RUNNER_TURN:
                GameObject runner = this.GetNextRunner();
                if (runner != null)
                {
                    playerAbilitiesScript = PlayerUtils.FetchPlayerAbilitiesScript(runner);
                }
                break;

            case TurnStateEnum.CATCHER_TURN:
                GameObject catcher = TeamUtils.GetPlayerTeamMember(PlayerFieldPositionEnum.CATCHER, TeamUtils.GetPlayerIdFromPlayerFieldPosition(PlayerFieldPositionEnum.CATCHER));
                playerAbilitiesScript = PlayerUtils.FetchPlayerAbilitiesScript(catcher);
                break;

            case TurnStateEnum.FIELDER_TURN:
                GameObject fielder = TeamUtils.GetPlayerTeamMember(CurrentFielderTypeTurn, TeamUtils.GetPlayerIdFromPlayerFieldPosition(CurrentFielderTypeTurn));
                playerAbilitiesScript = PlayerUtils.FetchPlayerAbilitiesScript(fielder);
                break;

            default:
                break;
            }

            if (playerAbilitiesScript != null)
            {
                CameraController.FocusOnPlayer(playerAbilitiesScript.gameObject.transform);
                CommandMenuManager.GenerateCommandMenu(playerAbilitiesScript);
            }
        }
    }
    public async Task ToggleNotifications()
    {
        bool status;

        if (TeamUtils.userSettings.FirstOrDefault(x => x.DiscordID == Context.User.Id) != null && TeamUtils.userSettings.FirstOrDefault(x => x.DiscordID == Context.User.Id).NotificationsEnabled)
        {
            TeamUtils.UpdateSettings(Context.User.Id, false); status = false;
        }
        else
        {
            TeamUtils.UpdateSettings(Context.User.Id, true); status = true;
        }

        await ReplyAsync("", false, Utilities.GetEmbedMessage("Notifications", "Updated", $" Notifications Enabled: {status.ToString()}", Context.User)); return;
    }
Exemple #24
0
    public void HitBallAction(GameObject actionUser)
    {
        //BATTER TURN
        GameObject      batter = TeamUtils.GetPlayerTeamMember(PlayerFieldPositionEnum.BATTER, TeamUtils.GetPlayerIdFromPlayerFieldPosition(PlayerFieldPositionEnum.BATTER));
        BatterBehaviour batterBehaviourScript = PlayerUtils.FetchBatterBehaviourScript(batter);

        batterBehaviourScript.IsReadyToSwing     = true;
        batterBehaviourScript.IsSwingHasFinished = false;

        if (PlayerUtils.HasBatterPosition(batter))
        {
            PlayerStatus playerStatusScript = PlayerUtils.FetchPlayerStatusScript(batter);
            batterBehaviourScript.CalculateBatterColliderInterraction(PitcherGameObject, BallControllerScript, playerStatusScript);
        }
    }
Exemple #25
0
    public async Task SendRoll([Remainder] string search)
    {
        Team team = TeamUtils.GetTeam(Context.User.Id);

        //Checks whether the player is in a team, and whether or not they own it
        if (team == null)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_No_Team, Context.User)); return;
        }
        if (team.TeamLeader != Context.User.Id)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Notifications", "Error", Language.Team_Error_Not_Leader, Context.User)); return;
        }

        //Grabs the server
        ServerInfo s = await Utilities.GetServer(search);

        bool correct;

        //Asks whether or not the server is correct
        await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Server", $"Add **{s.ServerName}** as this team's server?", "1. Yes\n2. No\n\n**Please type the number of your answer.**", Context.User));

        var response = await NextMessageAsync();

        if (response.Content == "1")
        {
            correct = true;
        }
        else if (response.Content == "2")
        {
            correct = false;
        }
        else
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Server", "Error", Language.Team_Creation_Error_Invalid, Context.User)); return;
        }

        //If correct, add team and display success message, else display unsuccessful message
        if (correct)
        {
            TeamUtils.SetServer(team, s); await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Server", "Success", $"Successfully added **{s.ServerName}** as this team's server.", Context.User));
        }
        else
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Team Server", "Unsuccessful", Language.Team_Server_Error_Broad, Context.User));
        }
    }
        private void OnDrawGizmos()
        {
            Gizmos.color = TeamUtils.GetTeamColor(settings.teamId);

            if (settings.capturePoint != null)
            {
                foreach (var a in settings.nextPoints)
                {
                    if (a != null)
                    {
                        RuleMakerUtils.DrawArrow(settings.capturePoint.transform.position, a.transform.position, 3);
                    }
                }
            }

            Gizmos.color = Color.white;
        }
        private void Window_Initialized(object sender, EventArgs e)
        {
            TeamUtils.registerTeamAbvMapping(new Config().getTeamAbrvMapping());

            dp    = DependencyProperty.Register("LineupInfo", typeof(object), typeof(LineupDataObj), new UIPropertyMetadata());
            dpPos = DependencyProperty.Register("Positions", typeof(object), typeof(PositionObj), new UIPropertyMetadata());

            engine.initialize(Config.getConfigurationFilePath("rosterReport.PRT"));

            CB_LIST_OF_TEAMS.Items.Add("SELECT ONE");
            foreach (Team team in engine.CompleteListOfTeams)
            {
                CB_LIST_OF_TEAMS.Items.Add(team);
            }
            CB_LIST_OF_TEAMS.SelectedIndex = 0;


            if (engine.TeamLineupData.hasEmptyData())
            {
                MessageBox.Show("It appears this is the first time you have run the program. Team division assignments are required in order to estimate the number of games played vs each team.  On the next screen please assign each team a division.",
                                "Team division assignments are required", MessageBoxButton.OK, MessageBoxImage.Information);
                OpponentsDlg dlg = new OpponentsDlg(engine.TeamLineupData, engine.CompleteListOfTeams);
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    this.Close();
                }
                engine.saveDatabase();
            }

            applyDivisionToTeams();

            GRID.Background    = new SolidColorBrush(Colors.LightSteelBlue);
            GRID.ShowGridLines = true;

            dialogInitialized = true;

            batterInfo   = new TeamBatterInfo(GRID_INFO, GRID);
            balanceUsage = new BalanceUsageStats(GRID_USAGE_STATS);
        }
    public RunnerBehaviour ConvertBatterToRunner(PlayerStatus batterStatusScript)
    {
        PlayersTurnManager playersTurnManager = GameUtils.FetchPlayersTurnManager();
        GameObject         currentBatter      = batterStatusScript.gameObject;
        GameObject         bat             = PlayerUtils.GetPlayerBatGameObject(currentBatter);
        GameManager        gameManager     = GameUtils.FetchGameManager();
        RunnerBehaviour    runnerBehaviour = currentBatter.AddComponent <RunnerBehaviour>();

        gameManager.AttackTeamRunnerList.Add(runnerBehaviour.gameObject);
        gameManager.AttackTeamRunnerListClone.Add(runnerBehaviour.gameObject);
        gameManager.AttackTeamBatterListClone.Remove(currentBatter);
        playersTurnManager.CurrentRunner = runnerBehaviour.gameObject;
        runnerBehaviour.EquipedBat       = bat;
        bat.SetActive(false);
        Destroy(currentBatter.GetComponent <BatterBehaviour>());

        batterStatusScript.PlayerFieldPosition = PlayerFieldPositionEnum.RUNNER;
        TeamUtils.AddPlayerTeamMember(PlayerFieldPositionEnum.RUNNER, currentBatter, TeamUtils.GetBaseballPlayerOwner(currentBatter));

        int batterCount = gameManager.AttackTeamBatterListClone.Count;

        if (batterCount > 0)
        {
            GameObject nextBatter = gameManager.AttackTeamBatterListClone.First();
            gameManager.EquipBatToPlayer(nextBatter);
            TeamUtils.AddPlayerTeamMember(PlayerFieldPositionEnum.BATTER, nextBatter, TeamUtils.GetBaseballPlayerOwner(nextBatter));
        }

        string runnerNumber  = runnerBehaviour.gameObject.name.Split('_').Last();
        string newRunnerName = NameConstants.RUNNER_NAME + "_" + runnerNumber;

        runnerBehaviour.gameObject.name = newRunnerName;


        playersTurnManager.TurnState = TurnStateEnum.STANDBY;

        return(runnerBehaviour);
    }
Exemple #29
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (ColliderUtils.HasBallCollided(collision) && !GameData.isPaused)
        {
            GameObject     ball = collision.gameObject;
            BallController ballControllerScript = BallUtils.FetchBallControllerScript(ball);

            if (ballControllerScript.IsHit)
            {
                timeElapsed += Time.deltaTime;

                if (timeElapsed >= TIME_TO_WAIT_IN_FOUL_ZONE)
                {
                    Debug.Log("the ball is foul");
                    timeElapsed = 0;

                    DialogBoxManager dialogBoxManagerScript = GameUtils.FetchDialogBoxManager();
                    dialogBoxManagerScript.DisplayDialogAndTextForGivenAmountOfTime(1f, false, "FOUL!!");
                    PlayersTurnManager playersTurnManager     = GameUtils.FetchPlayersTurnManager();
                    GameObject         pitcher                = TeamUtils.GetPlayerTeamMember(PlayerFieldPositionEnum.PITCHER, TeamUtils.GetPlayerIdFromPlayerFieldPosition(PlayerFieldPositionEnum.PITCHER));
                    GameManager        gameManager            = GameUtils.FetchGameManager();
                    GameObject         currentBatter          = gameManager.AttackTeamBatterListClone.First();
                    BatterBehaviour    currentBatterBehaviour = PlayerUtils.FetchBatterBehaviourScript(currentBatter);
                    GameObject         bat = currentBatterBehaviour.EquipedBat;
                    currentBatterBehaviour.FoulOutcomeCount += 1;
                    currentBatter.transform.rotation         = Quaternion.identity;
                    bat.transform.position = FieldUtils.GetBatCorrectPosition(currentBatter.transform.position);
                    bat.transform.rotation = Quaternion.Euler(0f, 0f, -70f);
                    gameManager.ReinitPitcher(pitcher);
                    gameManager.ReturnBallToPitcher(ballControllerScript.gameObject);
                    gameManager.ReinitRunners(gameManager.AttackTeamRunnerList);
                    ballControllerScript.IsInFoulState = false;
                    playersTurnManager.TurnState       = TurnStateEnum.PITCHER_TURN;
                    PlayersTurnManager.IsCommandPhase  = true;
                }
            }
        }
    }
    public void CalculatePitcherColliderInterraction(GameObject ballGameObject, BallController ballControllerScript, GenericPlayerBehaviour genericPlayerBehaviourScript)
    {
        int runnersOnFieldCount   = -1;
        List <GameObject> runners = PlayerUtils.GetRunnersOnField();

        runnersOnFieldCount = runners.Count;

        if (runnersOnFieldCount < 1)
        {
            return;
        }

        //Choose the runner who just hit the ball
        GameObject runnerToGetOut = runners.Last();

        bool hasIntercepted = false;
        PlayersTurnManager playersTurnManager = GameUtils.FetchPlayersTurnManager();

        if (ballControllerScript.BallHeight == BallHeightEnum.HIGH || ballControllerScript.BallHeight == BallHeightEnum.LOW)
        {
            GameManager      gameManager            = GameUtils.FetchGameManager();
            DialogBoxManager dialogBoxManagerScript = GameUtils.FetchDialogBoxManager();
            dialogBoxManagerScript.DisplayDialogAndTextForGivenAmountOfTime(1f, false, "TAG OUT !!!!!!!");

            ballControllerScript.Target = null;


            PlayerActionsManager.InterceptBall(ballGameObject, ballControllerScript, genericPlayerBehaviourScript);
            hasIntercepted = true;

            gameManager.AttackTeamRunnerList.Remove(runnerToGetOut);
            runnerToGetOut.SetActive(false);
            playersTurnManager.UpdatePlayerTurnQueue(runnerToGetOut);
            gameManager.AttackTeamBatterListClone.First().SetActive(true);
            RunnerBehaviour runnerBehaviourScript = PlayerUtils.FetchRunnerBehaviourScript(runnerToGetOut);
            BatterBehaviour batterBehaviourScript = PlayerUtils.FetchBatterBehaviourScript(gameManager.AttackTeamBatterListClone.First());
            batterBehaviourScript.EquipedBat = runnerBehaviourScript.EquipedBat;
            runnerBehaviourScript.EquipedBat = null;

            if (runnersOnFieldCount == 1)
            {
                GameData.isPaused = true;
                StartCoroutine(gameManager.WaitAndReinit(dialogBoxManagerScript, PlayerUtils.FetchPlayerStatusScript(gameManager.AttackTeamBatterListClone.First()), FieldBall));
                return;
            }
            else
            {
                GameObject bat = batterBehaviourScript.EquipedBat;
                bat.transform.SetParent(null);
                bat.transform.position = FieldUtils.GetBatCorrectPosition(batterBehaviourScript.transform.position);
                bat.transform.rotation = Quaternion.Euler(0f, 0f, -70f);
                bat.transform.SetParent(gameManager.AttackTeamBatterListClone.First().transform);
                batterBehaviourScript.EquipedBat.SetActive(true);
                TeamUtils.AddPlayerTeamMember(PlayerFieldPositionEnum.BATTER, batterBehaviourScript.gameObject, TeamUtils.GetBaseballPlayerOwner(batterBehaviourScript.gameObject));
            }
        }

        if (runnersOnFieldCount >= 1)
        {
            if (!hasIntercepted)
            {
                PlayerActionsManager.InterceptBall(ballGameObject, ballControllerScript, genericPlayerBehaviourScript);
            }

            PlayerActionsManager playerActionsManager = GameUtils.FetchPlayerActionsManager();
            PlayerAbilities      playerAbilities      = PlayerUtils.FetchPlayerAbilitiesScript(this.gameObject);
            playerAbilities.ReinitAbilities();
            PlayerAbility passPlayerAbility = new PlayerAbility("Pass to fielder", AbilityTypeEnum.BASIC, AbilityCategoryEnum.NORMAL, playerActionsManager.GenericPassAction, this.gameObject, true);
            playerAbilities.AddAbility(passPlayerAbility);
            playersTurnManager.TurnState      = TurnStateEnum.PITCHER_TURN;
            PlayersTurnManager.IsCommandPhase = true;
        }
    }