Example #1
0
        public void Initialize(Vector2 startLocation)
        {
            IsDisposed = false;
            Location   = startLocation;

            if (Maths.Chance(50))
            {
                Direction = 1;
            }
            else
            {
                Direction = -1;
            }

            if (Maths.Chance(50) || Level.Instance.MGCnt == Level.MAX_MG_CNT)
            {
                Boom1 bm = Level.Instance.BoomPool.New();
                bm.Initialize(new Vector2(Animation.Width / 2 - 9, Animation.Height / 2), null);
                Guns.Add(bm);
            }
            else
            {
                MG1 mg = Level.Instance.MGPool.New();
                mg.Initialize(new Vector2(Animation.Width / 2 - 4 - 10, Animation.Height), new Vector2(Animation.Width / 2 - 4 + 10, Animation.Height), null);
                Guns.Add(mg);
                Level.Instance.MGCnt++;
            }
        }
        /// <summary>
        /// Call this after getting me from the pool.
        /// </summary>
        /// <param name="startLoc"></param>
        public void Initialize(Vector2 startLoc)
        {
            IsDisposed = false;
            Location   = startLoc;

            int  rndWpn;
            bool pass;

            do
            {
                pass   = true;
                rndWpn = Maths.RandomNr(1, 100);
                if (rndWpn < 30)
                {
                    AutoAim aa = Level.Instance.AutoAimPool.New();
                    aa.Initialize(new Vector2(Animation.Width / 2 - 8, Animation.Height / 2 - 8), null);
                    Guns.Add(aa);
                    Velocity = 2.4f;
                }
                else if (rndWpn < 70)
                {
                    Boom1 bm = Level.Instance.BoomPool.New();
                    bm.Initialize(new Vector2(Animation.Width / 2 - 9, Animation.Height / 2), null);
                    Guns.Add(bm);
                    Velocity = 3f;
                }
                else
                {
                    if (Level.Instance.MGCnt < Level.MAX_MG_CNT)
                    {
                        Level.Instance.MGCnt++;
                        Velocity = 3f;
                        MG1 mg = Level.Instance.MGPool.New();
                        mg.Initialize(new Vector2(Animation.Width / 2 - 4 - 10, Animation.Height), new Vector2(Animation.Width / 2 - 4 + 10, Animation.Height), null);
                        Guns.Add(mg);
                    }
                    else
                    {
                        pass = false;
                    }
                }
            } while (!pass);
        }
        public void AddGun(eEnemyGunType gunType)
        {
            switch (gunType)
            {
            case eEnemyGunType.AutoAim:
                AutoAim aa = Level.Instance.AutoAimPool.New();
                aa.Initialize(new Vector2(Animation.Width / 2 - 8, Animation.Height / 2 - 8), Owner);
                Guns.Add(aa);
                break;

            case eEnemyGunType.Boom1Enemy:
                Boom1 b = Level.Instance.BoomPool.New();
                b.Initialize(new Vector2(Animation.Width / 2 - 9, 0), Owner);
                Guns.Add(b);
                break;

            case eEnemyGunType.MG1:
                throw new Exception("MG Can not be added");

            case eEnemyGunType.Missile:
                Missile m = Level.Instance.MissilePool.New();
                m.Initialize(new Vector2(Animation.Width / 2 - 9, Animation.Height / 2 - 11), Owner);
                Guns.Add(m);
                break;

            case eEnemyGunType.DualMissile45:
                DualMissile45 dm = Level.Instance.DualMissile45Pool.New();
                dm.Initialize(new Vector2(Animation.Width / 2 - 11, 5), Owner);
                Guns.Add(dm);
                break;

            default:
                throw new CaseStatementMissingException();
            }
            UpdateAquiredGuns();
        }