// Spawn drones from each start location to each destination location void SpawnDrones() { //FIXME: This is an ugly fix for not spawning on each other Vector3 space = new Vector3(0, 0, 70); for (int j = 0; j < drones_per_location; j++) { for (int i = 0; i < spawn_locations.Length; i++) { GameObject droneInstance = (GameObject)Instantiate(drone, spawn_locations[i].position + (space * j), spawn_locations[i].rotation); droneInstance.tag = "Npc"; if (TeamHelper.IsSameTeam(gameObject.layer, 8)) { droneInstance.layer = 8; } else { droneInstance.layer = 11; } // Propagate layer TeamHelper.PropagateLayer(droneInstance, droneInstance.layer); GameObject triggerObject = droneInstance.transform.FindChild("Trigger").gameObject; triggerObject.layer = 3; droneInstance.GetComponent <GunSwitcher>().LayerChanged(); DroneBehaviour behav = droneInstance.GetComponent <DroneBehaviour>(); behav.target = destination[i]; this.networkSyncDroneSpawn(droneInstance); } } }
private void SetObjectLayerRPC(NetworkViewID owner, int objectID, int layer) { //Debug.Log("SetObjectLayerRPC received."); GameObject obj = base.GetObject(owner, objectID); obj.name = "Player_" + layer; obj.layer = layer; TeamHelper.PropagateLayer(obj, layer); }
/// <summary> /// Initializes the server-side objects. /// </summary> private void createServerSideObjects() { Player server = new Player(base.NetworkControl.LocalViewID, Network.player); base.NetworkControl.Players.Add(server.ID, server); base.ObjectTables.AddPlayerTable(server); Debug.Log("Created server player: " + server.ID); Player serverPlayer = base.NetworkControl.ThisPlayer; // Initialize the starting positions of the motherships. Vector3 team1MothershipPos = new Vector3(2000, 0, 0); Vector3 team2MothershipPos = new Vector3(-2000, 0, 0); // Initialize te motherships. GameObject team1Mothership = (GameObject)GameObject.Instantiate( this.MothershipPrefab, team1MothershipPos, Quaternion.identity ); GameObject team2Mothership = (GameObject)GameObject.Instantiate( this.MothershipPrefab, team2MothershipPos, Quaternion.identity ); // Assign teams to the motherships. TeamHelper.PropagateLayer(team1Mothership, (int)Layers.Team1Mothership); TeamHelper.PropagateLayer(team2Mothership, (int)Layers.Team2Mothership); team1Mothership.name = "Team1Mothership"; team2Mothership.name = "Team2Mothership"; // Generate object IDs for the motherships. int team1MothershipID = base.GUIDGenerator.GenerateID(); int team2MothershipID = base.GUIDGenerator.GenerateID(); // Assign some values. ObjectSync team1MSObjSync = team1Mothership.GetComponent <ObjectSync>(); team1MSObjSync.Type = ObjectSyncType.Mothership; team1MSObjSync.AssignID(serverPlayer, team1MothershipID); HealthControl team1MSHealthControl = team1Mothership.GetComponent <HealthControl>(); team1MSHealthControl.DrawHealthInfo = false; ObjectSync team2MSObjSync = team2Mothership.GetComponent <ObjectSync>(); team2MSObjSync.Type = ObjectSyncType.Mothership; team2MSObjSync.AssignID(serverPlayer, team2MothershipID); HealthControl team2MSHealthControl = team2Mothership.GetComponent <HealthControl>(); team2MSHealthControl.DrawHealthInfo = false; base.ObjectTables.AddPlayerObject(serverPlayer, team1MothershipID, team1Mothership); base.ObjectTables.AddPlayerObject(serverPlayer, team2MothershipID, team2Mothership); }
private void CreateDroneRPC(NetworkViewID owner, int objectID, Vector3 position, int layer) { GameObject drone = (GameObject)GameObject.Instantiate(this.AIDronePrefab, position, Quaternion.identity); //ObjectSync objSync = drone.GetComponent<ObjectSync>(); drone.GetComponent <HealthControl>().DrawHealthInfo = false; //drone.GetComponent<DroneBehaviour>().enabled = false; //drone.GetComponent<NpcListUpdater>().enabled = false; //drone.GetComponent<MovingObjectSync>().SuppressVelocitySync = true; TeamHelper.PropagateLayer(drone, layer); base.AddToObjectTables(drone, owner, objectID); }
private void CreatePlayerShipRPC(NetworkViewID playerID, int objectID, NetworkMessageInfo info) { Debug.Log("Create player ship RPC received!"); Player owner = base.NetworkControl.Players[playerID]; // Create the player ship. GameObject playerShip = (GameObject)GameObject.Instantiate(this.PlayerPrefab); TeamHelper.PropagateLayer(playerShip, (int)owner.Team); if (base.NetworkControl.LocalViewID == playerID) { // Set variables for when this ship is controlled by the client receiving the RPC. base.ObjectTables.ThisPlayerObjects.PlayerShipID = objectID; playerShip.GetComponentInChildren <Camera>().enabled = true; } else { // Disable components that mostly has to do with interface and controls for when the // ship is controlled by another player. playerShip.GetComponentInChildren <Camera>().enabled = false; playerShip.GetComponentInChildren <AudioListener>().enabled = false; playerShip.GetComponent <ShipControl>().enabled = false; playerShip.GetComponent <SoftwareMouse>().enabled = false; playerShip.GetComponent <HUD>().enabled = false; playerShip.GetComponent <PlayerHealthControl>().DrawHealthInfo = false; playerShip.GetComponentInChildren <ThirdPersonCrosshair>().enabled = false; } // Set object type. ObjectSync objSync = playerShip.GetComponent <ObjectSync>(); objSync.Type = ObjectSyncType.PlayerShip; // Set spawn point reference. Player player = this.NetworkControl.Players[playerID]; int spawnPointID = this.ObjectTables.PlayerObjects[player].PlayerSpawnPointID; GameObject spawnPoint = this.ObjectTables.GetPlayerObject(player, spawnPointID); playerShip.GetComponent <PlayerHealthControl>().RespawnPoint = spawnPoint.GetComponent <PlayerRespawner>(); spawnPoint.GetComponent <PlayerRespawner>().AttachPlayer(playerShip); // Add to global object tables. base.ObjectTables.PlayerObjects[owner].PlayerShipID = objectID; base.AddToObjectTables(playerShip, playerID, objectID); }
private void CreateMothershipRPC(NetworkViewID owner, int objectID, int layer) { //Debug.Log("Received CreateMothershipRPC"); GameObject motherShip = (GameObject)GameObject.Instantiate(this.MothershipPrefab); motherShip.GetComponent <DroneSpawn>().enabled = false; //motherShip.GetComponent<MovingObjectSync>().SuppressVelocitySync = true; TeamHelper.PropagateLayer(motherShip, layer); if (motherShip.layer == (int)Layers.Team1Mothership) { motherShip.name = "Team1Mothership"; } else if (motherShip.layer == (int)Layers.Team2Mothership) { motherShip.name = "Team2Mothership"; } base.AddToObjectTables(motherShip, owner, objectID); }