public void associateBombs()
        {
            UFO ufo = (UFO)FactoryManager.getUfoFactry().cParent.pChild;

            if (ufo.launch)
            {
                if (ufo.x > 50)
                {
                    Random random = new Random(DateTime.UtcNow.Millisecond);
                    int    number = random.Next(1, 3);

                    if (number == 2)
                    {
                        Bomb bomb = getActivatedBomb();
                        bomb.x     = ufo.x;
                        bomb.y     = ufo.y;
                        associated = true;
                    }
                }
            }
            if (!associated)
            {
                int colCount = FactoryManager.getAlienFactry().columnCount;
                if (colCount > 0)
                {
                    Random     random        = new Random(DateTime.UtcNow.Millisecond);
                    int        number        = random.Next(1, colCount);
                    PCSTree    columnPcsTree = FactoryManager.getAlienFactry().cPCSTree;
                    GameObject column        = (GameObject)columnPcsTree.getRoot().pChild;

                    while (column != null)
                    {
                        number--;
                        if (number == 0)
                        {
                            GameObject alien = (GameObject)column.pChild;

                            if (bomb == null)
                            {
                                Bomb bomb = getActivatedBomb();
                                //bomb = (Bomb)GhostManager.find(GameObject.GameObjectName.Bomb);

                                //GhostManager.remove(bomb);
                                //BombFactory bombF = FactoryManager.getBombFactry();
                                //bombF.activate(bomb);
                                if (bomb == null)
                                {
                                    Debug.WriteLine("bomb null");
                                }
                            }
                            bomb.x = alien.x;
                            bomb.y = alien.y;
                            break;
                        }
                        column = (GameObject)column.pSibling;
                    }
                }
            }
            associated = false;
        }
Example #2
0
        public void loadUFO()
        {
            UFOFactory ufoFactory = FactoryManager.getUfoFactry();
            UFORoot    ufoRoot    = (UFORoot)ufoFactory.createUFO(UFO.UFOType.UFORoot, GameObject.GameObjectName.UFORoot, 0, 0, 0);

            ufoFactory.setParent(ufoRoot);

            UFO         ufo    = ufoFactory.createUFO(UFO.UFOType.AlienUFO, GameObject.GameObjectName.AlienUFO, 1, Unit.ufoPosX, Unit.ufoPosY);
            Random      random = new Random(DateTime.UtcNow.Millisecond);
            int         number = random.Next(1, 40);
            UFOActivate ufoAct = new UFOActivate(ufo);

            TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateUFO, ufoAct, number);
        }
        public override void notify()
        {
            TimerManager.addDelta(delta);
            FactoryManager.getBombFactry().removeChildren();
            UFO ufo = (UFO)FactoryManager.getUfoFactry().cParent.pChild;

            if (ufo.launch)
            {
                ufo.reset();
                Random      random = new Random(DateTime.UtcNow.Millisecond);
                int         number = random.Next(1, 40);
                UFOActivate ufoAct = new UFOActivate(ufo);
                TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateUFO, ufoAct, number);
            }
            //   Game.freezeGame();
        }