示例#1
0
		protected override async void Start()
		{
			base.Start();
			clientConnection = new ClientConnection();
			clientConnection.Disconnected += ClientConnection_Disconnected;
			clientConnection.RegisterForRealtimeUpdate(GetCurrentPositionDto);
			clientConnection.RegisterFor<PointerPositionChangedDto>(OnClientPointerChanged);

			Zone.AmbientColor = new Color(0.3f, 0.3f, 0.3f);
			DirectionalLight.Brightness = 0.5f;

			environmentNode = Scene.CreateChild();
			EnableGestureTapped = true;

			cubeNode = environmentNode.CreateChild();
			cubeNode.SetScale(0.2f);
			cubeNode.Position = new Vector3(1000, 1000, 1000);
			var box = cubeNode.CreateComponent<Box>();
			box.Color = Color.White;

			var moveAction = new MoveBy(0.5f, new Vector3(0, 0.005f, 0));
			cubeNode.RunActions(new RepeatForever(new RotateBy(1f, 0, 120, 0)));
			cubeNode.RunActions(new RepeatForever(moveAction, moveAction.Reverse()));

			//material = Material.FromColor(Color.Gray); //-- debug mode
			material = Material.FromColor(Color.Transparent, true);

			await RegisterCortanaCommands(new Dictionary<string, Action> {
				{ "stop spatial mapping", StopSpatialMapping}
			});

			while (!await ConnectAsync()) { }
		}
示例#2
0
		async void MoveRandomly()
		{
			while (IsAlive)
			{
				var moveAction = new MoveBy(0.75f, new Vector3(RandomHelper.NextRandom(-0.4f, 0.4f), RandomHelper.NextRandom(-0.3f, 0.3f), 0));
				await Node.RunActionsAsync(moveAction, moveAction.Reverse());
			}
		}
示例#3
0
		/// <summary>
		/// Set boundaries for random movements
		/// </summary>
		protected async void MoveRandomly(float minX, float maxX, float minY, float maxY, float duration)
		{
			while (IsAlive)
			{
				var moveAction = new MoveBy(duration, new Vector3(RandomHelper.NextRandom(minX, maxX), RandomHelper.NextRandom(minY, maxY), 0));
				await Node.RunActionsAsync(moveAction, moveAction.Reverse());
			}
		}
示例#4
0
		public async void Rotate()
		{
			if (planeNode == null)//not created yet
				return;
			var moveAction = new MoveBy(1f, new Vector3(0, 0, 5));
			var rotateAction = new RotateBy(duration: 1, deltaAngleX: 0, deltaAngleY: 90, deltaAngleZ: 20);
			//planeNode.GetComponent<StaticModel>().Model = CoreAssets.Models.Sphere;
			//planeNode.SetScale(7f);
			await planeNode.RunActionsAsync(new Urho.Actions.Parallel(moveAction, rotateAction));
			await planeNode.RunActionsAsync(new RepeatForever(new RotateBy(duration: 1, deltaAngleX: 0, deltaAngleY: 90, deltaAngleZ: 0)));
		}
		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);
		}
示例#6
0
		public override void OnAttachedToNode(Node node)
		{
			base.OnAttachedToNode(node);
			Application.Input.TouchEnd += Input_TouchEnd;
			Application.Input.TouchBegin += Input_TouchBegin;

			cubeNode = node.CreateChild();
			cubeNode.Position = new Vector3(1000, 1000, 1000);
			cubeNode.SetScale(0.02f);
			var box = cubeNode.CreateComponent<Box>();
			box.Color = Color.White;

			var moveAction = new MoveBy(0.5f, new Vector3(0, 0.005f, 0));
			cubeNode.RunActionsAsync(new RepeatForever(new RotateBy(1f, 0, 120, 0)));
			cubeNode.RunActionsAsync(new RepeatForever(moveAction, moveAction.Reverse()));

			camera = Scene.GetChildrenWithComponent<Camera>(true).First().GetComponent<Camera>();
			octree = Scene.GetComponent<Octree>(true);
		}
示例#7
0
文件: MoveBy.cs 项目: Zamir7/urho
		public MoveByState (MoveBy action, Node target)
			: base (action, target)
		{ 
			PositionDelta = action.PositionDelta;
			PreviousPosition = StartPosition = target.Position;
		}
示例#8
0
 public MoveByState(MoveBy action, Node target)
     : base(action, target)
 {
     PositionDelta    = action.PositionDelta;
     PreviousPosition = StartPosition = target.Position;
 }