Exemplo n.º 1
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());
     }
 }
Exemplo n.º 2
0
        protected override async void Init()
        {
            InitialRotation = new Quaternion(180, 270, -30);
            var cache = Application.ResourceCache;
            var node  = Node;
            var model = node.CreateComponent <StaticModel>();

            model.Model = cache.GetModel(Assets.Models.Monkey);
            model.SetMaterial(cache.GetMaterial(Assets.Materials.Monkey).Clone(""));
            node.SetScale(RandomHelper.NextRandom(0.1f, 0.12f));
            node.Position = new Vector3(0f, 5f, 0f);

            // load weapons:
            node.AddComponent(new XamarinCube());

            node.Position = new Vector3(3 * (RandomHelper.NextBoolRandom() ? 1 : -1), RandomHelper.NextRandom(0, 2), 0);
            await Node.RunActionsAsync(new MoveTo(1f, new Vector3(RandomHelper.NextRandom(-2, 2), RandomHelper.NextRandom(2, 4), 0)));

            MoveRandomly(minX: -2f, maxX: 2f, minY: -1f, maxY: 1f, duration: 0.5f);
            StartShooting();
        }
Exemplo n.º 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());
     }
 }