public void AircraftFactoryCreatesPlaneTest()
        {
            var factory = new AircraftFactory();
            var plane   = factory.CreateVehicle <Plane>();

            Assert.IsInstanceOfType(plane, typeof(Plane));
        }
        public void AircraftFactoryCreatesDroneTest()
        {
            var factory = new AircraftFactory();
            var drone   = factory.CreateVehicle <Drone>();

            Assert.IsInstanceOfType(drone, typeof(Drone));
        }
        public void AircraftFactoryCreatesRocketTest()
        {
            var factory = new AircraftFactory();
            var rocket  = factory.CreateVehicle <Rocket>();

            Assert.IsInstanceOfType(rocket, typeof(Rocket));
        }
Exemplo n.º 4
0
    /// <summary>
    /// 开始游戏
    /// </summary>
    public void StartGame()
    {
        // 初始从第一关开始
        Level = ConfigMgr.instance.gameConfig.GetLevelConfig(1);
        // 初始化得分
        Score = 0;
        // 初始化核弹
        BombCnt = 0;


        // 关闭开始游戏界面
        PanelMgr.instance.HidePanel <StartGamePanel>();

        // 显示游戏战斗界面
        PanelMgr.instance.ShowPanel <MainGamePanel>();

        // 创建主角飞机
        player = AircraftFactory.CreateAircraft(AircraftType.Player);

        // 初始化核弹生成器
        m_superBombGenerator.Init();


        gameState = GameState.Playing;
    }
Exemplo n.º 5
0
 /// <summary>
 /// Singleton get instance
 /// </summary>
 /// <returns>AircraftFactory's instance</returns>
 public static AircraftFactory GetAircraftFactory()
 {
     if (aircraftFactory == null)
     {
         aircraftFactory = new AircraftFactory();
     }
     return(aircraftFactory);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 清理飞机和子弹物体
 /// </summary>
 public void ClearObjs()
 {
     if (null != player)
     {
         player.DestroySelf();
     }
     // 清空所有飞机
     AircraftFactory.DestroyFactoryRoot();
     m_enemyGenerator.ClearAll();
     // 清空所有子弹
     EnemyBulletGenerator.CLear();
 }
Exemplo n.º 7
0
    //public GliderFactory gliderFactory;
    //public AircraftFactory aircraftFactory;
    //public RocketFactory rocketFactory;

    public IPlane createItem(Requirements reqs)
    {
        if (reqs.rocket)
        {
            RocketFactory rocketFactory = new RocketFactory();
            return(rocketFactory.ManufactureRocket(reqs));
        }
        else if (reqs.numberOfEngines > 0)
        {
            AircraftFactory aircraftFactory = new AircraftFactory();
            return(aircraftFactory.ManufacturePoweredAircraft(reqs));
        }
        else
        {
            GliderFactory gliderFactory = new GliderFactory();
            return(gliderFactory.ManufactureGlider(reqs));
        }
    }
Exemplo n.º 8
0
    /// <summary>
    /// 随机生成一个敌机
    /// </summary>
    private void RandomGenerateEnemy()
    {
        EnemyAircraft enemy        = null;
        var           config       = m_enemyRandom.Next();
        var           aircraftType = (AircraftType)config.Index;

        if (m_reusePool.ContainsKey(aircraftType) && m_reusePool[aircraftType].Count > 0)
        {
            enemy = m_reusePool[aircraftType].Dequeue();
            enemy.ActiveSelf(true);
        }
        else
        {
            enemy = (EnemyAircraft)AircraftFactory.CreateAircraft((AircraftType)config.Index);
            enemy.backToPoolAction = () =>
            {
                // 对象回收
                if (!m_reusePool.ContainsKey(aircraftType))
                {
                    m_reusePool[aircraftType] = new Queue <EnemyAircraft>();
                }
                m_reusePool[aircraftType].Enqueue(enemy);

                if (m_aliveEnemy.Contains(enemy))
                {
                    m_aliveEnemy.Remove(enemy);
                }
            };
        }
        enemy.blood     = config.Blood;
        enemy.moveSpeed = Random.Range(config.MinSpeed, config.MaxSpeed);
        enemy.ResetTimeToFire(1);
        enemy.RandomStartPos();
        if (!m_aliveEnemy.Contains(enemy))
        {
            m_aliveEnemy.Add(enemy);
        }
    }
Exemplo n.º 9
0
        private List <AircraftModel> CreateAircraftModel()
        {
            AircraftFactory boeing  = GetAircrafFactory("Boeing");
            AircraftFactory atr     = GetAircrafFactory("ATR");
            AircraftFactory airbus  = GetAircrafFactory("Airbus");
            AircraftFactory embraer = GetAircrafFactory("Embraer");

            var aircraftModels = new List <AircraftModel>()
            {
                new AircraftModel()
                {
                    AircraftFactory = boeing, Model = "737-700"
                },
                new AircraftModel()
                {
                    AircraftFactory = boeing, Model = "737-800"
                },
                new AircraftModel()
                {
                    AircraftFactory = boeing, Model = "737 MAX 8"
                },
                new AircraftModel()
                {
                    AircraftFactory = boeing, Model = "777-300ER"
                },
                new AircraftModel()
                {
                    AircraftFactory = boeing, Model = "787-8"
                },
                new AircraftModel()
                {
                    AircraftFactory = boeing, Model = "787-9"
                },

                new AircraftModel()
                {
                    AircraftFactory = atr, Model = "72"
                },

                new AircraftModel()
                {
                    AircraftFactory = airbus, Model = "A318"
                },
                new AircraftModel()
                {
                    AircraftFactory = airbus, Model = "A320"
                },
                new AircraftModel()
                {
                    AircraftFactory = airbus, Model = "A321"
                },
                new AircraftModel()
                {
                    AircraftFactory = airbus, Model = "A330-200"
                },
                new AircraftModel()
                {
                    AircraftFactory = airbus, Model = "A380-800"
                },

                new AircraftModel()
                {
                    AircraftFactory = embraer, Model = "190"
                }
            };

            _context.AddRange(aircraftModels);
            _context.SaveChanges();

            return(aircraftModels);
        }