Exemple #1
1
 protected override Vector3 GetTargetTile(PacmanController player)
 {
     float distance = Vector3.Distance(this.transform.position, player.transform.position);
     if ((distance / base.GetMap().TileSize) >= 8)
     {
         // We are too far away, attack pacman directly:
         return player.transform.position;
     }
     else
     {
         // We're too close, retreat to home corner:
         return this.HomeCorner;
     }
 }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        GameObject cageGameObject = GameObject.FindWithTag("Cage");

        this._cage = cageGameObject.GetComponent <Cage>();
        if (this._cage == null)
        {
            Debug.LogError("Couldn't find the cage!");
        }
        GameObject playerGameObject = GameObject.FindWithTag("Player");

        this._player = playerGameObject.GetComponent <PacmanController>();
        if (this._player == null)
        {
            Debug.LogError("Didn't find player!");
        }
        GameObject mapGameObject = GameObject.FindWithTag("Map");

        this._map = mapGameObject.GetComponent <GameField>();
        if (this._map == null)
        {
            Debug.LogError("Couldn't find the Map!");
        }
        this.Reset();
    }
Exemple #3
0
 override protected void affectPacman(PacmanController pacman)
 {
     for (int i = 0; i < (int)Random.Range(minAmount, maxAmount); i++)
     {
         Instantiate(lightRedBall, new Vector3(Random.Range(-2.0f, 2.0f), 5.0f, 0.0f), Quaternion.identity);
     }
 }
Exemple #4
0
    public override void Reset()
    {
        scatterEvent = new ConcreteFsmEvent();
        deathEvent   = new ConcreteFsmEvent();

        pacman     = GameObject.FindObjectOfType <PacmanController>();
        controller = owner.root.gameObject.GetComponent <GhostController>();
    }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        GameObject tempObj = GameObject.FindGameObjectWithTag("Pacman");

        pcInstance = tempObj.GetComponent <PacmanController>();

        animation = GetComponent <Animation>();
    }
Exemple #6
0
 override protected void affectPacman(PacmanController pacman)
 {
     for (int i = 0; i < (int)Random.Range(4.0f, 9.0f); i++)
     {
         Instantiate(tinyGreenBall, gameObject.transform.position + new Vector3(0, 0.1f, 0), Quaternion.identity);
     }
     pacman.increaseScore(pointsValue);
 }
Exemple #7
0
 override protected void affectPacman(PacmanController pacman)
 {
     if (Random.Range(0.0f, 1.0f) < chanceToLossLife)
     {
         if (pacman.decreaseLife() == 0)
         {
             Destroy(pacman.gameObject);
         }
     }
 }
Exemple #8
0
    IEnumerator Pickup(Collider player)
    {
        PacmanController pcInstance = player.GetComponent <PacmanController>();

        pcInstance.isPowerUp = true;

        yield return(new WaitForSeconds(duration));

        pcInstance.isPowerUp = false;

        Destroy(gameObject);
    }
    // Use this for initialization
    void Start()
    {
        // Set initial value for score and lives
        score = 0;
        lives = 3;

        // Set initial UI text for score and lives
        scoreText.text = "Score: " + score;
        livesText.text = "Lives: " + lives;

        // Get reference of the PacmanController script
        pacmanControllerScript = GameObject.FindObjectOfType <PacmanController>();
    }
Exemple #10
0
    protected override Vector3 GetTargetTile(PacmanController player)
    {
        Tile pacmanTile = base.GetMap().GetTileAt(player.transform.position).
            InDirection(player.GetCurrentDirection(), 2); // With added offset of 2 in moving direction.
        Tile blinkyTile = base.GetMap().GetTileAt(_blinky.transform.position);

        // Calculate the Direction-Vector:
        Vector3 direction = pacmanTile.Position - blinkyTile.Position;
        // Add the direction, effectively doubling it's length:
        Vector3 target = pacmanTile.Position + direction;
        Debug.DrawLine(blinkyTile.Position, target, Color.red);
        Debug.DrawLine(blinkyTile.Position, pacmanTile.Position, Color.green);
        return target;
    }
Exemple #11
0
    protected override Vector3 GetTargetTile(PacmanController player)
    {
        float distance = Vector3.Distance(this.transform.position, player.transform.position);

        if ((distance / base.GetMap().TileSize) >= 8)
        {
            // We are too far away, attack pacman directly:
            return(player.transform.position);
        }
        else
        {
            // We're too close, retreat to home corner:
            return(this.HomeCorner);
        }
    }
Exemple #12
0
    protected override Vector3 GetTargetTile(PacmanController player)
    {
        Tile pacmanTile = base.GetMap().GetTileAt(player.transform.position).
                          InDirection(player.GetCurrentDirection(), 2); // With added offset of 2 in moving direction.
        Tile blinkyTile = base.GetMap().GetTileAt(_blinky.transform.position);

        // Calculate the Direction-Vector:
        Vector3 direction = pacmanTile.Position - blinkyTile.Position;
        // Add the direction, effectively doubling it's length:
        Vector3 target = pacmanTile.Position + direction;

        Debug.DrawLine(blinkyTile.Position, target, Color.red);
        Debug.DrawLine(blinkyTile.Position, pacmanTile.Position, Color.green);
        return(target);
    }
Exemple #13
0
    IEnumerator Pickup(Collider player)
    {
        Instantiate(pickupEffect, transform.position, transform.rotation);

        PacmanController stats = player.GetComponent <PacmanController> ();

        stats.MovementSpeed *= multiplier;

        GetComponent <MeshRenderer> ().enabled = false;
        GetComponent <Collider> ().enabled     = false;

        powerUpCube.SetActive(false);

        yield return(new WaitForSeconds(duration));

        //stats.MovementSpeed /= multiplier;

        Destroy(gameObject);
    }
Exemple #14
0
    /// <summary>Called when the lobby scene from Unity is loaded.</summary>
    /// <param name="lvl">Id of the level loaded.</param>
    /// <returns>void</returns>
    public override void onLevelWasLoaded(int lvl)
    {
        base.onLevelWasLoaded(lvl);
        loaded                = true;
        player_               = GameObject.FindGameObjectWithTag("Player");
        playerScript_         = player_.GetComponent <PacMove>();
        gameController_       = GameObject.FindGameObjectWithTag("Pacman");
        gameControllerScript_ = gameController_.GetComponent <PacmanController>();
        circleCamera          = GameObject.FindGameObjectWithTag("CircleCamera");
        rand = circleCamera.GetComponent <Randomizer>();

        if (Application.isMobilePlatform)
        {
            Screen.orientation = ScreenOrientation.Portrait;
            float ratio = (float)Screen.width / Screen.height;
            ((GameObject)GameObject.FindGameObjectWithTag("MainCamera")).GetComponent <Camera>().projectionMatrix = Matrix4x4.Perspective(60 * 1 / ratio, ratio, 0.3f, 50);
            circleCamera.GetComponent <Camera>().aspect = ratio;
        }
        setParameter(new Parameter());
    }
Exemple #15
0
    private void OnTriggerEnter(Collider other)
    {
        //Debug.Log("Collided with " + other.name);
        PacmanController pacman = other.GetComponentInParent <PacmanController>();

        if (pacman != null)
        {
            GameManager.Instance.pelletsLeft--;
            gameObject.SetActive(false);
            if (isPowerUp)
            {
                for (int i = 0; i < allGhosts.Length; i++)
                {
                    if (allGhosts[i].state != GhostState.Frightened && allGhosts[i].state != GhostState.Dead)
                    {
                        allGhosts[i].SetFrightened(6);
                    }
                }
            }
        }
    }
Exemple #16
0
    private const float RETURNING_SPEED_PENALTY  = 1.5f; // +50%

    protected void Start()
    {
        GameObject pacmanGameObject = GameObject.FindWithTag("Player");

        if (pacmanGameObject == null)
        {
            Debug.LogError("Couldn't find the Player!");
        }
        this._pacman = pacmanGameObject.GetComponent <PacmanController>();
        if (this._pacman == null)
        {
            Debug.LogError("Couldn't find Script on pacman!");
        }
        GameObject mapGameObject = GameObject.FindWithTag("Map");

        this._map = mapGameObject.GetComponent <GameField>();
        if (this._map == null)
        {
            Debug.Log("Couldn't find the Map!");
        }
        GameObject cageObject = GameObject.FindWithTag("Cage");

        if (cageObject != null)
        {
            this._cage = cageObject.GetComponent <Cage>();
        }
        if (this._cage == null)
        {
            Debug.LogError("Can't find the Cage!");
        }
        if (this.FrightenedMaterial == null)
        {
            Debug.LogError("No material for Frightened mode was added!");
        }
        this._originalMaterial = renderer.material;
    }
Exemple #17
0
 protected override Vector3 GetTargetTile(PacmanController player)
 {
     Tile current = base.GetMap().GetTileAt(player.transform.position);
     return current.InDirection(player.GetCurrentDirection(), TILE_OFFSET).Position;
 }
 // Use this for initialization
 void Start()
 {
     GameObject cageGameObject = GameObject.FindWithTag("Cage");
     this._cage = cageGameObject.GetComponent<Cage>();
     if (this._cage == null)
     {
         Debug.LogError("Couldn't find the cage!");
     }
     GameObject playerGameObject = GameObject.FindWithTag("Player");
     this._player = playerGameObject.GetComponent<PacmanController>();
     if (this._player == null)
     {
         Debug.LogError("Didn't find player!");
     }
     GameObject mapGameObject = GameObject.FindWithTag("Map");
     this._map = mapGameObject.GetComponent<GameField>();
     if (this._map == null)
     {
         Debug.LogError("Couldn't find the Map!");
     }
     this.Reset();
 }
 void Start()
 {
     pacman = GetComponent <PacmanController>();
 }
 void Start()
 {
     pc = GetComponentInParent <PacmanController> ();
 }
 void Start()
 {
     pacmanController  = pacman.GetComponent <PacmanController> ();
     pathFinder        = GetComponent <GhostPathFinder>();
     ghostStateManager = GetComponent <GhostStateManager>();
 }
Exemple #22
0
 protected override Vector3 GetTargetTile(PacmanController player)
 {
     // Simply follow pacman:
     return(player.transform.position);
 }
Exemple #23
0
 protected override Vector3 GetTargetTile(PacmanController player)
 {
     // Simply follow pacman:
     return player.transform.position;
 }
Exemple #24
0
    protected override Vector3 GetTargetTile(PacmanController player)
    {
        Tile current = base.GetMap().GetTileAt(player.transform.position);

        return(current.InDirection(player.GetCurrentDirection(), TILE_OFFSET).Position);
    }
Exemple #25
0
 override protected void affectPacman(PacmanController pacman)
 {
     pacman.increaseScore(pointsValue);
 }
 void Start()
 {
     pc = GetComponentInParent<PacmanController> ();
 }
Exemple #27
0
 protected void Start()
 {
     GameObject pacmanGameObject = GameObject.FindWithTag("Player");
     if (pacmanGameObject == null)
     {
         Debug.LogError("Couldn't find the Player!");
     }
     this._pacman = pacmanGameObject.GetComponent<PacmanController>();
     if (this._pacman == null)
     {
         Debug.LogError("Couldn't find Script on pacman!");
     }
     GameObject mapGameObject = GameObject.FindWithTag("Map");
     this._map = mapGameObject.GetComponent<GameField>();
     if (this._map == null)
     {
         Debug.Log("Couldn't find the Map!");
     }
     GameObject cageObject = GameObject.FindWithTag("Cage");
     if (cageObject != null)
     {
         this._cage = cageObject.GetComponent<Cage>();
     }
     if (this._cage == null)
     {
         Debug.LogError("Can't find the Cage!");
     }
     if (this.FrightenedMaterial == null)
     {
         Debug.LogError("No material for Frightened mode was added!");
     }
     this._originalMaterial = renderer.material;
 }
Exemple #28
0
 /// <summary>
 /// Ghost implementations have to call this method to tell the path-finding algorithm, where it should lead the ghost to.
 /// </summary>
 protected abstract Vector3 GetTargetTile(PacmanController player);
Exemple #29
0
 override protected void affectPacman(PacmanController pacman)
 {
     pacman.multiplySpeed(multiply);
 }
Exemple #30
0
 virtual protected void affectPacman(PacmanController pacman)
 {
     Debug.Log("Pacman has eatean a ball");
 }
Exemple #31
0
 /// <summary>
 /// Ghost implementations have to call this method to tell the path-finding algorithm, where it should lead the ghost to.
 /// </summary>
 protected abstract Vector3 GetTargetTile(PacmanController player);
Exemple #32
0
 override protected void affectPacman(PacmanController pacman)
 {
     pacman.addHeart();
 }
	// Use this for initialization
	void Start () {
		playerController =player.GetComponent<PacmanController>();
		soundCtrl = gameObject.transform.FindChild("SoundController").GetComponent<SoundController>();
	}
	// Use this for initialization
	void Start () {
		controller = GetComponent<PacmanController>();
	}
Exemple #35
0
 override protected void affectPacman(PacmanController pacman)
 {
     pacman.getMultiplyBonus(multiplyBonus);
 }
Exemple #36
0
 private void Awake()
 {
     ghosts = GameObject.FindGameObjectsWithTag("Ghost").Select(x => x.GetComponent <GhostController>()).ToArray();
     pacman = GameObject.FindGameObjectWithTag("Pacman").GetComponent <PacmanController>();
 }