Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        _audio = AudioController.Instance;
        _score = ScoreBoard.Instance;

        currentLevel = startLevel;

        // Get the movers
        pacManMover = pacMan.GetComponent <PacManMove> ();
        blinkyMover = blinky.GetComponent <GhostMove> ();
        pinkyMover  = pinky.GetComponent <GhostMove> ();
        inkyMover   = inky.GetComponent <GhostMove> ();
        clydeMover  = clyde.GetComponent <GhostMove> ();

        pacMan.SetActive(false);

        _audio.PlayStartMusic();
        GameObject readyInst = Instantiate(ready);

        Destroy(readyInst, _audio.StartMusicLength - 1.25f);

        RenderExtraPacs();
        RenderLevel();
        StartCoroutine(RemovePac());
        StartCoroutine(StartInitialSiren());
    }
Beispiel #2
0
    new void Start()
    {
        base.Start();

        switch (ThisGhost)
        {
        case Ghost.BLINKY:
            ScatterTarget = new Vector2(28, 36);
            GhostHome     = new Vector2(14, 19);
            break;

        case Ghost.INKY:
            ScatterTarget = new Vector2(28, 1);
            GhostHome     = new Vector2(12, 19);
            break;

        case Ghost.PINKY:
            ScatterTarget = new Vector2(3, 36);
            GhostHome     = new Vector2(14, 19);
            break;

        case Ghost.CLYDE:
            ScatterTarget = new Vector2(1, 1);
            GhostHome     = new Vector2(16, 19);
            break;
        }

        Directions.Add(Vector2.up);
        Directions.Add(Vector2.down);
        Directions.Add(Vector2.left);
        Directions.Add(Vector2.right);

        // Start off moving left
        SetDestination(Vector2.left);
        Direction = Vector2.left;
        Animation = true;

        // Everybody but Blinky is in the ghost house
        if (ThisGhost != Ghost.BLINKY)
        {
            InGhostHouse = true;
        }

        SetDotsToLeave();

        PacManMover = PacMan.GetComponent <PacManMove> ();
        if (ThisGhost == Ghost.INKY)
        {
            Debug.Log("Linking Blinky's mover to Inky's");
            GameObject blinky = GameObject.FindGameObjectWithTag("Blinky");
            BlinkyMover = blinky.GetComponent <GhostMove> ();
        }
    }
Beispiel #3
0
    void Update()
    {
        PacManMove pacMan   = GameObject.Find("PacMan").GetComponent <PacManMove>();
        Vector3    position = pacMan.transform.position;
        float      delta    = (Time.time - time) * 0.75f;

        position.y        += 1;
        transform.position = Vector3.Lerp(defaultPosition, position, delta);

        if (transform.position.Equals(position))
        {
            inPosition = true;
            Quaternion.Euler(0, tiltAroundY, 0);
            Quaternion target = Quaternion.Euler(0, tiltAroundY, 0);
            transform.rotation = Quaternion.Lerp(transform.rotation, target, Time.deltaTime * tiltAroundY);
        }

        if (inPosition == true)
        {
            if (tiltAroundY <= 0)
            {
                tiltAroundY = 359;
            }
            else if (tiltAroundY > 359)
            {
                tiltAroundY = 0;
            }

            if (Input.GetButton("Horizontal"))
            {
                tiltAroundY += Input.GetAxis("Horizontal") * pacMan.MoveSpeed;
                Quaternion.Euler(0, tiltAroundY, 0);
                Quaternion target = Quaternion.Euler(0, tiltAroundY, 0);
                transform.rotation = Quaternion.Lerp(transform.rotation, target, Time.deltaTime * tiltAroundY);
            }
        }
    }