public void OnReset() { UI_Home.SetActive(true); UI_Game.SetActive(false); _txtAsteroidsCount.text = _asteroidsCount.value.ToString("00"); _txtAsteroidsSpeed.text = _asteroidsSpeed.value.ToString("00"); _txtAsteroidsMass.text = _asteroidsMass.value.ToString("00"); _txtAsteroidsDistance.text = _asteroidsDistance.value.ToString("00"); _txtPlanetsCount.text = _planetsCount.value.ToString("00"); _txtPlanetsSpeed.text = _planetsSpeed.value.ToString("00"); _txtPlanetsMass.text = _planetsMass.value.ToString("00"); _txtPlanetsDistance.text = _planetsDistance.value.ToString("00"); selected = null; foreach (GameObject o in _objs) { if (o.tag == "Sun") { continue; } Destroy(o); } _objs.Clear(); if (cam != null) { cam.transform.position = new Vector3(0, 115, -550); cam.transform.eulerAngles = Vector3.zero; } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player" && IsAlive) { AudioSource.PlayClipAtPoint(itemPick, transform.position); WeaponBehaviour wb = other.gameObject.GetComponent <WeaponBehaviour>(); if (wb.firstWeapon) { switch (type) { case POWER_TYPE.DAMAGE: wb.DoubleDamage(); Kill(); break; case POWER_TYPE.HEALTH: other.GetComponent <Player>().RestoreLife(20); break; case POWER_TYPE.AMMO: wb.AddAmmoWeaponsEquiped(15); break; case POWER_TYPE.LAST: break; default: break; } UI_Game.GetInstance().ItemPicked(); Kill(); } } }
private void OnTriggerEnter(Collider other) { if (other.tag == "WeaponItem") { SetWeapon(other.GetComponent <WeaponItem>().GetIndex()); other.gameObject.SetActive(false); UI_Game.GetInstance().ItemPicked(); } }
private void Start() { items.Capacity = maxItems; ui = (UI_Game)GameObject.Find("PlayerUI").GetComponent <UI_Game> (); for (int i = 0; i < 24; i++) { items.Add(null); } itemCount = 0; }
private void Awake() { if (!instance) { instance = this; } else { Destroy(this.gameObject); } }
public EndGameState(UI_EndGameScreen endGameMenu, UI_Game gameUI, CheckEndGame checkEndGameProcessor, Grid grid, Player whitePlayer, Player blackPlayer) { _endGameMenu = endGameMenu; _gameUI = gameUI; _checkEndGameProcessor = checkEndGameProcessor; _grid = grid; _whitePlayer = whitePlayer; _blackPlayer = blackPlayer; }
// Use this for initialization void Start() { playerObj = GameObject.Find("Player"); enemySpawners = GameObject.FindObjectsOfType <SpawnPoint>(); _ui = GameObject.Find("PlayerUI").GetComponent <UI_Game> (); playerMngr = playerObj.GetComponent <PlayerManager>(); // Disable the player initially playerObj.GetComponent <PlayerMovement>().enabled = false; _hasShownAlert = false; wave = 1; currentState = GameState.START; }
public void OnClickInit() { _objs.Clear(); currentObj = 0; _objs.Add(GameObject.FindWithTag("Sun")); int i; for (i = 0; i < _asteroidsCount.value; i++) { Object3D ast = Instantiate(asteroid[Random.Range(0, asteroid.Length)].gameObject).GetComponent <Object3D>(); ast.name = "Asteroid " + (i + 1); float rMass = Random.Range(1, _asteroidsMass.value); float rDist = Random.Range(50f, _asteroidsDistance.value); float rSpeed = Random.Range(-_asteroidsSpeed.value, _asteroidsSpeed.value); ast.init(rMass, rDist, rSpeed); _objs.Add(ast.gameObject); } for (i = 0; i < _planetsCount.value; i++) { Object3D ast = Instantiate(Planet.gameObject).GetComponent <Object3D>(); ast.name = "Planet " + (i + 1); float rMass = Random.Range(50, _planetsMass.value); float rDist = Random.Range(250f, _planetsDistance.value); float rSpeed = Random.Range(-_planetsSpeed.value, _planetsSpeed.value); ast.GetComponent <MeshRenderer>().material.color = new Color32((byte)(Random.value * 255f), (byte)(Random.value * 255f), (byte)(Random.value * 255f), (byte)255f); ast.transform.localScale = Vector3.one * (rMass / 10f); ast.init(rMass, rDist, rSpeed); _objs.Add(ast.gameObject); } cam.OnInit(); UI_Home.SetActive(false); UI_Game.SetActive(true); }
void Start() { _recipePanel = transform.Find("RecipePanel").GetComponent <RecipePanel> (); _recipes = new List <CraftingRecipe> (); _inventory = (Inventory)GameObject.Find("Player").GetComponent <Inventory>(); _ui = (UI_Game)GameObject.Find("PlayerUI").GetComponent <UI_Game> (); _recipeList = transform.Find("CraftingList/Recipes").GetComponent <RecipeList> (); _image = transform.GetComponent <Image> (); _color = _image.color; _color.a = 0f; _image.color = _color; // read from the text file TextAsset reader = Resources.Load("crafting-recipes") as TextAsset; _index = 0; foreach (string line in reader.text.Split("\n".ToCharArray())) { if (line.Length > 0) { if (line [0] != '#') // commented lines start with # // add to list { CraftingRecipe newRecipe = new CraftingRecipe(line); // ensure it was a valid recipe if (!newRecipe.CraftedItemName.Equals("invalid")) { _recipes.Add(newRecipe); _recipeList.AddRecipe(newRecipe); } } } } _recipeList.Select(0); _recipePanel.ShowRecipe(_recipes[_index]); enabled = false; }
private void SetWeapon(int v) { switch (v) { case 0: firstWeapon = weaponList[v]; currentWeapon = firstWeapon; firstWeapon.gameObject.SetActive(true); #if UNITY_ANDROID GetComponent <MobileControls>().ActivateAllFunctions(); #endif UI_Game.GetInstance().ActivateAllUI(firstWeapon); break; case 1: secondaryWeapon = weaponList[v]; ChangeWeapons(); break; default: break; } currentWeapon.WeaponSelected(); }
public StartMenuState(UI_StartMenu startMenu, UI_Game gameUI, GameManager gm) { _startMenu = startMenu; _gameUI = gameUI; _gm = gm; }
public void WinGame() { win = true; UI_Game.GetInstance().WinState(); }