// ---------------------------------------------------------------- // Initialize // ---------------------------------------------------------------- public void Initialize(GameController _gameControllerRef, Transform tf_world, RoomData _roomData) { gameControllerRef = _gameControllerRef; MyRoomData = _roomData; this.gameObject.name = MyRoomData.RoomKey; GameUtils.ParentAndReset(this.gameObject, tf_world); this.transform.localPosition = PosGlobal; // Position me! // Initialize channels! gateChannels = new GateChannel[5]; for (int i = 0; i < gateChannels.Length; i++) { gateChannels[i] = new GateChannel(this, i); } // Instantiate my props! RoomData rd = MyRoomData; ResourcesHandler rh = ResourcesHandler.Instance; int numProgressGates = 0; // for deteriming their indexes. int numVeils = 0; // for determining their indexes. foreach (PropData propData in rd.allPropDatas) { System.Type pt = propData.GetType(); if (false) { } // Enemies else if (pt == typeof(DweebData)) { Dweeb newProp = Instantiate(rh.Dweeb).GetComponent <Dweeb>(); newProp.Initialize(this, propData as DweebData); } // Grounds else if (pt == typeof(CrateData)) { Crate newProp = Instantiate(rh.Crate).GetComponent <Crate>(); newProp.Initialize(this, propData as CrateData); } else if (pt == typeof(DispGroundData)) { DispGround newProp = Instantiate(rh.DispGround).GetComponent <DispGround>(); newProp.Initialize(this, propData as DispGroundData); } else if (pt == typeof(GateData)) { Gate newProp = Instantiate(rh.Gate).GetComponent <Gate>(); newProp.Initialize(this, propData as GateData); gateChannels[newProp.ChannelID].AddGate(newProp); } else if (pt == typeof(ToggleGroundData)) { ToggleGround newProp = Instantiate(rh.ToggleGround).GetComponent <ToggleGround>(); newProp.Initialize(this, propData as ToggleGroundData); } else if (pt == typeof(PlatformData)) { Platform newProp = Instantiate(rh.Platform).GetComponent <Platform>(); newProp.Initialize(this, propData as PlatformData); } else if (pt == typeof(GroundData)) { Ground newProp = Instantiate(rh.Ground).GetComponent <Ground>(); newProp.Initialize(this, propData as GroundData); } // Everything else! else if (pt == typeof(BatteryData)) { Battery newProp = Instantiate(rh.Battery).GetComponent <Battery>(); newProp.Initialize(this, propData as BatteryData); } else if (pt == typeof(BuzzsawData)) { Buzzsaw newProp = Instantiate(rh.Buzzsaw).GetComponent <Buzzsaw>(); newProp.Initialize(this, propData as BuzzsawData); } else if (pt == typeof(CharBarrelData)) { CharBarrel newProp = Instantiate(rh.CharBarrel).GetComponent <CharBarrel>(); newProp.Initialize(this, propData as CharBarrelData, charBarrels.Count); charBarrels.Add(newProp); } else if (pt == typeof(CharUnlockOrbData)) { CharUnlockOrb newProp = Instantiate(rh.CharUnlockOrb).GetComponent <CharUnlockOrb>(); newProp.Initialize(this, propData as CharUnlockOrbData); } else if (pt == typeof(CameraBoundsData)) { CameraBounds newProp = Instantiate(rh.CameraBounds).GetComponent <CameraBounds>(); newProp.Initialize(this, propData as CameraBoundsData); } else if (pt == typeof(GateButtonData)) { GateButton newProp = Instantiate(rh.GateButton).GetComponent <GateButton>(); newProp.Initialize(this, propData as GateButtonData); gateChannels[newProp.ChannelID].AddButton(newProp); } else if (pt == typeof(GemData)) { Gem newProp = Instantiate(rh.Gem).GetComponent <Gem>(); newProp.Initialize(this, propData as GemData, gems.Count); gems.Add(newProp); } else if (pt == typeof(InfoSignData)) { InfoSign newProp = Instantiate(rh.InfoSign).GetComponent <InfoSign>(); newProp.Initialize(this, propData as InfoSignData); } else if (pt == typeof(LaserData)) { Laser newProp = Instantiate(rh.Laser).GetComponent <Laser>(); newProp.Initialize(this, propData as LaserData); } else if (pt == typeof(LiftData)) { Lift newProp = Instantiate(rh.Lift).GetComponent <Lift>(); newProp.Initialize(this, propData as LiftData); } else if (pt == typeof(PlayerStartData)) { PlayerStart newProp = Instantiate(rh.PlayerStart).GetComponent <PlayerStart>(); newProp.Initialize(this, propData as PlayerStartData); } else if (pt == typeof(ProgressGateData)) { ProgressGate newProp = Instantiate(rh.ProgressGate).GetComponent <ProgressGate>(); newProp.Initialize(this, propData as ProgressGateData, numProgressGates++); } else if (pt == typeof(RoomDoorData)) { RoomDoor newProp = Instantiate(rh.RoomDoor).GetComponent <RoomDoor>(); newProp.Initialize(this, propData as RoomDoorData); } else if (pt == typeof(SnackData)) { Snack newProp = Instantiate(rh.Snack).GetComponent <Snack>(); newProp.Initialize(this, propData as SnackData, snacks.Count); snacks.Add(newProp); } else if (pt == typeof(SpikesData)) { Spikes newProp = Instantiate(rh.Spikes).GetComponent <Spikes>(); newProp.Initialize(this, propData as SpikesData); } else if (pt == typeof(TurretData)) { Turret newProp = Instantiate(rh.Turret).GetComponent <Turret>(); newProp.Initialize(this, propData as TurretData); } else if (pt == typeof(VeilData)) { Veil newProp = Instantiate(rh.Veil).GetComponent <Veil>(); newProp.Initialize(this, propData as VeilData, numVeils++); } else { Debug.LogWarning("PropData not recognized: " + propData); } } AddHardcodedRoomElements(); // For development, add bounds so we don't fall out of unconnected rooms! AutoAddInvisibounds(); roomGizmos.Initialize(this); shutters.Initialize(this); }