public class GameManagerEditor : Editor { // extend the Editor class // called when Unity Editor Inspector is updated public override void OnInspectorGUI() { // show the default inspector stuff for this component DrawDefaultInspector(); // get a reference to the GameManager script on this target gameObject GameManager2 myGM = (GameManager2)target; // add a custom button to the Inspector component if (GUILayout.Button("Reset Player State")) { // if button pressed, then call function in script PlayerPrefManager.ResetPlayerState(myGM.GetStartLives(), false); } // add a custom button to the Inspector component if (GUILayout.Button("Reset Highscore")) { // if button pressed, then call function in script PlayerPrefManager.SetHighscore(0); } // add a custom button to the Inspector component if (GUILayout.Button("Output Player State")) { // if button pressed, then call function in script PlayerPrefManager.ShowPlayerPrefs(); } }
// Update is called once per frame void Update() { for (int g = 0; g < ghosts.Count; g++) { ghosts[g].OnUpdate(MapManager.Get(), GameManager2.Get().GetPlayer()); } }
void RestartTime() { if (totalMoleCount < maxMoles) { emerging = Random.Range(emergeMinTime, emergeMaxTime); if (totalMoleCount < 6) { //add delay to first moles emerging += delay * totalMoleCount; } totalMoleCount++; } else { stopped = true; //if everyone stopped, finish bool finished = true; foreach (Mole m in moleList) { if (!m.stopped) { finished = false; } } if (finished) { GameManager2.FinishGame(); } } }
void Update() { if (Input.GetMouseButtonDown(0)) { bulletAmt--; if (bulletAmt <= 0) { GameManager2.OnDuckMiss(); } Vector3 mousePos = Input.mousePosition; mousePos.z = Camera.main.transform.position.z; if (Physics.Raycast(Camera.main.ScreenToWorldPoint(mousePos), Camera.main.transform.forward, out hit, Mathf.Infinity)) { { if (hit.transform.tag == "Duck") { DuckHealth movement = hit.transform.GetComponent <DuckHealth>(); } } } } }
void Start() { instance = this; scoreText.text = "0"; currentMult = 1; multiText.text = "x" + currentMult; currentCombo = 0; comboText.text = ""; comboTrackText.text = ""; currentScore = 0; playerAnimator.SetBool("Attack", false); playerAnimator.SetBool("Hit", false); playerAnimator.SetBool("StartSongWalk", true); n = 0; treasure.SetActive(false); treasureText.text = ""; treasureCounter = 0; //audioSource = GetComponent<AudioSource>(); StartCoroutine(IntroSound()); startPanel.SetActive(true); timer.gameObject.SetActive(false); timer.text = ""; totalNotes = FindObjectsOfType <NoteObject2>().Length + FindObjectsOfType <HoldNotes>().Length; resultsScreen.SetActive(false); CCounter.SetActive(false); }
private void Chase() { if (timer >= changeDirectionTimer) { if (UnityEngine.Random.Range(0, 100) > 70) { path.Clear(); path = MapManager.Get().GetPath(currentTileX, currentTileY, GameManager2.Get().GetPlayer().currentTileX, GameManager2.Get().GetPlayer().currentTileY); } timer = 0f; } else { timer += Time.deltaTime; } if (IsAtDestination()) { if (path.Count > 0) { PathmapTile nextTile = path[0]; path.RemoveAt(0); SetNextTile(new Vector2Int(nextTile.posX, nextTile.posY)); } else { path.Clear(); path = MapManager.Get().GetPath(currentTileX, currentTileY, GameManager2.Get().GetPlayer().currentTileX, GameManager2.Get().GetPlayer().currentTileY); } } MoveToDestination(); }
public void OnItemColleted(Item item) { if (item.tag == "SmallDot") { smallDots.Remove((SmallDot)item); GameManager2.Get().UpdateScore(item.points); dotCount--; } else if (item.tag == "PowerDot") { powerDots.Remove((PowerDot)item); EnemyManager.Get().SetEnemiesVulnerables(); GameManager2.Get().UpdateScore(item.points); dotCount--; } else if (item.tag == "Cherry") { GameManager2.Get().UpdateScore(item.points); DisableCherry(item); } item.gameObject.SetActive(false); if (dotCount == 0) { GameManager2.Get().Win(); } }
// Use this for initialization private void Start() { Instance = this; serverMenu.SetActive(false); connectMenu.SetActive(false); DontDestroyOnLoad(gameObject); }
void Awake() { if (instance == null) { instance = this; } }
void Start() { gameManager = GameManager2.gm; if (!gameManager) { Debug.LogError("Missing game manager instance!"); } }
void Update() { if (Input.GetMouseButtonDown(0)) { GameManager2.GetInstance().AddScore(5); //instance2 는 public이 아니므로, 함수를 통해 호출 Debug.Log(GameManager2.GetInstance().GetScore()); } }
public void KillDuck() { if (isInvincible == false) { anim.Play("DuckDeath"); GameManager2.OnDuckShot(); } }
void Start() { GameManager = gameManager; money = startMoney; Lives = startLives; Rounds = 0; InvokeRepeating("MoneyOnTime", 0, 1); }
void OnTriggerEnter2D(Collider2D hitInfo) { if (hitInfo.name == "ball2") { string wallName = transform.name; GameManager2.Score(wallName); hitInfo.gameObject.SendMessage("RestartGame", 1.0f, SendMessageOptions.RequireReceiver); } }
// Start is called before the first frame update private void Awake() { view = GameObject.FindGameObjectWithTag("View").GetComponent <View>(); model = GameObject.FindGameObjectWithTag("Model").GetComponent <Model>(); camera2 = GetComponent <CameraManager2>(); gameManager2 = GetComponent <GameManager2>(); }
void OnTriggerEnter(Collider other) { if (other.tag == "Hammer" && transform.localPosition.y > minHitY && !sound.isPlaying) //isPlaying is a gamb to prevent double hit { sound.Play(); GameManager2.IncrementScore(); RestartTime(); } }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } }
protected void Awake() { if (Instance != null) { Destroy(gameObject); } else { Instance = this; } }
//public object SceneManagment { get; private set; } private void Awake() { if (instance) { DestroyImmediate(gameObject); return; } instance = this; DontDestroyOnLoad(gameObject); }
/// <summary> /// This is a lazy way of caching several components utilised by the Agent /// </summary> protected override void LazyLoad() { if (m_NavMeshAgent == null) { m_NavMeshAgent = GetComponent <NavMeshAgent>(); } if (m_GameManager == null) { m_GameManager = GameManager2.Instance; } }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Debug.Log("Instance already exists, destroying objects"); Destroy(this); } }
public void DirectionChanger(Vector3 _dir) { Direction = new Vector3(Direction.x * _dir.x, Direction.y * _dir.y, 0); bounce++; if (bounce >= bounceMax) { Direction = new Vector3(0, 1, 0); GameManager2.OnDuckMiss(); } }
void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } DontDestroyOnLoad(gameObject); }
public void init(Color color, Control control, GameManager2 gameMan) { foreach (Transform t in transform) { if (t.tag == "Block") { t.GetComponent <SpriteRenderer>().color = color; } } this.control = control; this.gameManager2 = gameMan; }
// Start is called before the first frame update void Start() { //load game manager gameManager = GameObject.Find("Pixel UI Canvas").GetComponent <GameManager2>(); //load animator animator = GetComponent <Animator>(); //load rigidbody rigidBody = GetComponent <Rigidbody2D>(); //load body size bodySize = GetComponent <BoxCollider2D>().size; //load body center bodyCenter = GetComponent <BoxCollider2D>().offset; }
void Awake() { //GameObject cameraObject = Instantiate(camObj, this.transform); //camObj = cameraObject; this.GetComponent <EscMenu>().ShowEscMenu(false); thisEntity = this.GetComponent <Entity>(); myMatch = FindObjectOfType <GameManager2>(); myView = GetComponent <PhotonView>(); if (myView.IsMine) { this.GetComponent <Scoreboard>().Init(); } }
void OnTriggerEnter(Collider hit) { if (hit.tag == "Killzone") { Destroy(gameObject); } if (hit.tag == "FlyZone") { GameManager2.OnDuckFlyAway(); Destroy(gameObject); } }
void Start() { if (Instance != null) { throw new System.Exception("Cannot have more than one Game Manager at a time."); } Instance = this; Rect canvasRect = gameObject.GetComponent <RectTransform>().rect; container.PlaceElement(new Vector2(canvasRect.width, canvasRect.height), Vector2.zero); popupContainer.PlaceElement(new Vector2(canvasRect.width, canvasRect.height), Vector2.zero); StartGame(); }
void MoveAroundTheMap() { MovementDirection nextDirection = (MovementDirection)(UnityEngine.Random.Range(0, ((int)MovementDirection.DirectionCount))); Vector2Int newDirection = new Vector2Int(); switch (nextDirection) { case MovementDirection.Up: newDirection.Set(0, 1); break; case MovementDirection.Down: newDirection.Set(0, -1); break; case MovementDirection.Left: newDirection.Set(-1, 0); break; case MovementDirection.Right: newDirection.Set(1, 0); break; } int nextTileX = GetCurrentTileX() + (int)newDirection.x; int nextTileY = GetCurrentTileY() + (int)newDirection.y; if (MapManager.Get().TileIsValid(nextTileX, nextTileY) && UnityEngine.Random.Range(0, 100) > 90) { SetNextTile(new Vector2Int(nextTileX, nextTileY)); direction = newDirection; } else { nextTileX = GetCurrentTileX() + (int)direction.x; nextTileY = GetCurrentTileY() + (int)direction.y; if (MapManager.Get().TileIsValid(nextTileX, nextTileY)) { SetNextTile(new Vector2Int(nextTileX, nextTileY)); } } path.Clear(); path = MapManager.Get().GetPath(currentTileX, currentTileY, GameManager2.Get().GetPlayer().currentTileX, GameManager2.Get().GetPlayer().currentTileY); MoveToDestination(); }