private void DrawForceField(SpriteBatch spriteBatch, Tree tree)
 {
     var a = tree.glowStrength * tree.growth;
     var color = new Color(1f, 1f, 1f, a);
     var scale = tree.glowRange * (tree.texture.Width / playerTexture.Width * 0.85f);
     spriteBatch.Draw(playerTexture, Vector3.Transform(tree.worldPosition, worldToScreen).ToVector2(), null, color, 0, new Vector2(playerTexture.Width/2, playerTexture.Height/2), scale, SpriteEffects.None, 0);
  
 }
 public void CreateRandomSeeds(int num, Tree tree)
 {
     for (int i = 0; i < num; i++)
     {
         //seedCollection.SpawnSeed(new Vector3(posX, world.getHeigth(posX) + offsetY, 0.0f));
         seedCollection.SpawnSeed(tree.GetNextSeedPosition());
     }
 }
 internal Tree CreateTree(Vector3 seedPos, TreeType type, bool isBlueprint, String name)
 {
     Tree newTree = new Tree(this, seedPos, type, isBlueprint, name);
     trees.Add(newTree);
     return newTree;
 }
 private void showBlueprint()
 {
     if (!game.treeCollection.HasTreeAtPosition(worldPosition.X))
     {
         blueprint = game.treeCollection.CreateTree(worldPosition, TreeType.PAWN, true, "");
     }
 }
        public void Respawn()
        {
            position = initialPosition;
            stunTimer = 2.0f;
            isStunned = true;

            // reset controls
            waitForReleaseA = false;
            waitForReleaseB = false;
            waitForReleaseLeft = false;
            waitForReleaseRight = false;
            waitForBPConfirm = false;
            blueprint = null;

            currentXAcceleration = 0.0f;
            currentYAcceleration = 0.0f;

            game.cameras[index].MoveTo(worldPosition.ToVector2(), 1.0f);
        }
        public void Reset()
        {
            position = initialPosition;

            // reset stun mode
            stunTimer = 0.0f;
            isStunned = false;

            // reset controls
            waitForReleaseA = false;
            waitForReleaseB = false;
            waitForReleaseLeft = false;
            waitForReleaseRight = false;
            waitForBPConfirm = false;
            blueprint = null;

            currentXAcceleration = 0.0f;
            currentYAcceleration = 0.0f;
        }
        public void HandleInput(GamePadState gamepadState, KeyboardState kbs)
        {
            var actionButton = gamepadState.IsButtonDown(Buttons.A) || kbs.IsKeyDown(Keys.Enter);
            var cancelButton = gamepadState.IsButtonDown(Buttons.B) || kbs.IsKeyDown(Keys.Back);

            var stick = gamepadState.ThumbSticks.Left;

            float x = stick.X, y = stick.Y;

            if (kbs != null)
            {
                x = kbs.IsKeyDown(Keys.Right) ? 1 : x;
                x = kbs.IsKeyDown(Keys.Left) ? -1 : x;

                y = kbs.IsKeyDown(Keys.Up) ? 1 : y;
                y = kbs.IsKeyDown(Keys.Down) ? -1 : y;
            }

            if (!isStunned)
            {

                if (waitForBPConfirm)
                {
                    if (xVelocity == 0)
                        showBlueprint();
                    Move(0, 0);
                    if (actionButton && !waitForReleaseA)
                    {
                        game.treeCollection.trees.Remove(blueprint);
                        game.createTree(this, blueprint.treeType, blueprint.name, blueprint.price);
                        lastUsedType = blueprint.treeType;
                        blueprint = null;
                        waitForBPConfirm = false;
                        waitForReleaseA = true;
                        GameServices.GetService<MusicManager>().Play("MenuSelect");
                    }
                    if (cancelButton && !waitForReleaseB)
                    {
                        game.treeCollection.trees.Remove(blueprint);
                        lastUsedType = blueprint.treeType;
                        blueprint = null;
                        waitForBPConfirm = false;
                        waitForReleaseB = true;
                        GameServices.GetService<MusicManager>().Play("MenuSelect");
                    }
                    if (x < 0.0f && !waitForReleaseLeft && !waitForReleaseA)
                    {
                        var type = blueprint.treeType;
                        game.treeCollection.trees.Remove(blueprint);
                        blueprint = game.treeCollection.CreateTree(worldPosition, type.Previous(), true, "");
                        waitForReleaseLeft = true;
                        GameServices.GetService<MusicManager>().Play("MenuSelect");
                    }
                    if (x > 0.0f && !waitForReleaseRight)
                    {
                        var type = blueprint.treeType;
                        game.treeCollection.trees.Remove(blueprint);
                        blueprint = game.treeCollection.CreateTree(worldPosition, type.Next(), true, "");
                        waitForReleaseRight = true;
                        GameServices.GetService<MusicManager>().Play("MenuSelect");
                    }

                }
                else
                {

                    Move(x, y);

                    if (actionButton && !waitForReleaseA)
                    {
                        if (!game.treeCollection.HasTreeAtPosition(worldPosition.X))
                        {
                            blueprint = game.treeCollection.CreateTree(worldPosition, lastUsedType, true, "");
                            waitForBPConfirm = true;
                            waitForReleaseA = true;
                        }

                        GameServices.GetService<MusicManager>().Play("MenuSelect");
                    }
                }
                if (!actionButton)
                    waitForReleaseA = false;
                if (!cancelButton)
                    waitForReleaseB = false;
                if (x == 0)
                {
                    waitForReleaseLeft = false;
                    waitForReleaseRight = false;
                }
            }
        }