상속: MonoBehaviour
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();
        }
    }
예제 #2
0
 // Update is called once per frame
 void Update()
 {
     for (int g = 0; g < ghosts.Count; g++)
     {
         ghosts[g].OnUpdate(MapManager.Get(), GameManager2.Get().GetPlayer());
     }
 }
예제 #3
0
    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();
            }
        }
    }
예제 #4
0
파일: Shooter2.cs 프로젝트: nriien/DGM-1600
    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>();
                    }
                }
            }
        }
    }
예제 #5
0
    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);
    }
예제 #6
0
 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();
        }
    }
예제 #8
0
 // Use this for initialization
 private void Start()
 {
     Instance = this;
     serverMenu.SetActive(false);
     connectMenu.SetActive(false);
     DontDestroyOnLoad(gameObject);
 }
예제 #9
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
예제 #10
0
 void Start()
 {
     gameManager = GameManager2.gm;
     if (!gameManager)
     {
         Debug.LogError("Missing game manager instance!");
     }
 }
예제 #11
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         GameManager2.GetInstance().AddScore(5); //instance2 는 public이 아니므로, 함수를 통해 호출
         Debug.Log(GameManager2.GetInstance().GetScore());
     }
 }
예제 #12
0
 public void KillDuck()
 {
     if (isInvincible == false)
     {
         anim.Play("DuckDeath");
         GameManager2.OnDuckShot();
     }
 }
예제 #13
0
    void Start()
    {
        GameManager = gameManager;
        money       = startMoney;
        Lives       = startLives;
        Rounds      = 0;

        InvokeRepeating("MoneyOnTime", 0, 1);
    }
예제 #14
0
 void OnTriggerEnter2D(Collider2D hitInfo)
 {
     if (hitInfo.name == "ball2")
     {
         string wallName = transform.name;
         GameManager2.Score(wallName);
         hitInfo.gameObject.SendMessage("RestartGame", 1.0f, SendMessageOptions.RequireReceiver);
     }
 }
예제 #15
0
    // 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>();
    }
예제 #16
0
 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();
     }
 }
예제 #17
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
예제 #18
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
 }
예제 #19
0
 protected void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
예제 #20
0
    //public object SceneManagment { get; private set; }

    private void Awake()
    {
        if (instance)
        {
            DestroyImmediate(gameObject);
            return;
        }
        instance = this;

        DontDestroyOnLoad(gameObject);
    }
예제 #21
0
 /// <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);
     }
 }
예제 #23
0
    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();
        }
    }
예제 #24
0
 void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
     DontDestroyOnLoad(gameObject);
 }
예제 #25
0
 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;
 }
예제 #26
0
파일: Player2.cs 프로젝트: Smilotte/BitDash
 // 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;
 }
예제 #27
0
 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();
     }
 }
예제 #28
0
    void OnTriggerEnter(Collider hit)
    {
        if (hit.tag == "Killzone")
        {
            Destroy(gameObject);
        }

        if (hit.tag == "FlyZone")
        {
            GameManager2.OnDuckFlyAway();
            Destroy(gameObject);
        }
    }
예제 #29
0
    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();
    }
예제 #30
0
    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();
    }