コード例 #1
0
ファイル: PacManMove.cs プロジェクト: barryw/PacBoy
    /// <summary>
    /// Get the ghost that currently shares PacMan's tile
    /// </summary>
    /// <returns>The at pac man tile.</returns>
    public GhostMove GhostAtPacManTile()
    {
        GhostMove ghost = null;

        if (BlinkyMover.Tile == Tile)
        {
            ghost = BlinkyMover;
        }

        if (PinkyMover.Tile == Tile)
        {
            ghost = PinkyMover;
        }

        if (InkyMover.Tile == Tile)
        {
            ghost = InkyMover;
        }

        if (ClydeMover.Tile == Tile)
        {
            ghost = ClydeMover;
        }

        return(ghost);
    }
コード例 #2
0
ファイル: ModeMenager.cs プロジェクト: HMPFLABUL/Pacman
    void Awake()
    {
        b = GameObject.Find("blinky").GetComponent <GhostMove>();
        p = GameObject.Find("pinky").GetComponent <GhostMove>();
        i = GameObject.Find("inky").GetComponent <GhostMove>();
        c = GameObject.Find("clyde").GetComponent <GhostMove>();

        resetMachine = false;
        blinder      = GameObject.Find("blackout");
        confuse      = GameObject.Find("confuse");
        MainCam      = GameObject.Find("Main Camera").GetComponent <Camera>();
        r            = MainCam.GetComponent <Rotate>();
        modeState    = ModeState.Norm;
        if (_instance == null)
        {
            _instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            if (this != _instance)
            {
                Destroy(this.gameObject);
            }
        }
    }
コード例 #3
0
        private Boolean IsMovable(Position p, GhostMove gm)
        {
            if (Exists(p))
            {
                if (gm == GhostMove.Down)
                {
                    if (p.Row == 5)
                    {
                        return(false);
                    }

                    if (boardState[p.Row + 1, p.Col] == GetMyPlayerID())
                    {
                        return(false);
                    }
                }
                else if (gm == GhostMove.Left)
                {
                    if (p.Col == 0)
                    {
                        return(false);
                    }

                    if (boardState[p.Row, p.Col - 1] == GetMyPlayerID())
                    {
                        return(false);
                    }
                }
                else if (gm == GhostMove.Right)
                {
                    if (p.Col == 5)
                    {
                        return(false);
                    }

                    if (boardState[p.Row, p.Col + 1] == GetMyPlayerID())
                    {
                        return(false);
                    }
                }
                else if (gm == GhostMove.Up)
                {
                    if (p.Row == 0)
                    {
                        if (p.Col == 0 || p.Col == 5)
                        {
                            return(true);
                        }
                        return(false);
                    }

                    if (boardState[p.Row - 1, p.Col] == GetMyPlayerID())
                    {
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
コード例 #4
0
ファイル: GameController.cs プロジェクト: barryw/PacBoy
    // 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());
    }
コード例 #5
0
        /// <summary>
        /// 2P のポジションを反転する
        /// Converts the position.
        /// </summary>
        /// <returns>The position.</returns>
        /// <param name="player2move">Player2move.</param>
        private Move ConvertPosition(Move player2move)
        {
            if (player2move != null)
            {
                GhostMove gm = GhostMove.Down;
                if (player2move.GhostM == GhostMove.Down)
                {
                    gm = GhostMove.Up;
                }
                else
                if (player2move.GhostM == GhostMove.Left)
                {
                    gm = GhostMove.Right;
                }
                else
                if (player2move.GhostM == GhostMove.Right)
                {
                    gm = GhostMove.Left;
                }
                else
                if (player2move.GhostM == GhostMove.Up)
                {
                    gm = GhostMove.Down;
                }

                Move m = new Move(new Position(5 - player2move.Pos.Row, 5 - player2move.Pos.Col), gm);
                return(m);
            }
            return(null);
        }
コード例 #6
0
 private void Start()
 {
     readyToShoot    = true;
     inArea          = false;
     parentGhostMove = transform.parent.GetComponent <GhostMove>();
     // частота стрельбы
     shootFrequency = parentGhostMove.shootFrequency;
     drawGizmos     = parentGhostMove.drawGizmos;
 }
コード例 #7
0
ファイル: PacManMove.cs プロジェクト: barryw/PacBoy
    /// <summary>
    /// Check to see if the ghosts and Pac Man occupy the same tile
    /// </summary>
    void CheckForGhostCollision()
    {
        GhostMove ghost = GhostAtPacManTile();

        if (ghost != null && (ghost.CurrentMode == GhostMove.Mode.CHASE || ghost.CurrentMode == GhostMove.Mode.SCATTER))
        {
            //StartCoroutine (ShowDeathAnimation ());
        }
    }
コード例 #8
0
ファイル: Ghost.cs プロジェクト: ChangeCraft/gppcc12-game
    private void Start()
    {
        ghostMove = GetComponent <GhostMove>();

        animator = GetComponent <Animator>();
        animator.runtimeAnimatorController = ghostAnimStd;

        eatable = false;

        ToPosition(ghostHomePosition, false, ghostAnimStd);
    }
コード例 #9
0
ファイル: GhostMove.cs プロジェクト: barryw/PacBoy
    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> ();
        }
    }
コード例 #10
0
ファイル: PacManMove.cs プロジェクト: barryw/PacBoy
    new void Start()
    {
        base.Start();
        Direction      = Vector2.left;
        Animation      = true;
        AnimationSpeed = 1.5f;

        BlinkyMover = Blinky.GetComponent <GhostMove> ();
        PinkyMover  = Pinky.GetComponent <GhostMove> ();
        InkyMover   = Inky.GetComponent <GhostMove> ();
        ClydeMover  = Clyde.GetComponent <GhostMove> ();
    }
コード例 #11
0
    private void SwitchControlledGhost(int _ghostNumber)
    {
        //Sets all ghosts to not player controlled
        foreach (var ghost in ghosts)
        {
            RemovePlayerTag(ghost);
            GhostMove ghostMove = ghost.GetComponent <GhostMove>();
            ghostMove.SetControlledTo(false);
        }

        //Sets the given ghost to be player controlled
        SetPlayerTag(_ghostNumber);
        ghosts[_ghostNumber].GetComponent <GhostMove>().SetControlledTo(true);
    }
コード例 #12
0
        /// <summary>
        /// テスト用Move入力関数(コンソールから)
        /// </summary>
        public Move TmpMove()
        {
            for (int i = 0; i < gamestate.BoardState.GetLength(0); i++)
            {
                for (int j = 0; j < gamestate.BoardState.GetLength(1); j++)
                {
                    Console.Write("{0}  ", gamestate.BoardState[i, j]);
                }
                Console.WriteLine();
            }


            GhostMove gm = new GhostMove();

            Console.WriteLine("x");
            int x = int.Parse(Console.ReadLine());

            Console.WriteLine("y");

            int y = int.Parse(Console.ReadLine());

            Console.WriteLine("gm");
            string gmString = Console.ReadLine();

            switch (gmString)
            {
            case "u":
                gm = GhostMove.Up;
                break;

            case "d":
                gm = GhostMove.Down;
                break;

            case "l":
                gm = GhostMove.Left;
                break;

            case "r":
                gm = GhostMove.Right;
                break;

            default:
                gm = GhostMove.Up;
                break;
            }

            return(new Move(new Position(x, y), gm));
        }
コード例 #13
0
    private void Start()
    {
        //cycle through all ghosts and disable their player control
        //cycle through all ghosts and set their respawn time
        foreach (var ghost in ghosts)
        {
            GhostMove ghostMoveScript = ghost.GetComponent <GhostMove>();
            Ghost     ghostScript     = ghost.GetComponent <Ghost>();

            ghostMoveScript.SetControlledTo(false);
            StartCoroutine(ghostScript.Respawn(initGhostSpawnTime));

            initGhostSpawnTime += initGhostSpawnTime;
        }

        currentControlledGhost = 0;
        SwitchControlledGhost(currentControlledGhost);
    }
コード例 #14
0
ファイル: PacmanController.cs プロジェクト: kirogazcor/PACMAN
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "Ghosts")        // Столкновение с призраком
     {
         GhostMove GM = col.gameObject.GetComponent <GhostMove>();
         // Ссылка на скрипт GhostMoves призрака
         // с которым столкнулся пакман
         if (!(GM.MoveMode == GhostMove.Mode.Frightened || GM.MoveMode == GhostMove.Mode.Home))
         {
             // Исключение смерти при столкновении
             // с испуганным или мертвым призраком
             StartCoroutine("Death");    // Запуск корутины смерти пакмана
         }
     }
     if (col.tag == "Energizer")
     {
         StopCoroutine("Energizer");
         StartCoroutine("Energizer");    // Запуск корутины съедания энерджайзера
     }
 }
コード例 #15
0
    void GhostsBackToBox()
    {
        foreach (GameObject ghost in ghosts)
        {
            ghost.SetActive(true);
            GhostMove ghostMoveScript = ghost.GetComponent <GhostMove>();

            if (ghostMoveScript != null)
            {
                ghostMoveScript.enabled = false;
            }

            Ghost ghostScript = ghost.GetComponent <Ghost>();
            if (ghostScript != null)
            {
                ghostScript.ResetGhost();
            }
        }

        StartCoroutine(HandleMoveGhosts());
    }
コード例 #16
0
 public void RegistreGhost(GhostMove ghost)
 {
     ghosts.Add(ghost);
 }
コード例 #17
0
    // Update is called once per frame
    void FixedUpdate()
    {
        bool chasing = false;

        foreach (GameObject e in enemies)
        {
            GhostMove gm = e.GetComponent <GhostMove>();
            if (gm.isRunning())
            {
                chasing = true;
            }
        }
        if (chasing && !powerUpPlayed)
        {
            // sound effect for large pacdot collected
            source.PlayOneShot(powerUp, 1f);
            powerUpPlayed = true;
        }
        else
        {
            powerUpPlayed = false;
        }
        if (!chasing)
        {
            powerUpPlayed = false;
        }
        else
        {
            powerUpPlayed = true;
        }

        switch (GameManager.gameState)
        {
        case GameManager.GameState.Game:
            ReadInputAndMove();
            Animate();
            break;

        case GameManager.GameState.Dead:
            foreach (GameObject e in enemies)
            {
                GhostMove gm = e.GetComponent <GhostMove>();
                gm.SetWait();
            }
            if (!_deadPlaying && !gameOverDoneAlready)
            {
                // sound effect for pacman death
                source.PlayOneShot(wah, 1f);
            }
            StartCoroutine("PlayDeadAnimation");
            break;
        }
        if (Pacdot.allCollected)
        {
            // sound effect for game won
            if (!winSoundPlayed)
            {
                source.PlayOneShot(win, 1f);
            }
            foreach (GameObject e in enemies)
            {
                GhostMove gm = e.GetComponent <GhostMove>();
                gm.SetWait();
            }
            StartCoroutine(GameWon());
            winSoundPlayed = true;
        }
        //Pacdot.allCollected = false;
    }
コード例 #18
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <remarks>
 /// ゴーストの位置と移動方向を設定する
 /// </remarks>
 /// <param name="p">
 ///
 /// </param>
 /// <param name="gm">
 ///
 /// </param>
 public Move(Position p, GhostMove gm)
 {
     Pos    = p;
     GhostM = gm;
 }
コード例 #19
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <remarks>
 /// ゴーストの位置と移動方向を設定する
 /// </remarks>
 /// <param name="row">
 /// 行番号
 /// </param>
 /// <param name="col">
 /// 列番号
 /// </param>
 /// <param name="gm">
 /// ゴーストの移動方向
 /// </param>
 public Move(int row, int col, GhostMove gm)
 {
     Pos    = new Position(row, col);
     GhostM = gm;
 }