Beispiel #1
0
		public FadeOutState (FadeOut action, Node target)
			: base (action, target)
		{
			staticSprite = Target.GetComponent<StaticSprite2D>();
			if (staticSprite != null)
				return;

			shape = Target.GetComponent<Shape>();
			if (shape != null)
				return;

			throw new NotSupportedException("The node should have StaticSprite2D or Shape component");
		}
Beispiel #2
0
        public FadeOutState(FadeOut action, Node target)
            : base(action, target)
        {
            staticSprite = Target.GetComponent <StaticSprite2D>();
            if (staticSprite != null)
            {
                return;
            }

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

            throw new NotSupportedException("The node should have StaticSprite2D or Shape 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);
		}