示例#1
0
        public EnemyPlaneBase(Level level, float width, float height, Planes.PlaneType planeType)
            : base(level, width, height, true, null, planeType)
        {
            isEnemy          = true;
            movementVector   = new PointD((float)direction * (ConstantsObj as GameConsts.EnemyPlaneBase).Speed, 0);
            locationState    = LocationState.Air;
            wheelsState      = WheelsState.In;
            motorState       = EngineState.Working;
            isAlarmDelivered = false;
            temp             = new PointD(0, 0);

            InitIterpolateSet();
        }
示例#2
0
        /// <summary>
        /// Tworzy samolot z wylosawnym po³o¿eniem (któryœ z krañców planszy).
        /// </summary>
        /// <param name="level"></param>
        public EnemyPlaneBase(Level level, Planes.PlaneType planeType)
            : base(level, true, planeType)
        {
            StartPositionInfo info = new StartPositionInfo();

            //wylosowanie pozycji
            Random r      = new Random();
            int    atEnd  = r.Next(0, 2); //losuje 0 albo 1
            float  endPos = (level.LevelTiles.Count) * LevelTile.TileWidth - 2.0f * width;

            float x;

            if ((level.MissionType == MissionType.Dogfight || level.MissionType == MissionType.Survival) && level.EnemyPlanesLeft == level.EnemyFightersPoolCount)
            {
                // pierwszy samolot jest blizej lotniskowca
                x = atEnd * endPos * 0.6f + (1 - atEnd) * endPos * 0.4f;
            }
            else
            {
                x = atEnd * endPos + (1 - atEnd) * endPos * 0.05f;
            }

            x += r.Next(-6, 6);

            // HARD!
            //x = 1350; GameConsts.UserPlane.Singleton.GodMode=true;

            float y = r.Next(30, 40);

            info.Direction         = atEnd == 0 ? Direction.Right : Direction.Left;
            info.EngineState       = EngineState.Working;
            info.WheelsState       = WheelsState.In;
            info.PositionType      = StartPositionType.Airborne;
            info.Position          = new PointD(x, y);
            info.Speed             = GetConsts().Speed *0.01f * r.Next(90, 111);
            bounds                 = new Quadrangle(new PointD(x, y), width, height);
            this.startPositionInfo = info;
            Init();

            attackObject = AttackObject.None;
            //	StartEngine();
            level.OnEnemyPlaneFromTheSide(!(atEnd == 1));
            temp = new PointD(0, 0);

            InitIterpolateSet();

            //Console.WriteLine("Enemy plane from the " + (atEnd==1?"right.":"left."));
        }