コード例 #1
0
ファイル: Player.cs プロジェクト: res09ggm/ucimobile
        public void performGravitySphere()
        {
            if (!performingGravitySphere && energy > 10)
            {
                performingGravitySphere = true;
                energy -= 10;
                //create sphere first
                gravity = new GravityController(5f, 10f, 2f);
                //gravity.DisabledOnGroup = 3;
                //gravity.EnabledOnGroup = 2;
                gravity.DisabledOnCategories = Category.Cat4;
                gravity.EnabledOnCategories = Category.Cat3;

                GameplayScreen._world.AddController(gravity);

                // fixture for planet (the one that has gravity)
                planet = BodyFactory.CreateBody(GameplayScreen._world);
                planet.Position = GameplayScreen.clickedPosition;
                CircleShape planetShape = new CircleShape(2, 1);
                planet.CreateFixture(planetShape);
                planet.CollidesWith = Category.None;
                planet.IgnoreCCD = false;
                gravity.AddBody(planet);

                listOfCurrentPlanets.Add(planet);

                for (int i = 0; i < GameplayScreen._world.BodyList.Count; i++)
                {
                    Body p = GameplayScreen._world.BodyList[i];
                    GameplayScreen._world.BodyList[i] = p;
                }

                Timer newTimer = new Timer(new undoGravitySphereDelegate(this.undoGravitySphere), GameplayScreen.getInstance().getCurrentGameTime(), 2500);
                GameplayScreen.getInstance().gameTimers.addTimer(newTimer);
            }
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: res09ggm/ucimobile
 public void performGravityFlip()
 {
     if (!performingGravityFlip && energy > 20)
     {
         performingGravityFlip = true;
         energy -= 20;
         Vector2 oldGravity = GameplayScreen._world.Gravity;
         GameplayScreen._world.Gravity = new Vector2(0f, -oldGravity.Y);
         //Delegate d = new Delegate(this, "undoGravityFlip");
         Timer newTimer = new Timer(new undoGravityFlipDelegate(this.undoGravityFlip), GameplayScreen.getInstance().getCurrentGameTime(), 2200);
         GameplayScreen.getInstance().gameTimers.addTimer(newTimer);
     }
     //else flash screen/make error sound.
 }