Exemple #1
0
        public void AirAreaLeave(TriggerArgs args)
        {
            IPlayer pl = (IPlayer)args.Sender;

            for (int i = 0; i < AirPlayerList.Count; i++)
            {
                if (AirPlayerList[i].Player == pl)
                {
                    AirPlayerList.RemoveAt(i);
                    return;
                }
            }
        }
Exemple #2
0
        public void AirAreaEnter(TriggerArgs args)
        {
            string  data   = ((IObject)args.Caller).CustomId;
            IPlayer pl     = (IPlayer)args.Sender;
            TPlayer player = GetPlayer(pl);

            if (player == null)
            {
                return;
            }
            string[]          typeList = data.Split(';');
            TPlayerStrikeInfo plInfo   = new TPlayerStrikeInfo
            {
                Player = pl
            };

            for (int i = 0; i < typeList.Length; i++)
            {
                string[] strikeInfo = typeList[i].Split(':');
                int      id         = StrikeNameToInt(strikeInfo[0]);
                if (CanStrikeJamming(id) && player.Armor.Jammer)
                {
                    continue;
                }
                int angle = 0;
                if (strikeInfo.Length > 1)
                {
                    angle = Convert.ToInt32(strikeInfo[1]);
                }
                TStrikeInfo info = new TStrikeInfo
                {
                    Id    = id,
                    Angle = angle
                };
                plInfo.StrikeList.Add(info);
            }
            if (plInfo.StrikeList.Count > 0)
            {
                AirPlayerList.Add(plInfo);
            }
        }
Exemple #3
0
        /// <summary>
        /// Update loop (must be enabled in the OnStartup() function or AfterStartup() function).
        /// </summary>
        /// <param name="elapsed">Time elapsed</param>
        public void OnUpdate(float elapsed)
        {
            try
            {
                if (GameState == 0)
                {
                    try
                    {
                        RefreshPlayerMenus();
                    }
                    catch (Exception e)
                    {
                        DebugLogger.DebugOnlyDialogLog("CAUSED BY REFRESHPLAYERMENUS" + e.StackTrace, CameraPosition);
                        DebugLogger.DebugOnlyDialogLog(e.Message, CameraPosition);
                        var st    = new System.Diagnostics.StackTrace(e, true);
                        var frame = st.GetFrame(0);
                        var line  = frame.GetFileLineNumber();
                        DebugLogger.DebugOnlyDialogLog("METHOD: " + e.TargetSite.Name + " LINE: " + line, CameraPosition);
                    }

                    foreach (var p in PlayerList)
                    {
                        if (p == null)
                        {
                            continue;
                        }
                        if (p.User == null)
                        {
                            continue;
                        }
                        var player = p.User.GetPlayer();
                        if (player == null)
                        {
                            continue;
                        }
                        PlayerModifiers mods = player.GetModifiers();
                        mods.MaxEnergy              = 0;
                        mods.MeleeStunImmunity      = 1;
                        mods.EnergyRechargeModifier = 0;
                        player.SetModifiers(mods);
                    }

                    for (int i = 0; i < PlayerMenuList.Count; i++)
                    {
                        PlayerMenuList[i].Update();
                    }
                }
                else if (GameState == 1)
                {
                    if (TimeToStart > 0)
                    {
                        return;
                    }
                    GlobalGame.SetCurrentCameraMode(CameraMode.Static);
                    GameState = 2;
                    AirPlayerList.Clear();
                    ThrownTrackingList.Clear();
                    PreWeaponTrackingUpdate();
                    PostWeaponTrackingUpdate();
                    RemoveObjects();
                    RemoveTurrets();
                    RemoveShieldGenerators();
                    ResetElectronicWarfare();
                    RespawnUnknownObjects();
                    ResetEffects();
                    RemoveWeapons();
                    MapPartList[CurrentMapPartIndex].Start();
                    TimeToStart = AreaTime;
                    if (!IsDebug && PlayerList.Count < 2)
                    {
                        Game.SetGameOver("NOT ENOUGH PLAYERS");
                        GameState = 100;
                        return;
                    }
                }
                else if (GameState == 2)
                {
                    if (Game.GetCameraArea().Left == CameraPosition.X && Game.GetCameraArea().Top == CameraPosition.Y)
                    {
                        if (IsFirstMatch)
                        {
                            TeamBalance();
                        }
                        Game.RunCommand("MSG BATTLE BEGINS");
                        GameState = 3;
                    }
                }
                else if (GameState == 3)
                {
                    int areaStatus = MapPartList[CurrentMapPartIndex].Update();
                    int capturedBy = MapPartList[CurrentMapPartIndex].CapturedBy;
                    UpdateEffects();
                    ThrownWeaponUpdate();
                    PreWeaponTrackingUpdate();
                    for (int i = 0; i < PlayerList.Count; i++)
                    {
                        PlayerList[i].Update();
                    }
                    PostWeaponTrackingUpdate();
                    UpdateTurrets();
                    UpdateShieldGenerators();
                    ThrowingUpdate();
                    if (IsAllPlayerDead())
                    {
                        GameState   = 6;
                        TimeToStart = 5;
                    }
                    else if (TimeToStart <= 0)
                    {
                        if (capturedBy == 0)
                        {
                            SpawnDrone(4, PlayerTeam.Team3);
                        }
                        else if (capturedBy == 1)
                        {
                            SpawnDrone(5, PlayerTeam.Team1);
                        }
                        else if (capturedBy == 2)
                        {
                            SpawnDrone(5, PlayerTeam.Team2);
                        }
                        TimeToStart = 30;
                    }
                    int teamStatus = IsOneTeamDead();
                    if (teamStatus != 0 || GameState == 6)
                    {
                        for (int i = 0; i < PlayerList.Count; i++)
                        {
                            PlayerList[i].Stop();
                        }
                        for (int i = 0; i < TurretList.Count; i++)
                        {
                            TurretList[i].StopMovement();
                        }
                    }
                    if (areaStatus == 1)
                    {
                        Game.RunCommand("MSG BLUE TEAM CAPTURED ALL POINTS");
                        SpawnDrone(4, PlayerTeam.Team1);
                        TimeToStart = 30;
                    }
                    else if (areaStatus == 2)
                    {
                        Game.RunCommand("MSG RED TEAM CAPTURED ALL POINTS");
                        SpawnDrone(4, PlayerTeam.Team2);
                        TimeToStart = 30;
                    }
                    if (teamStatus == 1)
                    {
                        TimeToStart = 5;
                        GameState   = 7;
                    }
                    else if (teamStatus == 2)
                    {
                        TimeToStart = 5;
                        GameState   = 8;
                    }
                }
                else if (GameState == 4)
                {
                    var mapPart = MapPartList[CurrentMapPartIndex];
                    mapPart.BlueRoundsWon++;
                    MapPartList[CurrentMapPartIndex].Restart();
                    AddTeamExp(10, 3, PlayerTeam.Team1, false);

                    if (mapPart.CurrentRound < RoundsPerMapPart && mapPart.BlueRoundsWon != RoundsPerMapPart - 1)
                    {
                        // won this round, but not enough to advance
                        RemoveWeapons();
                        GameState   = 1;
                        TimeToStart = 5;
                        AddTeamExp(10, 4, PlayerTeam.Team1, false);
                        IsFirstMatch = false;
                        Game.RunCommand("MSG BLUE WON THIS ROUND!");
                        Game.RunCommand("MSG RED: " + mapPart.RedRoundsWon + " - BLUE: " + mapPart.BlueRoundsWon);
                        mapPart.CurrentRound++;
                        Game.RunCommand("MSG STARTING NEXT ROUND (" + MapPartList[CurrentMapPartIndex].CurrentRound + "/" + RoundsPerMapPart + ")");
                    }
                    else
                    {
                        // won this round, and it's enough to advance
                        if (RoundsPerMapPart > 1)
                        {
                            // more than one win was needed to advance
                            Game.RunCommand("MSG BLUE WAS THE BEST OF " + RoundsPerMapPart + "!");
                            mapPart.RedRoundsWon  = 0;
                            mapPart.BlueRoundsWon = 0;
                            TimeToStart           = 5;
                        }

                        if (CurrentMapPartIndex > 0)
                        {
                            CurrentMapPartIndex--;
                            IsFirstMatch = false;
                            GameState    = 1;
                        }
                        else
                        {
                            AddTeamExp(30 + RoundsPerMapPart, 4, PlayerTeam.Team1, false);
                            GameState = -1;
                        }
                    }
                }
                else if (GameState == 5)
                {
                    var mapPart = MapPartList[CurrentMapPartIndex];
                    mapPart.RedRoundsWon++;
                    mapPart.Restart();
                    AddTeamExp(10, 3, PlayerTeam.Team2, false);

                    if (mapPart.CurrentRound < RoundsPerMapPart && mapPart.RedRoundsWon != RoundsPerMapPart - 1)
                    {
                        RemoveWeapons();
                        GameState    = 1;
                        TimeToStart  = 5;
                        IsFirstMatch = false;
                        AddTeamExp(10, 4, PlayerTeam.Team2, false);
                        Game.RunCommand("MSG RED TEAM WON THIS ROUND!");
                        Game.RunCommand("MSG RED: " + mapPart.RedRoundsWon + " - BLUE: " + mapPart.BlueRoundsWon);
                        mapPart.CurrentRound++;
                        Game.RunCommand("MSG STARTING NEXT ROUND (" + MapPartList[CurrentMapPartIndex].CurrentRound + "/" + RoundsPerMapPart + ")");
                    }
                    else
                    {
                        //  won this round, and it's enough to advance

                        if (RoundsPerMapPart > 1)
                        {
                            // more than one win was needed to advance
                            Game.RunCommand("MSG RED TEAM WAS THE BEST OF " + RoundsPerMapPart + "!");
                            mapPart.RedRoundsWon  = 0;
                            mapPart.BlueRoundsWon = 0;
                            TimeToStart           = 5;
                        }

                        if (CurrentMapPartIndex < MapPartList.Count - 1)
                        {
                            CurrentMapPartIndex++;
                            IsFirstMatch = false;
                            GameState    = 1;
                        }
                        else
                        {
                            AddTeamExp(30 + RoundsPerMapPart, 4, PlayerTeam.Team2, false);
                            GameState = -2;
                        }
                    }
                }
                else if (GameState == 6)
                {
                    if (TimeToStart <= 0)
                    {
                        var mapPart = MapPartList[CurrentMapPartIndex];
                        mapPart.Restart();
                        TimeToStart = 5;
                        Game.RunCommand("MSG NOBODY CAPTURED THE AREA!");
                        GameState = 1;
                    }
                }
                else if (GameState == 7)
                {
                    if (TimeToStart <= 0)
                    {
                        GameState = 4;
                    }
                }
                else if (GameState == 8)
                {
                    if (TimeToStart <= 0)
                    {
                        GameState = 5;
                    }
                }
                else if (GameState == -1 || GameState == -2)
                {
                    var menuCameraPosition = GlobalGame.GetSingleObjectByCustomId("MenuCameraPosition").GetWorldPosition();
                    CameraPosition.X = menuCameraPosition.X;
                    CameraPosition.Y = menuCameraPosition.Y;
                    for (int i = 0; i < PlayerMenuList.Count; i++)
                    {
                        PlayerMenuList[i].ShowExp();
                    }
                    GlobalGame.SetWeatherType(WeatherType.None);
                    GameState -= 2;
                }
                else if (GameState == -3)
                {
                    if (!IsDataSaved)
                    {
                        SaveData();
                    }

                    if (TimeToStart <= 0)
                    {
                        Game.SetGameOver("BLUE TEAM WINS!");
                    }
                }
                else if (GameState == -4)
                {
                    if (!IsDataSaved)
                    {
                        SaveData();
                    }

                    if (TimeToStart <= 0)
                    {
                        Game.SetGameOver("RED TEAM WINS!");
                    }
                }
                UpdateCamera();
            }
            catch (Exception e)
            {
                DebugLogger.DebugOnlyDialogLog(e.StackTrace, CameraPosition);
                DebugLogger.DebugOnlyDialogLog(e.Message, CameraPosition);
                var st    = new System.Diagnostics.StackTrace(e, true);
                var frame = st.GetFrame(0);
                var line  = frame.GetFileLineNumber();
                DebugLogger.DebugOnlyDialogLog("METHOD: " + e.TargetSite.Name + " LINE: " + line, CameraPosition);
            }
        }