public void Start(MyDistantObjectImpostorTypeEnum type)
        {
            float angleHorizontal = MathHelper.ToRadians(MyUtils.GetRandomFloat(0, 360));
            float angleVertical = MathHelper.ToRadians(MyUtils.GetRandomFloat(0, 360));

            float LOW_PRIORITY_ANGLE = MathHelper.ToRadians(45);
            if (((angleVertical >= (MathHelper.PiOver2 - LOW_PRIORITY_ANGLE)) && (angleVertical <= (MathHelper.PiOver2 + LOW_PRIORITY_ANGLE))) ||
                ((angleVertical >= (3 * MathHelper.PiOver2 - LOW_PRIORITY_ANGLE)) && (angleVertical <= (3 * MathHelper.PiOver2 + LOW_PRIORITY_ANGLE))))
            {
                angleVertical = MathHelper.ToRadians(MyUtils.GetRandomFloat(0, 360));
            }
            
            int typeEnum = MyUtils.GetRandomInt(0, 3);
            m_angleHorizontal = angleHorizontal;
            m_angleVertical = angleVertical;           
            Angle = 0;
            Color = new Vector4(1f, 1f, 1f, 1f);
            Type = type;
            m_fading = true;
            m_glowTime = 0;

            //  We make a random starting alpha and a random blink multiplier
            //  so they don't all blink at the same time
            if (Type == MyDistantObjectImpostorTypeEnum.Blinker)
            {
                Radius = MyUtils.GetRandomFloat(3000, 5000f);
                m_blinkMultiplierUp = MyUtils.GetRandomFloat(70f, 90.0f);
                m_blinkMultiplierDown = MyUtils.GetRandomFloat(70f, 90.0f);
                m_startingRadius = Radius;
            }

            //  Moving objects are initialized with a random destination
            if (Type == MyDistantObjectImpostorTypeEnum.Mover)
            {
                
                Radius = MyUtils.GetRandomFloat(4000, 6000f);
                m_targetHorizontal = MathHelper.ToRadians(MyUtils.GetRandomFloat(0, 360));
                m_moverSpeed = MyUtils.GetRandomFloat(MyDistantObjectsImpostorsConstants.MAX_MOVE_DISTANCE*0.3f, MyDistantObjectsImpostorsConstants.MAX_MOVE_DISTANCE);
            }

            //  Explosions also have a blink multiplier to make flashes more random.
            //  Explosions will appear around their targer angles, but
            //  will stay in the same general area
            if (Type == MyDistantObjectImpostorTypeEnum.Explosion)
            {
                Radius = MyUtils.GetRandomFloat(4000f, 6000f);
                Color.X = MyUtils.GetRandomFloat(170.0f / 255f, 1.0f);
                Color.Y = MyUtils.GetRandomFloat(100.0f / 255f, Color.X);
                Color.Z = MyUtils.GetRandomFloat(0.0f, 40.0f / 255f);
                Color.W = MyUtils.GetRandomFloat(0.0f, 1.0f);
                m_blinkMultiplierUp = MyUtils.GetRandomFloat(11f, 16f);
                m_blinkMultiplierDown = MyUtils.GetRandomFloat(0.5f, 2f);
                m_targetHorizontal = m_angleHorizontal;
                m_targetVertical = m_angleVertical;
                m_startingRadius = Radius;
                m_IsWaiting = false;
                m_exploding = Convert.ToBoolean(MyUtils.GetRandomInt(0,1));
                m_explosionDelay = MyUtils.GetRandomInt((int)(MyDistantObjectsImpostorsConstants.EXPLOSION_WAIT_MILLISECONDS / 2.0f), (int)(MyDistantObjectsImpostorsConstants.EXPLOSION_WAIT_MILLISECONDS * 3f));
            }
        }
Пример #2
0
        void CreateImpostors()
        {
            m_impostors = new List <MyDistantObjectImpostor>();
            MyDistantObjectImpostorTypeEnum lastType = MyDistantObjectImpostorTypeEnum.Blinker;

            for (int i = 0; i < MyDistantObjectsImpostorsConstants.MAX_NUMBER_DISTANT_OBJECTS; i++)
            {
                //  assign some value because something must be assigned. later down in code we decide what impostor type will be this
                MyDistantObjectImpostorTypeEnum type = MyDistantObjectImpostorTypeEnum.Blinker;

                //  First third will be blinkers
                if (i <= MyDistantObjectsImpostorsConstants.MAX_NUMBER_DISTANT_OBJECTS * 0.33f)
                {
                    type = MyDistantObjectImpostorTypeEnum.Blinker;
                    m_impostorProperties[(int)type].IndexStart = 0;
                }
                //  Second third will be explosions
                if (i > MyDistantObjectsImpostorsConstants.MAX_NUMBER_DISTANT_OBJECTS * 0.33f)
                {
                    type = MyDistantObjectImpostorTypeEnum.Explosion;

                    //  If this is first explosion impostor we calculate its start index
                    if (lastType == MyDistantObjectImpostorTypeEnum.Blinker)
                    {
                        m_impostorProperties[(int)type].IndexStart = (MyVoxelMapImpostorsConstants.VERTEXES_PER_IMPOSTOR * i);
                        lastType = MyDistantObjectImpostorTypeEnum.Explosion;
                    }
                }
                //  Last third will be movers
                if (i > MyDistantObjectsImpostorsConstants.MAX_NUMBER_DISTANT_OBJECTS * 0.66f)
                {
                    type = MyDistantObjectImpostorTypeEnum.Mover;

                    //  If this is first explosion impostor we calculate its start index
                    if (lastType == MyDistantObjectImpostorTypeEnum.Explosion)
                    {
                        m_impostorProperties[(int)type].IndexStart = (MyVoxelMapImpostorsConstants.VERTEXES_PER_IMPOSTOR * i);
                        lastType = MyDistantObjectImpostorTypeEnum.Mover;
                    }
                }

                //  We calculate how many impostors of each type we have
                m_impostorProperties[(int)type].Count++;
                MyDistantObjectImpostor impostor = new MyDistantObjectImpostor();
                impostor.Start(type);
                m_impostors.Add(impostor);
            }
        }
Пример #3
0
        public void Start(MyDistantObjectImpostorTypeEnum type)
        {
            float angleHorizontal = MathHelper.ToRadians(MyUtils.GetRandomFloat(0, 360));
            float angleVertical   = MathHelper.ToRadians(MyUtils.GetRandomFloat(0, 360));

            float LOW_PRIORITY_ANGLE = MathHelper.ToRadians(45);

            if (((angleVertical >= (MathHelper.PiOver2 - LOW_PRIORITY_ANGLE)) && (angleVertical <= (MathHelper.PiOver2 + LOW_PRIORITY_ANGLE))) ||
                ((angleVertical >= (3 * MathHelper.PiOver2 - LOW_PRIORITY_ANGLE)) && (angleVertical <= (3 * MathHelper.PiOver2 + LOW_PRIORITY_ANGLE))))
            {
                angleVertical = MathHelper.ToRadians(MyUtils.GetRandomFloat(0, 360));
            }

            int typeEnum = MyUtils.GetRandomInt(0, 3);

            m_angleHorizontal = angleHorizontal;
            m_angleVertical   = angleVertical;
            Angle             = 0;
            Color             = new Vector4(1f, 1f, 1f, 1f);
            Type       = type;
            m_fading   = true;
            m_glowTime = 0;

            //  We make a random starting alpha and a random blink multiplier
            //  so they don't all blink at the same time
            if (Type == MyDistantObjectImpostorTypeEnum.Blinker)
            {
                Radius = MyUtils.GetRandomFloat(3000, 5000f);
                m_blinkMultiplierUp   = MyUtils.GetRandomFloat(70f, 90.0f);
                m_blinkMultiplierDown = MyUtils.GetRandomFloat(70f, 90.0f);
                m_startingRadius      = Radius;
            }

            //  Moving objects are initialized with a random destination
            if (Type == MyDistantObjectImpostorTypeEnum.Mover)
            {
                Radius             = MyUtils.GetRandomFloat(4000, 6000f);
                m_targetHorizontal = MathHelper.ToRadians(MyUtils.GetRandomFloat(0, 360));
                m_moverSpeed       = MyUtils.GetRandomFloat(MyDistantObjectsImpostorsConstants.MAX_MOVE_DISTANCE * 0.3f, MyDistantObjectsImpostorsConstants.MAX_MOVE_DISTANCE);
            }

            //  Explosions also have a blink multiplier to make flashes more random.
            //  Explosions will appear around their targer angles, but
            //  will stay in the same general area
            if (Type == MyDistantObjectImpostorTypeEnum.Explosion)
            {
                Radius                = MyUtils.GetRandomFloat(4000f, 6000f);
                Color.X               = MyUtils.GetRandomFloat(170.0f / 255f, 1.0f);
                Color.Y               = MyUtils.GetRandomFloat(100.0f / 255f, Color.X);
                Color.Z               = MyUtils.GetRandomFloat(0.0f, 40.0f / 255f);
                Color.W               = MyUtils.GetRandomFloat(0.0f, 1.0f);
                m_blinkMultiplierUp   = MyUtils.GetRandomFloat(11f, 16f);
                m_blinkMultiplierDown = MyUtils.GetRandomFloat(0.5f, 2f);
                m_targetHorizontal    = m_angleHorizontal;
                m_targetVertical      = m_angleVertical;
                m_startingRadius      = Radius;
                m_IsWaiting           = false;
                m_exploding           = Convert.ToBoolean(MyUtils.GetRandomInt(0, 1));
                m_explosionDelay      = MyUtils.GetRandomInt((int)(MyDistantObjectsImpostorsConstants.EXPLOSION_WAIT_MILLISECONDS / 2.0f), (int)(MyDistantObjectsImpostorsConstants.EXPLOSION_WAIT_MILLISECONDS * 3f));
            }
        }