void Start() { gameController = GameObject.Find("GameController"); player = GameObject.Find("Player"); tutorialManager = gameController.GetComponent <TutorialManager>(); mapManager = gameController.GetComponent <ManageMap>(); uiController = gameController.GetComponent <UIControl>(); resourceAndUpgradeManager = gameController.GetComponent <ResourceAndUpgradeManager>(); abilityController = player.GetComponent <AbilityController>(); movementController = player.GetComponent <MovementController>(); playerHealthControl = player.GetComponent <PlayerHealthControl>(); firstTurn = false; combatActive = false; }
//The below value is used in another method to set the rotation of this object //private float rotAngle; // Start is called before the first frame update void Awake() { player = GameObject.FindGameObjectWithTag("Player"); //Access and store a reference to the player game object playerHealthControl = player.GetComponent <PlayerHealthControl>(); gridLayout = GameObject.Find("Grid").GetComponent <GridLayout>(); //Access and store a reference to the grid layout target = gridLayout.CellToWorld(player.GetComponent <MovementController>().playerCellPosition); //set the target position equal to the position of the mouse pointer timer = 0; //set the initial value of the timer that tracks the life of the laser animation SetRotation(); //Call the function that will orient this object in the direction of the target. laserSprite = gameObject.GetComponent <SpriteRenderer>(); //Access and store a reference to the sprite renderer so it can be used to set the length and width of the laser laserLength = Vector3.Distance(player.transform.position, transform.position); //Set the laser length equal to the distance between the player and the target laserSprite.size = new Vector2(0.1f, laserLength - 0.1f); //Set the size of the x and y components of the laser sprite. The width of the laser sprite is set as a fixed value while the length is determined based on the distance between the player and the target. A small amount is subtracted from the legth so the laser appears to hit the outside of the target instead of the center. //The below operations were an attempt to set the angle in a different way from what is done. It was not successful, but may be a better way to do it if you can figure out how to get it to work //rotAngle = Vector2.SignedAngle(Vector2.right,target.transform.position- transform.position); //transform.eulerAngles=new Vector3(0, 0, rotAngle*Mathf.Rad2Deg); }
// Start is called before the first frame update void Awake() { player = GameObject.FindGameObjectWithTag("Player"); //Access and store a reference to the player game object gameController = GameObject.Find("GameController"); //Access and store a reference to the player game object abilityController = player.GetComponent <AbilityController>(); movementController = player.GetComponent <MovementController>(); playerHealthControl = player.GetComponent <PlayerHealthControl>(); resourceAndUpgradeManager = gameController.GetComponent <ResourceAndUpgradeManager>(); mapManager = gameController.GetComponent <ManageMap>(); uiController = gameController.GetComponent <UIControl>(); gridLayout = GameObject.Find("Grid").GetComponent <GridLayout>(); //Access and store a reference to the grid layout turnManager = gameController.GetComponent <TurnManager>(); target = gridLayout.CellToWorld(player.GetComponent <AbilityController>().target); turnsAlive = 0; turnDelay = 1; alreadyUsed = false; rocketYield = resourceAndUpgradeManager.CurrentMaxRocketYield; SetRotation(); //Call the function that will orient this object in the direction of the target. Debug.Log("Rocket reporting in"); }
// Start is called before the first frame update void Start() { ThreatLevel = 0; player = GameObject.Find("Player"); abilityController = player.GetComponent <AbilityController>(); playerHealthControl = player.GetComponent <PlayerHealthControl>(); movementController = player.GetComponent <MovementController>(); gameController = GameObject.Find("GameController"); uiController = gameController.GetComponent <UIControl>(); mapManager = gameController.GetComponent <ManageMap>(); tutorialManager = gameController.GetComponent <TutorialManager>(); uiController.SetResourceCount(resources); gridlayout = GameObject.Find("Grid").GetComponent <GridLayout>(); highScoreObjectList = new List <HighScoreObject>() { new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0), new HighScoreObject("AAA", 0) }; if (mapManager.saveName == "TutorialFile") { resourceAndUpgradeDataSaveFileName = "tutorialResourceAndUpgradeDataSaveFile"; } if (QuickSaveRoot.Exists(resourceAndUpgradeDataSaveFileName)) //use the quicksave feature to check if a save file exists { LoadResourceAndUpgradeData(); //if a save file exists, call the load function } else { playerHealthControl.RestoreHealth(); playerHealthControl.RestoreShields(); abilityController.laserRange = currentMaxLaserRange; uiController.SetLaserCharge(abilityController.laserRange, currentMaxLaserRange); } LoadHighScores(); }
// Start is called before the first frame update void Awake() { gridLayout = GameObject.Find("Grid").GetComponent <GridLayout>(); //Access and store the GridLayout component enemyCellPosition = gridLayout.WorldToCell(transform.position); //Get this enemy's cell position and convert it to the nearest hex coordinates. This is the first half of an operation to center this object in it's position in the hex grid transform.position = gridLayout.CellToWorld(enemyCellPosition); //Take the hex grid position from the last operation, convert it back to world coordinates and set this object's position to those coordinates player = GameObject.FindGameObjectWithTag("Player"); //Access and store the player game object movementController = player.GetComponent <MovementController>(); gameController = GameObject.Find("GameController"); abilityController = player.GetComponent <AbilityController>(); //Access and store the ability controller highlightEnabled = false; mapManager = gameController.GetComponent <ManageMap>(); //Access and store a reference to the map manager script clickManager = gameController.GetComponent <ClickManager>(); //Access and store a reference to the click manager script resourceAndUpgradeManager = gameController.GetComponent <ResourceAndUpgradeManager>(); tutorialManager = gameController.GetComponent <TutorialManager>(); playerHealthControl = player.GetComponent <PlayerHealthControl>(); shotIncoming = false; //Set the initial state of the laser animation string clone = "(Clone)"; thisEnemyName = gameObject.name; thisEnemyName = thisEnemyName.Replace(clone, ""); inFlats = false; //thisEnemyObject = new EnemyObject(enemyCellPosition.x, enemyCellPosition.y, thisEnemyName); }
// Start is called before the first frame update void Start() { weaponState = true; gameController = GameObject.Find("GameController"); gridLayout = GameObject.Find("Grid").GetComponent <GridLayout>(); //store a reference to the grid layout component mapManager = gameController.GetComponent <ManageMap>(); //store a reference to the map manager clickManager = gameController.GetComponent <ClickManager>(); uiController = gameController.GetComponent <UIControl>(); turnManager = gameController.GetComponent <TurnManager>(); resourceAndUpgradeManager = gameController.GetComponent <ResourceAndUpgradeManager>(); tutorialManager = gameController.GetComponent <TutorialManager>(); player = GameObject.FindGameObjectWithTag("Player"); //store a reference to the player game object playerHealthControl = player.GetComponent <PlayerHealthControl>(); movementController = player.GetComponent <MovementController>(); maxLaserRange = resourceAndUpgradeManager.CurrentMaxLaserRange; //set the initial state of the maximum laser range parameter maxJumpRange = resourceAndUpgradeManager.CurrentMaxJumpRange; instX = player.transform.position.x; //set the initial x position for instantiated objects instY = player.transform.position.y; //set the initial y position for instantiated objects Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //get the current position of the mouse pointer //target = gridLayout.WorldToCell(ray.origin); //set the initial position of the target (i.e. where is the mouse pointing in grid coordinates) target = gridLayout.WorldToCell(clickManager.TouchPosition); //set the initial position of the target (i.e. where is the mouse pointing in grid coordinates) //target = gridLayout.WorldToCell(clickManager.ClickPosition); //set the initial position of the target (i.e. where is the mouse pointing in grid coordinates) laserState = false; //set the initial state of the laser ability activation jumpState = false; jumpCells = new List <Vector3Int>(); rocketRange = resourceAndUpgradeManager.CurrentMaxRocketRange; rocketReloadTime = resourceAndUpgradeManager.CurrentMaxRocketReload; playerFlats = new List <Vector3Int>(); timer = 0.0f; turnOffAb = false; abilityActive = false; uiController.SetLaserCharge(laserRange, maxLaserRange); uiController.SetJumpCharge(jumpRange, maxJumpRange); uiController.SetShieldBoostRechargeState(currentShieldBoostCharge, shieldBoostRechargeTime); uiController.SetRocketReloadState(currentRocketReloadAmount, rocketReloadTime); }
private void Awake() { upgradeState = true; fogOfWar = GameObject.Find("TilemapFogOfWar"); landOnPlanet = GameObject.Find("LandingButton").GetComponent <Button>(); //get a reference to the planet landing button endPlayerTurn = GameObject.Find("PlayerButtonBackground"); //get a reference to the planet landing button endEnemyTurn = GameObject.Find("EndEnemyTurnButton").GetComponent <Button>(); //get a reference to the planet landing button playerTurnIcon = GameObject.Find("PlayerTurnIconBackground"); enemyTurnIcon = GameObject.Find("EnemyTurnIconBackground"); gameController = GameObject.Find("GameController"); mapManager = gameController.GetComponent <ManageMap>(); turnManager = gameController.GetComponent <TurnManager>(); resourceAndUpgradeManager = gameController.GetComponent <ResourceAndUpgradeManager>(); tutorialManager = gameController.GetComponent <TutorialManager>(); levelMusic = gameController.GetComponent <AudioSource>(); player = GameObject.Find("Player"); abilityController = player.GetComponent <AbilityController>(); playerHealthControl = player.GetComponent <PlayerHealthControl>(); movementController = player.GetComponent <MovementController>(); playerShipSounds = player.GetComponent <AudioSource>(); levelMusicVolume = levelMusic.volume; playerShipSoundsVolume = playerShipSounds.volume; resourceWarningMessage = GameObject.Find("AllResourcesCollectedWarningBackgroundImage"); resourceWarningMessage.SetActive(false); healthPanel = GameObject.Find("HealthPanel"); emptyHealthPanel = GameObject.Find("EmptyHealthPanel"); shieldPanel = GameObject.Find("ShieldPanel"); emptyShieldPanel = GameObject.Find("EmptyShieldPanel"); emptyLaserChargeHolder = GameObject.Find("EmptyLaserCharge"); laserChargeHolder = GameObject.Find("FullLaserCharge"); emptyJumpChargeHolder = GameObject.Find("EmptyJumpCharge"); jumpChargeHolder = GameObject.Find("FullJumpCharge"); resourceTextDisplay = GameObject.Find("ResourceCountText (TMP)").GetComponent <TMP_Text>(); landOnPlanet.gameObject.SetActive(false); //disable the planet landing button so it cannot be clicked until desired endPlayerTurn.SetActive(false); //disable the planet landing button so it cannot be clicked until desired endEnemyTurn.gameObject.SetActive(false); //disable the planet landing button so it cannot be clicked until desired abilityUsedIcon = GameObject.Find("AbilityUsedToken"); moveUsedIcon = GameObject.Find("HasMovedToken"); abilityUsedIcon.SetActive(false); moveUsedIcon.SetActive(false); playerTurnIcon.SetActive(false); enemyTurnIcon.SetActive(false); isPaused = false; //set the game pause state to false quietSounds = false; sceneIndex = SceneManager.GetActiveScene().buildIndex; //get a reference to the current scene index rocketSlider = GameObject.Find("RocketReloadMeter").GetComponent <Slider>(); rocketReloadingImage = GameObject.Find("RocketReloadingImage"); shieldSlider = GameObject.Find("ShieldBoostRechargeMeter").GetComponent <Slider>(); shieldRechargingingImage = GameObject.Find("ShieldRechargingImage"); rocketReloadingImage.SetActive(false); shieldRechargingingImage.SetActive(false); upgradeHologramActive = false; threatLevelSlider = GameObject.Find("ThreatLevelIndicator").GetComponentInChildren <Slider>(); gameSavingMessage = GameObject.Find("GameSavingMessageBackgroundImage"); uiCanvas = GameObject.Find("Canvas").GetComponent <Canvas>(); victoryPanel.SetActive(true); scoreTextDisplay = GameObject.Find("ScoreText(TMP)").GetComponent <TMP_Text>(); nameTextDisplay = GameObject.Find("HighScoreNameInputField(TMP)").GetComponent <TMP_InputField>(); victoryPanel.SetActive(false); Transform[] allTransforms = healthPanel.GetComponentsInChildren <Transform>(); foreach (Transform child in allTransforms) { healthList.Add(child.gameObject); } allTransforms = shieldPanel.GetComponentsInChildren <Transform>(); foreach (Transform child in allTransforms) { shieldList.Add(child.gameObject); } allTransforms = emptyHealthPanel.GetComponentsInChildren <Transform>(); foreach (Transform child in allTransforms) { emptyHealthList.Add(child.gameObject); } allTransforms = emptyShieldPanel.GetComponentsInChildren <Transform>(); foreach (Transform child in allTransforms) { emptyShieldList.Add(child.gameObject); } allTransforms = emptyLaserChargeHolder.GetComponentsInChildren <Transform>(); foreach (Transform child in allTransforms) { emptyLaserList.Add(child.gameObject); } allTransforms = laserChargeHolder.GetComponentsInChildren <Transform>(); foreach (Transform child in allTransforms) { laserList.Add(child.gameObject); } allTransforms = emptyJumpChargeHolder.GetComponentsInChildren <Transform>(); foreach (Transform child in allTransforms) { emptyJumpList.Add(child.gameObject); } allTransforms = jumpChargeHolder.GetComponentsInChildren <Transform>(); foreach (Transform child in allTransforms) { jumpList.Add(child.gameObject); } //if (QuickSaveRoot.Exists(resourceAndUpgradeManager.ResourceAndUpgradeDataSaveFileName)||mapManager.saveName=="TutorialFile") //{ // //Do nothing //} //else //{ // newGameMessage.SetActive(true); //} masterUpgradeLayoutGroup = GameObject.Find("MasterUpgradeHorizontalLayoutGroup"); healthUpgradeObject = GameObject.Find("HealthUpgradeObject"); shieldUpgradeObject = GameObject.Find("ShieldUpgradeObject"); laserRangeUpgradeObject = GameObject.Find("LaserRangeUpgradeObject"); laserRechargeUpgradeObject = GameObject.Find("LaserRechargeUpgradeObject"); rocketRangeUpgradeObject = GameObject.Find("RocketRangeUpgradeObject"); rocketReloadUpgradeObject = GameObject.Find("RocketReloadUpgradeObject"); rocketYieldUpgradeObject = GameObject.Find("RocketYieldUpgradeObject"); jumpRangeUpgradeObject = GameObject.Find("JumpRangeUpgradeObject"); jumpRechargeUpgradeObject = GameObject.Find("JumpRechargeUpgradeObject"); shieldBoostUpgradeObject = GameObject.Find("ShieldBoostUpgradeObject"); shieldBoostRechargeUpgradeObject = GameObject.Find("ShieldBoostRechargeUpgradeObject"); shieldOverboostUpgradeObject = GameObject.Find("ShieldOverboostUpgradeObject"); healthRepairObject = GameObject.Find("HealthRepairObject"); sensorRangeUpgradeObject = GameObject.Find("SensorRangeUpgradeObject"); masterUpgradeLayoutGroup.SetActive(false); rocketButtonHolder = GameObject.Find("RocketButtonHolder"); shieldButtonHolder = GameObject.Find("ShieldButtonHolder"); jumpButtonHolder = GameObject.Find("JumpButtonHolder"); rocketButtonHolder.SetActive(resourceAndUpgradeManager.RocketsInstalled); shieldButtonHolder.SetActive(resourceAndUpgradeManager.ShieldBoostInstalled); jumpButtonHolder.SetActive(resourceAndUpgradeManager.JumpDriveInstalled); SetThreatLevelSlider(resourceAndUpgradeManager.ThreatLevel); zoomSlider = GameObject.Find("ZoomSlider").GetComponent <Slider>(); zoomSlider.value = 0.5f; virtualCamera = GameObject.Find("CM vcam1"); }
private void Awake() { instance = this; }