상속: MonoBehaviour
예제 #1
0
 public void Rpc_updateVisualEffect(PowerUp.PowerUpType p_index, bool p_value)
 {
     if (!isServer)
     {
         if (powerUpVisualEffects[(int)p_index] != null) powerUpVisualEffects[(int)p_index].SetActive(p_value);
     }
 }
예제 #2
0
    void OnTriggerEnter(Collider col)
    {
        //If the field affects the player
        if (col.gameObject.tag == "Player" && this.active == true) {
            //Get the player object
            GameObject player = col.gameObject;

            switch (behaviourOption) {
            case 0:
                damagePlayer(player);
                break;
            case 1:
                healPlayer(player);
                break;
            case 2:
                destroyPlayer(player);
                break;
            case 3:
                GameObject container = GameObject.Find("Container");
                powerUp = container.GetComponent<InitialisePowerUp>().powerUps[powerUpID];
                givePowerUp(player);
                break;
            default:
                print("Wrong field ID");
                break;
            }
            StartCoroutine(fieldTimeout(10));

            if (isVolatile) {

                Destroy(gameObject);
            }
        }
    }
예제 #3
0
 /// <summary>
 /// Initialize the powerup
 /// </summary>
 void Start()
 {
     int powerUpType = (int)(Random.value * 7.9999f);
     switch (powerUpType)
     {
         case 0:
             powerUp = new FlightPowerUp();
             break;
         case 1:
             powerUp = new SuperMassPowerUp();
             break;
         case 2:
             powerUp = new ColorPowerUp();
             break;
         case 3:
             powerUp = new StrengthPowerUp();
             break;
         case 4:
             powerUp = new ExplosionPowerUp();
             break;
         case 5:
             powerUp = new BlowPowerUp();
             break;
         case 6:
             powerUp = new TileModifierPowerUp();
             break;
         case 7:
             powerUp = new MeshModifierPowerUp();
             break;
         default:
             throw new System.NotImplementedException("PowerUp " + powerUpType + " not implemented");
     }
     gameObject.GetComponent<Renderer>().material.color = powerUp.PowerUpColor;
 }
예제 #4
0
    public void Set_bullet_type(PowerUp.Element element)
    {
        if (tag == "Player")
        {
            //Debug.Log("Call set bullet type");
        }

        switch (element)
        {
            case PowerUp.Element.Fire:
                currentModel = Instantiate(Fire_bullet, transform.position, transform.rotation) as GameObject;
                currentModel.name = Fire_bullet.name;
                break;
            case PowerUp.Element.Ice:
                currentModel = Instantiate(Ice_bullet, transform.position, transform.rotation) as GameObject;
                currentModel.name = Ice_bullet.name;
                break;
            case PowerUp.Element.Electric:
                currentModel = Instantiate(Electric_bullet, transform.position, transform.rotation) as GameObject;
                currentModel.name = Electric_bullet.name;
                break;
            case PowerUp.Element.Antimatter:
                currentModel = Instantiate(Antimatter_bullet, transform.position, transform.rotation) as GameObject;
                currentModel.name = Antimatter_bullet.name;
                break;
        };

        currentModel.transform.parent = transform;
    }
예제 #5
0
    //4 operações + atualizar o count
    public void PowerUpCaught(PowerUp p_pu)
    {
        //remove the PowerUp from a spawnedlocation
        //and position it far from the viewport
        int __num = -1;
        for (int i = 0; i < spawnedLocation.Length; i++)
        {
            if (spawnedLocation[i] == p_pu)
            {
                spawnedLocation[i] = null;
                p_pu.transform.position = new Vector3(100, 100, 0);
                __num = i;
                break;
            }
        }
        //remove the PowerUp from the active Pool
        activePool.Remove(p_pu);
        //put it back to the available pool
        availablePool.Add(p_pu);
        //update the spawnCount variable
        spawnedCount--;

        Debug.Log(gameObject.ToString() + " " + __num);
        Rpc_Remove(__num);
    }
예제 #6
0
파일: HindernisF.cs 프로젝트: BPfuelb/xkFD
        public HindernisF(Texture2D textur, Texture2D texturCheat, Vector2 position, Punkt p1, Punkt p2, Punkt p5, Punkt p10, PowerUp powerUp)
            : base(textur, position, texturCheat)
        {
            Vector2 notePos1 = new Vector2((int)position.X + 6, (int)position.Y + 345);
            Vector2 notePos2 = new Vector2((int)position.X + 275, (int)position.Y + 280);

            hitboxListe.Add(new Hitbox((int)position.X, (int)position.Y + 488, 320, 200));
            hitboxListe.Add(new Hitbox((int)position.X + 65, (int)position.Y + 100, 180, 305));

            double zufallPowerUp = .8;

            // Noten zufällig zuweisen
            for (int i = 0; i < 2; i++)
            {
                switch ((int)game1.rand.Next(5))
                {
                    case 0:
                        if (i == 0)
                            notenListe.Add(new NotenHitbox(p1, this, (int)notePos1.X, (int)notePos1.Y, 32, 32));
                        else
                            notenListe.Add(new NotenHitbox(p1, this, (int)notePos2.X, (int)notePos2.Y, 32, 32));
                        break;
                    case 1:
                        if (i == 0)
                            notenListe.Add(new NotenHitbox(p2, this, (int)notePos1.X, (int)notePos1.Y, 32, 32));
                        else
                            notenListe.Add(new NotenHitbox(p2, this, (int)notePos2.X, (int)notePos2.Y, 32, 32));
                        break;
                    case 2:
                        if (i == 0)
                            notenListe.Add(new NotenHitbox(p5, this, (int)notePos1.X, (int)notePos1.Y, 32, 32));
                        else
                            notenListe.Add(new NotenHitbox(p5, this, (int)notePos2.X, (int)notePos2.Y, 32, 32));

                        break;
                    case 3:
                        if (i == 0)
                            notenListe.Add(new NotenHitbox(p10, this, (int)notePos1.X, (int)notePos1.Y, 32, 32));
                        else
                            notenListe.Add(new NotenHitbox(p10, this, (int)notePos2.X, (int)notePos2.Y, 32, 32));
                        break;
                    case 4:
                        if (i == 0 && game1.rand.Next() > zufallPowerUp)
                            notenListe.Add(new NotenHitbox(powerUp, this, (int)notePos1.X, (int)notePos1.Y, 32, 32));
                        else if (game1.rand.Next() > zufallPowerUp)
                            notenListe.Add(new NotenHitbox(powerUp, this, (int)notePos2.X, (int)notePos2.Y, 32, 32));
                        break;
                }
            }



            foreach (NotenHitbox noteHitbox in notenListe)
            {
                punkteAnzahl += noteHitbox.punkt.wertigkeit;
            }
        }
예제 #7
0
 public void ClearOtherActivePowerUps(PowerUp powerUp)
 {
     activePowerUp = powerUp;
     foreach (PowerUp pu in powerUps)
     {
         if (pu != powerUp)
             pu.setActive(false);
     }
 }
예제 #8
0
    public void ChangeForm(PowerUp.Element element)
    {
        //disbable double jumping for all form, except Magnetic
        if (this.tag == "Player")
        {
            Movement script = (Movement)this.GetComponent("Movement");
            script.EnableMultipleJump(false);
            Debug.Log("Character form change");
            //Debug.Log(currentForm);
        }
        if (this.tag == "Enemy")
        {
            Debug.Log("Enemy change form");
        }

        switch(element)
        {
            case PowerUp.Element.Normal:
                ChangeModel(normalModel, transform.position, transform.rotation);
                ChangeElement(PowerUp.Element.Normal);

                break;
            case PowerUp.Element.Antimatter:
                ChangeModel(antimatterModel, transform.position, transform.rotation);
                ChangeElement(PowerUp.Element.Antimatter);

                break;
            case PowerUp.Element.Fire:
                ChangeModel(fireModel, transform.position, transform.rotation);
                ChangeElement(PowerUp.Element.Fire);

                break;
            case PowerUp.Element.Ice:
                ChangeModel(iceModel, transform.position, transform.rotation);
                ChangeElement(PowerUp.Element.Ice);

                break;
            case PowerUp.Element.Electric:
                ChangeModel(electricModel, transform.position, transform.rotation);
                ChangeElement(PowerUp.Element.Electric);

                break;
            case PowerUp.Element.Magnetic:

                if (this.tag == "Player")
                {
                    Movement script = (Movement)this.GetComponent("Movement");
                    script.EnableMultipleJump(true);
                }

                ChangeModel(magneticModel, transform.position, transform.rotation);
                ChangeElement(PowerUp.Element.Magnetic);

                break;
        };
    }
예제 #9
0
    /*
    void SuckSoul(){

        float forceX, forceY;
        Vector2 dist = transform.position - soul.transform.position;

        // Calculo el "angulo" entre el alma y la aspiradora. Dot 1/-1 estoy en linea recta perfecta. Dot 0 esta a un costado.
        float dotAngle = Vector2.Dot(transform.up.normalized, dist.normalized);
        if(dotAngle == 0){
            // ya estoy en un extremo de la pantalla
            return;
        }else if(dotAngle < 0){
            // angulo absoluto con la recta imaginaria del up del player, sin importar de que lado de ella este
            dotAngle = -dotAngle;
        }

        // Calculo la fuerza en x
        forceX = dist.x * dotAngle * dotAngle;

        // Calculo la fuerza en y
        float dotRange = 1-angleThreshold;	// va de 0 (el dot minimo en el que deja de aplicar fuerza) a 1 (linea recta perfecta)
        float normalizedDotAngle = (dotAngle - angleThreshold)/dotRange; // calculo que valor representa el dot actual en la escala 0-1 del angularRange
        forceY = suckingPower * normalizedDotAngle/dist.y;

        // Creo la fuerza con ambos componentes (x, y) y se la agrego al alma
        Vector2 suckForce = new Vector2(forceX, forceY);
        soul.AddSuckingForce(suckForce);
    }
    */
    public void RegisterNewEffect(PowerUp p)
    {
        // FIXME logica de stackeo de efectos, deberia ir aca??? PASAR A QEUE
        // FIXME otra opcion puede ser que no se stackeen los del mismo tipo??? || que stackeen menor efecto???
        if(powerUpsInEffect.Count > 2){
            Debug.Log("Habia tres? " + powerUpsInEffect.Count);
            powerUpsInEffect[0].RemoveEffectTo(this);
        }
        powerUpsInEffect.Add(p);
    }
예제 #10
0
    //enum Bullet_Type{Fire, Ice, Electric, Antimatter};
    void Shoot(PowerUp.Element element, Vector3 position, Quaternion rotation)
    {
        //Debug.Log ("Shoot");

        GameObject newBullet = Instantiate(Bullet, position, rotation) as GameObject;
        Bullet script = (Bullet)newBullet.GetComponent("Bullet");
        script.Set_bullet_type(element);

        script.SendFlying();
    }
예제 #11
0
    public void UpdateVisualEffect(PowerUp.PowerUpType p_index, bool p_value)
    {
        for (int i = 0; i < powerUpVisualEffects.Length; i++)
            {
                powerUpVisualEffects[i].SetActive(false);
            }

        if (powerUpVisualEffects[(int)p_index] != null) powerUpVisualEffects[(int)p_index].SetActive(p_value);

        Rpc_updateVisualEffect(p_index, p_value);
    }
예제 #12
0
 public void Add(PowerUp powerUp)
 {
     if(indexByType.ContainsKey(powerUp.typeName)){
         // si es de un tipo repetido -> lo sumo al slot que ya existia
         slots[indexByType[powerUp.typeName]].Add(powerUp);
     }else{
         // si es de un tipo que no tenia -> nuevo slot
         currentIndex++;
         indexByType.Add(powerUp.typeName, currentIndex);
         slots.Insert(currentIndex, new Slot(powerUp, maxAmountOfEach));
     }
     UpdateDisplay();
 }
예제 #13
0
 public void DeletePowerup()
 {
     if (power_up == PowerUp.INVISIBILITY)
     {
         GameObject.Find("baseMale").GetComponent<SkinnedMeshRenderer>().enabled = true;
     }
     else if (power_up == PowerUp.INVULNERABLE)
     {
     //			GetComponent<ParticleSystem>().enableEmission = false;
     }
     power_up = PowerUp.NONE;
     power_up_time_remaining = 0.0f;
 }
예제 #14
0
 public PowerUp getPowerUp( string name )
 {
     PowerUp reward = new PowerUp();
     bool success;
     success = powerUpDict.TryGetValue(name, out reward);
     if(!success)
     {
         Debug.Log("getPowerUp:  Powerup not found!");
         reward.desc = "Default";
         reward.sp = null;
         reward.alias = "Default";
         reward.Id = -1;
     }
     return reward;
 }
예제 #15
0
 public PlayerBody(Texture2D tex, World world, ContentManager content)
 {
     this.tex = tex;
     this.world = world;
     this.content = content;
     playerBody = BodyFactory.CreateRectangle(world, 20.0f / 64.0f, 20.0f / 64.0f, 1f, pos / 64.0f);
     playerBody.BodyType = BodyType.Dynamic;
     playerBody.Mass = 2f;
     playerBody.Friction = 0.5f;
     playerBody.BodyId = 1;
     playerBody.CollisionCategories = Category.Cat1;
     playerBody.CollidesWith = Category.All ^ Category.Cat5;
     playerBody.OnCollision +=new OnCollisionEventHandler(playerBody_OnCollision);
     score = 0;
     this.currentPower = PowerUp.None;
 }
    IEnumerator spawnRoutine; // Referencia a la corrutina de spawneo de powerUps

    #endregion Fields

    #region Methods

    public int GetPoolIndexForType(PowerUp p)
    {
        // Que indice en su pool es el tipo este??
        int index = 0;
        PowerUpsPool[] pool = pooledHeavenPowerUps;
        if(p.celestialAlignment == CelestialAlignment.HELL)
            pool = pooledHellPowerUps;

        for(int i = 0; i < pool.Length; ++i){
            if(pool[i].type == p.typeName){
                index = i;
                break;
            }
        }
        return index;
    }
예제 #17
0
    public void ActivatePowerUp(string tag)
    {
        switch (LevelTypeManager.currentLevel)
        {
            case LevelTypeManager.Level.standard:
                powerup = PowerUp.jumpBoost;
                break;
            case LevelTypeManager.Level.lowGravity:
                powerup = PowerUp.doubleJump;
                break;
            case LevelTypeManager.Level.flappyBird:
                powerup = PowerUp.smash;
                charges = numSmashCharges;
                break;
            case LevelTypeManager.Level.gravityFlip:
                powerup = PowerUp.glide;
                break;
        }

        playerMovement.speedBoost();
        playerMovement.incPowerups();

        createPowerupEffect();

        powerUpSpriteRenderer.color = powerUpColours[0];
        LevelSounds.inst.playPickup(transform.position);

        //switch (powerup)
        //{
        //    case PowerUp.doubleJump:
        //        powerUpSpriteRenderer.color = powerUpColours[0];
        //        PowerupSounds.inst.playDoubleJumpPickup();
        //        break;
        //    case PowerUp.glide:
        //        powerUpSpriteRenderer.color = powerUpColours[1];
        //        PowerupSounds.inst.playGlidePickup();
        //        break;
        //    case PowerUp.jumpBoost:
        //        powerUpSpriteRenderer.color = powerUpColours[2];
        //        PowerupSounds.inst.playBoostJumpPickup();
        //        break;
        //    case PowerUp.smash:
        //        powerUpSpriteRenderer.color = powerUpColours[3];
        //        PowerupSounds.inst.playSmashPickup();
        //        break;
        //}
    }
 void ChangeWeaponTo(PowerUp.WeaponType newWeapon)
 {
     currentWeapon = newWeapon;
     switch (currentWeapon)
     {
         case PowerUp.WeaponType.normal:
             break;
         case PowerUp.WeaponType.tripleShot:
             playerController.shotSpawnerLength = 3;
             break;
         case PowerUp.WeaponType.rocket:
             playerController.bolt = powerUp.newWeapon;
             break;
         default:
             break;
     }
 }
예제 #19
0
 // Update is called once per frame
 void Update()
 {
     GameObject player = GameObject.Find("Joueur 1");
     if (player != null)
     {
         CarStatus car = player.GetComponent<CarStatus>();
         if (car != null && savePowerUp != car.MyPowerUp && car.MyPowerUp != null)
         {
             image.sprite = Resources.Load(car.MyPowerUp.GetSpriteName(), typeof(Sprite)) as Sprite;
             image.CrossFadeAlpha(1, 0.5f, false);
             savePowerUp = car.MyPowerUp;
         }
         else if (car.MyPowerUp == null) {
             image.CrossFadeAlpha(0, 0.5f, false);
             savePowerUp = null;
         }
     }
 }
예제 #20
0
 public void ActivatePowerUp(PowerUp power)
 {
     if (power == null) {
         Debug.LogError("Error: Power is Null (probably)");
         return;
     }
     if (!activePowers.Contains (power) && activePowers.Count < maxAmtPow) {
         activePowers.Add (power);
         power.Start();
         gameObject.AddComponent (power.GetType ());
         // Debug.Log("Adding: " + power.ToString ());
         if (goodPowerUpIDs.Contains(power.getPowerUpID())){
             powerUpParticles.startColor = Color.green;
         } else if (neutralPowerUpIDs.Contains(power.getPowerUpID())){
             powerUpParticles.startColor = Color.yellow;
         } else if (badPowerUpIDs.Contains(power.getPowerUpID())){
             powerUpParticles.startColor = Color.red;
         }
         powerUpParticles.enableEmission = true;
     }
 }
예제 #21
0
    public void desctiptionSetAndButton(PowerUp up, Sprite sprite)
    {
        Loot loot = new Loot();

        loot.thisLoot = up;
        currentLootTable.loots.Add(loot);
        CanBeSaved();
        Loot       param = loot;
        GameObject empty;

        empty = Instantiate(dropSlider);
        empty.transform.SetParent(dropContent.transform, false);
        empty.GetComponent <Image>().color = Color.Lerp(Color.blue, Color.white, 0.8f);
        empty.transform.Find("Text").GetComponent <Text>().text     = param.thisLoot.name;
        empty.transform.Find("Image").GetComponent <Image>().sprite = sprite;

        SetValue(empty, param);
        empty.transform.Find("SliderChance").GetComponent <Slider>().onValueChanged.AddListener((value) => { SetValue(empty, param); });
        empty.transform.Find("SliderAmount").GetComponent <Slider>().onValueChanged.AddListener((value) => { SetValue(empty, param); });
        empty.transform.Find("Delete").GetComponent <Button>().onClick.AddListener(() => DeleteLootObject(empty, param));
    }
예제 #22
0
 public void ShipDestroyed(Enemy e)
 {
     //掉落升级道具的概率
     if (Random.value <= e.powerUpDropChance)
     {
         //Random.value生成一个0到1之间的数字(但不包括1)
         //如果e.powerUpDropChance的值为0.5f,则有50%的概率
         //产生升级道具。在测试时,这个值被设置为1f
         //选择要挑选哪个升级道具
         //从powerUpFrequency中选取其中一种可能
         int        ndx    = Random.Range(0, powerUpFrequency.Length);
         WeaponType puType = powerUpFrequency[ndx];
         //生成升级道具
         GameObject go = Instantiate(prefabPowerUp) as GameObject;
         PowerUp    pu = go.GetComponent <PowerUp>();
         //将其设置为正确的武器类型
         pu.SetType(puType);
         //将其摆放在被敌机被消灭时的位置
         pu.transform.position = e.transform.position;
     }
 }
    public void ShipDestroyed(Enemy e)
    { // Potentially generate a PowerUp
        AudioManager.Play(AudioClipName.Boom);
        powerUpFrequency[0] = Hero.GetZeroWeapon();

        if (Random.value <= e.powerUpDropChance)                          // Random.value - property that generates a random float between 0(inclusive) and 1(inclusive)
        {                                                                 // Choose which PowerUp to pick
          // Pick one from the possibilities in powerUpFrequency
            int        ndx    = Random.Range(0, powerUpFrequency.Length); // e
            WeaponType puType = powerUpFrequency[ndx];

            // Spawn a PowerUp
            GameObject go = Instantiate(prefabPowerUp) as GameObject;
            PowerUp    pu = go.GetComponent <PowerUp>();

            // Set it to the proper WeaponType
            pu.SetType(puType); // f
            // Set it to the position of the destroyed ship
            pu.transform.position = e.transform.position;
        }
    }
예제 #24
0
    public void shipDestroyed(Enemy e)
    {                                   // c The ShipDestroyed() method will be called by an Enemy ship whenever it is destroyed. It sometimes creates a power-up in place of the destroyed ship
        // Potentially generate a PowerUp
        if (Random.value <= e.powerUpDropChance)
        {                                                                 // d Each type of ship will have a powerUpDropChance, which is a number between 0 and 1. Random.value is a property that generates a random float between 0 (inclusive) and 1 (inclusive). (Because Random.value is inclusive of both 0 and 1, the number could potentially be either 0 or 1.)
                                                                          // If that number is less than or equal to the powerUpDropChance, a PowerUp is instantiated. The drop chance is part of the Enemy class so that various enemies can have higher or lower chances of dropping a PowerUp (e.g., Enemy_0 could rarely drop one, whereas Enemy_4 could always drop one).
                                                                          // Choose which PowerUp to pick
                                                                          // Pick one from the possibilities in powerUpFrequency
            int        ndx    = Random.Range(0, powerUpFrequency.Length); // e This line makes use of the powerUpFrequency array. When Random.Range() is called with two integer values, it chooses a number between the first number (inclusive) and the second number (exclusive)
            WeaponType puType = powerUpFrequency[ndx];

            // Spawn a PowerUp
            GameObject go = Instantiate(prefabPowerUp) as GameObject;
            PowerUp    pu = go.GetComponent <PowerUp>();
            // Set it to the proper WeaponType
            pu.SetType(puType);                                            // f After a power-up type has been selected, the SetType() method is called on the instantiated PowerUp, and the PowerUp then handles coloring itself, setting its _type, and displaying the correct letter in its letter TextMesh

            // Set it to the position of the destroyed ship
            pu.transform.position = e.transform.position;
        }
    }
예제 #25
0
        private async void handlePowerUpIsHit(PowerUp powerUp)
        {
            this.PowerUpActivated?.Invoke(this, EventArgs.Empty);
            if (powerUp.PowerUpType == PowerUpType.Timer)
            {
                this.playerManager.TimerPowerUp();
                powerUp.Sprite.Visibility = Visibility.Collapsed;
                var timeRemaining = new TimeRemainingEventArgs {
                    TimeRemaining = this.playerManager.TimeRemaining
                };
                this.TimeRemainingCount?.Invoke(this, timeRemaining);
            }
            else
            {
                this.playerIsImmune       = true;
                powerUp.Sprite.Visibility = Visibility.Collapsed;
                await Task.Delay(3000);

                this.playerIsImmune = false;
            }
        }
예제 #26
0
    public float enemySpawnRate; // Delay between Enemy spawns

    public void ShipDestroyed(Enemy e)
    {
        // Potentially generate a PowerUp
        if (Random.value <= e.powerUpDropChance)
        {
            // Random.value generates a value between 0 & 1 (though never == 1)
            // If the e.powerUpDropChance is 0.50f, a PowerUp will be generated
            //   50% of the time. For testing, it's now set to 1f.
            // Choose which PowerUp to pick
            // Pick one from the possibilities in powerUpFrequency
            int        ndx    = Random.Range(0, powerUpFrequency.Length);
            WeaponType puType = powerUpFrequency[ndx];
            // Spawn a PowerUp
            GameObject go = Instantiate(prefabPowerUp) as GameObject;
            PowerUp    pu = go.GetComponent <PowerUp>();
            // Set it to the proper WeaponType
            pu.SetType(puType);
            // Set it to the position of the destroyed ship
            pu.transform.position = e.transform.position;
        }
    }
예제 #27
0
        public void PickupPowerUp(PowerUp powerUp, float gain)
        {
            powerupCount++;

            if (powerUp == PowerUp.Health)
            {
                health += gain;
                if (health > 100)
                {
                    health = 100;
                }
            }
            else if (powerUp == PowerUp.Shield)
            {
                shield += gain;
                if (shield > 100)
                {
                    shield = 100;
                }
            }
        }
예제 #28
0
 public void ShipDestroyed(Enemy e, int s)
 { // c
     score += s;
     scoreText.GetComponent <Text>().text = "Score: " + score;
     IncrementEnemyScore(e);
     // Potentially generate a PowerUp
     if (Random.value <= e.powerUpDropChance)
     { // d
       // Choose which PowerUp to pick
       // Pick one from the possibilities in powerUpFrequency
         int        ndx    = Random.Range(0, powerUpFrequency.Length); // e
         WeaponType puType = powerUpFrequency[ndx];
         // Spawn a PowerUp
         GameObject go = Instantiate(prefabPowerUp) as GameObject;
         PowerUp    pu = go.GetComponent <PowerUp>();
         // Set it to the proper WeaponType
         pu.SetType(puType); // f
                             // Set it to the position of the destroyed ship
         pu.transform.position = e.transform.position;
     }
 }
예제 #29
0
        public void PickupPowerUp(PowerUp powerUp, float gain)
        {
            powerupCount++;

            if (powerUp == PowerUp.Health)
            {
                health += gain;
                if (health > MAX_HEALTH)
                {
                    health = MAX_HEALTH;
                }
            }
            else if (powerUp == PowerUp.Shield)
            {
                shield += gain;
                if (shield > MAX_SHIELD)
                {
                    shield = MAX_SHIELD;
                }
            }
        }
예제 #30
0

        
예제 #31
0
    public void AbsorbPowerUp(GameObject go)
    {
        PowerUp pu = go.GetComponent <PowerUp>();

        switch (pu.type)
        {
        case WeaponType.shield:
            shieldLevel++;
            break;

        default:
            // if(pu.type == weapons[0].type)
            // {
            //     Weapon w = GetEmptyWeaponSlot();
            //     if(w != null)
            //     {
            //         w.SetType(pu.type);
            //     }
            // }
            // else
            // {
            //     ClearWeapons();
            //     weapons[0].SetType(pu.type);
            // }
            for (int i = 0; i < 5; i++)
            {
                if (!weaponStates[pu.type][i])
                {
                    weaponStates[pu.type][i] = true;
                    if (pu.type == weaponTypes[activeWeapon])
                    {
                        SetWeapons(pu.type);
                    }
                    break;
                }
            }
            break;
        }
        pu.AbsorbedBy(this.gameObject);
    }
예제 #32
0
    void OnTriggerEnter(Collider col)
    {
        //If the field affects the player
        if (col.gameObject.tag == "Player" && this.active == true)
        {
            //Get the player object
            GameObject player = col.gameObject;

            switch (behaviourOption)
            {
            case 0:
                damagePlayer(player);
                break;

            case 1:
                healPlayer(player);
                break;

            case 2:
                destroyPlayer(player);
                break;

            case 3:
                GameObject container = GameObject.Find("Container");
                powerUp = container.GetComponent <InitialisePowerUp>().powerUps[powerUpID];
                givePowerUp(player);
                break;

            default:
                print("Wrong field ID");
                break;
            }
            StartCoroutine(fieldTimeout(10));

            if (isVolatile)
            {
                Destroy(gameObject);
            }
        }
    }
예제 #33
0
    public void Spawn()
    {
        GameObject projectile;

        mixCount = mixCount + mixinsWeght;
        float   randomHeight = Random.Range(minHeightRange, maxHeightRange);
        Vector3 randomPos    = new Vector3(transform.position.x, transform.position.y + randomHeight, transform.position.z);

        if (mixCount >= 2f)
        {
            projectile = (GameObject)Instantiate(
                mixinsPrefabs[Random.Range(0, mixinsPrefabs.Length)],
                randomPos,
                Quaternion.identity
                );

            PowerUp p = projectile.GetComponent <PowerUp> ();
            p.sm = sm;

            mixCount = 0f;
        }
        else
        {
            // Create the Bullet from the Bullet Prefab

            projectile = (GameObject)Instantiate(
                enemyPrefab,
                randomPos,
                Quaternion.identity
                );
            Enemy e = projectile.GetComponent <Enemy> ();
            e.hp = enemyHP;
            e.sm = sm;
        }

        // Add velocity to the projectile
        projectile.GetComponent <Rigidbody>().velocity = transform.right * sm.levelList[sm.currentLevel].shipSpeed;

        //enemy is de-spawned by a de-spawner object in scene
    }
예제 #34
0
파일: Main.cs 프로젝트: BenRenaud/Bentendo
    public void shipDestroyed(Enemy e)
    {
        NumofEonScreen--;
        BoomSFX.Play();
        switch (e.name)
        {
        case "Enemy_0(Clone)":
            Main.E0kills += 1;
            score        += E0Score;
            break;

        case "Enemy_1(Clone)":
            Main.E1kills += 1;
            score        += E1Score;
            break;

        case "Enemy_2(Clone)":
            score += E2Score;
            break;

        case "Enemy_3(Clone)":
            Main.E3kills += 1;
            score        += E3Score;
            break;

        case "Enemy_4(Clone)":
            score += E4Score;
            break;
        }
        if (Random.value <= e.powerUpDropChance)
        {
            int        ndx    = Random.Range(0, powerUpFrequency.Length);
            WeaponType puType = powerUpFrequency[ndx];

            GameObject go = Instantiate(prefabPowerUp) as GameObject;
            PowerUp    pu = go.GetComponent <PowerUp>();
            pu.SetType(puType);
            pu.transform.position = e.transform.position;
        }
    }
예제 #35
0
        private void usePowerUp(PowerUp type)
        {
            checkDirections();
            for (int i = 0; i < modelLevel.levelData.PowerUps.Count(); i++)
            {
                if (modelLevel.levelData.PowerUps[i].powerUp == type)
                {
                    if (modelLevel.levelData.PowerUps[i].Count != 0)
                    {
                        switch (modelLevel.levelData.PowerUps[i].powerUp)
                        {
                        case PowerUp.phase:
                            bool afterUse = usePhase();
                            if (afterUse)
                            {
                                modelLevel.levelData.PowerUps[i].Count--;
                                updatePoweUpCount();
                            }
                            break;

                        case PowerUp.bullet:
                            if (modelLevel.levelData.numberOfCrates > 0)
                            {
                                if (!isShooting)
                                {
                                    isShooting = true;
                                    bool afterUse2 = useBullet();
                                    if (afterUse2)
                                    {
                                        modelLevel.levelData.PowerUps[i].Count--;
                                        updatePoweUpCount();
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }
예제 #36
0
    public PowerUp GetPowerUp()
    {
        if (powerUpID == PowerUpList.RANDOM)
        {
            Array values = Enum.GetValues(typeof(PowerUpList));
            powerUpID = (PowerUpList)UnityEngine.Random.Range(0, values.Length - 1);
        }
        PowerUp chosenPowerUp = null;

        // Add new Powerups here (pt 2 of 2)
        switch (powerUpID)
        {
        case PowerUpList.RocketBoost:
            //Debug.Log("Chose the Debug PowerUp!");
            chosenPowerUp = new RocketBoost();
            //print("Chosen Power null? : " + (chosenPowerUp == null));
            break;

        case PowerUpList.Brake:
            chosenPowerUp = new BrakePowerUp();
            break;

        case PowerUpList.MoonJump:
            chosenPowerUp = new MoonJump();
            break;

        case PowerUpList.Bomb:
            chosenPowerUp = new BombPowerUp();
            break;

        case PowerUpList.GravityVortex:
            chosenPowerUp = new GravityVortexPowerUp();
            break;
        }
        gameObject.GetComponent <MeshRenderer>().enabled = false;
        gameObject.GetComponent <Collider>().enabled     = false;
        spawned       = false;
        turnsInactive = 0;
        return(chosenPowerUp);
    }
예제 #37
0
        public void AddPowerUp(TipoPowerUps novoPowerUp, int i = -1)
        {
            if (i < 0)
            {
                i = GerenciadorPartida.Turno;
            }
            Inventario inv = GerenciadorPartida.OrdemJogadores[i].GetComponent <Inventario>();

            if (inv.powerUps.Count >= 3)
            {
                return;
            }

            Transform pnlDescricao = TabuleiroHUD.PnlsDescricoes[i];

            bool pnlActive = pnlDescricao.gameObject.activeSelf;

            pnlDescricao.gameObject.SetActive(true);

            string txt = LeitorDescr.LeLinha((int)novoPowerUp);

            PowerUp pw = new PowerUp();

            pw.tipo      = novoPowerUp;
            pw.titulo    = txt.Split(';')[0];
            pw.descricao = txt.Split(';')[1];

            inv.powerUps.Add(pw);

            int teste = powerUps.Count - 1;

            pnlDescricao = pnlDescricao.GetChild(teste);

            pnlDescricao.Find("titulo").GetComponentInChildren <Text>().text   = pw.titulo;
            pnlDescricao.Find("conteudo").GetComponentInChildren <Text>().text = pw.descricao;

            pnlDescricao.gameObject.SetActive(pnlActive);

            TabuleiroHUD.FundoPowerUps(TabuleiroHUD.corOn, powerUps.Count - 1, i);
        }
예제 #38
0
    IEnumerator Respawn()
    {
        respawnCount--;
        menuOpen = false;
        deathPanel.SetActive(false);

        foreach (RoomInstance room in GetComponent <SheetAssigner>().roomList)
        {
            room.RefreshRooms();
        }

        GetComponent <LevelGeneration>().ClearMap();
        GetComponent <LevelGeneration>().DrawMap();
        Time.timeScale = 1;

        yield return(new WaitForSeconds(1.0f));

        // Give power up to enemy in room that player died in, if player has any power ups
        if (PlayerCharacter.instance.GetPowerUps().Count > 0)
        {
            int     rand      = Random.Range(0, currentRoom.mobList.Count);
            PowerUp lostPower = PlayerCharacter.instance.RemoveRandPowerUp();
            Debug.Log("currentRoom: " + currentRoom.name + "\nMobList: " + currentRoom.mobList.Count);
            currentRoom.mobList[rand].GetComponent <Entity>().AddPowerUp(lostPower);
        }

        // Move rooms back to starting position
        gameplayCanvas.GetChild(1).transform.localPosition = new Vector3(0, 0, 0);

        // Respawn the player
        PlayerCharacter.instance.transform.position = new Vector3(0, -GetComponent <SheetAssigner>().verticalOffset / 5.4f, 0);
        PlayerCharacter.instance.GetComponent <SpriteRenderer>().enabled = true;
        PlayerCharacter.instance.InitializePlayer();
        PlayerCharacter.instance.RefreshPowerUp();

        foreach (RoomInstance room in GetComponent <SheetAssigner>().roomList)
        {
            room.RefreshRoomCleared();
        }
    }
예제 #39
0
    public void SetPowerUp(PowerUp powerType, float?powerDuration = null, float?powerParam = null)
    {
        this.powerUpDuration = powerDuration;
        this.powerUp         = powerType;
        Debug.Log($"{this.Team} ninja gets power-up {this.powerUp}, duration: {this.powerUpDuration}!");
        if (powerUpCoroutine != null)
        {
            StopCoroutine(powerUpCoroutine);
        }

        bonusSpeed    = 0;
        bonusDamage   = 0;
        isRangeAttack = false;
        isImmortal    = false;
        switch (this.powerUp)
        {
        case PowerUp.SpeedUp:
            bonusSpeed      += powerParam.Value;
            powerUpCoroutine = StartCoroutine(powerUpRoutine(this.powerUpDuration.Value));
            break;

        case PowerUp.Katana:
            bonusDamage     += powerParam.Value;
            powerUpCoroutine = StartCoroutine(powerUpRoutine(this.powerUpDuration.Value));
            break;

        case PowerUp.Shurikens:
            bonusDamage      = 1;
            isRangeAttack    = true;
            powerUpCoroutine = StartCoroutine(powerUpRoutine(this.powerUpDuration.Value));
            break;

        case PowerUp.Immortality:
            isImmortal       = true;
            powerUpCoroutine = StartCoroutine(powerUpRoutine(this.powerUpDuration.Value));
            break;
        }

        ninjaAnimation.PowerUpAnimation(powerUp);
    }
예제 #40
0
    public void NewPowerUp(Vector3 position, PowerUp.PowerUpType type)
    {
        Rigidbody powerUpRB;

        if (!TryTakeRBFromInactivePool(out powerUpRB))
        {
            powerUpCount++;
            GameObject powerUpObject = Instantiate(powerupPrefab) as GameObject;
            powerUpObject.transform.parent = this.transform;
            powerUpObject.name             = "powerup " + powerUpCount;
            powerUpRB = powerUpObject.GetComponent <Rigidbody>();
        }
        PowerUp powerUp = powerUpRB.gameObject.GetComponent <PowerUp>();

        powerUp.Initialize(type, this);

        powerUpRB.gameObject.SetActive(true);
        powerUpRB.transform.position = position;
//		powerUpRB.transform.localRotation = Quaternion.LookRotation(direction);
//		powerUpRB.velocity = direction * bulletSpeed;
        activeRBs.Add(powerUpRB);
    }
예제 #41
0
    PowerUp FindCompatiblePowerUp()
    {
        int n = 0;

        if (!canSpawnRevive)
        {
            PowerUp powerUp = null;

            do
            {
                n       = Random.Range(0, inactive.Count);
                powerUp = inactive[n];
            } while (powerUp.name == "Revive");

            return(powerUp);
        }
        else
        {
            n = Random.Range(0, inactive.Count);
            return(inactive[n]);
        }
    }
예제 #42
0
    public void update(float time)
    {
        //Check if it is time to spawn a new power up
        if (canSpawn)
        {
            spawnCounter += time;
            if (spawnCounter > powerUpSpawnTime)
            {
                spawnCounter = 0;
                canSpawn     = false;

                //Get a random position to spawn the power up
                int     randomIndex = UnityEngine.Random.Range(0, spawnPointList.Length);
                Vector3 position    = spawnPointList[randomIndex].position;

                powerUp = EntityManager.instantiatePowerUp(PowerUpIds.retrieveRandomPowerUpId());
                powerUp.transform.position = position;

                powerUp.onPickUp += onPowerUpPickUp;
            }
        }
    }
예제 #43
0
 public void DeactivatePowerUp(PowerUp power)
 {
     if (!power) {
         for (int i = 0; i < activePowers.Count; i++) {
             PowerUp power2 = (PowerUp)(gameObject.GetComponent(activePowers[0].GetType()));
             power2.DestroyAllHelper();
         }
         activePowers.Clear ();
         // Debug.Log ("Deactivated powerup is null");
         powerUpParticles.enableEmission = false;
     } else if (activePowers.Contains (power)) {
         Destroy (gameObject.GetComponent (power.GetType ()));
         activePowers.Remove (power);
         // Debug.Log("Attempting to remove " + power.ToString ());
         if (activePowers.Count <= 0) {
             powerUpParticles.enableEmission = false;
         }
     } else {
         Debug.LogError("Tried to remove a power that the object did not have. Power: " + power.ToString ());
     }
     //gameObject.GetComponent<pu.GetType()>
 }
예제 #44
0
    // Update is called once per frame
    void Update()
    {
        PlayerMovement();

        EnergySystem();

        //When fire is pressed AND current game time is greater then previous laser fire time + fire rate(cooldown)
        if (Input.GetButton("Fire1") && Time.time > _nextFire)
        {
            FireLaser();
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            GameObject[] PowerUps = GameObject.FindGameObjectsWithTag("PowerUp");
            //enable magnets on powerups
            foreach (GameObject PowerUp in PowerUps)
            {
                PowerUp.GetComponent <Powerup>().EnableMagnet();
            }
        }
    }
예제 #45
0
    public void AbsorbPowerUp(GameObject go)
    {
        PowerUp pu = go.GetComponent <PowerUp>();

        switch (pu.type)
        {
        case WeaponType.shield:                                              // a

            shieldLevel++;

            break;



        default:                                                             // b

            if (pu.type == weapons[0].type)
            {     // If it is the same type  // c
                Weapon w = GetEmptyWeaponSlot();

                if (w != null)
                {
                    // Set it to pu.type

                    w.SetType(pu.type);
                }
            }
            else
            {     // If this is a different weapon type               // d
                ClearWeapons();

                weapons[0].SetType(pu.type);
            }

            break;
        }

        pu.AbsorbedBy(this.gameObject);
    }
예제 #46
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        //do only if ended timer
        if (timer > Time.time)
        {
            return;
        }

        //if hit player
        Player player = collision.gameObject.GetComponentInParent <Player>();

        if (player & addPowerUp == false)
        {
            addPowerUp = true;

            //animation
            anim.SetTrigger("Open");

            PowerUp p = null;

            if (powerUp is SpeedUpCharacter)
            {
                p = ScriptableObject.CreateInstance("SpeedUpCharacter") as SpeedUpCharacter;
            }
            else if (powerUp is Shield)
            {
                p = ScriptableObject.CreateInstance("Shield") as Shield;
            }
            else
            {
                p = ScriptableObject.CreateInstance("SlowDown") as SlowDown;
            }

            p.Init(powerUp);

            //add power up to player and UI
            player.AddPowerUp(p);
        }
    }
예제 #47
0
    public void AddPowerUp(PowerUp powerUp)
    {
        _powerUps.Add(powerUp);

        switch (powerUp.MyPowerUp)
        {
        case PowerUp.PowerUpEnum.Adrenaline:
            _currentAmountOfAdrenaline++;
            break;

        case PowerUp.PowerUpEnum.Rage:
            _currentAmountOfRage++;
            break;

        case PowerUp.PowerUpEnum.TimeMachine:
            _currentAmountOfTimeMachine++;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
예제 #48
0
    public void PowerUpBall(GameObject player, PowerUp.PowerUpType typeToChangeTo, PowerUp powerUp)
    {
        projectiles.powerUps.Add(powerUp); powerUp.transform.position = new Vector2(10000, 10000);

        foreach (GameObject ball in player.GetComponent <PlayerBallController>().balls)
        {
            if (ball.GetComponent <Ball>().myType == PowerUp.PowerUpType.Basic)
            {
                //if there is a basic ball to replace
                player.GetComponent <PlayerBallController>().balls.Remove(ball);
                Destroy(ball);
                GameObject newBall = projectiles.GetBall(typeToChangeTo).gameObject;
                newBall.transform.position = player.transform.position;
                newBall.GetComponent <Ball>().players[0] = players[0].gameObject;
                newBall.GetComponent <Ball>().players[1] = players[1].gameObject;
                newBall.SetActive(true);
                player.GetComponent <PlayerBallController>().balls.Add(newBall);
                return;
            }
        }
        UI.OpenBallSwitching(player.GetComponent <PlayerBallController>(), projectiles.GetBall(typeToChangeTo));
    }
예제 #49
0
    private void SpawnPowerUp()
    {
        if (m_powerUpCount < m_maxFieldPowerUps)
        {
            ++m_powerUpCount;

            int firstSlot = 0;
            for (int i = 0; i < m_maxPowerUps; ++i)
            {
                if (m_spawnPositionsOpen[i])
                {
                    firstSlot = i; break;
                }
            }

            m_spawnPositionsOpen[firstSlot] = false;
            PowerUp toAdd = m_powerUps[firstSlot];
            toAdd.gameObject.SetActive(true);
            toAdd.gameObject.transform.position = GetRandomSpawnPos();
            toAdd.MoveABit();
        }
    }
예제 #50
0
    void Start()
    {
        //Set bars to half
        curHunger = 75f;
        curKarma  = 50f;

        hungerBar.SetMaxHunger(maxHunger);
        if (karmaBar != null)
        {
            karmaBar.SetMaxHunger(maxKarma);
        }
        ds       = gameObject.GetComponent <DialogueStorage>();
        lifem    = FindObjectOfType <LifeManager>();
        scoreMan = FindObjectOfType <ScoreManager>();

        PlayerPrefs.SetString("curLevel", SceneManager.GetActiveScene().name);
        currentLevel = PlayerPrefs.GetString("curLevel");


        PlayerPrefs.SetInt("playerCurScore", 0);
        pow = gameObject.GetComponent <PowerUp>();
    }
예제 #51
0
    public void ApplayPowerUp(PowerUp type)
    {
        Debug.Log("Applaing PowerUp");
        switch (type)
        {
        case PowerUp.Platform:
            ApplayPlatformPowerUp();
            break;

        case PowerUp.Health:
            ApplayHealthPowerUp();
            break;

        case PowerUp.Balls:
            ApplayBallsPowerUp();
            break;

        case PowerUp.Rockets:
            ApplayRocketsPowerUp();
            break;
        }
    }
예제 #52
0
    public void powerUpEffect(PowerUp powerUp)
    {
        GameObject otherPlayer = GameObject.Find(gameObject.name == "player1" ? "player2" : "player1");

        if (powerUp.name == "Regeneration") {
            statuses [0] = statusList[0].time;
        }
        if (powerUp.name == "Damage Enemy") {
            otherPlayer.GetComponent<PlayerControl>().statuses [1] = statusList[1].time;
        }
        if (powerUp.name == "Slow Down Enemy") {
            otherPlayer.GetComponent<PlayerControl>().statuses [2] = statusList[2].time;
            statuses [3] = 0;
        }
        if (powerUp.name == "Boost") {
            statuses [3] = statusList[3].time;
            statuses [2] = 0; // When boost used it removes negative speed effects
            statuses [4] = 0; // Removing stunn status
        }
        if (powerUp.name == "Stun Enemy") {
            otherPlayer.GetComponent<PlayerControl>().statuses [4] = statusList[4].time;
        }
    }
예제 #53
0
    // Any and all cheat codes available here
    public void Cheats()
    {
        // Let the player choose their level, main menu through 1-4
        // or let them choose their powerup
        KeyCode[] levels = new KeyCode[] {
            KeyCode.Alpha0,
            KeyCode.Alpha1,
            KeyCode.Alpha2,
            KeyCode.Alpha3,
            KeyCode.Alpha4
        };
        PowerUp[] powerUps = new PowerUp[] {
            PowerUp.None,
            PowerUp.Jelly,
            PowerUp.None,
            PowerUp.None,
            PowerUp.None
        };
        // Change level
        if (Input.GetKey(KeyCode.Plus) || Input.GetKey(KeyCode.KeypadPlus)) {
            Application.LoadLevel(Application.loadedLevel + 1);
        } else if (Input.GetKey(KeyCode.Minus) || Input.GetKey(KeyCode.KeypadMinus)) {
            Application.LoadLevel(Application.loadedLevel - 1);
        }
        for (int i = 0; i < powerUps.Length; i++) {
            if (Input.GetKeyDown(levels[i])) {
                if (Input.GetKey(KeyCode.Tab)) {
                    PowerUpState = powerUps[i];
                }
            }
        }

        // Allow invincibility
        if (Input.GetKeyDown(KeyCode.Backspace)) {
            isInvincible = !isInvincible;
        }
    }
	void OnTriggerEnter(Collider other)
	{
		if(other.CompareTag("PowerUp"))
		{
			powerUp = other.GetComponent<PowerUp>();
			switch (powerUp.powerUpType) 
			{
			case PowerUp.PowerUpType.shield:
				shieldPrefab.SetActive(true);
				Invoke("DisableShield", powerUp.shieldLifeTime);
				break;
			case PowerUp.PowerUpType.speed:
				playerController.speed *= powerUp.speedMultiplier;
				Invoke("ResetPlayerSpeed",powerUp.speedLifeTime);
				break;
            case PowerUp.PowerUpType.weapon:
                ChangeWeaponTo(powerUp.weaponType);
                break;
			default:
				break;
			}
			Destroy(other.gameObject);
		}
	}
예제 #55
0
 public void activatePowerUp(PowerUp name)
 {
 }
예제 #56
0
 public void AddPowerUp(PowerUp powerUp)
 {
     powerUps.Add (powerUp);
     print("PowerUp " + powerUp.name + " added to player");
 }
예제 #57
0
 public void RemovePowerUp()
 {
     UpdateVisualEffect(powerUp.type, false);
     powerUp = null;
 }
예제 #58
0
 public void ReceivePowerUp(PowerUp p_powerup)
 {
     UpdateVisualEffect(p_powerup.type, true);
     powerUp = p_powerup;
 }
예제 #59
0
 // Sets the powerup associated with this upgrader
 public void setPower(PowerUp thePower)
 {
     this.myPower = thePower;
 }
예제 #60
0
 protected void BoatPowerUpCollision(Boat boat, PowerUp powerUp, List<PowerUp> collectedPowerUps)
 {
     boat.GainPowerUp(powerUp);
     collectedPowerUps.Add(powerUp);
 }