Наследование: MonoBehaviour
Пример #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        protected ParticleSystem(Game game, Tint tint)
            : base(game)
        {
            this.content = game.Content;
            colorTint    = tint;

            if (colorTint == Tint.Dark)
            {
                InitializeSettingsForDark(settings);
            }
            else
            {
                InitializeSettingsForLight(settings);
            }

            particles = new ParticleVertex[settings.MaxParticles];
            LoadParticleEffect();

            vertexDeclaration = new VertexDeclaration(Game.GraphicsDevice,
                                                      ParticleVertex.VertexElements);

            // Create a dynamic vertex buffer.
            int size = ParticleVertex.SizeInBytes * particles.Length;

            vertexBuffer = new DynamicVertexBuffer(Game.GraphicsDevice, size,
                                                   BufferUsage.WriteOnly |
                                                   BufferUsage.Points);
        }
Пример #2
0
        public override void Render(UiContext context, RectangleF clientRectangle)
        {
            if (Model == null)
            {
                return;
            }
            if (!CanRender(context))
            {
                return;
            }
            var rect = context.PointsToPixels(clientRectangle);

            if (Clip)
            {
                context.RenderContext.ScissorEnabled   = true;
                context.RenderContext.ScissorRectangle = rect;
            }
            Matrix4x4 rotationMatrix = Matrix4x4.Identity;
            var       rot            = Rotate + (RotateAnimation * (float)context.GlobalTime);

            if (rot != Vector3.Zero)
            {
                rotationMatrix = Matrix4x4.CreateRotationX(rot.X) *
                                 Matrix4x4.CreateRotationY(rot.Y) *
                                 Matrix4x4.CreateRotationZ(rot.Z);
            }

            float scaleMult = 1;

            if (BaseRadius > 0)
            {
                scaleMult = BaseRadius / model.GetRadius();
            }
            var transform = Matrix4x4.CreateScale(Model.XScale * scaleMult, Model.YScale * scaleMult, 1) *
                            rotationMatrix *
                            Matrix4x4.CreateTranslation(Model.X, Model.Y, 0);

            transform *= CreateTransform((int)context.ViewportWidth, (int)context.ViewportHeight, rect);
            context.RenderContext.Cull = false;
            model.UpdateTransform();
            model.Update(context.MatrixCam, context.GlobalTime, context.Data.ResourceManager);
            if (Tint != null)
            {
                var color = Tint.GetColor(context.GlobalTime);
                for (int i = 0; i < mats.Count; i++)
                {
                    mats[i].Mat.Dc = color;
                }
            }
            model.DrawImmediate(context.RenderContext, context.Data.ResourceManager, transform, ref Lighting.Empty);
            if (Tint != null)
            {
                for (int i = 0; i < mats.Count; i++)
                {
                    mats[i].Mat.Dc = mats[i].Dc;
                }
            }
            context.RenderContext.ScissorEnabled = false;
            context.RenderContext.Cull           = true;
        }
Пример #3
0
        /// <summary>
        /// Calculates a hash code for this object.
        /// </summary>
        /// <returns>The hash code for this instance of <see cref="RandomParticleProperties"/>.</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hash = 23;

                if (Speed != null)
                {
                    hash = hash * 31 + Speed.GetHashCode();
                }
                if (Tint != null)
                {
                    hash = hash * 31 + Tint.GetHashCode();
                }
                if (Scale != null)
                {
                    hash = hash * 31 + Scale.GetHashCode();
                }
                if (TimeToLive != null)
                {
                    hash = hash * 31 + TimeToLive.GetHashCode();
                }
                if (ColorFactor != null)
                {
                    hash = hash * 31 + ColorFactor.GetHashCode();
                }
                if (RotationChange != null)
                {
                    hash = hash * 31 + RotationChange.GetHashCode();
                }
                return(hash);
            }
        }
Пример #4
0
    public void NextLevel()
    {
        Tint tint = ((Tint)GameObject.FindObjectOfType(typeof(Tint)));

        Score.Instance.IncrementScore(new Vector3(-1.9f, 3.7f, 0));
        Ball[] balls = (Ball[])GameObject.FindObjectsOfType(typeof(Ball));
        if (speedLimit < speedLimitMax)
        {
            speedLimit += (speedLimitMax - speedLimit) / speedGainRate;
            speedFloor  = speedLimit - speedFloorDiff;
        }
        for (int i = 0; i < balls.Length; i++)
        {
            balls[i].speedLimit = speedLimit;
            balls[i].speedFloor = speedFloor;
            balls[i].GetComponentInChildren <TrailRenderer>().Clear();
        }
        if (tint.levels[Score.Instance.level % tint.levels.Length].backgroundParticleObj != null)
        {
            Destroy(tint.backgroundParticles);
        }
        level++;
        if (tint.levels[Score.Instance.level % tint.levels.Length].backgroundParticleObj != null)
        {
            tint.backgroundParticles = Instantiate(tint.levels[Score.Instance.level % tint.levels.Length].backgroundParticleObj, Vector3.zero, Quaternion.identity);
            tint.UpdateObjectColor(tint.backgroundParticles);
        }
        GameObject.Find("GameManager").GetComponent <GameManager>().SpawnBlocker();
        tint.UpdateColors();
    }
Пример #5
0
 public void OnSelectionStateChanged(SelectionState state)
 {
     Tint.ByState(state, gameObject);
     if (state == SelectionState.Pressed)
     {
         //_landingPath.drawPath = true;
     }
 }
Пример #6
0
 //Constructors
 public Lens(Manufacturer man, double th, double mag, Colours colour, Tint tint)
 {
     Manuf         = man;
     Thickness     = th;
     Magnification = mag;
     Colour        = colour;
     Tint          = tint;
 }
Пример #7
0
    void Awake()
    {
        inTutorial = false;
        tutorial   = GameObject.Find("Tutorial");
        tutorial.SetActive(false);
        tint = ((Tint)GameObject.FindObjectOfType(typeof(Tint)));
        if (!Settings.Instance.continued)
        {
            int roundCount = (PlayerPrefs.GetInt("RoundCount") + 1);
            PlayerPrefs.SetInt("RoundCount", roundCount);
            Firebase.Analytics.FirebaseAnalytics.SetUserProperty("round_count", roundCount.ToString());
            if (PlayerPrefs.GetInt("RoundCount") == 1)
            {
                Firebase.Analytics.FirebaseAnalytics.LogEvent("first_round_start");
            }
            else
            {
                Firebase.Analytics.FirebaseAnalytics.LogEvent("round_start", new Firebase.Analytics.Parameter("round_count", roundCount));
            }
        }
        else
        {
            Firebase.Analytics.FirebaseAnalytics.LogEvent("continued", new Firebase.Analytics.Parameter("blocker_name", Score.Instance.availableBlockers[Score.Instance.blockerIndex].name));
        }

        blockerCount = 0;
        screenObj    = GameObject.Find("Screen").GetComponent <BoxCollider2D>();
        if (SceneManager.GetActiveScene().name == "Gameplay")
        {
            Ads.Instance.RequestBanner();
        }
        GameObject screen              = GameObject.Find("Screen");
        float      screenWidthToWorld  = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.nearClipPlane)).x * 2;
        float      screenHeightToWorld = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.nearClipPlane)).y * 2;
        float      originalHeight      = 9.91f;
        float      originalWidth       = 5.66f;

        if (SceneManager.GetActiveScene().name == "Gameplay")
        {
            GameObject adBackground = GameObject.Find("BannerBackgroundBlank");
#if UNITY_ANDROID
            float bannerHeight = 150f * ((float)Screen.height / 1920f);
#elif UNITY_IOS
            float bannerHeight = 150f * ((float)Screen.height / 1334f);
#endif
            float newHeight = screenHeightToWorld * ((Screen.height - bannerHeight) / Screen.height);
            screen.transform.localScale          = new Vector3(screenWidthToWorld / originalWidth, newHeight / originalHeight, 1);
            screen.transform.localPosition       = new Vector3(0, (newHeight - originalHeight) / 2, screen.transform.localPosition.z);
            adBackground.transform.localPosition = new Vector3(0, (newHeight / 2) + (newHeight - originalHeight) / 2, adBackground.transform.localPosition.z);
        }
        else
        {
            screen.transform.localScale    = new Vector3(screenWidthToWorld / originalWidth, screenHeightToWorld / originalHeight, 1);
            screen.transform.localPosition = new Vector3(0, 0, screen.transform.localPosition.z);
        }
        CreatePaddles();
    }
Пример #8
0
        private void updateColor(ref Color color)
        {
            if (Tint == DefaultTint)
            {
                return;
            }

            color = new Color(color.ToVector4() * Tint.ToVector4());
        }
Пример #9
0
        public override void LoadDataToComponets(CosmeticProduct currentProduct, Control.ControlCollection controls)
        {
            base.LoadDataToComponets(currentProduct, controls);
            Control[] controlList = GetComponentsForInput(controls);
            Tint      currentTint = (Tint)currentProduct;

            controlList[durabilityIndex].Text  = currentTint.Durability.ToString();
            controlList[applicationIndex].Text = currentTint.ApplicationOfProduct;
        }
Пример #10
0
        public override void Render(DwarfTime gameTime,
                                    ChunkManager chunks,
                                    Camera camera,
                                    SpriteBatch spriteBatch,
                                    GraphicsDevice graphicsDevice,
                                    Effect effect, bool renderingForWater)
        {
            if (Primitive == null)
            {
                Primitive = new BatchBillboardPrimitive(graphicsDevice, SpriteSheet.GetTexture(), Width, Height, Frame, 1.0f, 1.0f, false, LocalTransforms, Tints, Colors);
            }


            if (IsVisible && ShouldDraw(camera))
            {
                if (!LightsWithVoxels)
                {
                    effect.Parameters["xTint"].SetValue(new Vector4(1, 1, 1, 1));
                }
                else
                {
                    effect.Parameters["xTint"].SetValue(Tint.ToVector4());
                }

                RasterizerState r = graphicsDevice.RasterizerState;
                graphicsDevice.RasterizerState = rasterState;
                effect.Parameters["xTexture"].SetValue(SpriteSheet.GetTexture());

                DepthStencilState origDepthStencil = graphicsDevice.DepthStencilState;
                DepthStencilState newDepthStencil  = DepthStencilState.DepthRead;
                graphicsDevice.DepthStencilState = newDepthStencil;


                //Matrix oldWorld = effect.Parameters["xWorld"].GetValueMatrix();
                effect.Parameters["xWorld"].SetValue(GlobalTransform);

                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    Primitive.Render(graphicsDevice);
                }

                effect.Parameters["xWorld"].SetValue(Matrix.Identity);

                if (origDepthStencil != null)
                {
                    graphicsDevice.DepthStencilState = origDepthStencil;
                }

                if (r != null)
                {
                    graphicsDevice.RasterizerState = r;
                }
            }
        }
Пример #11
0
//    int selected = 4;
    public override void OnInspectorGUI()
    {
        Tint obj = (Tint)target;

        GUILayout.Label("Tint Color");
        obj.TintColor = EditorGUILayout.ColorField(obj.TintColor);
        GUILayout.Label("Lightmap Options");
        obj.options = (Tint.AdjustTint)EditorGUILayout.EnumPopup(obj.options);
        GUILayout.Label("Execute ON");
        obj.executeTrigger = (Tint.ExecuteON)EditorGUILayout.EnumPopup(obj.executeTrigger);
    }
Пример #12
0
        public override int GetHashCode()
        {
            var hashCode = -1876634251;

            hashCode = hashCode * -1521134295 + Tint.GetHashCode();
            hashCode = hashCode * -1521134295 + BorderTint.GetHashCode();
            hashCode = hashCode * -1521134295 + BorderSize;
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Path);

            return(hashCode);
        }
Пример #13
0
 public RectangleChecker(Game game, Tint colorTint)
     : base(game, 0.2f, 1.0f, 1.0f)
 {
     this.colorTint = colorTint;
     cam            = (GameCamera)game.Services.GetService(typeof(BasicCamera));
     textureLibrary = (TexturesLibrary)game.Services.GetService(typeof(TexturesLibrary));
     checkerEffect  = new PhongEffect(game, colorTint);
     CheckerEffect.setOtherParams();
     LoadContent();
     generateChecker();
 }
Пример #14
0
    // Use this for initialization
    void Start()
    {
        ParticleSystem ps           = GetComponent <ParticleSystem>();
        Gradient       particleGrad = new Gradient();
        Tint           tint         = (Tint)GameObject.FindObjectOfType(typeof(Tint));

        particleGrad.SetKeys(new GradientColorKey[] { new GradientColorKey(tint.levels[Score.Instance.level % tint.levels.Length].scoreColor, 0.0f), new GradientColorKey(tint.levels[Score.Instance.level % tint.levels.Length].scoreColor, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(0.0f, 1.0f), new GradientAlphaKey(1.0f, 0.0f) });
        var col = GetComponent <ParticleSystem>().colorOverLifetime;

        col.color = particleGrad;
    }
Пример #15
0
        /// <summary>
        /// Tints the current image with the given color.
        /// </summary>
        /// <param name="color">
        /// The <see cref="T:System.Drawing.Color"/> to tint the image with.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Tint(Color color)
        {
            if (this.ShouldProcess)
            {
                Tint tint = new Tint {
                    DynamicParameter = color
                };
                this.CurrentImageFormat.ApplyProcessor(tint.ProcessImage, this);
            }

            return(this);
        }
Пример #16
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Exists.GetHashCode();
         hashCode = (hashCode * 397) ^ BlockId;
         hashCode = (hashCode * 397) ^ TextureIndex;
         hashCode = (hashCode * 397) ^ Tint.GetHashCode();
         hashCode = (hashCode * 397) ^ LightTopLeft.GetHashCode();
         hashCode = (hashCode * 397) ^ LightTopRight.GetHashCode();
         hashCode = (hashCode * 397) ^ LightBottomLeft.GetHashCode();
         hashCode = (hashCode * 397) ^ LightBottomRight.GetHashCode();
         return(hashCode);
     }
 }
Пример #17
0
        public override void GetDataFromComponents(CosmeticProduct currentProduct, Control.ControlCollection controls)
        {
            base.GetDataFromComponents(currentProduct, controls);
            Control[] controlList = GetComponentsForInput(controls);
            Tint      currentTint = (Tint)currentProduct;

            try
            {
                currentTint.Durability = Convert.ToInt32(controlList[durabilityIndex].Text);
            }
            catch
            {
                throw new Exception();
            }
            currentTint.ApplicationOfProduct = controlList[applicationIndex].Text;
        }
Пример #18
0
        /// <summary>
        /// Draws the content.
        /// </summary>
        /// <param name="spriteBatch">Sprite batch.</param>
        public void Draw(SpriteBatch spriteBatch)
        {
            Vector2 origin = new Vector2(SourceRectangle.Width / 2,
                                         SourceRectangle.Height / 2);

            if (!string.IsNullOrEmpty(Text))
            {
                DrawString(spriteBatch, font, StringUtils.WrapText(font, Text, SpriteSize.Width), ClientRectangle.ToXnaRectangle(),
                           TextHorizontalAlignment, TextVerticalAlignment, Tint.ToXnaColor() * Opacity);
            }

            // TODO: Do not do this for every Draw call
            Texture2D textureToDraw = texture;

            // TODO: Find a better way to do this, because this one doesn't keep the mipmaps
            if (alphaMask != null)
            {
                textureToDraw = TextureBlend(texture, alphaMask);
            }

            if (TextureLayout == TextureLayout.Stretch)
            {
                spriteBatch.Draw(textureToDraw, new Vector2(Location.X + ClientRectangle.Width / 2, Location.Y + ClientRectangle.Height / 2), SourceRectangle.ToXnaRectangle(),
                                 Tint.ToXnaColor() * Opacity, Rotation,
                                 origin, Scale.ToXnaVector2() * Zoom,
                                 SpriteEffects.None, 0.0f);
            }
            else if (TextureLayout == TextureLayout.Tile)
            {
                GraphicsDevice gd = GraphicsManager.Instance.Graphics.GraphicsDevice;

                Rectangle rec = new Rectangle(0, 0, ClientRectangle.Width, ClientRectangle.Height);

                // TODO: Is it ok to End and Begin again? Does it affect performance?
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null);

                spriteBatch.Draw(textureToDraw, new Vector2(Location.X, Location.Y), rec, Tint.ToXnaColor() * Opacity);

                spriteBatch.End();
                spriteBatch.Begin();
            }
        }
Пример #19
0
        public void TestTintRegex()
        {
            const string HexQuerystring  = "tint=6aa6cc";
            const string RgbaQuerystring = "tint=106,166,204,255";
            Color        expectedHex     = ColorTranslator.FromHtml("#" + "6aa6cc");
            Color        expectedRgba    = Color.FromArgb(255, 106, 166, 204);

            Tint tint = new Tint();

            tint.MatchRegexIndex(HexQuerystring);
            Color actualHex = tint.DynamicParameter;

            Assert.AreEqual(expectedHex, actualHex);

            tint = new Tint();
            tint.MatchRegexIndex(RgbaQuerystring);
            Color actualRgba = tint.DynamicParameter;

            Assert.AreEqual(expectedRgba, actualRgba);
        }
Пример #20
0
        protected override bool ParseCilInstructionInternal(Instruction instruction,
                                                            ProgramState state)
        {
            switch (instruction.OpCode.Code)
            {
            case Code.Isinst:
                (var objectExpression, var objectType) = state.Pop();
                var typeToCheck               = instruction.Operand as TypeReference;
                var returnIdentifier          = state.GetIdentifier(Identifier.IdentKind.Normal);
                var returnType                = new Tint(Tint.IntKind.IBool, true);
                var builtinFunctionExpression = new ConstExpression(
                    ProcedureName.BuiltIn__instanceof);
                var sizeofExpression = new SizeofExpression(
                    Typ.FromTypeReferenceNoPointer(typeToCheck),
                    SizeofExpression.SizeofExpressionKind.instof);
                var args = new List <Call.CallArg>
                {
                    new Call.CallArg(objectExpression, objectType),
                    new Call.CallArg(sizeofExpression, new Tvoid())
                };
                var callInstruction = new Call(
                    returnIdentifier,
                    returnType,
                    builtinFunctionExpression,
                    args,
                    new Call.CallFlags(),
                    state.CurrentLocation);
                var newNode = AddMethodBodyInstructionsToCfg(state, callInstruction);
                state.PushExpr(new VarExpression(returnIdentifier), returnType);
                state.PushInstruction(instruction.Next, newNode);
                return(true);

            default:
                return(false);
            }
        }
Пример #21
0
 // Use this for initialization
 void Start()
 {
     neg_rigid = NegativeObjects.GetComponentsInChildren<Rigidbody2D>();
     pos_objects = PositiveObjects.GetComponentsInChildren<SpriteRenderer>();
     poslink_humans = PosLinkHumanos.GetComponentsInChildren<BoxCollider2D>();
     changing_bg = ChangingBackgrounds.GetComponentsInChildren<SpriteRenderer>();
     tint = Tint_bg.GetComponent<Tint>();
     linked_objects = 0;
     phase = 1;
     hit_neg_obj = false;
     destroy_humanitos_after_clean = false;
     humanitos_count = 0;
     PosHumanosHelpers = new GameObject[12];
     poshumanoshelpers_index = 0;
     background_index = 2;
     cleaning = false;
     internal_timer_phase1 = 0f;
     health_of_city = 0;
     DetectNumberOfPosObjects();
 }
Пример #22
0
 //Constructors => although in DataHelper I am using object initializers
 public RoundLens(Manufacturer man, double rd, double th, double mag, Tint tint, Colours colour)
     : base(man, th, mag, colour, tint)
 {
     Radiant = rd;
 }
Пример #23
0
 private void Awake()
 {
     tint = ((Tint)GameObject.FindObjectOfType(typeof(Tint)));
     tint.UpdateObjectColor(gameObject);
 }
Пример #24
0
        protected override bool ParseCilInstructionInternal(Instruction instruction,
                                                            ProgramState state)
        {
            int     index;
            CfgNode node = null;

            switch (instruction.OpCode.Code)
            {
            case Code.Ldloc:
            case Code.Ldloca:
                try
                {
                    index = (int)instruction.Operand;
                }
                catch (System.InvalidCastException e)
                {
                    Log.WriteWarning(e.Message);
                    return(false);
                }
                break;

            case Code.Ldloc_0:
                index = 0;
                break;

            case Code.Ldloc_1:
                index = 1;
                break;

            case Code.Ldloc_2:
                index = 2;
                break;

            case Code.Ldloc_3:
                index = 3;
                break;

            case Code.Ldloc_S:
            case Code.Ldloca_S:
                try
                {
                    index = (instruction.Operand as VariableDefinition).Index;
                }
                catch (System.InvalidCastException e)
                {
                    Log.WriteWarning(e.Message);
                    return(false);
                }
                break;

            default:
                return(false);
            }

            (var variableExpression, var variableType) = CreateLocal(index, state.Method);

            // Updates the type to the appropriate boxed one if the variable contains a boxed
            // value.
            if (state.VariableIndexToBoxedValueType.ContainsKey(index))
            {
                variableType = state.VariableIndexToBoxedValueType[index];
            }
            else if (state.IndicesWithIsInstReturnType.Contains(index))
            {
                variableType = new Tint(Tint.IntKind.IBool, true);
            }

            if (instruction.OpCode.Code == Code.Ldloca || instruction.OpCode.Code == Code.Ldloca_S)
            {
                // Stores the variable as the value stored at the address expression.
                state.PushExpr(variableExpression, new Address(Tptr.PtrKind.Pk_pointer,
                                                               variableType,
                                                               variableExpression));
            }
            else if (state.VariableIndexToNullCheck.ContainsKey(index))
            {
                state.PushExpr(state.VariableIndexToNullCheck[index].expr,
                               state.VariableIndexToNullCheck[index].type);
            }
            else
            {
                // Loads the value at the heap location onto the stack.
                var variableInstruction = state.PushAndLoad(variableExpression,
                                                            variableType);
                node = AddMethodBodyInstructionsToCfg(state, variableInstruction);
                state.AppendToPreviousNode = true;
            }
            state.PushInstruction(instruction.Next, node);
            return(true);
        }
Пример #25
0
 public FireParticleSystem(Game game, Tint colorTint)
     : base(game, colorTint)
 {
 }
Пример #26
0
        // Constructor


        public AbstractEffect(Game game, Tint tint)
            : base(game)
        {
            colorTint = tint;
        }
Пример #27
0
        public override void SetEffect(GameTime gameTime, Effect effect)
        {
            base.SetEffect(gameTime, effect);


            if (effect.Parameters["AmbientIntensity"] != null)
            {
                effect.Parameters["AmbientIntensity"].SetValue(AmbientIntensity);
            }

            if (effect.Parameters["AmbientColor"] != null)
            {
                effect.Parameters["AmbientColor"].SetValue(AmbientColor.ToVector4());
            }

            if (effect.Parameters["itw"] != null)
            {
                effect.Parameters["itw"].SetValue(Matrix.Invert(Matrix.Transpose(World)));
            }

            if (MultiLight)
            {
                // Calculate the light direction in relation to me.
                if (effect.Parameters["LightDirection"] != null)
                {
                    effect.Parameters["LightDirection"].SetValue(Lights.Select(p => p.Position - Position).ToArray());
                }

                if (effect.Parameters["DiffuseIntensity"] != null)
                {
                    effect.Parameters["DiffuseIntensity"].SetValue(Lights.Select(p => p.LightIntensity).ToArray());
                }
                if (effect.Parameters["DiffuseColor"] != null)
                {
                    effect.Parameters["DiffuseColor"].SetValue(Lights.Select(p => p.Color.ToVector4()).ToArray());
                }

                if (effect.Parameters["SpecularColor"] != null)
                {
                    effect.Parameters["SpecularColor"].SetValue(Lights.Select(p => p.SpecularColor.ToVector4()).ToArray());
                }
                if (effect.Parameters["SpecularIntensity"] != null)
                {
                    effect.Parameters["SpecularIntensity"].SetValue(Lights.Select(p => p.SpecularIntensity).ToArray());
                }
            }
            else
            {
                if (effect.Parameters["LightDirection"] != null)
                {
                    effect.Parameters["LightDirection"].SetValue(Lights[0].Position - Position);
                }

                if (effect.Parameters["DiffuseIntensity"] != null)
                {
                    effect.Parameters["DiffuseIntensity"].SetValue(Lights[0].LightIntensity);
                }
                if (effect.Parameters["DiffuseColor"] != null)
                {
                    effect.Parameters["DiffuseColor"].SetValue(Lights[0].Color.ToVector4());
                }

                if (effect.Parameters["SpecularColor"] != null)
                {
                    effect.Parameters["SpecularColor"].SetValue(Lights[0].SpecularColor.ToVector4());
                }
                if (effect.Parameters["SpecularIntensity"] != null)
                {
                    effect.Parameters["SpecularIntensity"].SetValue(Lights[0].SpecularIntensity);
                }
            }

            if (effect.Parameters["CameraPosition"] != null)
            {
                effect.Parameters["CameraPosition"].SetValue(camera.Position);
            }

            if (effect.Parameters["ColorMap"] != null)
            {
                effect.Parameters["ColorMap"].SetValue(Game.Content.Load <Texture2D>(ColorAsset));
            }
            if (effect.Parameters["GlowMap"] != null)
            {
                effect.Parameters["GlowMap"].SetValue(Game.Content.Load <Texture2D>(GlowAsset));
            }
            if (effect.Parameters["BumpMap"] != null)
            {
                effect.Parameters["BumpMap"].SetValue(Game.Content.Load <Texture2D>(BumpAsset));
            }
            if (effect.Parameters["ReflectionMap"] != null)
            {
                effect.Parameters["ReflectionMap"].SetValue(Game.Content.Load <Texture2D>(ReflectionAsset));
            }

            if (effect.Parameters["worldIT"] != null)
            {
                effect.Parameters["worldIT"].SetValue(Matrix.Invert(Matrix.Transpose(World)));
            }

            if (effect.Parameters["viewI"] != null)
            {
                effect.Parameters["viewI"].SetValue(Matrix.Invert(camera.View));
            }

            if (effect.Parameters["cubeMap"] != null)
            {
                effect.Parameters["cubeMap"].SetValue(Game.Content.Load <TextureCube>(ColorAsset));
            }

            if (effect.Parameters["tint"] != null)
            {
                effect.Parameters["tint"].SetValue(Tint.ToVector4());
            }

            if (effect.Parameters["fresnelTex"] != null)
            {
                effect.Parameters["fresnelTex"].SetValue(Game.Content.Load <Texture2D>(GlowAsset));
            }

            if (effect.Parameters["EyePosition"] != null)
            {
                effect.Parameters["EyePosition"].SetValue(camera.Position);
            }

            if (effect.Parameters["time"] != null)
            {
                effect.Parameters["time"].SetValue((float)gameTime.TotalGameTime.TotalSeconds * 3);
            }


            if (effect.Parameters["CloudMap"] != null)
            {
                effect.Parameters["CloudMap"].SetValue(Game.Content.Load <Texture2D>(CloudMap));
            }

            if (effect.Parameters["WaveMap"] != null)
            {
                effect.Parameters["WaveMap"].SetValue(Game.Content.Load <Texture2D>(WaterRipples));
            }

            if (effect.Parameters["AtmosMap"] != null)
            {
                effect.Parameters["AtmosMap"].SetValue(Game.Content.Load <Texture2D>(AtmosAsset));
            }

            if (effect.Parameters["cloudSpeed"] != null)
            {
                effect.Parameters["cloudSpeed"].SetValue(cloudSpeed);
            }

            if (effect.Parameters["cloudHeight"] != null)
            {
                effect.Parameters["cloudHeight"].SetValue(cloudHeight);
            }

            if (effect.Parameters["cloudShadowIntensity"] != null)
            {
                effect.Parameters["cloudShadowIntensity"].SetValue(cloudShadowIntensity);
            }
        }
Пример #28
0
 /// <summary>
 /// SquareLens concreate class based on Lens class
 /// </summary>
 /// <param name="man">manufacturer</param>
 /// <param name="ht">height</param>
 /// <param name="wd">width</param>
 /// <param name="th">thickness</param>
 /// <param name="mag">magnification</param>
 /// <param name="tint">tint</param>
 /// <param name="colour">colour</param>
 public SquareLens(Manufacturer man, double wd, double ht, double th, double mag, Tint tint, Colours colour)
     : base(man, th, mag, colour, tint)
 {
     Width  = wd;
     Height = ht;
 }
Пример #29
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Hide no camera label
            NoCamera.Hidden = ThisApp.CameraAvailable;

            // Attach to camera view
            ThisApp.Recorder.DisplayView = CameraView;

            // Set min and max values
            Temperature.MinValue = 1000f;
            Temperature.MaxValue = 10000f;

            Tint.MinValue = -150f;
            Tint.MaxValue = 150f;

            // Create a timer to monitor and update the UI
            SampleTimer          = new Timer(5000);
            SampleTimer.Elapsed += (sender, e) => {
                // Convert color space
                var TempAndTint = ThisApp.CaptureDevice.GetTemperatureAndTintValues(ThisApp.CaptureDevice.DeviceWhiteBalanceGains);

                // Update slider positions
                Temperature.BeginInvokeOnMainThread(() => {
                    Temperature.Value = TempAndTint.Temperature;
                });

                Tint.BeginInvokeOnMainThread(() => {
                    Tint.Value = TempAndTint.Tint;
                });
            };

            // Watch for value changes
            Segments.ValueChanged += (sender, e) => {
                // Lock device for change
                if (ThisApp.CaptureDevice.LockForConfiguration(out Error))
                {
                    // Take action based on the segment selected
                    switch (Segments.SelectedSegment)
                    {
                    case 0:
                        // Activate auto focus and start monitoring position
                        Temperature.Enabled = false;
                        Tint.Enabled        = false;
                        ThisApp.CaptureDevice.WhiteBalanceMode = AVCaptureWhiteBalanceMode.ContinuousAutoWhiteBalance;
                        SampleTimer.Start();
                        Automatic = true;
                        break;

                    case 1:
                        // Stop auto focus and allow the user to control the camera
                        SampleTimer.Stop();
                        ThisApp.CaptureDevice.WhiteBalanceMode = AVCaptureWhiteBalanceMode.Locked;
                        Automatic           = false;
                        Temperature.Enabled = true;
                        Tint.Enabled        = true;
                        break;
                    }

                    // Unlock device
                    ThisApp.CaptureDevice.UnlockForConfiguration();
                }
            };

            // Monitor position changes
            Temperature.TouchUpInside += (sender, e) => {
                // If we are in the automatic mode, ignore changes
                if (Automatic)
                {
                    return;
                }

                // Update white balance
                SetTemperatureAndTint();
            };

            Tint.TouchUpInside += (sender, e) => {
                // If we are in the automatic mode, ignore changes
                if (Automatic)
                {
                    return;
                }

                // Update white balance
                SetTemperatureAndTint();
            };

            GrayCardButton.TouchUpInside += (sender, e) => {
                // If we are in the automatic mode, ignore changes
                if (Automatic)
                {
                    return;
                }

                // Get gray card values
                var gains = ThisApp.CaptureDevice.GrayWorldDeviceWhiteBalanceGains;

                // Set the new values
                if (ThisApp.CaptureDevice.LockForConfiguration(out Error))
                {
                    ThisApp.CaptureDevice.SetWhiteBalanceModeLockedWithDeviceWhiteBalanceGains(gains, null);
                    ThisApp.CaptureDevice.UnlockForConfiguration();
                }
            };
        }
Пример #30
0
 public override int GetHashCode()
 {
     return(Temperature.GetHashCode() ^ Tint.GetHashCode());
 }
Пример #31
0
        protected override bool ParseCilInstructionInternal(Instruction instruction,
                                                            ProgramState state)
        {
            ConstExpression constExp = null;
            Typ             type     = null;

            switch (instruction.OpCode.Code)
            {
            case Code.Ldc_I4_M1:
                (constExp, type) = MakeInt(-1);
                break;

            case Code.Ldc_I4:
                (constExp, type) = MakeInt((int)instruction.Operand);
                break;

            case Code.Ldc_I4_S:
                (constExp, type) = MakeInt((sbyte)instruction.Operand);
                break;

            case Code.Ldc_I4_0:
                (constExp, type) = MakeInt(0);
                break;

            case Code.Ldc_I4_1:
                (constExp, type) = MakeInt(1);
                break;

            case Code.Ldc_I4_2:
                (constExp, type) = MakeInt(2);
                break;

            case Code.Ldc_I4_3:
                (constExp, type) = MakeInt(3);
                break;

            case Code.Ldc_I4_4:
                (constExp, type) = MakeInt(4);
                break;

            case Code.Ldc_I4_5:
                (constExp, type) = MakeInt(5);
                break;

            case Code.Ldc_I4_6:
                (constExp, type) = MakeInt(6);
                break;

            case Code.Ldc_I4_7:
                (constExp, type) = MakeInt(7);
                break;

            case Code.Ldc_I4_8:
                (constExp, type) = MakeInt(8);
                break;

            case Code.Ldc_I8:
                (constExp, _) = MakeInt((long)instruction.Operand);
                type          = new Tint(Tint.IntKind.ILongLong);
                break;

            case Code.Ldc_R4:
                constExp = new ConstExpression((float)instruction.Operand);
                type     = new Tfloat(Tfloat.FloatKind.FFloat);
                break;

            case Code.Ldc_R8:
                constExp = new ConstExpression((double)instruction.Operand);
                type     = new Tfloat(Tfloat.FloatKind.FDouble);
                break;

            case Code.Ldstr:
                constExp = new ConstExpression((string)instruction.Operand);
                type     = new Tptr(Tptr.PtrKind.Pk_pointer, new Tstruct("System.String"));
                break;

            default:
                return(false);
            }

            state.PushExpr(constExp, type);
            state.PushInstruction(instruction.Next);

            return(true);
        }