Beispiel #1
0
 public static void ExitGame()
 {
     /* Done: quit game and restart another
      * - Don't stop "forever"
      * - Allow bools to restart
      *
      */
     ZombiomeManager.Stop(-1, false);
     IsInit = false;
 }
Beispiel #2
0
 public static void Start(int entityId)
 {
     /// Not sufficient, 2 instances are running, let's try a buff
     Debug.Log("ZombiomeManager started: " + started.ToString());
     if (started)
     {
         return;
     }
     Instance = new ZombiomeManager();
     Instance.Run();    // TODO ref bool only once ?
 }
Beispiel #3
0
    public static IEnumerator _Reset(int pid, string sel = "")
    {
        ZombiomeManager.Stop(pid, false);
        yield return(new WaitForSeconds(1f));

        ZBActivity.ZombiomeActivitySelector.SelectDebug(sel);
        Zone.ClearCache();
        yield return(new WaitForSeconds(0.2f));

        ZombiomeManager.Start(pid);
    }
Beispiel #4
0
    public static void OnDisconnect()
    {
        /* Done: quit game and restart another
         * - Don't stop "forever"
         * - Allow bools to restart
         *
         */
        EntityPlayerLocal player = GameManager.Instance.World.GetLocalPlayers()[0];

        ZombiomeManager.Stop(player.entityId, true);
        IsInit = false;
    }
Beispiel #5
0
    private static bool IsInit = false; // prevent on 2nd game ?
    public static void Init(int playerId)
    {
        /*
         * Should be safe to do multiple calls ...
         * - Depends on Map so need re apply on game change
         * - Should only be called once per game (mostly because of thread start)
         *
         * - Check: multiplayer local
         *  - Called twice with 2 local players -> if below
         *  - Each player triggers on connect ?
         */

        /* I should put this all in the buff ?? Anythin here may be duplicate */
        if (IsInit)
        {
            Printer.Write("Zombiome is already init !", playerId);
            // if (AutoStart) {
            //     ZombiomeManager.Reset(playerId, "");
            // }
            return;
        }

        Printer.Write("Zombiome.Init():", playerId);

        CSutils.Routines.Sanitizer.Fixer = () => ZombiomeManager._Reset(-1);
        CSutils.Catcher.SwallowErrors    = SwallowError;

        rand      = GameRandomManager.Instance.CreateGameRandom();
        worldSeed = GamePrefs.GetString(EnumGamePrefs.WorldGenSeed);
        worldSize = GamePrefs.GetInt(EnumGamePrefs.WorldGenSize);

        ZBiomeInfo.Define();

        if (nz4)
        {
            Zone.Get = Zone.GetFour;
        }
        else
        {
            Zone.Get = position => new Zone[] { Zone.GetSingle(position) }
        };
        ZBActivity.ZombiomeActivitySelector.Initialize();

        if (AutoStart)
        {
            ZombiomeManager.Reset(playerId, "");
        }
        IsInit = true; // bugs on restart new game coz no one set to none - use World hash ?

        Printer.Write("Zombiome..Init: Done");
        // ZombiomeManager.Start(playerId); // manually until release
    }
Beispiel #6
0
 public static void Stop(int entityId, bool forever)
 {
     Printer.Print("ZombiomeManager Stopping", entityId, Instance);
     if (Instance == null)
     {
         Printer.Print("ZombiomeManager Stop, but Instance is null");
     }
     else
     {
         ZombiomeManager prev = Instance;
         prev.Stop(forever);
     }
     Instance = null;
 }
Beispiel #7
0
    public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
    {
        // Debug.Log("ConsoleCmdZombiome");
        // foreach (string p in _params) Debug.Log(p);
        // GameManager.Instance.World.aiDirector.GetComponent<AIDirectorWanderingHordeComponent>().SpawnWanderingHorde(false);

        // PersistentPlayerData x =_world.GetGameManager().GetPersistentLocalPlayer()
        List <EntityPlayerLocal> players = GameManager.Instance.World.GetLocalPlayers(); // multiple on console only?
        EntityPlayerLocal        player  = players[0];
        Vector3 pos = player.GetPosition();

        if (_params[0] == "select" || _params[0] == "sel")
        {
            ZBActivity.ZombiomeActivitySelector.SelectDebug(_params[1]);
            Zone.ClearCache();
            return;
        }

        if (_params[0] == "log")  // Set log level
        {
            Printer.level = int.Parse(_params[1]);
            return;
        }
        if (_params[0] == "f")   // Debug: force activity
        {
            Zombiome.IgnoreScale = (_params.Count >= 2) ? bool.Parse(_params[1]) : !Zombiome.IgnoreScale;
            return;
        }

        if (_params[0] == "g")   // Debug: select a ghost
        {
            ZBActivity.Entities.Ghost.ghost_type = (_params.Count >= 2) ? _params[1] : "";
            return;
        }

        if (_params[0] == "w")   // Debug: select a water block
        {
            ZBiomeInfo.force_water_block = (_params.Count >= 2) ? _params[1] : "";
            return;
        }

        if (_params[0] == "nz")   // Debug: restrict one zone
        {
            int nz = int.Parse(_params[1]);
            if (nz == 1)
            {
                Zone.Get = position => new Zone[] { Zone.GetSingle(position) }
            }
            ;
            if (nz == 4)
            {
                Zone.Get = Zone.GetFour;
            }
            return;
        }


        if (_params[0] == "start")
        {
            string res = (_params.Count > 1) ? _params[1] : "";
            ZombiomeManager.Reset(player.entityId, res);
        }
        else if (_params[0] == "stop")
        {
            ZombiomeManager.Stop(player.entityId, true);                            // do not use this, it is definitive !
        }
        else if (_params[0] == "pause")
        {
            ZombiomeManager.Stop(player.entityId, false);
        }
    }
}