/// <summary>
 /// Initialize
 /// </summary>
 void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
 }
Exemple #2
0
 public Game()
 {
     _tube            = new Tube();
     _actor           = new Actor();
     _obstacleManager = new ObstacleManager();
     _gemManager      = new GemManager();
 }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        pointManager = GameObject.Find("Point Manager").GetComponent <PointManager> ();
        gemManager   = GameObject.Find("Gem Manager").GetComponent <GemManager> ();

        gemsRemaining = gemManager.totalGemCount / 2;
    }
    // Use this for initialization
    void Start()
    {
        pointManager = GameObject.Find("Point Manager").GetComponent <PointManager>();
        gemManager   = GameObject.Find("Gem Manager").GetComponent <GemManager>();

        foreach (Transform child in transform)
        {
            if (child.gameObject.name == "ChestSparkle")
            {
                chestSparkle = child.gameObject;
            }

            if (child.gameObject.name == "GemImage")
            {
                gems.Add(child.gameObject);
            }
        }

        //initialize gem counts
        int numGems = gemManager.GetGemCountOfTeam(teamNumber);

        int i = 0;

        for ( ; i < numGems; ++i)
        {
            gems[i].SetActive(true);
        }

        for ( ; i < gems.Count; ++i)
        {
            gems[i].SetActive(false);
        }
    }
Exemple #5
0
    void OnStateSteelMoving()
    {
        // 查看四周有没有钻石
        var gems = GameManager.instance.gems;

        foreach (var gem in gems)
        {
            if (TrySteelGem(gem))
            {
                m_TakingGem = gem;
                m_TakingGem.Take();
                break;
            }
        }

        // 偷到钻石了,往回跑
        if (m_TakingGem != null)
        {
            GoBack();
        }

        // 如果没有移动了,表示走到矿洞了,往回走
        if (!m_Movement.isMoving)
        {
            GoBack();
        }
    }
Exemple #6
0
        private void OnGemCreated(GemManager sender, GemController createdGemInstance)
        {
            GemControllerWrapper gem = Instantiate(gemPrefab);

            gem.SetInstance(createdGemInstance);
            gem.transform.parent = this.transform;
        }
Exemple #7
0
 private void BombSpawnerCheck()
 {
     if (matchHandler.currentMatches.Count == 4 || matchHandler.currentMatches.Count == 7)
     {
         matchHandler.CheckBombs();
     }
     if (matchHandler.currentMatches.Count == 5 || matchHandler.currentMatches.Count == 8)
     {
         if (ColumnOrRow() && selectedGem != null && selectedGem.isMatched)
         {
             if (!selectedGem.isColorBomb)
             {
                 selectedGem.isMatched = false;
                 selectedGem.ColorBombSpawner();
             }
             else
             {
                 if (selectedGem.sideGem != null)
                 {
                     GemManager _otherGem = selectedGem.sideGem.GetComponent <GemManager>();
                     if (_otherGem.isMatched && !_otherGem.isColorBomb)
                     {
                         _otherGem.isMatched = false;
                         _otherGem.ColorBombSpawner();
                     }
                 }
             }
         }
     }
 }
Exemple #8
0
 void Start()
 {
     spriteRenderer   = GetComponent <SpriteRenderer>();
     gemManager       = gem.GetComponent <GemManager>();
     audioSource      = GetComponent <AudioSource>();
     originalPosition = transform.localPosition;
 }
        private void OnGemCreated(GemManager sender, GemController gemController)
        {
            GemControllerWrapper wrapper = new GemControllerWrapper(gemController);

            DrawCanvas.Children.Add(wrapper.GemImage);
            DrawCanvas.Children.Add(wrapper.SpecialImage);
            wrapper.GemImage.MouseDown += Image_MouseDown;
            wrapper.OnOverEvent        += OnGemWrapperOver;
            gemControllers.Add(wrapper);
        }
Exemple #10
0
 private void Awake()
 {
     setReadyCoroutine  = WaitAndSetReady(0.2f);
     gemManagerInstance = new GemManager(rowCount, columnCount);
     gemManagerInstance.OnGemCreated         += OnGemCreated;
     gemManagerInstance.OnGemMatch           += OnGemMatch;
     gemManagerInstance.OnReadyStateChanged  += OnReadyStateChanged;
     gemManagerInstance.OnPossibleMoveCreate += OnPossibleMoveCreate;
     gemManagerInstance.Init();
 }
Exemple #11
0
    private void Start()
    {
        Instance = this;

        rubyText.text     = rubyGems.ToString();
        sapphireText.text = sapphireGems.ToString();
        onyxText.text     = onyxGems.ToString();
        diamondText.text  = diamondGems.ToString();
        emeraldText.text  = emeraldGems.ToString();
        goldText.text     = goldGems.ToString();
    }
Exemple #12
0
	// The Start function is good for initializing objects, but doesn't allow you to pass in parameters.
	// For any initialization that requires input, you'll probably want your own init function. 

	public void init(int gemType, GemManager m) {
		this.gemType = gemType;
		this.manager = m;
		name = "Gem";
		age = 0.0f;

		var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);	// Create a quad object for holding the gem texture.
		model = modelObject.AddComponent<GemModel>();						// Add a gemModel script to control visuals of the gem.
		model.init(gemType, this);
		BoxCollider2D coll = gameObject.AddComponent<BoxCollider2D>();
		coll.isTrigger = true;
	}
Exemple #13
0
    private void SingletonPattern()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }
Exemple #14
0
 private void OnGemMatch(GemManager sender, GemController instance)
 {
     if (instance.SpecialType == GemSpecialType.HitType)
     {
         return;
     }
     if (gemPoints.Count == 0)
     {
         StartCoroutine(SendGemPointsEventAtOnce());
     }
     gemPoints.Add(new GemPoint(instance.CurrentGemType, 1.0f));
 }
Exemple #15
0
    // Use this for initialization
    void Start()
    {
        score             = 0;
        timeSinceLastGem  = 0.0f;
        marbles           = new List <Marble>();
        tileFolder        = new GameObject();
        tileFolder.name   = "Tiles";
        marbleFolder      = new GameObject();
        marbleFolder.name = "Marbles";
        board             = new Tile [boardWidth, boardHeight];
        List <int> openColumns = new List <int>();

        for (int i = 0; i < 3; i++)
        {
            addMarble();
        }
        for (int i = 0; i < boardWidth; i++)
        {
            openColumns.Add(i);
        }
        for (int i = 0; i < boardWidth; i++)
        {
            for (int j = 0; j < boardHeight; j++)
            {
                board[i, j] = addTile(i - boardWidth / 2, j - boardHeight / 2);
                int rand = Random.Range(0, 5);
                if (rand == 0)
                {
                    board[i, j].addTurn(Random.Range(0, 4));
                }
            }
        }
        for (int row = 0; row < boardHeight; row++)
        {
            int colIndex = Random.Range(0, openColumns.Count);
            int col      = openColumns[colIndex];
            board[row, col].addTurn(Random.Range(0, 4));
            openColumns.RemoveAt(colIndex);
        }
        GameObject gemManagerObject = GameObject.CreatePrimitive(PrimitiveType.Quad);

        gemMan = gemManagerObject.AddComponent <GemManager>();
        gemMan.init(this, board);
        GameObject elManObject = GameObject.CreatePrimitive(PrimitiveType.Quad);

        elMan = elManObject.AddComponent <ElephantManager>();
        elMan.init(this);
        foreach (Marble t in marbles)
        {
            t.init(this);
        }
    }
Exemple #16
0
 private void OnReadyStateChanged(GemManager sender, bool value)
 {
     if (value)
     {
         StopCoroutine(setReadyCoroutine);
         setReadyCoroutine = WaitAndSetReady(0.2f);
         StartCoroutine(setReadyCoroutine);
     }
     else
     {
         StopCoroutine(setReadyCoroutine);
         IsReady = value;
     }
 }
Exemple #17
0
	// The Start function is good for initializing objects, but doesn't allow you to pass in parameters.
	// For any initialization that requires input, you'll probably want your own init function. 

	public void init(int x, int y, GemManager owner) {
		num_tiles_w = owner.num_tiles_w;
		num_tiles_h = owner.num_tiles_h;

		coordinants = new int[] {x, y};
		float[] pos = position (x, y);
		screen_x = (int) pos [0];
		screen_y = (int) pos [1];
		this.transform.position = Camera.main.ScreenToWorldPoint (new Vector3 (screen_x, screen_y, 9));

		var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);	// Create a quad object for holding the gem texture.
		model = modelObject.AddComponent<GemModel>();						// Add a gem_model script to control visuals of the gem.
		model.init(this);
	}
Exemple #18
0
    bool TrySteelGem(GemManager gem)
    {
        if (!gem.isVisible)
        {
            return(false);
        }

        if (Vector3.Distance(gem.transform.position, transform.position) < 0.5f)
        {
            return(true);
        }

        return(false);
    }
Exemple #19
0
	void initialize(){
		//		Screen.SetResolution (500, 500, true); // for John's weird screen
		board = gameObject.AddComponent<Board> ();
		board.init (num_tiles_w, num_tiles_h, pr_switch);

		gems = gameObject.AddComponent<GemManager> ();
		gems.init (num_tiles_w, num_tiles_h);
		makeGems ();

		trains = gameObject.AddComponent<TrainManager> ();
		trains.init (this);

		score = 0;
	}
Exemple #20
0
    void initialize()
    {
        //		Screen.SetResolution (500, 500, true); // for John's weird screen
        board = gameObject.AddComponent <Board> ();
        board.init(num_tiles_w, num_tiles_h, pr_switch);

        gems = gameObject.AddComponent <GemManager> ();
        gems.init(num_tiles_w, num_tiles_h);
        makeGems();

        trains = gameObject.AddComponent <TrainManager> ();
        trains.init(this);

        score = 0;
    }
Exemple #21
0
    // The Start function is good for initializing objects, but doesn't allow you to pass in parameters.
    // For any initialization that requires input, you'll probably want your own init function.

    public void init(int gemType, GemManager m)
    {
        this.gemType = gemType;
        this.manager = m;
        name         = "Gem";
        age          = 0.0f;

        var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);               // Create a quad object for holding the gem texture.

        model = modelObject.AddComponent <GemModel>();                                  // Add a gemModel script to control visuals of the gem.
        model.init(gemType, this);
        BoxCollider2D coll = gameObject.AddComponent <BoxCollider2D>();

        coll.isTrigger = true;
    }
Exemple #22
0
    // The Start function is good for initializing objects, but doesn't allow you to pass in parameters.
    // For any initialization that requires input, you'll probably want your own init function.

    public void init(int x, int y, GemManager owner)
    {
        num_tiles_w = owner.num_tiles_w;
        num_tiles_h = owner.num_tiles_h;

        coordinants = new int[] { x, y };
        float[] pos = position(x, y);
        screen_x = (int)pos [0];
        screen_y = (int)pos [1];
        this.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(screen_x, screen_y, 9));

        var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);               // Create a quad object for holding the gem texture.

        model = modelObject.AddComponent <GemModel>();                                  // Add a gem_model script to control visuals of the gem.
        model.init(this);
    }
Exemple #23
0
    void ShuffleGems()
    {
        List <GameObject> shuffledBoard = new List <GameObject>();

        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                if (allGems[i, j] != null)
                {
                    shuffledBoard.Add(allGems[i, j]);
                }
            }
        }

        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                int tileToUse = Random.Range(0, shuffledBoard.Count);

                int maxLoop = 0;
                while (MatchesAtBoard(i, j, shuffledBoard[tileToUse]) && maxLoop < 100)
                {
                    tileToUse = Random.Range(0, shuffledBoard.Count);
                    maxLoop++;
                }
                GemManager gem = shuffledBoard[tileToUse].GetComponent <GemManager>();
                maxLoop       = 0;
                gem.column    = i;
                gem.row       = j;
                allGems[i, j] = shuffledBoard[tileToUse];
                shuffledBoard.Remove(shuffledBoard[tileToUse]);
            }
        }
        if (isDeadLocked())
        {
            if (width <= 2 && height <= 2)
            {
                ShuffleGems();
            }
        }
    }
Exemple #24
0
    List <GameObject> GetRowPieces(int row)
    {
        List <GameObject> gems = new List <GameObject>();

        for (int i = 0; i < board.width; i++)
        {
            if (board.allGems[i, row] != null)
            {
                GemManager _gem = board.allGems[i, row].GetComponent <GemManager>();
                if (_gem.isColumnBomb)
                {
                    gems.Union(GetColumnPieces(i)).ToList();
                }
                gems.Add(board.allGems[i, row]);
                _gem.isMatched = true;
            }
        }
        return(gems);
    }
Exemple #25
0
    private List <GameObject> IsRowBomb(GemManager gem1, GemManager gem2, GemManager gem3)
    {
        List <GameObject> currentDots = new List <GameObject>();

        if (gem1.isRowBomb)
        {
            currentMatches.Union(GetRowPieces(gem1.row));
        }

        if (gem2.isRowBomb)
        {
            currentMatches.Union(GetRowPieces(gem2.row));
        }

        if (gem3.isRowBomb)
        {
            currentMatches.Union(GetRowPieces(gem3.row));
        }
        return(currentDots);
    }
Exemple #26
0
    List <GameObject> GetColumnPieces(int column)
    {
        List <GameObject> gems = new List <GameObject>();

        for (int i = 0; i < board.height; i++)
        {
            if (board.allGems[column, i] != null)
            {
                GemManager _gem = board.allGems[column, i].GetComponent <GemManager>();
                if (_gem.isRowBomb)
                {
                    gems.Union(GetRowPieces(i)).ToList();
                }

                gems.Add(board.allGems[column, i]);
                _gem.isMatched = true;
            }
        }
        return(gems);
    }
Exemple #27
0
    private List <GameObject> IsColumnBomb(GemManager gem1, GemManager gem2, GemManager gem3)
    {
        List <GameObject> currentDots = new List <GameObject>();

        if (gem1.isColumnBomb)
        {
            currentMatches.Union(GetColumnPieces(gem1.column));
        }

        if (gem2.isColumnBomb)
        {
            currentMatches.Union(GetColumnPieces(gem2.column));
        }

        if (gem3.isColumnBomb)
        {
            currentMatches.Union(GetColumnPieces(gem3.column));
        }
        return(currentDots);
    }
	// Use this for initialization
	void Start() {
		score = 0;
		timeSinceLastGem = 0.0f;
		marbles = new List<Marble>();
		tileFolder = new GameObject();
		tileFolder.name = "Tiles";
		marbleFolder = new GameObject();
		marbleFolder.name = "Marbles";
		board = new Tile [boardWidth, boardHeight];
		List<int> openColumns = new List<int>();
		for (int i = 0; i < 3; i++) {
			addMarble();
		}
		for (int i = 0; i < boardWidth; i++) {
			openColumns.Add(i);
		}
		for (int i = 0; i < boardWidth; i++) {
			for (int j = 0; j < boardHeight; j++) {
				board[i, j] = addTile(i - boardWidth / 2, j - boardHeight / 2);
				int rand = Random.Range(0, 5);
				if (rand == 0) {
					board[i, j].addTurn(Random.Range(0, 4));
				}
			}
		}
		for (int row = 0; row < boardHeight; row++) {
			int colIndex = Random.Range(0, openColumns.Count);
			int col = openColumns[colIndex];
			board[row, col].addTurn(Random.Range(0, 4));
			openColumns.RemoveAt(colIndex);
		}
        GameObject gemManagerObject = GameObject.CreatePrimitive(PrimitiveType.Quad);
        gemMan = gemManagerObject.AddComponent<GemManager>();
        gemMan.init(this, board);
		GameObject elManObject = GameObject.CreatePrimitive(PrimitiveType.Quad);
		elMan = elManObject.AddComponent<ElephantManager>();
		elMan.init(this);
		foreach (Marble t in marbles) {
            t.init(this);
        }
	}
 public void StartSelecting(GemManager manager,int _eqid)
 {
     current_gemManager = manager;
     gems = manager.GetStoredGems();
     size = gems.Count;
     if (size % 6 > 0)
     {
         pages = size / 6 + 1;
     }
     else
         pages = size / 6;
     current_page = 1;
     current_select = 0;
     eqid = _eqid-1;
     if (size == 0)
         cur.gameObject.SetActive(false);
     else
         cur.gameObject.SetActive(true);
     gameObject.SetActive(true);
     //Debug.Log("size " + size.ToString());
 }
Exemple #30
0
    public void CheckBombs()
    {
        if (board.selectedGem != null)
        {
            if (board.selectedGem.isMatched)
            {
                board.selectedGem.isMatched = false;

                if ((board.selectedGem.swipeAngle > -45 && board.selectedGem.swipeAngle <= 45) ||
                    (board.selectedGem.swipeAngle < -135 || board.selectedGem.swipeAngle >= 135))
                {
                    board.selectedGem.RowBombSpawner();
                }
                else
                {
                    board.selectedGem.ColumnBombSpawner();
                }
            }

            else if (board.selectedGem.sideGem != null)
            {
                GemManager sideGem = board.selectedGem.sideGem.GetComponent <GemManager>();

                if (sideGem.isMatched)
                {
                    sideGem.isMatched = false;

                    if ((board.selectedGem.swipeAngle > -45 && board.selectedGem.swipeAngle <= 45) ||
                        (board.selectedGem.swipeAngle < -135 || board.selectedGem.swipeAngle >= 135))
                    {
                        sideGem.RowBombSpawner();
                    }
                    else
                    {
                        sideGem.ColumnBombSpawner();
                    }
                }
            }
        }
    }
Exemple #31
0
    private bool ColumnOrRow()
    {
        int        numHorizontal = 0;
        int        numVertical   = 0;
        GemManager firstGem      = matchHandler.currentMatches[0].GetComponent <GemManager>();

        if (firstGem != null)
        {
            foreach (GameObject currentGem in matchHandler.currentMatches)
            {
                GemManager _gem = currentGem.GetComponent <GemManager>();
                if (_gem.row == firstGem.row)
                {
                    numHorizontal++;
                }
                if (_gem.column == firstGem.column)
                {
                    numVertical++;
                }
            }
        }
        return(numVertical == 5 || numHorizontal == 5);
    }
Exemple #32
0
    private IEnumerator FillBoardCounter()
    {
        Refill();
        yield return(new WaitForSeconds(refillTime));

        while (MatchesOnBoard())
        {
            streakValue++;
            yield return(new WaitForSeconds(refillTime));

            DestroyActualMatches();
        }
        matchHandler.currentMatches.Clear();
        selectedGem = null;
        yield return(new WaitForSeconds(refillTime));

        if (isDeadLocked())
        {
            ShuffleGems();
        }
        currentState = GameStates.move;
        streakValue  = 1;
    }
    // Use this for initialization
    void Start()
    {
        gemManager = GameObject.Find("Gem Manager").GetComponent <GemManager>();

        foreach (Transform child in transform)
        {
            pendants.Add(child.gameObject);
        }

        //initialize gem counts
        int numGems = gemManager.GetGemCountOfTeam(teamNumber);

        int i = 0;

        for (; i < numGems; ++i)
        {
            pendants[i].GetComponent <Pendant>().Activate();
        }

        for (; i < pendants.Count; ++i)
        {
            pendants[i].GetComponent <Pendant>().Deactivate();
        }
    }
        public NotificationModel(GemManager gemManager, GemRuleViewModel item, NotifierRule rule, String message, DateTime timeStamp, NotificationType notificationType)
        {
            this.DataId            = 0;
            this.IsGemNotification = true;
            this.NotificationType  = notificationType;
            this.TimeStamp         = timeStamp;
            this.Message           = message;
            if (gemManager != null)
            {
                this.BuyMoney  = gemManager.BuyGemPriceMoney;
                this.SellMoney = gemManager.BuyGoldPriceMoney;
            }

            this.Rule = rule;

            if (NotificationType == NotificationType.BuyGems)
            {
            }
            else if (NotificationType == NotificationType.BuyGold)
            {
                this.DataId = -1;
            }
            Name = message;
        }
Exemple #35
0
    private IEnumerator FindAllMatchesCo()
    {
        yield return(new WaitForSeconds(.2f));

        for (int i = 0; i < board.width; i++)
        {
            for (int j = 0; j < board.height; j++)
            {
                GameObject currentGem = board.allGems[i, j];

                if (currentGem != null)
                {
                    GemManager _currentGemPiece = currentGem.GetComponent <GemManager>();
                    if (i > 0 && i < board.width - 1)
                    {
                        GameObject leftGem = board.allGems[i - 1, j];

                        GameObject rightGem = board.allGems[i + 1, j];


                        if (leftGem != null && rightGem != null)
                        {
                            GemManager _rightGem = rightGem.GetComponent <GemManager>();
                            GemManager _leftGem  = leftGem.GetComponent <GemManager>();
                            if (leftGem.CompareTag(currentGem.tag) && rightGem.CompareTag(currentGem.tag))
                            {
                                currentMatches.Union(IsRowBomb(_leftGem, _currentGemPiece, _rightGem));

                                currentMatches.Union(IsColumnBomb(_leftGem, _currentGemPiece, _rightGem));


                                GetNearbyPieces(leftGem, currentGem, rightGem);
                            }
                        }
                    }

                    if (j > 0 && j < board.height - 1)
                    {
                        GameObject upGem = board.allGems[i, j + 1];

                        GameObject downGem = board.allGems[i, j - 1];


                        if (upGem != null && downGem != null)
                        {
                            GemManager _downGemPiece = downGem.GetComponent <GemManager>();
                            GemManager _upGemPiece   = upGem.GetComponent <GemManager>();
                            if (upGem.CompareTag(currentGem.tag) && downGem.CompareTag(currentGem.tag))
                            {
                                currentMatches.Union(IsColumnBomb(_upGemPiece, _currentGemPiece, _downGemPiece));

                                currentMatches.Union(IsRowBomb(_upGemPiece, _currentGemPiece, _downGemPiece));

                                GetNearbyPieces(upGem, currentGem, downGem);
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #36
0
    // Use this for initialization
    void Start()
    {
        //Init lane cooldow
        InitLane();

        //HACKKK: Seeding with a default value
        Random.seed = 0;

        mGemManager = GetComponent< GemManager > ();
    }