Inheritance: MonoBehaviour
Exemple #1
0
 public void ServerRespawnPlayer()
 {
     PlayerSpawn.ServerRespawnPlayer(playerScript.mind);
 }
Exemple #2
0
        public static GameObject Instantiate(ENTITY e)
        {
            GameObject entityObject;

            switch (e.Classname)
            {
            case "action_animate":
            {
                entityObject = AnimateAction.Instantiate(e);
                break;
            }

            case "action_move":
            {
                entityObject = MoveAction.Instantiate(e);
                break;
            }

            case "action_rotate":
            {
                entityObject = RotateAction.Instantiate(e);
                break;
            }

            case "action_sequence":
            {
                entityObject = ActionSequence.Instantiate(e);
                break;
            }

            case "action_sound":
            {
                entityObject = SoundAction.Instantiate(e);
                break;
            }

            case "action_wait":
            {
                entityObject = WaitAction.Instantiate(e);
                break;
            }

            case "audio_source":
            {
                entityObject = AudioSourceObject.Instantiate(e);
                break;
            }

            case "dream_environment":
            {
                entityObject = DreamEnvironment.Instantiate(e);
                break;
            }

            case "!map":
            {
                entityObject = MapObject.Instantiate(e);
                break;
            }

            case "!model":
            {
                entityObject = ModelObject.Instantiate(e);
                break;
            }

            case "music_controller":
            {
                entityObject = MusicController.Instantiate(e);
                break;
            }

            case "player_spawn":
            {
                entityObject = PlayerSpawn.Instantiate(e);
                break;
            }

            case "target":
            {
                entityObject = Target.Instantiate(e);
                break;
            }

            case "trigger_link":
            {
                entityObject = TriggerLink.Instantiate(e);
                break;
            }

            case "trigger_sequence":
            {
                entityObject = TriggerSequence.Instantiate(e);
                break;
            }

            case "trigger_sound":
            {
                entityObject = TriggerSound.Instantiate(e);
                break;
            }

            case "trigger_teleport":
            {
                entityObject = TriggerTeleport.Instantiate(e);
                break;
            }

            default:
            {
                Debug.LogWarning("Could not instantiate entity with classname " + e.Classname);
                entityObject = new GameObject(e.Classname);
                break;
            }
            }

            return(entityObject);
        }
Exemple #3
0
    private async void ServerSetUpPlayer(
        string unverifiedClientId,
        string unverifiedUsername,
        string unverifiedUserid,
        int unverifiedClientVersion,
        string unverifiedToken)
    {
        Logger.LogFormat("A joinedviewer called CmdServerSetupPlayer on this server, Unverified ClientId: {0} Unverified Username: {1}",
                         Category.Connections,
                         unverifiedClientId, unverifiedUsername);

        //Register player to player list (logging code exists in PlayerList so no need for extra logging here)
        var unverifiedConnPlayer = PlayerList.Instance.AddOrUpdate(new ConnectedPlayer
        {
            Connection = connectionToClient,
            GameObject = gameObject,
            Username   = unverifiedUsername,
            Job        = JobType.NULL,
            ClientId   = unverifiedClientId,
            UserId     = unverifiedUserid
        });

        var isValidPlayer = await PlayerList.Instance.ValidatePlayer(unverifiedClientId, unverifiedUsername,
                                                                     unverifiedUserid, unverifiedClientVersion, unverifiedConnPlayer, unverifiedToken);

        if (!isValidPlayer)
        {
            return;                         //this validates Userid and Token
        }
        // Check if they have a player to rejoin. If not, assign them a new client ID
        var loggedOffPlayer = PlayerList.Instance.TakeLoggedOffPlayerbyClientId(unverifiedClientId);

        if (loggedOffPlayer != null)
        {
            var checkForViewer = loggedOffPlayer.GetComponent <JoinedViewer>();
            if (checkForViewer)
            {
                Destroy(loggedOffPlayer);
                loggedOffPlayer = null;
            }
        }

        // Sync all player data and the connected player count
        CustomNetworkManager.Instance.SyncPlayerData(gameObject);
        UpdateConnectedPlayersMessage.Send();

        // Only sync the pre-round countdown if it's already started
        if (GameManager.Instance.CurrentRoundState == RoundState.PreRound)
        {
            if (GameManager.Instance.waitForStart)
            {
                TargetSyncCountdown(connectionToClient, GameManager.Instance.waitForStart,
                                    GameManager.Instance.startTime);
            }
            else
            {
                GameManager.Instance.CheckPlayerCount();
            }
        }

        //if there's a logged off player, we will force them to rejoin. Previous logic allowed client to reenter
        //their body or not, which should not be up to the client!
        if (loggedOffPlayer != null)
        {
            PlayerSpawn.ServerRejoinPlayer(this, loggedOffPlayer);
        }
        else
        {
            TargetLocalPlayerSetupNewPlayer(connectionToClient,
                                            GameManager.Instance.CurrentRoundState);
        }

        PlayerList.Instance.CheckAdminState(unverifiedConnPlayer, unverifiedUserid);
    }
 // Use this for initialization
 void Start()
 {
     active = false;
     pSpawn = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerSpawn> ();
 }
Exemple #5
0
 void Start()
 {
     spawnScript = GameObject.Find("PlayerSpawner").GetComponent <PlayerSpawn>();
 }
Exemple #6
0
        /// <summary>
        /// The h 2 spawn info.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void H2SpawnInfo(Map map)
        {
            map.OpenMap(MapTypes.Internal);

            // find default mc model
            map.BR.BaseStream.Position = map.MetaInfo.Offset[0] + 308;
            int tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            map.BR.BaseStream.Position = tempr + 4;
            int tempbipdtag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
            //map.CloseMap();
            int bipdmodeltag = map.Functions.FindModelByBaseClass(tempbipdtag);

            int ctfmodeltag = -1;
            int ballmodeltag = -1;
            int juggernautdmodeltag = -1;
            int assultmodeltag = -1;

            #region  //// Find objective models ////

            try
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position =
                    map.MetaInfo.Offset[
                        map.Functions.ForMeta.FindByNameAndTagType("mulg", "multiplayer\\multiplayer_globals")] + 12;
                tempr = map.BR.ReadInt32();
                if (tempr != 0)
                {
                    tempr -= map.SecondaryMagic;
                    map.BR.BaseStream.Position = tempr + 4;
                    int tempCtftag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    map.BR.BaseStream.Position = tempr + 12;
                    int tempBalltag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                    map.BR.BaseStream.Position = tempr + 36;
                    int tempHillShader = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                    // I believe the Hill Shader above is not used, but just in case. Otherwise, load the usual one below
                    if (tempHillShader == -1)
                    {
                        map.BR.BaseStream.Position = tempr + 1332;
                        int tempr2 = map.BR.ReadInt32();
                        if (tempr2 != 0)
                        {
                            tempr2 -= map.SecondaryMagic;
                            map.BR.BaseStream.Position = tempr2 + 196;
                            tempHillShader = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                        }
                    }

                    map.BR.BaseStream.Position = tempr + 52;
                    int tempJuggernauttag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    map.BR.BaseStream.Position = tempr + 60;
                    int tempAssaulttag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();

                    ctfmodeltag = map.Functions.FindModelByBaseClass(tempCtftag);
                    ballmodeltag = map.Functions.FindModelByBaseClass(tempBalltag);

                    // *** This is not right. It's a shader, not a model. But I don't know how to display a shader...
                    hillshadertag = map.Functions.ForMeta.FindMetaByID(tempHillShader);

                    juggernautdmodeltag = map.Functions.FindModelByBaseClass(tempJuggernauttag);
                    assultmodeltag = map.Functions.FindModelByBaseClass(tempAssaulttag);
                }
            }
            catch (Exception e)
            {
               System.Windows.Forms.MessageBox.Show("Error loading an objective model (CTF/Juggernaut/Assault/Bomb)\n" + e.Message);
            }

            #endregion

            #region //// Player Spawns ////

            try
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 256;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    map.BR.BaseStream.Position = tempr + (52 * x);
                    PlayerSpawn ps = new PlayerSpawn();
                    ps.Read(map);

                    ps.ModelTagNumber = bipdmodeltag;
                    ps.ModelName = map.FileNames.Name[ps.ModelTagNumber];

                    Spawn.Add(ps);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading player spawns", e);
            }

            #endregion

            #region //// trigger volumes / death zones ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 264;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    DeathZone tv = new DeathZone();
                    map.BR.BaseStream.Position = tempr + (68 * x);
                    tv.Read(map);

                    Spawn.Add(tv);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading death zones", e);
            }

            #endregion

            #region //// lights ////

            try
            {
                //// palette ////
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 240;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    temppalette2[x] = tempbase;
                    temppalette[x] = tempbase;
                }

                //// placement ////
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 232;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    map.BR.BaseStream.Position = tempr + (108 * x);
                    short tempshort = map.BR.ReadInt16();

                    LightSpawn ls = new LightSpawn();
                    map.BR.BaseStream.Position = tempr + (108 * x);
                    ls.Read(map);

                    if (ls.PaletteIndex == -1)
                    {
                        continue;
                    }

                    int nameIndex = temppalette2[tempshort];
                    if (nameIndex >= 0)
                        ls.TagPath = map.FileNames.Name[nameIndex];
                    ls.ModelTagNumber = temppalette[tempshort];
                    if (ls.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    ls.ModelName = map.FileNames.Name[ls.ModelTagNumber];
                    Spawn.Add(ls);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Lights", e);
            }

            #endregion

            #region //// sounds ////

            try
            {
                //// Sound Scenery palette ////
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 224;

                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    temppalette2[x] = tempbase;
                    temppalette[x] = tempbase;
                }

                //// placement ////
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 216;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    SoundSpawn ss = new SoundSpawn();
                    map.BR.BaseStream.Position = tempr + (80 * x);
                    ss.Read(map);

                    if (ss.PaletteIndex == -1 || temppalette2[ss.PaletteIndex] == -1)
                    {
                        ss.TagPath = NullTags;
                    }
                    else
                    {
                        ss.TagPath = map.FileNames.Name[temppalette2[ss.PaletteIndex]];
                    }

                    ss.ModelTagNumber = temppalette[ss.PaletteIndex];
                    if (ss.ModelTagNumber == -1)
                    {
                        // { continue; }
                        ss.ModelName = null;
                    }
                    else
                    {
                        ss.ModelName = map.FileNames.Name[ss.ModelTagNumber];
                    }

                    Spawn.Add(ss);
                }

            }
            catch (Exception e)
            {
                throw new Exception("Error loading sounds", e);
            }

            #endregion

            #region //// objectives ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 280;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    ObjectiveSpawn os = new ObjectiveSpawn();
                    map.BR.BaseStream.Position = tempr + (32 * x);
                    os.Read(map);

                    if (os.ObjectiveType == ObjectiveSpawn.ObjectiveTypeEnum.OddballSpawn && ballmodeltag != -1)
                    {
                        os.ModelTagNumber = ballmodeltag;
                    }
                    else if (os.ObjectiveType == ObjectiveSpawn.ObjectiveTypeEnum.CTFRespawn && ctfmodeltag != -1)
                    {
                        os.ModelTagNumber = ctfmodeltag;
                    }
                    else if (
                        os.ObjectiveType.ToString().StartsWith(
                            ObjectiveSpawn.ObjectiveTypeEnum.KingOfTheHill_1.ToString().Substring(0, 13)) &&
                        ctfmodeltag != -1)
                    {
                        os.ModelTagNumber = ctfmodeltag;
                    }
                    else if (os.ObjectiveType == ObjectiveSpawn.ObjectiveTypeEnum.AssaultRespawn && assultmodeltag != -1)
                    {
                        os.ModelTagNumber = assultmodeltag;
                    }
                    else
                    {
                        os.ModelTagNumber = bipdmodeltag;
                    }

                    os.ModelName = map.FileNames.Name[os.ModelTagNumber];
                    Spawn.Add(os);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading lights", e);
            }
            #endregion

            #region //// vehicles ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 120;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 112;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    VehicleSpawn vs = new VehicleSpawn();
                    map.BR.BaseStream.Position = tempr + (84 * x);
                    vs.Read(map);

                    if (vs.PaletteIndex == -1)
                    {
                        continue;
                    }

                    vs.TagPath = map.FileNames.Name[temppalette2[vs.PaletteIndex]];
                    vs.ModelTagNumber = temppalette[vs.PaletteIndex];
                    if (vs.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                    Spawn.Add(vs);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading vehicles", e);
            }

            #endregion

            #region //// equipment ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 136;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 128;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    EquipmentSpawn es = new EquipmentSpawn();
                    map.BR.BaseStream.Position = tempr + (56 * x);
                    es.Read(map);

                    if (es.PaletteIndex == -1)
                    {
                        continue;
                    }

                    es.TagPath = map.FileNames.Name[temppalette2[es.PaletteIndex]];
                    es.ModelTagNumber = temppalette[es.PaletteIndex];
                    if (es.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    es.ModelName = map.FileNames.Name[es.ModelTagNumber];
                    Spawn.Add(es);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading equipment", e);
            }

            #endregion

            #region //// bipeds ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 104;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 96;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    BipedSpawn bs = new BipedSpawn();
                    map.BR.BaseStream.Position = tempr + (84 * x);
                    bs.Read(map);

                    if (bs.PaletteIndex == -1)
                    {
                        continue;
                    }

                    bs.TagPath = map.FileNames.Name[temppalette2[bs.PaletteIndex]];
                    bs.ModelTagNumber = temppalette[bs.PaletteIndex];
                    if (bs.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    bs.ModelName = map.FileNames.Name[bs.ModelTagNumber];
                    Spawn.Add(bs);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Bipeds", e);
            }

            #endregion

            #region //// control ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 192;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 184;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    ControlSpawn cs = new ControlSpawn();
                    map.BR.BaseStream.Position = tempr + (68 * x);
                    cs.Read(map);

                    if (cs.PaletteIndex == -1)
                    {
                        continue;
                    }

                    cs.TagPath = map.FileNames.Name[temppalette2[cs.PaletteIndex]];
                    cs.ModelTagNumber = temppalette[cs.PaletteIndex];
                    if (cs.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    cs.ModelName = map.FileNames.Name[cs.ModelTagNumber];
                    Spawn.Add(cs);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Control", e);
            }

            #endregion

            #region //// machines ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 176;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 168;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    MachineSpawn ms = new MachineSpawn();
                    map.BR.BaseStream.Position = tempr + (72 * x);
                    ms.Read(map);

                    if (ms.PaletteIndex == -1)
                    {
                        continue;
                    }

                    if (temppalette2[ms.PaletteIndex] == -1 || temppalette[ms.PaletteIndex] == -1)
                    {
                        continue;
                    }

                    ms.TagPath = map.FileNames.Name[temppalette2[ms.PaletteIndex]];
                    ms.ModelTagNumber = temppalette[ms.PaletteIndex];
                    if (ms.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    ms.ModelName = map.FileNames.Name[ms.ModelTagNumber];
                    Spawn.Add(ms);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Machines", e);
            }

            #endregion

            #region //// scenery ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 88;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 80;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    ScenerySpawn ss = new ScenerySpawn();
                    map.BR.BaseStream.Position = tempr + (92 * x);
                    ss.Read(map);

                    if (ss.PaletteIndex == -1)
                    {
                        continue;
                    }

                    if (temppalette2[ss.PaletteIndex] == -1 || temppalette[ss.PaletteIndex] == -1)
                    {
                        continue;
                    }

                    ss.TagPath = map.FileNames.Name[temppalette2[ss.PaletteIndex]];
                    ss.ModelTagNumber = temppalette[ss.PaletteIndex];
                    if (ss.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    ss.ModelName = map.FileNames.Name[ss.ModelTagNumber];
                    Spawn.Add(ss);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Scenery", e);
            }

            #endregion

            #region //// weapons ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 152;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 144;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    WeaponSpawn ws = new WeaponSpawn();
                    map.BR.BaseStream.Position = tempr + (84 * x);
                    ws.Read(map);

                    if (ws.PaletteIndex == -1)
                    {
                        continue;
                    }

                    ws.TagPath = map.FileNames.Name[temppalette2[ws.PaletteIndex]];
                    ws.ModelTagNumber = temppalette[ws.PaletteIndex];
                    if (ws.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    ws.ModelName = map.FileNames.Name[ws.ModelTagNumber];
                    Spawn.Add(ws);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Weapons", e);
            }

            #endregion

            #region //// obstacles ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 816;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 808;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    ObstacleSpawn os = new ObstacleSpawn();
                    map.BR.BaseStream.Position = tempr + (76 * x);
                    os.Read(map);

                    if (os.PaletteIndex == -1)
                    {
                        continue;
                    }

                    if (temppalette2[os.PaletteIndex] == -1)
                    {
                        continue;
                    }

                    os.TagPath = map.FileNames.Name[temppalette2[os.PaletteIndex]];
                    os.ModelTagNumber = temppalette[os.PaletteIndex];
                    if (os.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    os.ModelName = map.FileNames.Name[os.ModelTagNumber];
                    Spawn.Add(os);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Obstacles", e);
            }

            #endregion

            #region //// collections ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 288;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    Collection collect = new Collection();
                    map.BR.BaseStream.Position = tempr + (144 * x);
                    collect.Read(map);

                    // ID Type
                    if (collect.TagPath == NullTags)
                    {
                        continue;
                    }

                    if (collect.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    collect.ModelName = map.FileNames.Name[collect.ModelTagNumber];
                    Spawn.Add(collect);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Collections", e);
            }

            #endregion

            #region //// cameras ////

            try
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 488;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    CameraSpawn cs = new CameraSpawn();
                    map.BR.BaseStream.Position = tempr + (64 * x);
                    cs.Read(map);

                    Spawn.Add(cs);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Collections", e);
            }

            #endregion

            #region //// AI_Squads ////

            try
            {
                // Reading Character Palette
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 376;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    map.BR.BaseStream.Position = tempr + (x * 8) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                // Reading ai squads reflexive
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 352;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    // Reads AI Squad character index
                    map.BR.BaseStream.Position = tempr + (x * 116) + 54;
                    short charIndex = map.BR.ReadInt16();

                    // Reading locations sub reflexive
                    map.BR.BaseStream.Position = tempr + (x * 116) + 72;
                    int locc = map.BR.ReadInt32();
                    int locr = map.BR.ReadInt32() - map.SecondaryMagic;

                    for (int y = 0; y < locc; y++)
                    {
                        AI_Squads ai = new AI_Squads(x);
                        map.BR.BaseStream.Position = locr + (100 * y);
                        ai.Read(map);

                        if (charIndex != -1)
                        {
                            ai.TagPath = map.FileNames.Name[temppalette2[charIndex]];
                            ai.ModelTagNumber = temppalette[charIndex];
                            if (ai.ModelTagNumber == -1)
                            {
                                continue;
                            }

                            // ai.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                            Spawn.Add(ai);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading AI Squads", e);
            }

            #endregion

            #region //// Spawn Zones ////

            try
            {
                // Reading Spawn Zone Section
                // 792 = Spawn Data
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 792;
                int SpawnDataCount = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                #region //// Inital Spawn Zones ////
                // 88 = Static Initial Spawn Zones
                map.BR.BaseStream.Position = tempr + 88;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int initialR = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < temppalette.Length; x++)
                {
                    // Each Initial Spawn Zone chunk = 48 bytes
                    map.BR.BaseStream.Position = initialR + (x * 48);
                    SpawnZone spawnZone = new SpawnZone(SpawnZoneType.Inital);
                    spawnZone.Read(map);

                    Spawn.Add(spawnZone);
                }
                #endregion

                #region //// Respawn Zones ////
                // 80 = Static Respawn Zones
                map.BR.BaseStream.Position = tempr + 80;
                temppalette = new int[map.BR.ReadInt32()];
                int respawnR = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < temppalette.Length; x++)
                {
                    // Each Respawn Zone chunk = 48 bytes
                    map.BR.BaseStream.Position = respawnR + (x * 48);
                    SpawnZone spawnZone = new SpawnZone(SpawnZoneType.Respawn);
                    spawnZone.Read(map);

                    Spawn.Add(spawnZone);
                }
                #endregion
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Spawn Zones (Initial)", e);
            }
            #endregion

            map.CloseMap();
        }
Exemple #7
0
        private void OverlayEntities(MapElement entities, Bitmap map, VirtualMap <char> solids, bool background)
        {
            CassetteBlock.Blocks.Clear();

            using (Graphics g = Graphics.FromImage(map)) {
                List <Entity> ents = new List <Entity>();
                for (int i = entities.Children.Count - 1; i >= 0; i--)
                {
                    MapElement child = entities.Children[i];

                    Entity entity = null;
                    if (child.Name.IndexOf("spikes", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        entity = background ? Spikes.FromElement(child) : null;
                    }
                    else if (child.Name.IndexOf("triggerSpikes", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        entity = background ? TriggerSpikes.FromElement(child) : null;
                    }
                    else if (child.Name.IndexOf("strawberry", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        entity = background ? Strawberry.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("goldenBerry", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Strawberry.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("redBlocks", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("greenBlocks", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("yellowBlocks", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("clutterCabinet", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterCabinet.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("introCar", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? IntroCar.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("clothesLine", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClothesLine.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("colorSwitch", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ColorSwitch.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("memorialTextController", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Strawberry.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bonfire", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Bonfire.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("trapDoor", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TrapDoor.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("movingPlatform", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? MovingPlatform.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("sinkingPlatform", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? SinkingPlatform.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("clutterDoor", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterDoor.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bridge", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Bridge.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bridgeFixed", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? BridgeFixed.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("jumpThru", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? JumpThru.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("door", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Door.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("blockField", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? BlockField.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("lamp", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Lamp.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("hahaha", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Haha.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("waterFall", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? WaterFall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("water", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Water.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("key", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Key.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("resortLantern", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ResortLantern.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bird", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Bird.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("memorial", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Memorial.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("player", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? PlayerSpawn.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("zipMover", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ZipMover.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("wire", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Wire.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("crumbleBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? CrumbleBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("refill", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Refill.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("spring", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Spring.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("fakeWall", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FakeWall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("exitBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FakeWall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("lightBeam", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? LightBeam.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("cobweb", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Cobweb.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("cassette", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Cassette.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("flutterBird", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FlutterBird.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("checkpoint", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Checkpoint.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("fallingBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FallingBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("introCrusher", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FallingBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("cassetteBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? CassetteBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("dashBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DashBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("coverupWall", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? CoverupWall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("npc", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? NPC.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("birdForsakenCityGem", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ForsakenCityGem.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("soundSource", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? SoundSource.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("friendlyGhost", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FriendlyGhost.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("floatingDebris", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FloatingDebris.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("hangingLamp", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? HangingLamp.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("lockBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? LockBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("heartGem", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? HeartGem.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("blackGem", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? HeartGem.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("dreamMirror", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DreamMirror.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("darkChaser", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DarkChaser.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("dreamBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DreamBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("touchSwitch", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TouchSwitch.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("switchGate", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? SwitchGate.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("invisibleBarrier", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? InvisibleBarrier.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("payphone", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Payphone.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("spinner", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Spinner.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("rotateSpinner", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? RotateSpinner.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("trackSpinner", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TrackSpinner.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("towerViewer", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TowerViewer.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("foregroundDebris", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = !background?ForegroundDebris.FromElement(child) : null;
                    }
                    else if (background)
                    {
                        Console.WriteLine(child.Name);
                    }
                    if (entity != null)
                    {
                        ents.Add(entity);
                    }
                }

                ents.Sort(delegate(Entity one, Entity two) {
                    int comp = two.Depth.CompareTo(one.Depth);
                    return(comp == 0 ? one.ID.CompareTo(two.ID) : comp);
                });

                for (int i = 0; i < ents.Count; i++)
                {
                    Entity entity = ents[i];
                    entity.Render(g, solids);
                }
            }
        }
Exemple #8
0
    public void CmdSpectate(string jsonCharSettings)
    {
        var characterSettings = JsonConvert.DeserializeObject <CharacterSettings>(jsonCharSettings);

        PlayerSpawn.ServerSpawnGhost(this, characterSettings);
    }
 public void RegisterPlayerSpawn(PlayerSpawn newSpawn)
 {
     playerSpawns.Add(newSpawn);
     Player player = RespawnPlayerSpawn(newSpawn);
 }
Exemple #10
0
    void Start()
    {
        buttonReleaseScript = GameObject.Find("ButtonRelease").GetComponent<ButtonReleased>();
        enemyObj = GameObject.FindGameObjectWithTag("Enemy");

        if(enemyObj != null)
        {
            enemyScript = enemyObj.GetComponent<Enemy>();
        }

        sm = GameObject.Find("SoundManager").GetComponent<SoundManager>();

        playerSpawn = FindObjectOfType<PlayerSpawn>();

        if(attackingUnit)
        {
            switch(gameObject.name)
            {
                case "PF_TomatoBaby(Clone)" :
                    weaponSound = sm.tomatoHittingEnemy;
                break;

                case "PF_BroccoliBaby(Clone)" :
                    weaponSound = sm.broccoliHittingEnemy;
                break;

                case "PF_CarrotBaby(Clone)" :
                    weaponSound = sm.carrotHittingEnemy;
                break;

                case "PF_OnionBaby(Clone)" :
                    weaponSound = sm.onionHittingEnemy;
                break;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("SwitchLeader"))
        {
            ToggleLeader();
        }
        if (Input.GetButtonDown("Disband"))
        {
            Disband();
        }

        List <Player> newlyDeadPlayers = new List <Player>();

        foreach (var currentPlayer in currentPlayers)
        {
            if (currentPlayer.transform.position.y < -10)
            {
                newlyDeadPlayers.Add(currentPlayer);
            }
        }

        foreach (var deadPlayer in newlyDeadPlayers)
        {
            PlayerSpawn playerSpawn = deadPlayer.playerSpawnBirthplace;
            playerSpawn.lastSpawnedPlayer    = null;
            deadPlayer.playerSpawnBirthplace = null;
            RespawnPlayerSpawn(playerSpawn);
        }

        currentTeam.RemoveAll(player => newlyDeadPlayers.Contains(player));
        currentPlayers.RemoveAll(player => newlyDeadPlayers.Contains(player));
        deadPlayers.AddRange(newlyDeadPlayers);

        List <Player> completelyDeadPlayers = new List <Player>();

        foreach (Player deadPlayer in deadPlayers)
        {
            if (deadPlayer.transform.position.y < -50)
            {
                completelyDeadPlayers.Add(deadPlayer);
            }
        }

        deadPlayers.RemoveAll(player => completelyDeadPlayers.Contains(player));
        foreach (Player deadPlayer in completelyDeadPlayers)
        {
            Destroy(deadPlayer.gameObject);
        }

        if (currentTeam.Count == 0)
        {
            RespawnPlayers();
        }
        else
        {
            if (!currentTeam.Contains(leader))
            {
                if (leader != null)
                {
                    leader.DiscardLeader();
                }
                leader            = currentTeam.First();
                LeaderPlayerSpawn = leader.playerSpawnBirthplace;
                leader.BecomeLeader();
                orbitFollow.SetFollowTarget(leader.followTarget);
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            foreach (var currentPlayer in currentTeam)
            {
                currentPlayer.SetInputEnabled(false);
            }
        }
        if (Input.GetMouseButtonUp(1))
        {
            foreach (var currentPlayer in currentTeam)
            {
                currentPlayer.SetInputEnabled(true);
            }
        }

        if (Input.GetMouseButton(1))
        {
            float left  = float.MaxValue;
            float right = float.MinValue;
            float down  = float.MaxValue;
            float up    = float.MinValue;

            foreach (var currentPlayer in currentTeam)
            {
                float x = currentPlayer.transform.position.x;
                float z = currentPlayer.transform.position.z;
                left  = Mathf.Min(x, left);
                right = Mathf.Max(x, right);
                up    = Mathf.Max(z, up);
                down  = Mathf.Min(z, down);
            }

            Vector3 center = new Vector3(left + ((right - left) / 2), 0, down + ((up - down) / 2));

            foreach (var currentPlayer in currentTeam)
            {
                currentPlayer.OverrideDirection(center - currentPlayer.transform.position);
            }
        }
    }
 public void CmdRejoin(GameObject loggedOffPlayer)
 {
     PlayerSpawn.ServerRejoinPlayer(this, loggedOffPlayer);
 }
 public void CmdRequestJob(JobType jobType, CharacterSettings characterSettings)
 {
     PlayerSpawn.ServerSpawnPlayer(this, GameManager.Instance.GetRandomFreeOccupation(jobType),
                                   characterSettings);
 }
 public override GameObject ServerSpawn(PlayerSpawnRequest spawnRequest)
 {
     // spawn them normally, with their preferred occupation
     return(PlayerSpawn.ServerSpawnPlayer(spawnRequest));
 }
Exemple #15
0
    void Start()
    {
        attackDelay = false;
        bottles = GameObject.Find("BottlesSpawner").GetComponent<BottlesSpawner>();
        buttonReleaseScript = GameObject.Find("ButtonRelease").GetComponent<ButtonReleased>();
        enemySpawner = GameObject.Find("EnemySpawner").GetComponent<EnemySpawner>();
        gameOverObj = GameObject.FindGameObjectWithTag("GO");
        gameSpawnScript = GameObject.Find("GameSpawner").GetComponent<GameSpawner>();
        inGameUI = GameObject.Find("InGameUIManager").GetComponent<InGameUIManager>();
        killed = false;
        nappyPad = GameObject.Find("NappyPadSpawner").GetComponent<NappyPadSpawner>().PF_NappyPad;
        nappyPadObj = GameObject.FindGameObjectWithTag("Ammo");

        if(nappyPadObj != null)
        {
            nappyPadScript = nappyPadObj.GetComponent<NappyPad>();
        }

        nappyPadShadow = GameObject.Find("NappyPadSpawner").GetComponent<NappyPadSpawner>().PF_NappyPadShadow;
        playerSpawn = GameObject.FindGameObjectWithTag("SpawnBlock").GetComponent<PlayerSpawn>();
        sm = GameObject.Find("SoundManager").GetComponent<SoundManager>();
        laugh = sm.laugh;

        SetState(0);
    }
 /// <summary>
 /// Server only. Spawn the joined viewer as the indicated antag, includes creating their player object
 /// and transferring them to it.
 /// </summary>
 /// <param name="spawnRequest">player's requested spawn</param>
 /// <returns>gameobject of the spawned antag that he player is now in control of</returns>
 public virtual GameObject ServerSpawn(PlayerSpawnRequest spawnRequest)
 {
     // spawn them normally but override the player-requested occupation with the antagonist occupation
     return(PlayerSpawn.ServerSpawnPlayer(spawnRequest, spawnRequest.JoinedViewer, AntagOccupation, spawnRequest.CharacterSettings, false));
 }
Exemple #17
0
 PlayerSpawn getSpawn(PlayerSpawn[] lPlayerSpawns,int pIndex)
 {
     return lPlayerSpawns[pIndex % lPlayerSpawns.Length];
 }
Exemple #18
0
 private static void SpawnDummyPlayer()
 {
     PlayerSpawn.ServerSpawnDummy();
 }
Exemple #19
0
 public void CmdSpectacte()
 {
     PlayerSpawn.ServerSpawnGhost(this);
 }
Exemple #20
0
        /// <summary>
        /// The h 2 spawn info.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void H2SpawnInfo(Map map)
        {
            map.OpenMap(MapTypes.Internal);

            // find default mc model
            map.BR.BaseStream.Position = map.MetaInfo.Offset[0] + 308;
            int tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            map.BR.BaseStream.Position = tempr + 4;
            int tempbipdtag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
            //map.CloseMap();
            int bipdmodeltag = map.Functions.FindModelByBaseClass(tempbipdtag);

            // Find objective models
            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position =
                map.MetaInfo.Offset[
                    map.Functions.ForMeta.FindByNameAndTagType("mulg", "multiplayer\\multiplayer_globals")] + 12;
            tempr = map.BR.ReadInt32();
            int ctfmodeltag = -1;
            int ballmodeltag = -1;
            int juggernautdmodeltag = -1;
            int assultmodeltag = -1;
            if (tempr != 0)
            {
                tempr -= map.SecondaryMagic;
                map.BR.BaseStream.Position = tempr + 4;
                int tempCtftag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                map.BR.BaseStream.Position = tempr + 12;
                int tempBalltag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                map.BR.BaseStream.Position = tempr + 36;
                int tempHillShader = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                // I believe the Hill Shader above is not used, but just in case. Otherwise, load the usual one below
                if (tempHillShader == -1)
                {
                    map.BR.BaseStream.Position = tempr + 1332;
                    int tempr2 = map.BR.ReadInt32();
                    if (tempr2 != 0)
                    {
                        tempr2 -= map.SecondaryMagic;
                        map.BR.BaseStream.Position = tempr2 + 196;
                        tempHillShader = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    }
                }

                map.BR.BaseStream.Position = tempr + 52;
                int tempJuggernauttag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                map.BR.BaseStream.Position = tempr + 60;
                int tempAssaulttag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                //map.CloseMap();

                ctfmodeltag = map.Functions.FindModelByBaseClass(tempCtftag);
                ballmodeltag = map.Functions.FindModelByBaseClass(tempBalltag);

                // *** This is not right. It's a shader, not a model. But I don't know how to display a shader...
                hillshadertag = map.Functions.ForMeta.FindMetaByID(tempHillShader);

                juggernautdmodeltag = map.Functions.FindModelByBaseClass(tempJuggernauttag);
                assultmodeltag = map.Functions.FindModelByBaseClass(tempAssaulttag);
            }

            #region //// Player Spawns ////

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 256;
            int tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (52 * x);

                PlayerSpawn ps = new PlayerSpawn();
                ps.offset = tempr + (52 * x);
                ps.X = map.BR.ReadSingle();
                ps.Y = map.BR.ReadSingle();
                ps.Z = map.BR.ReadSingle();
                ps.RotationDirection = map.BR.ReadSingle();
                ps.ModelTagNumber = bipdmodeltag;
                ps.ModelName = map.FileNames.Name[ps.ModelTagNumber];

                Spawn.Add(ps);
            }

            #endregion

            #region //// death zones ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 264;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < tempc; x++)
            {
                DeathZone ps = new DeathZone();

                // Load the deathzone name
                map.BR.BaseStream.Position = tempr + (68 * x);
                ps.Name = map.Strings.Name[map.BR.ReadInt16()];

                // We set the offset to 36 b/c we don't care about saving the name... right now anyways.
                ps.offset = tempr + (68 * x) + 36;

                // Load the deathzone coordinates
                map.BR.BaseStream.Position = tempr + (68 * x) + 36;
                ps.X = map.BR.ReadSingle();
                ps.Y = map.BR.ReadSingle();
                ps.Z = map.BR.ReadSingle();

                // Use ABS() to make sure our sizes are always positive
                ps.width = Math.Abs(map.BR.ReadSingle());
                ps.height = Math.Abs(map.BR.ReadSingle());
                ps.length = Math.Abs(map.BR.ReadSingle());

                // Deathzones are saved with a centre point and Width, Length, Height
                ps.X += ps.width / 2;
                ps.Y += ps.height / 2;
                ps.Z += ps.length / 2;

                Spawn.Add(ps);
            }

            #endregion

            #region //// lights ////

            //// palette ////
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 240;
            int[] temppalette = new int[map.BR.ReadInt32()];
            int[] temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                temppalette2[x] = tempbase;
                temppalette[x] = tempbase;
            }

            //// placement ////
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 232;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (108 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = tempr + (108 * x) + 8;
                LightSpawn vs = new LightSpawn();
                vs.offset = tempr + (108 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// sounds ////

            //// Sound Scenery palette ////
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 224;

            // temppalette variables declared in Lights section above
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                temppalette2[x] = tempbase;
                temppalette[x] = tempbase;
            }

            //// placement ////
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 216;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (80 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                SoundSpawn vs = new SoundSpawn();

                map.BR.BaseStream.Position = tempr + (80 * x) + 8;
                vs.offset = tempr + (80 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                map.BR.BaseStream.Position = tempr + (80 * x) + 54;
                vs.VolumeType = map.BR.ReadInt16();
                vs.Height = map.BR.ReadSingle();
                vs.DistanceBoundsLower = map.BR.ReadSingle();
                vs.DistanceBoundsUpper = map.BR.ReadSingle();
                vs.ConeAngleLower = map.BR.ReadSingle();
                vs.ConeAngleUpper = map.BR.ReadSingle();
                vs.OuterConeGain = map.BR.ReadSingle();

                if (temppalette2[tempshort] == -1)
                {
                    vs.TagPath = "Nulled Out";
                }
                else
                {
                    vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                }

                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    // { continue; }
                    vs.ModelName = null;
                }
                else
                {
                    vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                }

                Spawn.Add(vs);
            }

            #endregion

            #region //// objectives ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 280;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < tempc; x++)
            {
                ObjectiveSpawn ps = new ObjectiveSpawn();
                ps.offset = tempr + (32 * x);
                map.BR.BaseStream.Position = tempr + (32 * x);
                ps.X = map.BR.ReadSingle();
                ps.Y = map.BR.ReadSingle();
                ps.Z = map.BR.ReadSingle();
                ps.RotationDirection = map.BR.ReadSingle();
                ps.ObjectiveType = (ObjectiveSpawn.ObjectiveTypeEnum)map.BR.ReadInt16();
                ps.Team = (ObjectiveSpawn.TeamType)map.BR.ReadInt16();
                ps.number = map.BR.ReadInt16();

                if (ps.ObjectiveType == ObjectiveSpawn.ObjectiveTypeEnum.OddballSpawn && ballmodeltag != -1)
                {
                    ps.ModelTagNumber = ballmodeltag;
                }
                else if (ps.ObjectiveType == ObjectiveSpawn.ObjectiveTypeEnum.CTFRespawn && ctfmodeltag != -1)
                {
                    ps.ModelTagNumber = ctfmodeltag;
                }
                else if (
                    ps.ObjectiveType.ToString().StartsWith(
                        ObjectiveSpawn.ObjectiveTypeEnum.KingOfTheHill_1.ToString().Substring(0, 13)) &&
                    ctfmodeltag != -1)
                {
                    ps.ModelTagNumber = ctfmodeltag;
                }
                else if (ps.ObjectiveType == ObjectiveSpawn.ObjectiveTypeEnum.AssaultRespawn && assultmodeltag != -1)
                {
                    ps.ModelTagNumber = assultmodeltag;
                }
                else
                {
                    ps.ModelTagNumber = bipdmodeltag;
                }

                ps.ModelName = map.FileNames.Name[ps.ModelTagNumber];
                Spawn.Add(ps);
            }

            #endregion

            #region //// vehicles ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 120;
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                //map.CloseMap();
                temppalette2[x] = tempbase;
                temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 112;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (84 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = tempr + (84 * x) + 8;
                VehicleSpawn vs = new VehicleSpawn();
                vs.offset = tempr + (84 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// equipment ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 136;
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                //map.CloseMap();
                temppalette2[x] = tempbase;
                temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 128;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (56 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = tempr + (56 * x) + 8;
                EquipmentSpawn vs = new EquipmentSpawn();
                vs.offset = tempr + (56 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();

                // vs.RotationDirection = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// bipeds ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 104;
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                //map.CloseMap();
                temppalette2[x] = tempbase;
                temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 96;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (84 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = tempr + (84 * x) + 8;
                BipedSpawn vs = new BipedSpawn();
                vs.offset = tempr + (84 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// control ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 192;
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                //map.CloseMap();
                temppalette2[x] = tempbase;
                temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 184;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (68 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = tempr + (68 * x) + 8;
                ControlSpawn vs = new ControlSpawn();
                vs.offset = tempr + (68 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();

                // vs.RotationDirection = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// machines ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 176;
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                //map.CloseMap();
                temppalette2[x] = tempbase;
                temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 168;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (72 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = tempr + (72 * x) + 8;
                MachineSpawn vs = new MachineSpawn();
                vs.offset = tempr + (72 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                if (temppalette2[tempshort] == -1 || temppalette[tempshort] == -1)
                {
                    continue;
                }

                vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// scenery ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 88;
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                //map.CloseMap();
                temppalette2[x] = tempbase;
                temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 80;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (92 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = tempr + (92 * x) + 8;
                ScenerySpawn vs = new ScenerySpawn();
                vs.offset = tempr + (92 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                if (temppalette2[tempshort] == -1 || temppalette[tempshort] == -1)
                {
                    continue;
                }

                vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// weapons ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 152;
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                //map.CloseMap();
                temppalette2[x] = tempbase;
                temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 144;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (84 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = tempr + (84 * x) + 8;
                WeaponSpawn vs = new WeaponSpawn();
                vs.offset = tempr + (84 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// obstacles ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 816;
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                //map.CloseMap();
                temppalette2[x] = tempbase;
                temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
            }

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 808;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                map.BR.BaseStream.Position = tempr + (76 * x);
                short tempshort = map.BR.ReadInt16();

                if (tempshort == -1)
                {
                    continue;
                }

                map.BR.BaseStream.Position = tempr + (76 * x) + 8;
                ObstacleSpawn vs = new ObstacleSpawn();
                vs.offset = tempr + (76 * x) + 8;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.Scale = map.BR.ReadSingle();

                if (temppalette2[tempshort] == -1)
                {
                    continue;
                }

                vs.TagPath = map.FileNames.Name[temppalette2[tempshort]];
                vs.ModelTagNumber = temppalette[tempshort];
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// collections ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 288;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                Collection vs = new Collection();
                map.BR.BaseStream.Position = tempr + (144 * x) + 4;
                vs.SpawnsInMode = (Collection.SpawnsInEnum)map.BR.ReadInt32();

                // Why do they make the offset + 64? That just confuses stuff!!
                map.BR.BaseStream.Position = tempr + (144 * x) + 64;
                vs.offset = tempr + (144 * x) + 64;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();

                // test
                // if (vs.Pitch > 0) { vs.Pitch = -vs.Pitch; vs.isWeird = true; } else { vs.isWeird = false; }
                map.BR.BaseStream.Position = tempr + (144 * x) + 88;

                // ID Type
                char[] c = map.BR.ReadChars(4);
                vs.TagType = c[3].ToString() + c[2] + c[1] + c[0];

                // Tag Path ID
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                if (tempbase == -1)
                {
                    continue;
                }

                //map.CloseMap();
                vs.TagPath = map.FileNames.Name[tempbase];
                vs.ModelTagNumber = map.Functions.FindModelByBaseClass(tempbase);
                if (vs.ModelTagNumber == -1)
                {
                    continue;
                }

                vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                Spawn.Add(vs);
            }

            #endregion

            #region //// cameras ////

            //map.OpenMap(MapTypes.Internal);
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 488;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                //map.OpenMap(MapTypes.Internal);
                CameraSpawn vs = new CameraSpawn();
                map.BR.BaseStream.Position = tempr + (64 * x) + 36;
                vs.offset = tempr + (64 * x) + 36;
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();
                vs.Roll = map.BR.ReadSingle();
                vs.Pitch = map.BR.ReadSingle();
                vs.Yaw = map.BR.ReadSingle();
                vs.fov = map.BR.ReadSingle();
                vs.ModelTagNumber = -1;

                Spawn.Add(vs);
            }

            #endregion

            #region //// AI_Squads ////

            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 376;
            temppalette = new int[map.BR.ReadInt32()];
            temppalette2 = new int[temppalette.Length];
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            for (int x = 0; x < temppalette.Length; x++)
            {
                map.BR.BaseStream.Position = tempr + (x * 8) + 4;
                int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                temppalette2[x] = tempbase;
                temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
            }

            // Reading ai squads reflexive
            map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 352;
            tempc = map.BR.ReadInt32();
            tempr = map.BR.ReadInt32() - map.SecondaryMagic;

            for (int x = 0; x < tempc; x++)
            {
                // Reads AI Squad palette chunk
                map.BR.BaseStream.Position = tempr + (x * 116) + 54;
                short charNum = map.BR.ReadInt16();

                // Reading locations sub reflexive
                map.BR.BaseStream.Position = tempr + 72;
                int locc = map.BR.ReadInt32();
                int locr = map.BR.ReadInt32() - map.SecondaryMagic;

                AI_Squads vs = new AI_Squads();

                // chunk size * x and starting position
                map.BR.BaseStream.Position = locr + (100 * x);
                vs.offset = tempr + (100 * x);
                vs.ModelName = map.Strings.Name[(Int16)map.BR.ReadInt32()];
                vs.X = map.BR.ReadSingle();
                vs.Y = map.BR.ReadSingle();
                vs.Z = map.BR.ReadSingle();

                // facing direction
                map.BR.BaseStream.Position = locr + (100 * x) + 20;
                vs.RotationDirection = map.BR.ReadSingle();

                if (charNum != -1)
                {
                    vs.TagPath = map.FileNames.Name[temppalette2[charNum]];
                    vs.ModelTagNumber = temppalette[charNum];
                    if (vs.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    // vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                    Spawn.Add(vs);
                }
            }

            #endregion

            map.CloseMap();
        }
Exemple #21
0
    // Start is called before the first frame update
    void Start()
    {
        // The canvas and its child objects are prefabs
        // Unity seems to be a bit wonky when dragging prefabs into prefabs (stuff not already in the scene, maybe a reference issue...)
        // This is an attempt to get the specific button into the current menu object so non-mouse navigation will work without clicking somewhere first.
        var pauseCanvas  = GameObject.Find("CanvasPauseScreen");
        var resumeButton = pauseCanvas.transform.Find("PanelPause/ButtonResume");

        EventSystem eventSystem = EventSystem.current;

        eventSystem.firstSelectedGameObject = resumeButton.gameObject;


        var currentScene = SceneManager.GetActiveScene().name;
        var currentArea  = currentScene.Substring(9);



        if (currentArea != "sun")
        {
            GlobalSettings.onSun = false;
        }
        else
        {
            GlobalSettings.sunIsOut = false;
            GlobalSettings.onSun    = true;
        }

        // If the level is just starting, don't start in the air...
        if (GlobalSettings.levelStarting)
        {
            var startObject = GameObject.Find("SpawnStart");
            if (startObject == null)
            {
                startObject = GameObject.Find("SpawnDefault");
            }


            if (GameObject.Find("Player") == null)
            {
                PlayerSpawn.SpawnPlayer(Player, false, startObject.transform.position);
            }
        }
        else // Otherwise, spawn in the air, because the player will be arriving in the scene from jumping off the other scene...
        {
            // UnityEngine.Debug.Log("Spawning player at scene start");
            PlayerSpawn.SpawnPlayer(Player, false);

            // Spawn the indicator to show the entry point to the scene
            float indicatorYPosition = Camera.main.ViewportToWorldPoint(new Vector3(0f, 0f, 0f)).y;

            // If we're on earth, put the arrow at the top instead of the bottom, and flip the dumb thing over
            if (!GlobalSettings.onMoon)
            {
                indicatorYPosition = Camera.main.ViewportToWorldPoint(new Vector3(1f, 1f, 1f)).y;
                entryArrow         = Instantiate((GameObject)Resources.Load("EntryArrow"), new Vector3(GlobalSettings.xCoordinate, indicatorYPosition), Quaternion.identity);

                Vector3 objectScale = entryArrow.transform.localScale;
                objectScale *= -1;
                entryArrow.transform.localScale = objectScale;
            }

            entryArrow = Instantiate((GameObject)Resources.Load("EntryArrow"), new Vector3(GlobalSettings.xCoordinate, indicatorYPosition), Quaternion.identity);
        }
    }