Example #1
0
File: TintTo.cs Project: yrest/urho
        public TintToState(TintTo action, Node target)
            : base(action, target)
        {
            ColorTo             = action.ColorTo;
            ShaderParameterName = action.ShaderParameterName;
            MaterialIndex       = action.MaterialIndex;
            staticSprite        = Target.GetComponent <StaticSprite2D>();
            if (staticSprite != null)
            {
                ColorFrom = staticSprite.Color;
                return;
            }

            var staticModel = Target.GetComponent <StaticModel>();

            if (staticModel != null)
            {
                material = staticModel.GetMaterial(0);
                if (material != null)
                {
                    ColorFrom = material.GetShaderParameter(ShaderParameterName);
                    return;
                }
                else
                {
                    throw new NotSupportedException("StaticModel.Material should not be empty.");
                }
            }

            throw new NotSupportedException("The node should have StaticSprite2D or StaticModel+Material component");
        }
		protected override void OnUpdate(float timeStep)
		{
			var input = Input;

			const float duration = 1f; //2s
			FiniteTimeAction action = null;

			if (input.GetKeyPress(Key.W))
			{
				action = new MoveBy(duration, new Vector3(0, 0, 5));
			}

			if (input.GetKeyPress(Key.S))
			{
				action = new MoveBy(duration, new Vector3(0, 0, -5));
			}

			if (input.GetKeyPress(Key.E))
			{
				action = new FadeIn(duration); 
			}

			if (input.GetKeyPress(Key.Q))
			{
				action = new FadeOut(duration);
			}

			if (input.GetKeyPress(Key.R))
			{
				action = new EaseElasticInOut(new ScaleBy(duration, 1.3f));
			}

			if (input.GetKeyPress(Key.G))
			{
				action = new TintTo(duration, NextRandom(1), NextRandom(1), NextRandom(1));
			}

			if (action != null)
			{
				//can be awaited
				boxNode.RunActionsAsync(action);
			}
			base.OnUpdate(timeStep);
		}
Example #3
0
        public TintToState(TintTo action, Node target)
            : base(action, target)
        {
            ColorTo = action.ColorTo;

            staticSprite = Target.GetComponent <StaticSprite2D>();
            if (shape != null)
            {
                ColorFrom = staticSprite.Color;
                return;
            }

            shape = Target.GetComponent <Shape>();
            if (shape != null)
            {
                ColorFrom = shape.Color;
                return;
            }

            throw new NotSupportedException("The node should have StaticSprite2D or Shape component");
        }
Example #4
0
		public TintToState (TintTo action, Node target)
			: base (action, target)
		{   
			ColorTo = action.ColorTo;

			staticSprite = Target.GetComponent<StaticSprite2D>();
			if (shape != null)
			{
				ColorFrom = staticSprite.Color;
				return;
			}

			shape = Target.GetComponent<Shape>();
			if (shape != null)
			{
				ColorFrom = shape.Color;
				return;
			}

			throw new NotSupportedException("The node should have StaticSprite2D or Shape component");
		}