/// <summary> /// Check if you have enough money to spawn the desired ship. /// </summary> /// <param name="money">money existing in bank</param> /// <param name="spawner">ship to spawn cost</param> /// <returns></returns> public bool checkmoney(int money, int spawner) { bool output = false; int pointstodeploy = unitcon.getshipbynumber(spawner).GetComponent <_Ship>().PointsToDeploy; if (pointstodeploy <= money) { output = true; } else { output = false; } int maxships = UnitMovementcommandcontroller.getmaxshipnumbers(); int currentships = unitcon.teammembersout(unitcon.team).Count; if (currentships >= (maxships - 1)) { output = false; } if (unitcon.running == false) { output = false; } if (output) { unitcon.takemoney(pointstodeploy); } if (unitcon.checkiffactiondead(unitcon.team) == true) { output = false; } return(output); }
/// <summary> /// checks if the bot has enough money and is allowed to spawn ship. /// </summary> /// <param name="spawner"> the unit number corresponding to the desired ship to spawn</param> /// <returns>do you have enough money?</returns> public bool checkmoney(int spawner) { bool output = false; GameObject temp = unitcontrol.getshipbynumber(actualshiptobuy); if (temp) { int pointstodeploy = temp.GetComponent <_Ship>().PointsToDeploy; if (pointstodeploy <= money) { output = true; } else { output = false; } int maxships = UnitMovementcommandcontroller.getmaxshipnumbers(); int currentships = unitcontrol.teammembersout(team).Count; if (currentships >= (maxships - 1)) { output = false; } if ((crosslevelvar.campaign == false || (crosslevelvar.campaign == true && crosslevelvar.campaignlevel.objective != MainMenuCampaignControlScript.eMissionObjective.Survive)) && unitcontrol.checkiffactiondead(team) == true) { output = false; } if (output) { money -= pointstodeploy; } } return(output); }
/// <summary> /// initialise on deterministic start. /// </summary> public void StartMain() { mesh = GetComponent <MeshRenderer>(); original = mesh.material; unitcontrol = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>(); parent = transform.parent.GetComponent <_Ship>(); parentpasfinding = transform.parent.GetComponent <CustomPathfinding>(); World = GameObject.Find("WorldScaleBase"); if (transform.parent.Find("Engines")) { engines = transform.parent.Find("Engines").gameObject; } foreach (Transform t in transform.parent) { if (t.gameObject != this.gameObject && t.tag == "Pickup") { foreach (MeshRenderer mesh in t.GetComponentsInChildren <MeshRenderer>()) { parentchildren.Add(mesh); } } } started = true; if (transform.childCount > 0) { linerencontrol = transform.GetChild(0).GetComponent <LineRenderController>(); } }
/// <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); } } } }
/// <summary> /// check if the target gameobject is on the same team as the player. /// </summary> /// <param name="input"></param> /// <returns></returns> GameObject isalliedtarget(GameObject input) { if (UnitMovementcommandcontroller.getteam(input.GetComponent <_Ship>().ShipColor, unitcon.crosslevelholder.Gamemode) == UnitMovementcommandcontroller.getteam(unitcon.team, unitcon.crosslevelholder.Gamemode)) { return(pulsewave); } else { return(pulsewavered); } }
/// <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()); } }
/// <summary> /// Update the Reasource count. /// </summary> void Update() { if (Reasourcesthing) { if (unitcon == null) { unitcon = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>(); } if (reasourcestextmesh == null) { reasourcestextmesh = Reasourcesthing.GetComponent <TextMesh>(); } if (unitcon) { reasourcestextmesh.text = "Resources : " + unitcon.getmoney(); } } }
/// <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>(); } }
/// <summary> /// The initialisation function, transfers variables from the _shipscript and initialises everything else. /// </summary> public void Start() { World = GameObject.Find("World"); shipscript = GetComponent <_Ship>(); acceleration = 4; turnspeed = shipscript.MaxAngularSpeed; transformts = GetComponent <TSTransform>(); unitcom = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>(); waitforpushaway = (int)shipscript.MaxAngularSpeed % 5; int i = 0; foreach (Transform gam in transform) { if (gam.name == "Ship") { startmeshpos.Add(gam.transform.localPosition); Vector3 starttrans = gam.transform.localPosition; starttrans.z = Mathf.Lerp(-3000, startmeshpos[i].z, 1); gam.transform.localPosition = starttrans; i++; } } }
/// <summary> // checks if it can buy ship and if so, buys ship. /// <summary> void BuyShip() { addmoney(increaserate); if (actualshiptobuy == 0) { NextBuy = randominst.Next(0, 200); actualshiptobuy = getshiptobuy(NextBuy); if (unitcontrol.getshipbynumber(actualshiptobuy) != null) { NextBuyCost = unitcontrol.getshipbynumber(actualshiptobuy).GetComponent <_Ship>().PointsToDeploy; } } if (PhotonNetwork.isMasterClient && unitcontrol && checkmoney(money)) { TSVector spawnpos = startpos; if (unitcontrol.teammembersout(team).Count != 0) { spawnpos = PositinonRelativeToHeadset.getspawnpos(team); } if (crosslevelvar.campaign == true && crosslevelvar.campaignlevel.objective == MainMenuCampaignControlScript.eMissionObjective.Survive) { spawnpos = startpos; } if (InputRelay == null) { InputRelay = GameObject.Find("TrueSyncManager").GetComponent <RelayController>(); } if (InputRelay != null) { InputRelay.ordershipspawn(actualshiptobuy, spawnpos, UnitMovementcommandcontroller.findspawnteamreverse(team), PhotonNetwork.AllocateViewID()); } lastbuy = actualshiptobuy; actualshiptobuy = 0; } }
/// <summary> /// The level Function called on a level starting, checks what the situation is and updates everything based on that. /// </summary> /// <param name="scene"></param> /// <param name="scenemode"></param> void OnLevelFinishedLoading(Scene scene, LoadSceneMode scenemode) { if (SceneManager.GetActiveScene().buildIndex != 0 && SceneManager.GetActiveScene().buildIndex != 1) { Objectsholder = GameObject.Find("Objects"); unitcontrol = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>(); waitforit = 0; if (PhotonNetwork.room != null) { Debug.Log(PhotonNetwork.room.MaxPlayers); if (Blue) { Green.gameObject.SetActive(true); Blue.gameObject.SetActive(true); White.gameObject.SetActive(true); Yellow.gameObject.SetActive(true); Grey.gameObject.SetActive(true); Red.gameObject.SetActive(true); if (PhotonNetwork.room.MaxPlayers == 2) { Blue.gameObject.SetActive(false); White.gameObject.SetActive(false); Grey.gameObject.SetActive(false); Red.gameObject.SetActive(false); } if (PhotonNetwork.room.MaxPlayers == 4 && (string)PhotonNetwork.room.CustomProperties["3v3"] == "No") { White.gameObject.SetActive(false); Red.gameObject.SetActive(false); } } } } }
/// <summary> // called every second to update the AIs orders to adapt to the situation. /// <summary> public void GiveOrderwait(int waittime) { if (TrueSyncManager.Time > 0 && randominst != null) { ships.Clear(); ships = unitcontrol.teammembersout(team); List <TSTransform> temp = unitcontrol.targetsout(team); List <GameObject> removableships = new List <GameObject>(); List <TSTransform> enemyremovable = new List <TSTransform>(); foreach (GameObject ship in ships) { if (ship == null || ship.gameObject == null) { removableships.Add(ship); } } foreach (GameObject remov in removableships) { ships.Remove(remov); } foreach (TSTransform ship in temp) { if (ship == null || ship.gameObject == null) { enemyremovable.Add(ship); } } foreach (TSTransform remov in enemyremovable) { temp.Remove(remov); } debugmaxcount = ships.Count.ToString() + " out of " + UnitMovementcommandcontroller.getmaxshipnumbers().ToString(); if (startpos == new TSVector(0, 0, 0) && ships.Count > 0) { startpos = ships[0].GetComponent <TSTransform>().position + new TSVector(1, 0, 0); } Target = getclosesttarget(); if (((ismission == false && ships.Count > 0) || (crosslevelvar.campaign == true && crosslevelvar.campaignlevel.objective == MainMenuCampaignControlScript.eMissionObjective.Survive)) && unitcontrol) { BuyShip(); } if (temp.Count != 0) { enemyships = temp.ToArray(); } if (ships != null && ships.Count != 0 && ships.Count > 4) { state = AIstate.attacking; } if (ships != null && ships.Count != 0 && ships.Count <= 3) { state = AIstate.retreating; } if (ships != null && ships.Count != 0 && ships.Count > 2 && ships.Count < 4) { state = AIstate.maintain; } if (ships != null && ships.Count != 0 && state == AIstate.retreating && TSVector.Distance(ships[0].GetComponent <TSTransform>().position, startpos) < 1000) { state = AIstate.holding; } if (ships != null && ships != null && ships.Count != 0 && ships[0] && Target != null && ships[0].gameObject != null && state == AIstate.holding && TSVector.Distance(ships[0].GetComponent <TSTransform>().position, Target.GetComponent <TSTransform>().position) < 1000) { state = AIstate.attacking; } if (ships != null && ships.Count != 0 && state == AIstate.maintain && ships.Count > 0 && TSVector.Distance(ships[0].GetComponent <TSTransform>().position, startpos) < 1000) { state = AIstate.retreating; } if (ships != null && ships.Count != 0 && state == AIstate.maintain && ships.Count > 0 && TSVector.Distance(ships[0].GetComponent <TSTransform>().position, startpos) > 1000) { state = AIstate.attacking; } if (ismission && timepassedactual > 30) { state = AIstate.attacking; } if (ismission && timepassedactual < 30) { state = AIstate.holding; } if (ismission && unitcontrol.crosslevelholder.campaignlevel.objective == MainMenuCampaignControlScript.eMissionObjective.Survive) { state = AIstate.attacking; } int i = 0; foreach (GameObject ship in ships) { if (Target != null && ship.gameObject != null && state == AIstate.attacking) { ship.GetComponent <_Ship>().asignMoveOrder(Target.GetComponent <TSTransform>().position, Target.gameObject, RightHand_triggerInstantOrder.calculate_average_speed(ships.ToArray()), false); } if (ship.gameObject != null && state == AIstate.retreating) { ship.GetComponent <_Ship>().asignMoveOrder(TargetPosition(i, startpos, ships.Count), null, RightHand_triggerInstantOrder.calculate_average_speed(ships.ToArray()), false); } if (ship.gameObject != null && state == AIstate.holding) { _Ship shipscript = ship.GetComponent <_Ship>(); if (shipscript.HullType == eHullType.Light) { shipscript.asignMoveOrder(startpos, null, RightHand_triggerInstantOrder.calculate_average_speed(ships.ToArray()), false); } else { shipscript.asignMoveOrder(ship.GetComponent <TSTransform>().position, null, RightHand_triggerInstantOrder.calculate_average_speed(ships.ToArray()), false); } } i++; } } }
/// <summary> // checks if target is in range and the same team. /// <summary> void fireweaponcheckshield() { if (TSVector.Distance(parentscript.WeaponTarget.GetComponent <TSTransform>().position, parentscript.fac.transformts.position) < Range && UnitMovementcommandcontroller.getteam(parentscript.WeaponTarget.shipscript.ShipColor, unittargetcontrol.crosslevelholder.Gamemode) == UnitMovementcommandcontroller.getteam(parentscript.ShipColor, unittargetcontrol.crosslevelholder.Gamemode)) { fireweapon(parentscript.WeaponTarget.transform.position); } else { parentscript.WeaponTarget = null; } }
/// <summary> // Deterministic Update /// <summary> public void SpecUpdate() { timelefttilorder++; timepassedactual += TrueSyncManager.DeltaTime; if (timelefttilorder > 50 && ismission && PhotonNetwork.isMasterClient && shipstartspawn.Count > 0) { shipsmissionspawned++; TSVector spawnpos = PositinonRelativeToHeadset.getspawnpos(team); if (crosslevelvar.campaignlevel.objective == MainMenuCampaignControlScript.eMissionObjective.Survive) { spawnpos = startpos; } if (spawnpos == new TSVector(0, 0, 0)) { spawnpos = defaultspawnpos; } if (InputRelay == null) { InputRelay = GameObject.Find("TrueSyncManager").GetComponent <RelayController>(); } if (InputRelay != null) { InputRelay.ordershipspawn(shipstartspawn[0], (defaultspawnpos * 500) + new TSVector(0, 0, shipsmissionspawned * 1000), UnitMovementcommandcontroller.findspawnteamreverse(team), PhotonNetwork.AllocateViewID()); } shipstartspawn.RemoveAt(0); } }
/// <summary> /// Repeats every second to update the minimap. /// </summary> void Rep() { if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 0 && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 1) { if (Blue) { // give the player an indicator or how many ships each color owns and the player name assosiated with those ships. if (Green.gameObject.GetActive() == true) { Green.text = getplayername(LobbyScreenController.getteam1(), 0) + "Green: " + unitcontrol.teammembersout(_Ship.eShipColor.Green).Count + " ships"; } if (Blue.gameObject.GetActive() == true) { Blue.text = getplayername(LobbyScreenController.getteam1(), 1) + "Blue: " + unitcontrol.teammembersout(_Ship.eShipColor.Blue).Count + " ships"; } if (White.gameObject.GetActive() == true) { White.text = getplayername(LobbyScreenController.getteam1(), 2) + "White: " + unitcontrol.teammembersout(_Ship.eShipColor.White).Count + " ships"; } if (Yellow.gameObject.GetActive() == true) { Yellow.text = getplayername(LobbyScreenController.getteam2(), 0) + "Yellow: " + unitcontrol.teammembersout(_Ship.eShipColor.Yellow).Count + " ships"; } if (Grey.gameObject.GetActive() == true) { Grey.text = getplayername(LobbyScreenController.getteam2(), 1) + "Grey: " + unitcontrol.teammembersout(_Ship.eShipColor.Grey).Count + " ships"; } if (Red.gameObject.GetActive() == true) { Red.text = getplayername(LobbyScreenController.getteam2(), 2) + "Red: " + unitcontrol.teammembersout(_Ship.eShipColor.Red).Count + " ships"; } } if (unitcontrol == null) { unitcontrol = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>(); } // moves unused blips out of view. foreach (bliplinecontroller blip in allyblips) { blip.transform.localPosition = new Vector3(100000, 100000, 100000); } foreach (bliplinecontroller blip in enemyblips) { blip.transform.localPosition = new Vector3(100000, 100000, 100000); } foreach (bliplinecontroller blip in allyblips) { blip.targetgam = new Vector3(0, 0, 0); } List <GameObject> temp = unitcontrol.teammembersout(unitcontrol.team); if (temp != null && Ships_Left_Text != null) { Kills_Text.text = " ships : " + temp.Count.ToString() + " out of " + UnitMovementcommandcontroller.getmaxshipnumbers().ToString(); List <TSTransform> enemies = unitcontrol.targetsout(unitcontrol.team); for (int i = 0; i < enemies.Count; i++) { if (enemyblips[i] != null && enemyblips[i].gameObject != null && enemies[i] != null && enemies[i].gameObject != null) { enemyblips[i].transform.localPosition = new Vector3(0, enemies[i].transform.localPosition.x * 0.35f, enemies[i].transform.localPosition.z * 0.35f); } } } if (Time_Left_Text && ismission == false) { Time_Left_Text.text = unitcontrol.gettimeleft(); } else if (AIController && AIController.timepassedactual < 30) { Time_Left_Text.text = "Time til attack: " + (30 - TSMath.Round(AIController.timepassedactual)).ToString(); } else if (unitcontrol.crosslevelholder.campaign == true && unitcontrol.crosslevelholder.campaignlevel.objective == MainMenuCampaignControlScript.eMissionObjective.Survive) { Time_Left_Text.text = "Survive for: " + unitcontrol.gettimeleft(); } else if (Time_Left_Text) { Time_Left_Text.text = unitcontrol.gettimeleft(); } List <TSTransform> allies = unitcontrol.alliesout(); for (int i = 0; i < allies.Count; i++) { if (allyblip && allyblips[i].gameObject != null) { // asigns blip positions allyblips[i].source = allies[i]; allyblips[i].transform.localPosition = new Vector3(0, allies[i].transform.localPosition.x * 0.35f, allies[i].transform.localPosition.z * 0.35f); Vector3 tempa = allies[i].shipscript.fac.localtarget.ToVector() * 0.35f; allyblips[i].targetgam = new Vector3(0, tempa.x, tempa.z); } } if (Objectsholder == null) { Objectsholder = GameObject.Find("Objects"); } if (Cameratracking == null) { if (GameObject.Find("Camera (eye)") != null) { Cameratracking = GameObject.Find("Camera (eye)"); } else { Cameratracking = GameObject.Find("CenterEyeAnchor"); } } Vector3 playerloc = Objectsholder.transform.InverseTransformPoint(Cameratracking.transform.position); playerblip.transform.localPosition = new Vector3(0, playerloc.x * 0.35f, playerloc.z * 0.35f); } }
/// <summary> // deterministic start. /// <summary> public void StartMain(int inputint) { started = true; i = inputint; startcount = 0; customran = TSRandom.New(transform.parent.GetComponent <PhotonView>().viewID + inputint); parentscript = transform.parent.GetComponent <_Ship>(); if (guntypemain == guntype.EngineUpgrade) { parentscript.MaxSpeed = parentscript.MaxSpeed * 1.15f; } if (guntypemain == guntype.HPUpgrade) { parentscript.Armor = Mathf.RoundToInt(parentscript.Armor * 1.15f); } if (guntypemain == guntype.WeaponUpgrade) { foreach (Transform gun in transform.parent) { if (gun.tag == "Pickup") { _Weapon gunwep = gun.GetComponent <_Weapon>(); gunwep.timebetweenshots = gunwep.timebetweenshots * 1.15; } } } if (guntypemain == guntype.Cloak) { parentscript.iscloacked = true; } if (guntypemain == guntype.Tracker) { parentscript.isTracker = true; } unittargetcontrol = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>(); poolmanager = GameObject.Find("F3dPoolManager").GetComponent <F3DPoolManager>(); team = parentscript.ShipColor; if (verticalmovechild == null && transform.childCount > 0 && transform.GetChild(0).childCount > 0) { verticalmovechild = transform.GetChild(0).GetChild(0).gameObject; } _Ship parent = transform.parent.GetComponent <_Ship>(); if (Cannon_Projectile != null) { parent.Cannon_Projectile = Cannon_Projectile; } if (Missile_Projectile != null) { parent.Missile_Projectile = Missile_Projectile; } if (MiniGun_Projectile != null) { parent.MiniGun_Projectile = MiniGun_Projectile; } if (Lazer_Proectile != null) { parent.Lazer_Shot = Lazer_Proectile; } parent.shieldmaterial = shieldmatgam; damage = Calculate_damage(); audiosource = GetComponent <AudioSource>(); WorldBase = GameObject.Find("WorldScaleBase"); timepassed = 0; }