Example #1
0
 /// <summary>
 /// Reset everything when the level finishes loading.
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="scenemode"></param>
 void OnLevelFinishedLoading(Scene scene, LoadSceneMode scenemode)
 {
     if (this != null && this.gameObject != null && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 0 && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 1 && SceneManager.GetActiveScene().buildIndex != 5 && SceneManager.GetActiveScene().buildIndex != 6)
     {
         if (GameObject.Find("CrossLevelVariables") != null)
         {
             crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
         }
         if (crossvar.tutorial == true)
         {
             if (GameObject.Find("TutorialPanelHolder"))
             {
                 tutcontrol = GameObject.Find("TutorialPanelHolder").GetComponent <TutorialTextControlScript>();
             }
         }
         World = GameObject.Find("World");
         floor = GameObject.Find("Floor");
         if (floor)
         {
             floor.SetActive(false);
         }
         ontriggerenter = GetComponent <onTriggerEnterEnemy>();
         lineren        = gameObject.GetComponent <LineRenderer>();
         if (lineren == null)
         {
             lineren = gameObject.AddComponent <LineRenderer>();
         }
         lineren.startWidth = 0.01f;
         lineren.endWidth   = 0.01f;
         lineren.enabled    = false;
         lineren.material   = linemat;
     }
 }
 /// <summary>
 /// Initialisation.
 /// </summary>
 void Start()
 {
     locview  = GetComponent <PhotonView>();
     locaudio = GetComponent <AudioSource>();
     SceneManager.sceneLoaded += OnLevelFinishedLoading;
     GameObject[] voices = GameObject.FindGameObjectsWithTag("Voice");
     foreach (GameObject voice in voices)
     {
         if (voice.GetComponent <PhotonView>().owner == PhotonNetwork.player)
         {
             localplayer = voice.GetComponent <PlayerPrefabVoiceControlScript>();
         }
     }
     OnLevelFinishedLoading(SceneManager.GetActiveScene(), new LoadSceneMode());
     if (locview.isMine == true)
     {
         foreach (MeshRenderer mesh in GetComponentsInChildren <MeshRenderer>())
         {
             mesh.enabled = false;
         }
     }
     if (GameObject.Find("CrossLevelVariables"))
     {
         crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
     }
 }
Example #3
0
    /// <summary>
    /// Reset everything when nessesitated by the level loading.
    /// </summary>
    /// <param name="scene"></param>
    /// <param name="scenemode"></param>
    void OnLevelFinishedLoading(Scene scene, LoadSceneMode scenemode)
    {
        if (this != null && this.gameObject != null)
        {
            selectedships.Clear();
            if (oculuscam != null && oculuscam.gameObject != null && oculuscam.GetActive() == true)
            {
                cameramain = oculuscam.GetComponent <Camera>();
            }
            if (Vivecam != null && Vivecam.gameObject != null && Vivecam.GetActive() == true)
            {
                cameramain = Vivecam.GetComponent <Camera>();
            }
            if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex == 0 || UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex == 1)
            {
                resetallpos();
            }
            else
            {
                GameObject.Find("VRTK_SDK").transform.localPosition = new Vector3(0, 0, 0);
            }

            if (this != null && this.gameObject != null && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 0 && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 1 && SceneManager.GetActiveScene().buildIndex != 5 && SceneManager.GetActiveScene().buildIndex != 6)
            {
                GameObject varhold = GameObject.Find("CrossLevelVariables");
                if (varhold)
                {
                    crosslevelvarhol = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
                }
                if (crosslevelvarhol.tutorial == true)
                {
                    if (GameObject.Find("TutorialPanelHolder"))
                    {
                        tutcontrol = GameObject.Find("TutorialPanelHolder").GetComponent <TutorialTextControlScript>();
                    }
                }

                unitcon    = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>();
                photonview = GameObject.Find("JoinMultiplayer").GetComponent <PhotonView>();// establish tracking
                selectAll();
                lineren.enabled   = false;
                vrtkcontrolevents = GetComponent <VRTK_ControllerEvents>();
                team           = GameObject.Find("JoinMultiplayer").transform.parent.GetComponent <UnitMovementcommandcontroller>().team;
                ontriggerenter = GetComponent <onTriggerEnterEnemy>();
                tutorial       = GameObject.Find("TutorialPanelHolder");

                if (varhold && varhold.GetComponent <CrossLevelVariableHolder>().tutorial == false)
                {
                    tutorial.SetActive(false);
                    tutorial = null;
                }
                else
                {
                    tutorial.SetActive(true);
                }
            }
        }
    }
 /// <summary>
 /// Reset after a level loads and apopulate variables.
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="scenemode"></param>
 void OnLevelFinishedLoading(Scene scene, LoadSceneMode scenemode)
 {
     if (Reasourcesthing && reasourcestextmesh == null)
     {
         reasourcestextmesh = Reasourcesthing.GetComponent <TextMesh>();
     }
     if (GameObject.Find("Controllers") != null)
     {
         if (GameObject.Find("Controllers"))
         {
             unitcon = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>();
         }
         if (GameObject.Find("CrossLevelVariables"))
         {
             crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
         }
     }
     if (this != null && this.gameObject != null && scene.name != null)
     {
         this.gameObject.SetActive(false);
     }
     if (this != null && this.gameObject != null && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 0 && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 1 && SceneManager.GetActiveScene().buildIndex != 5 && SceneManager.GetActiveScene().buildIndex != 6)
     {
         unitcon  = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>();
         crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
     }
     if (Fighters != null)
     {
         Fighters.SetActive(true);
         Frigates.SetActive(true);
         Special.SetActive(true);
         if (crossvar.campaign == true)
         {
             if (crossvar.campaignlevel.shipsavaiable == MainMenuCampaignControlScript.eshipsavailable.fighers)
             {
                 Fighters.SetActive(true);
                 Frigates.SetActive(false);
                 Special.SetActive(false);
             }
             else if (crossvar.campaignlevel.shipsavaiable == MainMenuCampaignControlScript.eshipsavailable.frigates)
             {
                 Fighters.SetActive(true);
                 Frigates.SetActive(true);
                 Special.SetActive(false);
             }
             else if (crossvar.campaignlevel.shipsavaiable == MainMenuCampaignControlScript.eshipsavailable.all)
             {
                 Fighters.SetActive(true);
                 Frigates.SetActive(true);
                 Special.SetActive(true);
             }
         }
     }
 }
 void Start()
 {
     if (PhotonNetwork.connectedAndReady)
     {
         crosslevelholder = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
     }
     OnActive();
     // Get the game controller
     _gc          = GameObject.FindObjectOfType <GameController>();
     simObject    = this.GetComponent <DFNetwork.Simulation.SimulationLayer>();
     FleetBuilder = IORoot.findIO("fleet1");
     FleetBuilder.read();
 }
 /// <summary>
 /// Reset things upon level load.
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="scenemode"></param>
 void OnLevelFinishedLoading(Scene scene, LoadSceneMode scenemode)
 {
     if (this != null && this.gameObject != null)
     {
         locview  = GetComponent <PhotonView>();
         locaudio = GetComponent <AudioSource>();
         if (locview)
         {
             locview.onSerializeTransformOption = OnSerializeTransform.All;
         }
         transformview = GetComponent <PhotonTransformView>();
         if (locview)
         {
             locview.World = GameObject.Find("Objects");
         }
         if (transformview)
         {
             transformview.World = GameObject.Find("Objects");
         }
         if (scene.name != "mptest")
         {
             curchannel     = VoiceChannel.All;
             locview.ingame = false;
         }
         else
         {
             if (crossvar == null)
             {
                 if (GameObject.Find("CrossLevelVariables"))
                 {
                     crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
                 }
             }
             if (crossvar.Gamemode == CrossLevelVariableHolder.gamemode.TeamDeathMatch || crossvar.Gamemode == CrossLevelVariableHolder.gamemode.CapitalShip)
             {
                 curchannel = VoiceChannel.TeamOnly;
             }
             else
             {
                 curchannel = VoiceChannel.All;
             }
             if (PhotonNetwork.playerList.Length == 2)
             {
                 curchannel = VoiceChannel.All;
             }
             locview.ingame = true;
         }
     }
 }
 void OnLevelFinishedLoading(Scene scene, LoadSceneMode inputmode)
 {
     if (scene.buildIndex == 0)
     {
         testarea = false;
         tutorial = false;
         campaign = false;
         if (GameObject.Find("CrossLevelVariables") != null)
         {
             CrossLevelVariableHolder crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
             crossvar.tutorial = false;
             crossvar.campaign = false;
         }
     }
 }
 /// <summary>
 /// Check if you can spawn something and if so send a build order to the inputrelay.
 /// </summary>
 /// <param name="a">spawn ship int</param>
 /// <param name="name">ship name</param>
 /// <param name="timetospawn">time taken to spawn</param>
 public void spawnship(int a, string name, float timetospawn)
 {
     if (a != 0)
     {
         if (unitcon == null)
         {
             unitcon  = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>();
             crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
         }
         if (checkmoney(unitcon.getmoney(), a) == true)
         {
             bulcontrol.addbuildorder(new BuildQueController.buildorder(name, a, 1, timetospawn));
         }
     }
 }
 /// <summary>
 /// Given order immidately after the countdown ends.
 /// </summary>
 /// <param name="a">The ship to spawn</param>
 public void spawnshiprightnow(int a)
 {
     if (InputRelay == null)
     {
         InputRelay = GameObject.Find("TrueSyncManager").GetComponent <RelayController>();
     }
     if (unitcon == null)
     {
         unitcon  = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>();
         crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
     }
     if (InputRelay != null)
     {
         InputRelay.ordershipspawn(a, getspawnpos(unitcon.team), crossvar.findspawnpos(PhotonNetwork.player.ID), PhotonNetwork.AllocateViewID());
     }
 }
Example #10
0
    /// <summary>
    // initializes deterministic start.
    /// <summary>
    public void StartMain(int randominput)
    {
        int a = UnitMovementcommandcontroller.findspawnteamreverse(team);

        unitcontrol   = transform.parent.GetComponent <UnitMovementcommandcontroller>();
        crosslevelvar = unitcontrol.crosslevelholder;
        increaserate  = getaimoneyamount(crosslevelvar.botdifficulty, unitcontrol.moneyincreaserate).AsInt();
        if (unitcontrol.crosslevelholder.campaign == true && unitcontrol.crosslevelholder.campaignlevel.objective == MainMenuCampaignControlScript.eMissionObjective.Survive && unitcontrol.crosslevelholder.campaignlevel.name == "Final Assault")
        {
            increaserate = 80;
        }
        else if (unitcontrol.crosslevelholder.campaign == true && unitcontrol.crosslevelholder.campaignlevel.objective == MainMenuCampaignControlScript.eMissionObjective.Survive)
        {
            increaserate = 70;
        }
        World       = GameObject.Find("World").transform.Find("Objects").gameObject;
        state       = AIstate.attacking;
        debugseed   = 5 + a + randominput;
        randominst  = TSRandom.New(debugseed);
        startpos    = new TSVector(0, 0, 0);
        spawnerhold = a;
    }
    /// <summary>
    /// Initialise the menu position upon turning it on.
    /// </summary>
    public void TurnOn()
    {
        GameObject actualcamobj = null;

        if (cam1 != null && cam1.gameObject != null && cam1.GetActive() == true)
        {
            actualcamobj = cam1;
        }
        else if (cam2 != null && cam2.gameObject != null && cam2.GetActive() == true)
        {
            actualcamobj = cam2;
        }
        transform.position = CameraObj.transform.position;
        //    transform.localPosition = new Vector3(transform.localPosition.x, 0, transform.localPosition.z);
        transform.LookAt(actualcamobj.transform.position);
        transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
        if (unitcon == null)
        {
            unitcon  = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>();
            crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
        }
    }
    // Spawn objects
    private void SpawnObjects(bool bot, int a, int spawnfleet)
    {
        Debug.Log(a);

        if ((bot && crosslevelholder.bots == true && crosslevelholder.TestArea == false && crosslevelholder.campaign == false) || (bot == false && alreadyspawned == false))
        {
            if (bot == false)
            {
                alreadyspawned = true;
            }
            Spawned = true;
            Debug.Log("Joined room \"" + PhotonNetwork.room.Name + "\"");
            if (PhotonNetwork.isMasterClient && PhotonNetwork.offlineMode == false)
            {
                PhotonNetwork.room.IsOpen = true;
            }
            CrossLevelVariableHolder crosslevelvarholder = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>();
            _gc.convertspawnpoints(crosslevelvarholder.Gamemode);
            Vector3          spawnLocation = spawnpoint(_gc, a);
            Quaternion       lookDirection = Quaternion.identity;
            _Ship.eShipColor ShipColor     = getspawncolor(a);
            string           jsonFile      = "TestFleet.json";
            string           supercap      = "Super-Capital";

            savefleetform2(loadshipsform1(spawnfleet));

            Vector3 relPos = Vector3.zero - spawnLocation;
            lookDirection = Quaternion.LookRotation(relPos);
            fleetFileSerializer handl = fleetFileSerializer.Load(jsonFile);
            Debug.Log("Loaded \"" + jsonFile + "\" with the fleet named \"" + handl.FleetName + "\"");
            Debug.Log(handl.Ships.Count);
            if (bot && crosslevelholder.tutorial == false)
            {
                spawnbotcontroller(ShipColor);
            }
            float i = 0;
            foreach (fleetFileSerializer.Ship shp in handl.Ships)
            {
                if (shp.Type != "nothing")
                {
                    Debug.Log(shp.Type);
                    int viewID   = PhotonNetwork.AllocateViewID();
                    int playerID = PhotonNetwork.player.ID;
                    GetModule <MOD_SpawnObject>("Spawn Object").SendSpawnObject(shp.Type, (spawnLocation + new Vector3(0, 0, i)), lookDirection, viewID);
                    if (crosslevelholder.tutorial == false || bot == true)
                    {
                        pv.RPC("fixturrets", PhotonTargets.All, viewID, shp.Weapon1, shp.Weapon2, shp.Weapon3, shp.Weapon4, shp.Weapon5, shp.WeaponPos1, shp.WeaponPos2, shp.WeaponPos3, shp.WeaponPos4, shp.WeaponPos5, shp.WeaponScale1, shp.WeaponScale2, shp.WeaponScale3, shp.WeaponScale4, shp.WeaponScale5, a, bot, (spawnLocation * 1000) + new Vector3(0, 0, i * 1000));
                    }
                    else
                    {
                        pv.RPC("fixturrets", PhotonTargets.All, viewID, shp.Weapon1, shp.Weapon2, shp.Weapon3, shp.Weapon4, shp.Weapon5, shp.WeaponPos1, shp.WeaponPos2, shp.WeaponPos3, shp.WeaponPos4, shp.WeaponPos5, shp.WeaponScale1, shp.WeaponScale2, shp.WeaponScale3, shp.WeaponScale4, shp.WeaponScale5, a, bot, new Vector3(0, 0, i * 100) + new Vector3(1, 1, 1));
                    }
                    i++;
                }
            }
            int viewID2 = PhotonNetwork.AllocateViewID();
            StartCoroutine("Waitforread");
            if (crosslevelholder.Gamemode == CrossLevelVariableHolder.gamemode.CapitalShip)
            {
                GetModule <MOD_SpawnObject>("Spawn Object").SendSpawnObject(supercap, ((spawnLocation * 1000) + new Vector3(0, 0, i * 1000)), lookDirection, viewID2);
                pv.RPC("fixShip", PhotonTargets.All, viewID2, a, (spawnLocation * 1000) + new Vector3(0, 0, i * 1000));
            }
        }
        if (bot && crosslevelholder.campaign == true)
        {
            _Ship.eShipColor ShipColor = getspawncolor(a);
            Debug.Log(ShipColor);
            AIController gam = spawnbotcontroller(ShipColor);
            _gc.convertspawnpoints(CrossLevelVariableHolder.gamemode.TeamDeathMatch);
            gam.setmission(crosslevelholder.campaignlevel, (spawnpoint(_gc, a)).ToTSVector());
        }
    }