コード例 #1
0
    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();
        }
    }
コード例 #2
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();
 }
コード例 #3
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());
     }
 }
コード例 #4
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();
    }
コード例 #5
0
 public void RestartButtonPressed()
 {
     ResetUI();
     GameManager2.Get().Restart();
 }
コード例 #6
0
 void GhostDestroyed(Ghost g)
 {
     GameManager2.Get().GhostDestroyed();
 }