예제 #1
0
 void Shoot()
 {
     if (seedsLeft > 0)
     {
         tempSeed      = Instantiate(seed, seedSpawn.transform.position, Quaternion.identity);
         sp            = tempSeed.GetComponent <SeedProjectile>();
         sp.multiplier = dammage;
         sp.Launch(dammage, newValue);
         newValue = Random.Range(1.0f, 20.0f);
         seedsLeft--;
     }
 }
예제 #2
0
        //-----------------------------------------------------------------------------
        // Internal methods
        //-----------------------------------------------------------------------------

        private void Shoot()
        {
            if (!weapon.SeedTracker.IsMaxedOut && weapon.HasAmmo())
            {
                Vector2F[] projectilePositions = new Vector2F[] {
                    new Vector2F(16, 7),
                    new Vector2F(15, -2),
                    new Vector2F(0, -12),
                    new Vector2F(-4, -6),
                    new Vector2F(-9, 7),
                    new Vector2F(-4, 12),
                    new Vector2F(7, 15),
                    new Vector2F(15, 11)
                };

                // Spawn the seed projectile.
                SeedProjectile seed           = new SeedProjectile(weapon.CurrentSeedType, true);
                Vector2F       spawnOffset    = projectilePositions[angle] + new Vector2F(4, 11) - new Vector2F(8, 8);
                int            spawnZPosition = 0;

                if (!player.RoomControl.IsSideScrolling)
                {
                    spawnZPosition = 5;
                }
                else
                {
                    spawnOffset.Y -= 5.0f;
                    spawnZPosition = 0;
                }

                Player.ShootFromAngle(seed, angle,
                                      GameSettings.SEED_SHOOTER_SHOOT_SPEED,
                                      spawnOffset, spawnZPosition);
                weapon.SeedTracker.TrackEntity(seed);
                weapon.UseAmmo();

                AudioSystem.PlaySound(GameData.SOUND_SEED_SHOOTER);

                // Begin shooting.
                isShooting = true;
                shootTimer = 0;
            }
            else
            {
                Player.BeginNormalState();
            }
        }
예제 #3
0
 void TestshooT()
 {
     if (seedsLeft > 0)
     {
         tempSeed      = Instantiate(seed, seedSpawn.transform.position, Quaternion.identity);
         sp            = tempSeed.GetComponent <SeedProjectile>();
         sp.multiplier = shootPower;
         sp.Launch(shootPower, newValue);
         newValue = Random.Range(1.0f, 20.0f);
         seedsLeft--;
         if (seedsLeft == 0)
         {
             StartCoroutine(GameOver());
         }
         spring.transform.localPosition = new Vector3(0, 0.7f, 0.45f);
         shootPower = 0f;
     }
 }
예제 #4
0
        //-----------------------------------------------------------------------------
        // Overridden methods
        //-----------------------------------------------------------------------------

        // Called when the items button is pressed (A or B).
        public override void OnButtonPress()
        {
            if (!seedTracker.IsEmpty || !HasAmmo())
            {
                return;
            }

            UseAmmo();

            SeedType seedType = CurrentSeedType;

            int direction = Player.UseDirection;

            Player.Direction = direction;

            // Determine the seed spawn position based on player facing direction.
            Vector2F seedPos;

            if (direction == Directions.Up)
            {
                seedPos = Directions.ToVector(direction) * 1;
            }
            else if (direction == Directions.Down)
            {
                seedPos = Directions.ToVector(direction) * 8;
            }
            else
            {
                seedPos = new Vector2F(0, 6) + (Directions.ToVector(direction) * 4);
            }

            // Spawn the main seed projectile.
            SeedProjectile seed = new SeedProjectile(seedType, false);

            Player.ShootProjectile(seed,
                                   Directions.ToVector(direction) * GameSettings.SLINGSHOT_SEED_SPEED,
                                   seedPos, 5);
            seedTracker.TrackEntity(seed);

            // Spawn the extra 2 seeds for the Hyper Slingshot.
            if (level == Item.Level2)
            {
                for (int i = 0; i < 2; i++)
                {
                    int sideDirection = direction + (i == 0 ? 1 : 3);

                    // Calculate the velocity based on a degree offset.
                    float degrees = direction * GMath.QuarterAngle;
                    if (i == 0)
                    {
                        degrees += GameSettings.SLINGSHOT_SEED_DEGREE_OFFSET;
                    }
                    else
                    {
                        degrees -= GameSettings.SLINGSHOT_SEED_DEGREE_OFFSET;
                    }
                    Vector2F velocity = Vector2F.CreatePolar(GameSettings.SLINGSHOT_SEED_SPEED, degrees);
                    velocity.Y = -velocity.Y;

                    // Spawn the seed.
                    seed = new SeedProjectile(seedType, false);
                    Player.ShootProjectile(seed, velocity, seedPos, 5);
                    seedTracker.TrackEntity(seed);
                }
            }

            // Set the tool animation.
            Player.EquipTool(Player.ToolVisual);
            if (level == Item.Level1)
            {
                Player.ToolVisual.PlayAnimation(GameData.ANIM_SLINGSHOT_1);
            }
            else
            {
                Player.ToolVisual.PlayAnimation(GameData.ANIM_SLINGSHOT_2);
            }
            Player.ToolVisual.AnimationPlayer.SubStripIndex = direction;

            // Begin the player busy state.
            Player.BusyState.SetEndAction(delegate(PlayerState playerState) {
                playerState.Player.UnequipTool(playerState.Player.ToolVisual);
            });
            Player.BeginBusyState(10, GameData.ANIM_PLAYER_THROW, GameData.ANIM_PLAYER_MINECART_THROW);
        }