示例#1
0
        public void Update(QuadTree quadTree)
        {
            // repeat the vortexanimation
            if (mVortexAnim.IsDestroyed && !mDestroyed)
            {
                mVortexAnim  = new VortexAnim(mAnim, mVortexRegion1.Location.ToVector2());
                mVortexAnim2 = new VortexAnim(mAnim, mVortexRegion2.Location.ToVector2());
                MapScreen.mSmallThingsManager.AddThing(mVortexAnim);
                MapScreen.mSmallThingsManager.AddThing(mVortexAnim2);
            }


            // damage a ship if its too close to a storm.
            FisherShip dummyShip1          = new FisherShip(new Vector2(mVortexRegion1.X, mVortexRegion1.Y));
            var        possibleCollisions1 = new List <AShip>();

            quadTree.Retrieve(possibleCollisions1, dummyShip1);

            FisherShip dummyShip2          = new FisherShip(new Vector2(mVortexRegion1.X, mVortexRegion1.Y));
            var        possibleCollisions2 = new List <AShip>();

            quadTree.Retrieve(possibleCollisions2, dummyShip2);

            if (possibleCollisions1.Count > 0 || possibleCollisions2.Count > 0)
            {
                foreach (var pCShip in possibleCollisions1)
                {
                    if (mVortexRegion1.Contains(pCShip.Position) &&
                        pCShip.Owned && !mCoolDown)
                    {
                        SoundManager.PlayEfx("efx/warp");
                        pCShip.Position = mVortexRegion2.Location.ToVector2();
                        pCShip.Moving   = false;

                        /*
                         * if (pCShip is FlagShip)
                         * {
                         *  Game1.mMapScreen.mMapCamera.Position = (mVortexRegion2.Location.ToVector2() - new Vector2(60, 20));
                         * }
                         */
                        mCoolDown = true;
                    }
                    if (mVortexRegion2.Contains(pCShip.Position) &&
                        pCShip.Owned && !mCoolDown)
                    {
                        SoundManager.PlayEfx("efx/warp");
                        pCShip.Position = mVortexRegion1.Location.ToVector2();
                        pCShip.Moving   = false;

                        /*
                         * if (pCShip is FlagShip)
                         * {
                         *  Game1.mMapScreen.mMapCamera.Position = (mVortexRegion1.Location.ToVector2() -
                         *                                         new Vector2(60, 20));
                         * }
                         */
                        mCoolDown = true;
                    }
                }
            }

            // cooldown for disallowing multiple teleportations
            if (mCoolDown)
            {
                if (mCoolDownCounter < 300)
                {
                    mCoolDownCounter += 1;
                }
                else
                {
                    mCoolDownCounter = 0;
                    mCoolDown        = false;
                }
            }

            mTimeToLive -= 1;

            if (mTimeToLive < 0)
            {
                mDestroyed = true;
                EnvironmentManager.mVortexNumber -= 1;
                mVortexAnim.KillVortex();
                mVortexAnim2.KillVortex();
            }
        }