Esempio n. 1
0
    void basicFireTowardsMouse()
    {
        tutText.pushToMin(2);
        fireSound.Play();
        Vector2 mousePos     = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 velDirection = mousePos - new Vector2(playerTransform.position.x, playerTransform.position.y);

        velDirection.Normalize();

        bulletInstance = Instantiate(bullet, playerTransform.position, playerTransform.rotation);
        switch (bulletPowerup)
        {
        case PowerupType.MASSIVE_BULLET:
            bulletInstance.transform.localScale *= 5;
            bulletInstance.GetComponent <Collider2D>().enabled = false;
            bulletPowerup = PowerupType.NONE;
            break;

        default:
            bulletPowerup = PowerupType.NONE;
            break;
        }
        bulletCam.SetActive(true);
        bulletCam.SendMessage("SetBullet", bulletInstance);
        bulletInstance.GetComponent <Rigidbody2D>().velocity = velDirection * bulletSpeed;
    }
Esempio n. 2
0
    void bigFireTowardsMouse(float intensity)
    {
        tutText.pushToMin(7);
        shotChargeSound.Stop();
        fireSound.Play();
        Vector2 mousePos     = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 velDirection = mousePos - new Vector2(playerTransform.position.x, playerTransform.position.y);

        velDirection.Normalize();

        bulletInstance = Instantiate(bullet, playerTransform.position, playerTransform.rotation);
        GameObject bulletHaloInstance = Instantiate(bulletHalo, playerTransform.position, playerTransform.rotation);

        bulletHaloInstance.transform.SetParent(bulletInstance.transform);
        bulletHaloInstance.transform.localScale *= 1 + 5 * intensity;
        bulletInstance.transform.position       += new Vector3(0, 0, 1);//behind
        switch (bulletPowerup)
        {
        case PowerupType.MASSIVE_BULLET:
            bulletInstance.transform.localScale *= 5;
            bulletInstance.GetComponent <Collider2D>().enabled = false;
            bulletPowerup = PowerupType.NONE;
            break;

        default:
            bulletPowerup = PowerupType.NONE;
            break;
        }
        bulletCam.SetActive(true);
        bulletCam.SendMessage("SetBullet", bulletInstance);
        bulletInstance.GetComponent <CircleCollider2D>().enabled = false;
        bulletInstance.GetComponent <Rigidbody2D>().velocity     = velDirection * bulletSpeed;
        bulletInstance.BroadcastMessage("SetDamage", intensity * 5);
        GetComponent <Rigidbody2D>().AddForce(intensity * (-velDirection) * recoilAmount);
    }
Esempio n. 3
0
    override protected Powerup createPowerup(float x, float y, PowerupType type)
    {
        RenderedPowerup rendered = new RenderedPowerup(this, x, y, type, resourceScript);

        powerups.Add(rendered as Powerup);
        return(rendered);
    }
 public void SetPowerup(Powerup powerup)
 {
     this.powerup = powerup;
     GetComponent <Animator>().runtimeAnimatorController = powerup.animator;
     name = powerup.name;
     type = powerup.type;
 }
Esempio n. 5
0
 public Powerup(PowerupScript script)
 {
     Type = script.Type;
     Amount = script.Amount;
     Duration = script.Duration;
     Lifetime = script.Lifetime;
 }
Esempio n. 6
0
    void UpdateType(PowerupType powerup_type)
    {
        if (current)
        {
            Destroy(current.gameObject);
        }

        Transform prefab = null;

        switch (powerup_type)
        {
        case PowerupType.ExtraJump:
            prefab = powerupExtraJumpPrefab;
            break;

        case PowerupType.Gun:
            prefab = powerupGunPrefab;
            break;

        case PowerupType.Transparency:
            prefab = powerupTransparencyPrefab;
            break;
        }

        if (prefab != null)
        {
            current = (Instantiate(prefab, transform.position, transform.rotation) as Transform);
        }
    }
Esempio n. 7
0
        public static void Create(Vector3 pos, PowerupType type)
        {
            GameObject p;

            if (Player.Instance == null)
            {
                return;
            }
            type = Player.Instance.PickValidPowerup(type);

            if (type == PowerupType.FrontCannon)
            {
                p = new GameObject(GameRes.Data.Prefabs.Powerups.FrontCannon_Prefab);
            }
            else if (type == PowerupType.DiagonalCannon)
            {
                p = new GameObject(GameRes.Data.Prefabs.Powerups.DiagonalCannon_Prefab);
            }
            else if (type == PowerupType.SideCannon)
            {
                p = new GameObject(GameRes.Data.Prefabs.Powerups.SideCannon_Prefab);
            }
            else if (type == PowerupType.KillAll)
            {
                p = new GameObject(GameRes.Data.Prefabs.Powerups.KillAll_Prefab);
            }
            else
            {
                return;
            }

            p.Transform.Pos = pos;
            p.Transform.Vel = new Vector3(MathF.Rnd.NextVector2(1.0f));
            Scene.Current.RegisterObj(p);
        }
Esempio n. 8
0
 /// <summary>
 /// A helper function that will remove the Blade powerup and restore defaults.
 /// </summary>
 void unApplyBlades()
 {
     this.PowerupType   = this.PowerupType ^= PowerupType.Blades;
     this.velocity     /= 2;
     bladesPowerupTimer = 0;
     //TO DO: make Player vulerable again, since not implemented yet.
 }
Esempio n. 9
0
 internal EquipmentBlockBase(BinaryReader binaryReader) : base(binaryReader)
 {
     this.powerupType        = (PowerupType)binaryReader.ReadInt16();
     this.grenadeType        = (GrenadeType)binaryReader.ReadInt16();
     this.powerupTimeSeconds = binaryReader.ReadSingle();
     this.pickupSound        = binaryReader.ReadTagReference();
 }
Esempio n. 10
0
    public void SpawnPowerUp(PowerupType powerupType, Cell thisCell, float horizontalCell, float verticalCell)
    {
        switch (powerupType)
        {
        case PowerupType.Invulnerability:
            powerUpToCreate = m_InvulnerablePowerup;
            break;

        case PowerupType.Range:
            powerUpToCreate = m_RangePowerup;
            break;

        case PowerupType.Shake:
            powerUpToCreate = m_ShakePowerup;
            break;

        case PowerupType.Speed:
            powerUpToCreate = m_SpeedPowerup;
            break;

        case PowerupType.Trick:
            powerUpToCreate = m_TrickPowerup;
            break;
        }

        Debug.Log("SPAWNING POWERUP: " + powerupType + "   CellX: " + horizontalCell + "   Vertical Cell: " + verticalCell);

        // Spawn a powerup then destroy the game object
        Vector3    powerupPos      = new Vector3(GetHorizontalPos(horizontalCell), GetVerticalPos(verticalCell), powerUpToCreate.transform.position.z);
        GameObject powerupInstance = Instantiate(powerUpToCreate, powerupPos, transform.rotation) as GameObject;

        thisCell.CellGameObject = powerupInstance;
    }
Esempio n. 11
0
        private void OnPowerupChanged(PowerupType newType, PowerupType oldType)
        {
            if (destroyPowerupButton.targetGraphic != null)
            {
                destroyPowerupButton.targetGraphic.color =
                    newType == PowerupType.DestroyCell ?
                    powerupButtonHighlightColor :
                    powerupButtonNormalColor;
            }

            if (swapPowerupButton.targetGraphic != null)
            {
                swapPowerupButton.targetGraphic.color =
                    newType == PowerupType.SwapCells ?
                    powerupButtonHighlightColor :
                    powerupButtonNormalColor;
            }

            if (scramblePowerupButton.targetGraphic != null)
            {
                scramblePowerupButton.targetGraphic.color =
                    newType == PowerupType.Scramble ?
                    powerupButtonHighlightColor :
                    powerupButtonNormalColor;
            }
        }
        public GameObject GenerateAsteroid(AsteroidType type)
        {
            GameObject result = null;

            if (type == AsteroidType.Small)
            {
                PowerupType p = Player.Instance != null?Player.Instance.PickValidPowerup(PowerupType.Random) : PowerupType.None;

                result = new GameObject(p == PowerupType.Blue ? GameRes.Data.Prefabs.AsteroidSmallBlue_Prefab : GameRes.Data.Prefabs.AsteroidSmall_Prefab);
            }
            else if (type == AsteroidType.Medium)
            {
                PowerupType p = Player.Instance != null?Player.Instance.PickValidPowerup(PowerupType.Random) : PowerupType.None;

                result = new GameObject(p == PowerupType.Blue ? GameRes.Data.Prefabs.AsteroidMediumBlue_Prefab : GameRes.Data.Prefabs.AsteroidMedium_Prefab);
            }
            else if (type == AsteroidType.Big)
            {
                int rnd = MathF.Rnd.Next(3);
                result = new GameObject(rnd == 0 ? GameRes.Data.Prefabs.AsteroidBig1_Prefab : (rnd == 1 ? GameRes.Data.Prefabs.AsteroidBig2_Prefab : GameRes.Data.Prefabs.AsteroidBig3_Prefab));
            }

            result.Transform.Pos = this.FindValidAsteroidPos(250);
            Scene.Current.RegisterObj(result);
            return(result);
        }
Esempio n. 13
0
    public void Start()
    {
        // choose a new powerup
        currentPowerupType = (PowerupType)UnityEngine.Random.Range(0, System.Enum.GetNames(typeof(PowerupType)).Length);
        mats = GetComponent <MeshRenderer>().materials;
        // Change material
        switch (currentPowerupType)
        {
        case PowerupType.powerupHealth:
        {
            name    = "Health Powerup";
            mats[0] = healthMat;
            break;
        }

        case PowerupType.powerupSpeed:
        {
            name    = "Speed Powerup";
            mats[0] = speedMat;
            break;
        }

        case PowerupType.firerate:
        {
            name    = "Fire Rate";
            mats[0] = fireRateMat;
            break;
        }
        }
        GetComponent <MeshRenderer>().materials = mats;
    }
Esempio n. 14
0
 public static Color GetColor(PowerupType type)
 {
     //if our color is magenta, that means we didnt find the color
     Color c = Color.magenta;
     switch (type)
     {
         case (PowerupType.Health):
             c = HealthColor;
             break;
         case (PowerupType.HealthRegen):
             c = HealthColor;
             break;
         case (PowerupType.Stamina):
             c = StaminaColor;
             break;
         case (PowerupType.StaminaRegen):
             c = StaminaColor;
             break;
         case (PowerupType.Experience):
             c = ExperienceColor;
             break;
         case (PowerupType.MovementSpeed):
             c = MovementSpeedColor;
             break;
     }
     return c;
 }
Esempio n. 15
0
    public void Start()
    {
        // choose a new powerup
        currentPowerupType = (PowerupType)UnityEngine.Random.Range(0, System.Enum.GetNames(typeof(PowerupType)).Length);
        mats = GetComponent <MeshRenderer>().materials;
        // Change material
        switch (currentPowerupType)
        {
        case PowerupType.powerupHealth:
        {
            name    = "Health Powerup";
            mats[0] = healthIcon;
            break;
        }

        case PowerupType.powerupSpeed:
        {
            name    = "Speed Powerup";
            mats[0] = speedIcon;
            break;
        }

        case PowerupType.powerupMissileCDReduction:
        {
            name    = "Missile CD Powerup";
            mats[0] = missileCDIcon;
            break;
        }
        }
        GetComponent <MeshRenderer>().materials = mats;
    }
Esempio n. 16
0
        public PowerupType PickValidPowerup(PowerupType type)
        {
            int powerupCount = 1 +
                               instance.powerDiagonal + instance.powerFront + instance.powerSide +
                               Powerup.Instances.Count() +
                               Asteroid.Instances.Count(a => a.ContainedPowerup != PowerupType.None);
            float timeSinceLast = Time.GameTimer - lastPowerupTime;

            if (type == PowerupType.Blue)
            {
                if (this.powerFront + this.powerDiagonal + this.powerSide < 13)
                {
                    type = MathF.Rnd.WeightedNext(
                        new[] { PowerupType.FrontCannon, PowerupType.DiagonalCannon, PowerupType.SideCannon },
                        new[] {
                        this.powerFront < 5 ? 1.5f : 0.0f,
                        this.powerDiagonal < 4 ? 1.25f : 0.0f,
                        this.powerSide < 4 ? 1.0f : 0.0f
                    });
                }
                else
                {
                    type = PowerupType.None;
                }
            }
            else if (type == PowerupType.Green)
            {
                type = PowerupType.KillAll;
            }
            else if (type == PowerupType.Random)
            {
                if (timeSinceLast >= 10000.0f)
                {
                    float noneWeight = 2.0f * MathF.Pow(powerupCount, 1.5f);
                    if (this.powerFront + this.powerDiagonal + this.powerSide < 13)
                    {
                        type = MathF.Rnd.WeightedNext(
                            new[] { PowerupType.None, PowerupType.Blue, PowerupType.Green },
                            new[] { 1.0f + noneWeight, 1.0f, 2.0f });
                    }
                    else
                    {
                        type = MathF.Rnd.WeightedNext(
                            new[] { PowerupType.None, PowerupType.Green },
                            new[] { 1.0f + noneWeight, 3.0f });
                    }
                }
                else
                {
                    type = PowerupType.None;
                }

                if (type != PowerupType.None)
                {
                    lastPowerupTime = Time.GameTimer;
                }
            }

            return(type);
        }
    //collisions with obstacles and ground
    private void OnTriggerEnter2D(Collider2D collider)
    {
        //if it hits an obstacle, quit
        if (collider.gameObject.tag == "Obstacle")
        {
            isDead        = true;
            randomC.clips = deathClips;
            randomC.PlaySound(true);
            GameControl.GetComponent <GameControl>().GameOver();
            transform.position = new Vector3(transform.position.x, OriginalPosition.y, transform.position.z);
        }

        //if collided with ground, its running
        if (collider.gameObject.tag == "Ground")
        {
            isGrounded = true;
            gameObject.GetComponent <Rigidbody2D>().velocity = Vector3.zero;
        }

        //if collided with a powerup, change appropriate stat and destroy powerup
        if (collider.gameObject.tag == "Powerup")
        {
            isPoweredUp = true;
            PowerupType type = collider.gameObject.GetComponent <PowerUp>().type;
            Destroy(collider.gameObject);

            //TODO: add more types
            switch (type)
            {
            case PowerupType.IncreaseJumpHeight:
                maxJumpHeight = 1.5f;
                break;
            }
        }
    }
Esempio n. 18
0
 public Powerup(int x, int y, PowerupType powerupType)
     : base("Sprites", x, y, new Rectangle(96 + 32 * (int)powerupType, 144, 32, 32), 0.4f)
 {
     _type = powerupType;
     color.A = 0;
     visibleTimer = 0;
 }
Esempio n. 19
0
 public Powerup(PowerupType type, float amount, float duration, float lifetime)
 {
     Type = type;
     Amount = amount;
     Duration = duration;
     Lifetime = lifetime;
 }
Esempio n. 20
0
        public Powerup(int x, int y, int width, int height, Player player, PowerupType effectType, int effectAmount, Color effectColor, int effectDuration, Weapon weapon)
        {
            this.bounds         = new Rectangle(x, y, width, height);
            this.player         = player;
            this.effectAmount   = effectAmount;
            this.effectColor    = effectColor;
            this.effectType     = effectType;
            this.effectDuration = effectDuration;
            switch (effectType)
            {
            case PowerupType.FireRateBoost:
                srcRect = new Rectangle(0, 0, 16, 16);
                break;

            case PowerupType.HealthBoost:
                srcRect = new Rectangle(32, 0, 16, 16);
                break;

            case PowerupType.SpeedBoost:
                srcRect = new Rectangle(16, 0, 16, 16);
                break;

            case PowerupType.Shotgun:
                srcRect = new Rectangle(48, 0, 16, 16);
                break;
            }
            this.weapon = weapon;
        }
Esempio n. 21
0
        public static IEnumerable <KeyValuePair <Point, PowerupType> > GenerateMapPowerups(Map map)
        {
            foreach (var item in map.tiles)
            {
                if (item.Object is Block)
                {
                    Random rand      = new Random(item.GetHashCode());
                    int    randValue = rand.Next(0, 100);
                    if (randValue < 50)
                    {
                        PowerupType newPowerUp = 0;

                        if (randValue < 20)
                        {
                            (item.Object as Block).HiddenItem = new BombRangePowerup(0);
                            newPowerUp = PowerupType.ExtraPower;
                        }
                        else if (randValue < 40)
                        {
                            (item.Object as Block).HiddenItem = new ExtraBombPowerup(0);
                            newPowerUp = PowerupType.ExtraBomb;
                        }
                        else
                        {
                            (item.Object as Block).HiddenItem = new KickAbilityPowerup(0);
                            newPowerUp = PowerupType.KickAbility;
                        }

                        yield return(new KeyValuePair <Point, PowerupType>(item.MapCoordinate, newPowerUp));
                    }
                }
            }
            yield break;
        }
Esempio n. 22
0
    public void AddPowerup(PowerupType type, float time, Sprite powerupIcon)
    {
        if (type == PowerupType.HealthPack)
        {
            playerController.AddHealth(20);
        }

        audioSource.PlayOneShot(powerupAudioClip);
        if (time == 0)
        {
            return;
        }

        GameObject powerupIconGameObject = Instantiate(powerupItemPrefab);

        powerupIconGameObject.GetComponent <Image>().sprite = powerupIcon;
        powerupIconGameObject.transform.SetParent(powerupUiRoot.transform, false);

        if (!powerupQueue.ContainsKey(type))
        {
            powerupQueue[type] = new Queue <PowerupHandle>();
        }

        powerupQueue[type].Enqueue(new PowerupHandle(type, time, powerupIconGameObject));
    }
Esempio n. 23
0
        public void CreateDebris(AsteroidType t, PowerupType p)
        {
            GameObject debris;
            if (t == AsteroidType.Medium)
            {
                if (p == PowerupType.Blue)
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidMediumBlue_Prefab);
                else if (p == PowerupType.Green)
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidMediumGreen_Prefab);
                else
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidMedium_Prefab);
            }
            else
            {
                if (p == PowerupType.Blue)
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidSmallBlue_Prefab);
                else if (p == PowerupType.Green)
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidSmallGreen_Prefab);
                else
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidSmall_Prefab);
            }
            debris.Transform.Pos = this.GameObj.Transform.Pos;
            debris.Transform.Vel += this.GameObj.Transform.Vel;

            Scene.Current.RegisterObj(debris);
        }
Esempio n. 24
0
 public Powerup(int x, int y, PowerupType powerupType)
     : base("Sprites", x, y, new Rectangle(96 + 32 * (int)powerupType, 144, 32, 32), 0.4f)
 {
     _type        = powerupType;
     color.A      = 0;
     visibleTimer = 0;
 }
Esempio n. 25
0
    /// <summary>
    /// Adds to the current powerup progress.
    /// </summary>
    /// <param name="amount">How much? (you get a powerup at 100)</param>
    public void AddPowerupProgress(float amount)
    {
        if (!GameManager.ShouldUpdate()) {
            return;
        }

        playerObject.powerupProgress += amount * CharacterAbilityManager.powerupProgressMod[playerNum];

        if (playerObject.powerupProgress >= 100) {
            // Powerup time!
            currChoice = 0;
            var choices = PowerupInfo.Choose2RandomPowerups(playerObject.playerNum);
            type1 = choices[0];
            type2 = choices[1];

            choice1.text = PowerupInfo.Name(type1);
            choice1.color = Color.white;

            choice2.text = PowerupInfo.Name(type2);
            choice2.color = Color.white;

            GameManager.gameState = GameState.ChoosePowerup;
            choice1.GetComponent<Button>().interactable = true;
            choice2.GetComponent<Button>().interactable = true;
        }
    }
Esempio n. 26
0
        /// <summary>
        /// Applies the specified powerup to the ship
        /// </summary>
        /// <param name="powerup">the indicated powerup</param>
        public void ApplyPowerup(PowerupType powerup)
        {
            //Meteor triggers on pickup, no need to store it.
            //Alternatively, it could be stored and triggered on a custom key
            //Another alternative - Store it as a once-per-press powerup, and remove it after the first press
            if ((powerup & PowerupType.MeteorPowerup) > 0)
            {
                TriggerMeteor();
                return;
            }

            // Store the new powerup in the PowerupType bitmask
            this.PowerupType |= powerup;

            //Apply special logic for powerups here
            switch (powerup)
            {
            case PowerupType.Blades:
                ApplyBlades();
                break;

            case PowerupType.EightBallShield:
                TriggerEightBallShield();
                break;

            case PowerupType.TriShield:
                ApplyTriShield();
                break;

            case PowerupType.Ale:
                GetDrunk();
                break;
            }
        }
Esempio n. 27
0
        public RenderedPowerup(RenderedWorld parent, float x, float y, PowerupType type, Game resourceScript) : base(parent, x, y, type)
        {
            // Create the unity object
            GameObject cloneSource = null;

            switch (type)
            {
            case PowerupType.Bombs:
                cloneSource = resourceScript.Protobombs;
                break;

            case PowerupType.Gravity:
                cloneSource = resourceScript.Protogravity;
                break;

            case PowerupType.Lightning:
                cloneSource = resourceScript.Protolightnings;
                break;

            case PowerupType.Minions:
                cloneSource = resourceScript.Protominions;
                break;

            case PowerupType.Rockets:
                cloneSource = resourceScript.Protorockets;
                break;

            case PowerupType.Speed:
                cloneSource = resourceScript.Protospeed;
                break;
            }
            ObjectTransform          = Object.Instantiate(cloneSource.transform);
            ObjectTransform.position = new Vector3(x, y);
        }
Esempio n. 28
0
    // Powerup creation/deletion
    virtual protected Powerup createPowerup(float x, float y, PowerupType type)
    {
        Powerup powerup = new Powerup(this, x, y, type);

        powerups.Add(powerup);
        return(powerup);
    }
    public void ActivatePowerup(PowerupType powerup_type, float duration)
    {
        switch (powerup_type)
        {
        case PowerupType.DOUBLEJUMP:
            lightning.LightningPlay(duration);
            StopCoroutine("DoubleJump");
            StartCoroutine("DoubleJump", duration);
            break;

        case PowerupType.DOUBLESPEED:
            flames.FlamePlay(duration);
            StopCoroutine("SpeedUp");
            StartCoroutine("SpeedUp", duration);
            break;

        case PowerupType.HEALTH:
            health += 10;
            if (health > 100)
            {
                health = 100;
            }
            break;
        }
    }
Esempio n. 30
0
    public void spawn(PowerupType powerupType)
    {
        CreatePowerup(powerupType);

        //Vector3 velocityChange = Quaternion.Euler(0.0F, 0.0F, angle) * (BulletSpeed * direction);
        this.rb.velocity = new Vector3(0.0F, 1.0F, 0.0F);
    }
 public Powerup(GameManager gameManager, Point location, float maximumSpeed, PowerupType powerupType)
     : base(gameManager, new Rect(location, GameSprite.PowerupSize), CollisionLayer.Powerup, maximumSpeed)
 {
     this.powerupType = powerupType;
     SetSpriteSource();
     velocity.Y = maximumSpeed;
 }
Esempio n. 32
0
    private void Awake()
    {
        // Set Type and Sprite
        int random = Random.Range(0, (int)Enum.GetValues(typeof(PowerupType)).Cast <PowerupType>().Max() + 1);

        type         = (PowerupType)random;
        image.sprite = sprites[random];
    }
Esempio n. 33
0
 public void PickupPowerupCoroutine(PowerupType typeOfPowerup)
 {
     foreach (PlayerStats ps in AllPlayerStats)
     {
         IEnumerator pickupPowerupCoroutine = ps.OnPowerupPickup(typeOfPowerup);
         StartCoroutine(pickupPowerupCoroutine);
     }
 }
Esempio n. 34
0
    public void TriggerAmmoPickup(GunType gunType, PowerupType powerupType)
    {
        EventLogger.PrintToLog("Player Gains Ammo Powerup: " + gunType);
        Assert.IsTrue(_guns.ContainsKey(gunType));
        _guns[gunType].PickupAmmo();

        _statsManagerScript.PickupPowerupCoroutine(powerupType);
    }
Esempio n. 35
0
    public Powerup Create(PowerupType type)
    {
        var powerup = _container.InstantiatePrefabForComponent <Powerup>(_projectSettings.Prefabs.Powerup);

        powerup.Type = type;

        return(powerup);
    }
Esempio n. 36
0
    public void ReplaceHiddenPowerup(PowerupType newValue)
    {
        var index     = GameComponentsLookup.HiddenPowerup;
        var component = (HiddenPowerupComponent)CreateComponent(index, typeof(HiddenPowerupComponent));

        component.value = newValue;
        ReplaceComponent(index, component);
    }
Esempio n. 37
0
 public Powerup(Texture2D texture, PowerupType type)
 {
     this.Texture = texture;
     Position = new Vector2(TOBamGame.Random.Next(0, ScreenManager.Width), -texture.Height + 1);
     Velocity.Y = 1.2f;
     Size = new Vector2(Texture.Width, Texture.Height);
     Power = type;
 }
Esempio n. 38
0
 public Powerup(int x, int y, PowerupType type)
 {
     ShouldBeRemoved = false;
     Type = type;
     X = x;
     Y = y;
     Time = 0;
 }
Esempio n. 39
0
 // Called when a player with a powerup just hit the ball
 void DoFriendlyHit(PowerupType powerup)
 {
     switch (powerup) {
     case PowerupType.Fireball:  // ACTIVATE FIREBALL
         ballHandle.flamin = true;
         break;
     }
 }
Esempio n. 40
0
    public void AddPowerup(PowerupType newValue)
    {
        var index     = GameComponentsLookup.Powerup;
        var component = (PowerupComponent)CreateComponent(index, typeof(PowerupComponent));

        component.value = newValue;
        AddComponent(index, component);
    }
Esempio n. 41
0
        float waitTime; // time to wait until respawn

        #endregion Fields

        #region Constructors

        // (zero when powerup is pickable)
        /// <summary>
        /// Create a new powerup
        /// </summary>
        public Powerup(
            PowerupType type,
            Matrix transform,
            Model model)
        {
            powerupType = type;
            this.transform = transform;
            this.model = model;
        }
Esempio n. 42
0
 public Powerup(PowerupType type, Vector3 position)
 {
     this.Type = type;
     this.Position = position;
     this.Model = null;
     this.Activated = false;
     this.Collected = false;
     this.Timer = 10;
     this.BoundingSphere = new BoundingSphere();
     this.World = Matrix.Identity;
 }
Esempio n. 43
0
        public Powerup(TileObjectManager manager, int tilePosX, int tilePosY, PowerupType pType, Texture2D tex, SoundEffectInstance powerupSound)
            : base(manager, tilePosX, tilePosY)
        {
            this.pType = pType;
            this.powerupTex = tex;
            this.powerupSoundInstance = powerupSound;

            Solid = false;

            //Hook to destroy when burnt
            OnFireSpread += Destroy;
            OnPlayerCollision += PlayerCollect;
        }
Esempio n. 44
0
 // Called when a powerup is over and done
 void EndPowerup(PowerupType powerup, PaddleObject player)
 {
     switch(powerup) {
     case PowerupType.Magnet:
         player.magnetized = false;
         break;
     case PowerupType.Iceball:
         player.icy = false;
         break;
     case PowerupType.Ghost:
         player.ghostly = false;
         break;
     }
 }
Esempio n. 45
0
        // Base Constructor
        public Powerup(PowerupType powerupType, Vector2 position, Texture2D texture, bool isTilePosition, bool isBouncy)
            : base(position, texture)
        {
            this.powerupType = powerupType;

            if (isTilePosition)
                this.position = new Vector2(position.X * Tile.Width, position.Y * Tile.Height);
            else
                this.position = position;

            this.isBouncy = isBouncy;
            this.isBouncy = true;
            this.bounce = 0.0f;
        }
Esempio n. 46
0
 public void PickedUpPowerup(PowerupType powerUpType)
 {
     if (powerUpType == PowerupType.Health)
     {
         _health = maxHealth;
         healthBar.ShowPercentage((float)_health / maxHealth);
     }
     else
     {
         type = powerUpType.ToCharacterType();
         SetupLook();
     }
     AudioSource.PlayClipAtPoint(powerupSound, Vector3.zero);
 }
Esempio n. 47
0
 public void receievePowerup(PowerupType type)
 {
     //TODO: Add the powerup to our list of powerups
     /*switch (pu.type) {
         case "shotspeedup":
             break;
         case "health":
             break;
         default:
             Debug.Log(String.Format("%s is not a valid powerup type!", type));
             return;
     }
     */
 }
Esempio n. 48
0
 public Powerup(GraphicsDeviceManager gdm, SpriteBatch sb, ContentManager cm, Vector2 position)
 {
     this.position = position;
     Random rng = new Random();
     double rand = rng.NextDouble();
     if (rand < 0.9)
     {
         powerupTexture = cm.Load<Texture2D>("Images/health-powerup");
         type = PowerupType.Health;
     }
     else
     {
         powerupTexture = cm.Load<Texture2D>("Images/charge-powerup");
         type = PowerupType.Charge;
     }
 }
Esempio n. 49
0
        public Powerup(PowerupType type, double amount, Vector position)
            : base(Sorting.Group, "Powerups", 3)
        {
            BodyShape = new RectangleShape();
            BodyShape.Size = new Vector2f(BodyRadius, BodyRadius);
            BodyShape.Origin = BodyShape.Size * 0.5f;
            BodyShape.FillColor = BodyColor;

            Type = type;
            Amount = amount;
            Position = position;

            Game.Sounds.Prepare(ref SFX_Create, "Blip2", 10, 1.0f);
            Game.Sounds.Prepare(ref SFX_Pickup, "Powerup1", 10, 1.0f);

            SFX_Create.Play();
        }
Esempio n. 50
0
    public void ActivatePowerup(PowerupType type)
    {
        if (currentPowerup != PowerupType.Normal)
        {
            EndPowerup();
        }

        currentPowerup = type;
        PlayerBallControl pbc = player.GetComponent<PlayerBallControl> ();
        Color particleColor = Color.white;
        switch (currentPowerup)
        {
        case PowerupType.SuperJump:
            pbc.jumpForce = superJumpBoost;
            powerupTime = superJumpTime;
            particleColor = superJumpColor;
            break;

        case PowerupType.Spiderball:
            this.GetComponent<Spiderball>().enabled = true;
            powerupTime = spiderballTime;
            particleColor = spiderBallColor;
            break;

        case PowerupType.Gliding:
            this.GetComponent<Parachuter>().enabled = true;
            powerupTime = glidingTime;
            particleColor = glidingColor;
            break;

        case PowerupType.Balloon:
            this.GetComponent<Ballonist>().enabled = true;
            powerupTime = balloonTime;
            particleColor = balloonColor;
            break;
        }
        particleObj = Instantiate (particlePrefab, transform.position, Quaternion.identity) as Transform;
        particleObj.particleSystem.startColor = particleColor;
        powerupTimer = 0f;
        if (timeObj != null) {
            timeObj.GetComponent<PowerUpTime>().StartTimer(powerupTime, particleColor);
        }
    }
Esempio n. 51
0
        public Powerup(Game1 game, Vector3 pos, PowerupType powerupType)
            : base(game, pos)
        {
            Type = GameObjectType.Powerup;

            initModel(MODELNAME);
            Velocity = VELOCITY;
            Acceleration = ACCELERATION;
            RotationVelocity = ROTATION_VELOCITY;
            SightRange = SIGHT_RANGE;
            Scale = SCALE;
            transformation = TRANSFORM;
            isCollidable = false;

            // Type of powerup
            this.powerupType = powerupType;

            // Powerup travels in random direction when spawned
            this.vel.X = Velocity;
            this.vel.Y = Velocity * (float)game.random.NextDouble();
        }
Esempio n. 52
0
    private void CreatePowerup(PowerupType powerupType)
    {
        Type = powerupType;
        /* float mass;
        switch (powerupType)
        {

            case PowerupType.HEALTHPACK:
                mass = 2.0F;
                break;
            case PowerupType.SHOTSPEED:
                mass = 4.0F;
                break;
            default:
                Debug.LogWarning("This isn't right");
                mass = 2.0F;
                break;
        } */

        //this.Mass = mass;
    }
Esempio n. 53
0
        public static void Create(Vector3 pos, PowerupType type)
        {
            GameObject p;

            if (Player.Instance == null) return;
            type = Player.Instance.PickValidPowerup(type);

            if (type == PowerupType.FrontCannon)
                p = new GameObject(GameRes.Data.Prefabs.Powerups.FrontCannon_Prefab);
            else if (type == PowerupType.DiagonalCannon)
                p = new GameObject(GameRes.Data.Prefabs.Powerups.DiagonalCannon_Prefab);
            else if (type == PowerupType.SideCannon)
                p = new GameObject(GameRes.Data.Prefabs.Powerups.SideCannon_Prefab);
            else if (type == PowerupType.KillAll)
                p = new GameObject(GameRes.Data.Prefabs.Powerups.KillAll_Prefab);
            else
                return;

            p.Transform.Pos = pos;
            p.Transform.Vel = new Vector3(MathF.Rnd.NextVector2(1.0f));
            Scene.Current.RegisterObj(p);
        }
Esempio n. 54
0
        public Powerup CreatePowerup(TileObjectManager manager, int tilePosX, int tilePosY, PowerupType pType)
        {
            if (!loaded) return null;

            Texture2D pTex;

            switch (pType)
            {
                case PowerupType.BOMB_UP:
                    pTex = powerupTex[0];
                    break;
                case PowerupType.FIRE_UP:
                    pTex = powerupTex[1];
                    break;
                case PowerupType.SPEED_UP:
                    pTex = powerupTex[2];
                    break;
                default:
                    pTex = powerupTex[0];
                    break;
            }

            return new Powerup(manager, tilePosX, tilePosY, pType, pTex, powerupSoundInstance);
        }
Esempio n. 55
0
    public void SpawnPowerUp(PowerupType powerupType, Cell thisCell, float horizontalCell, float verticalCell)
    {
        switch (powerupType)
        {
            case PowerupType.Invulnerability:
                powerUpToCreate = m_InvulnerablePowerup;
                break;
            case PowerupType.Range:
                powerUpToCreate = m_RangePowerup;
                break;
            case PowerupType.Shake:
                powerUpToCreate = m_ShakePowerup;
                break;
            case PowerupType.Speed:
                powerUpToCreate = m_SpeedPowerup;
                break;
            case PowerupType.Trick:
                powerUpToCreate = m_TrickPowerup;
                break;
        }

        Debug.Log("SPAWNING POWERUP: "+powerupType + "   CellX: "+horizontalCell + "   Vertical Cell: "+verticalCell);

        // Spawn a powerup then destroy the game object
        Vector3 powerupPos = new Vector3(GetHorizontalPos(horizontalCell), GetVerticalPos(verticalCell), powerUpToCreate.transform.position.z);
        GameObject powerupInstance = Instantiate(powerUpToCreate, powerupPos, transform.rotation) as GameObject;

        thisCell.CellGameObject = powerupInstance;
    }
 /// <summary>
 /// A helper function that will remove the Blade powerup and restore defaults.
 /// </summary>
 void unApplyBlades()
 {
     this.PowerupType = this.PowerupType ^= PowerupType.Blades;
     this.velocity /= 2;
     bladesPowerupTimer = 0;
     //TO DO: make player vulerable again, since not implemented yet.
 }
 //Clear the powerups
 public void ClearPowerups()
 {
     PowerupType = PowerupType.None;
 }
        /// <summary>
        /// Applies the specified powerup to the ship
        /// </summary>
        /// <param name="powerup">the indicated powerup</param>
        public void ApplyPowerup(PowerupType powerup)
        {
            //Meteor triggers on pickup, no need to store it.
            //Alternatively, it could be stored and triggered on a custom key
            //Another alternative - Store it as a once-per-press powerup, and remove it after the first press
            if ((powerup & PowerupType.MeteorPowerup) > 0)
            {
                TriggerMeteor();
                return;
            }

            //This will level us up if we hit another homing missile
            if ((powerup & PowerupType.HomingMissiles) > 0)
            {
                HomingMissileLevel = (short)MathHelper.Min(HomingMissileLevel + 1, 3);
            }

            // Store the new powerup in the PowerupType bitmask
            this.PowerupType = powerup | PowerupType;

            //Apply special logic for powerups here
            switch (powerup)
            {
                case PowerupType.Blades:
                    ApplyBlades();
                    break;

                case PowerupType.EightBallShield:
                    TriggerEightBallShield();
                    break;

                case PowerupType.TriShield:
                    ApplyTriShield();
                    break;

                case PowerupType.Ale:
                    GetDrunk();
                    break;

                case PowerupType.EnergyBlast:
                    energyBlastLevel++;
                    break;

                case PowerupType.BubbleBeam:
                    BubbleBullet.POWER_LEVEL++;
                    break;
            }
        }
Esempio n. 59
0
 /// <summary>
 /// Applies the specified powerup to the ship
 /// </summary>
 /// <param name="powerup">the indicated powerup</param>
 public void ApplyPowerup(PowerupType powerup)
 {
     // Store the new powerup in the PowerupType bitmask
     this.PowerupType |= powerup;
 }
        /// <summary>
        /// Factory method for spawning a projectile
        /// </summary>
        /// <param name="projectileType">The type of projectile to create</param>
        /// <param name="position">The position of the projectile in the game world</param>
        /// <returns>The game object id of the projectile</returns>
        public Powerup CreatePowerup(PowerupType powerupType, Vector2 position)
        {
            Powerup powerup;
            uint id = NextID();

            switch (powerupType)
            {
                case PowerupType.Fireball:
                    powerup = new FireballPowerup(id, content, position);
                    break;

                case PowerupType.Frostball:
                    powerup = new FrostballPowerup(id, content, position);
                    break;

                case PowerupType.BubbleBeam:
                    powerup = new BubbleBeamPowerup(id, content, position);
                    break;

                case PowerupType.Freezewave:
                    powerup = new FreezewavePowerup(id, content, position);
                    break;

                case PowerupType.Blades:
                    powerup = new BladesPowerup(id, content, position);
                    break;

                case PowerupType.EightBallShield: //added EightBallShield
                    powerup = new EightBallShieldPowerup(id, content, position);
                    break;

                case PowerupType.TriShield:
                    powerup = new TriShieldPowerup(id, content, position);
                    break;

                case PowerupType.DroneWave:
                    powerup = new DroneWavePowerup(id, content, position);
                    break;

                case PowerupType.Birdcrap:
                    powerup = new BirdcrapPowerup(id, content, position);
                    break;

                case PowerupType.EnergyBlast:
                    powerup = new EnergyBlastPowerup(id, content, position);
                    break;

                case PowerupType.Bomb:
                    powerup = new BombPowerUp(id, content, position);
                    break;

                case PowerupType.Ale:
                    powerup = new AlePowerup(id, content, position);
                    break;

                case PowerupType.ShotgunPowerup:
                    powerup = new ShotgunPowerup(id, content, position);
                    break;

                case PowerupType.MeteorPowerup:
                    powerup = new MeteorPowerup(id, content, position);
                    break;

                case PowerupType.Railgun:
                    powerup = new Railgun(id, content, position);
                    break;

                case PowerupType.HomingMissiles:
                    powerup = new HomingMissilesPowerup(id, content, position);
                    break;

                default:
                    throw new NotImplementedException("The powerup type " + Enum.GetName(typeof(ProjectileType), powerupType) + " is not supported");
            }

            powerup.ObjectType = ObjectType.Powerup;
            QueueGameObjectForCreation(powerup);
            return powerup;
        }