OnMouseDown() public method

public OnMouseDown ( ) : void
return void
コード例 #1
0
    private void findMissiledElementsUpside(List <Point> listBomb, Dictionary <int, int> dictionary, List <Point> elementsToDelete)
    {
        visitedBomb.Add(new Point(listBomb[0].GetX(), listBomb[0].GetY()));
        var x = listBomb[0].GetX();

        for (int i = 0; i < Height; i++)
        {
            if (!visitedBomb.Contains(new Point(x, i)))
            {
                if ((Grid[x, i].transform.gameObject.tag.Equals("bomb")))
                {
                    String bombId = Grid[x, i].transform.gameObject.name;
                    Bomb   bomb   = GameObject.Find(bombId).GetComponent <Bomb>();
                    bomb.OnMouseDown();
                }
                else if (Grid[x, i].transform.gameObject.tag.Equals("missile"))
                {
                    String            bombId = Grid[x, i].transform.gameObject.name;
                    MissileHorizontal bomb   = GameObject.Find(bombId).GetComponent <MissileHorizontal>();
                    bomb.OnMouseDown();
                }
                else if (Grid[x, i].transform.gameObject.tag.Equals("upmissile"))
                {
                    String          bombId = Grid[x, i].transform.gameObject.name;
                    MissileVertical bomb   = GameObject.Find(bombId).GetComponent <MissileVertical>();
                    bomb.OnMouseDown();
                }
            }
            addElement(x, i, elementsToDelete, dictionary);
        }
    }
コード例 #2
0
    private void findBombedElements(List <Point> listBomb, Dictionary <int, int> dictionary, List <Point> elementsToDelete)
    {
        visitedBomb.Add(listBomb[0]);
        var deletedBombs = new List <Point>();

        while (listBomb.Count > 0)
        {
            for (int i = listBomb[0].GetX() - 1; i <= listBomb[0].GetX() + 1; i++)
            {
                for (int j = listBomb[0].GetY() - 1; j <= listBomb[0].GetY() + 1; j++)
                {
                    if (i < 0 || i >= Width || j < 0 || j >= Height)
                    {
                        continue;
                    }
                    addElement(i, j, elementsToDelete, dictionary);
                    Point point = new Point(i, j);
                    if (!visitedBomb.Contains(point))
                    {
                        if (Grid[i, j].transform.gameObject.tag.Equals("bomb") && !listBomb.Contains(point) &&
                            !deletedBombs.Contains(point))
                        {
                            String bombId = Grid[i, j].transform.gameObject.name;
                            Bomb   bomb   = GameObject.Find(bombId).GetComponent <Bomb>();
                            bomb.OnMouseDown();
                        }
                        else if (Grid[i, j].transform.gameObject.tag.Equals("missile"))
                        {
                            String            bombId = Grid[i, j].transform.gameObject.name;
                            MissileHorizontal bomb   = GameObject.Find(bombId).GetComponent <MissileHorizontal>();
                            bomb.OnMouseDown();
                        }
                        else if (Grid[i, j].transform.gameObject.tag.Equals("upmissile"))
                        {
                            String          bombId = Grid[i, j].transform.gameObject.name;
                            MissileVertical bomb   = GameObject.Find(bombId).GetComponent <MissileVertical>();
                            bomb.OnMouseDown();
                        }
                    }
                }
            }
            if (listBomb.Count > 0)
            {
                var deletePoint = listBomb[0];
                listBomb.RemoveAt(0);
                deletedBombs.Add(deletePoint);
            }
        }
    }