Наследование: MonoBehaviour
 public void Update(GameTime gameTime)
 {
     if (powerup == null)
     {
         if (remaining < 0)
         {
             remaining = rand.NextDouble() * 10 + 10;
             lock (phyWorld)
                 powerup = (Powerup)Activator.CreateInstance(
                     types[rand.Next(0, types.Length)], phyWorld, gameplay, rand);
             powerup.LoadContent(content);
         }
         else
             remaining -= gameTime.ElapsedGameTime.TotalSeconds;
     }
     else
     {
         if (powerup.IsActive)
             powerup.Update();
         else
         {
             phyWorld.RemoveBody(powerup);
             powerup = null;
         }
     }
 }
Пример #2
0
 public void AddPowerup(Powerup powerup, bool isShape = false)
 {
     if (isShape)
         shapePowers.Add(powerup);
     else
         powerupList.Add(powerup);
 }
Пример #3
0
	public void CollectPowerup(Powerup powerup) {
		foreach (var gun in gunList) {
			if (gun.gun.powerupLevel < MaxPowerupLevel()) {
				gun.gun.powerupLevel++;
			}
		}
	}
Пример #4
0
 // Use this for initialization
 void Start()
 {
     shotFired = false;
     canShoot = true;
     machineGunUnlocked = false;
     powerup = GameObject.Find("Player").GetComponent<Powerup>();
 }
Пример #5
0
 void Awake()
 {
     powerup = Powerup.None;
     values = Enum.GetValues(typeof(Powerup));
     doors = GameObject.FindGameObjectsWithTag("Door");
     arrows = new List<Transform>();
     radar = false;
 }
Пример #6
0
	public static void LoadPowerupInfo (IList powerupInfo)
	{
		powerups = new Dictionary<string, Powerup>();

		foreach (Dictionary<string, object> info in powerupInfo) {
			var powerupID = info["id"] as string;
			var playerInQuota = (bool)info["player_in_quota"];
			var settings = info["settings"] as Dictionary<string, object>;
			powerups[powerupID] = new Powerup() { playerInQuota = playerInQuota, settings = settings };
		}
	}
Пример #7
0
 public void CreateAt(Vector3 location, Powerup main, int cred)
 {
     var pup = which(main).Spawn(location, Quaternion.identity);
     for (var i = 1; i <= cred; i++)
     {
         var loc = location + Random.onUnitSphere * spawnRadius;
         var sCred = smallCredits.Spawn(loc, Quaternion.identity);
         var logic = sCred.GetComponent<PowerupLogic>();
         logic.Origin = pup.transform.position;
         logic.AddLifetime(-i * 1.5f);
     }
 }
Пример #8
0
 public bool CheckPowerup(Powerup powerup)
 {
     if (powerup.timer <= 0.0f)
     {
         //TODO: Deactivate powerup
         Debug.Log("Powerup deactivated");
         touch.Reset();
         return false;
     }
     else
     {
         powerup.timer -= Time.deltaTime;
         return true;
     }
 }
        public static Collectible CreateCollectible(CollectibleType collectibleType, Vector2 position, Tile currentTile)
        {
            Collectible newCollectible = null;

            switch (collectibleType)
            {
                case CollectibleType.POWERUP:
                    int randomType = RandomManager.GetRandomInt(0, 1);
                    switch (randomType)
                    {
                        case 0:
                            newCollectible = new Powerup(DespicableGame.GetTexture(DespicableGame.GameTextures.SPEEDBOOST), position, currentTile, Powerup.PowerupType.SPEEDBOOST);
                            break;

                        case 1:
                            if (RandomManager.GetRandomTrueFalse(75))
                            {
                                newCollectible = new Powerup(DespicableGame.GetTexture(DespicableGame.GameTextures.TOY_PISTOL), position, currentTile, Powerup.PowerupType.TOY_PISTOL);
                            }
                            else
                            {
                                newCollectible = new Powerup(DespicableGame.GetTexture(DespicableGame.GameTextures.PLAYERTRAP_COLLECTIBLE), position, currentTile, Powerup.PowerupType.PLAYERTRAP);
                            }

                            break;

                    }
                    break;

                case CollectibleType.GOAL:
                    newCollectible = new Goal(DespicableGame.GetTexture(DespicableGame.GameTextures.GOAL), position, currentTile);
                    break;

                case CollectibleType.TRAP:
                    newCollectible =  new Trap(DespicableGame.GetTexture(DespicableGame.GameTextures.TRAP), position, currentTile);
                    break;

                case CollectibleType.SHIP:
                    newCollectible = new Ship(DespicableGame.GetTexture(DespicableGame.GameTextures.LEVEL_EXIT), position, currentTile);
                    break;

                case CollectibleType.BANANA:
                    newCollectible = new Banana(DespicableGame.GetTexture(DespicableGame.GameTextures.BANANA), position, currentTile);
                    break;
            }

            return newCollectible;
        }
Пример #10
0
        public void CreatePowerupFastball()
        {
            PowerupBubble b = CreateBubble();
            b.Texture = greenBubbleTexture;

            Powerup p = new Powerup();
            b.P_Position = new Vector2(250, 410);
            b.P_Velocity = new Vector2(0, 0);
            b.P_Texture = fastPupTexture;
            b.P_Rotation = 0f;
            b.P_Spin = 1.0f;
            p.OnActivate += ActivatePowerupFastball;
            p.OnDeactivate += DectivatePowerupFastball;
            b.powerup = p;

            bubbles.Add(b);
        }
Пример #11
0
        public override void applyPowerup(Powerup p)
        {
            if (p is Powerups.SpeedBoostPowerup)
            {
                resetPowerupState();

                powerupTimer = p.Duration;

                this.powerupState = powerupstate.SpeedBoost;

                this.MaxVel = Powerups.SpeedBoostPowerup.SPEED_BOOST_SPEED;
                this.MaxVelDash = Powerups.SpeedBoostPowerup.SPEED_BOOST_DASH_SPEED;
                this.MaxAcc = Powerups.SpeedBoostPowerup.SPEED_BOOST_ACCEL;
                this.MaxAccDash = Powerups.SpeedBoostPowerup.SPEED_BOOST_DASH_ACCEL;

                AudioManager.getSound("Power_Up").Play();
            }
        }
Пример #12
0
 GameObject which(Powerup type)
 {
     switch (type)
     {
         case Powerup.MISSILES:
             return missiles;
         case Powerup.POWER:
             return power;
         case Powerup.SHIELD:
             return shield;
         case Powerup.CREDITS:
             return credits;
         case Powerup.ENGI:
             return engi;
         default:
             return smallCredits;
     }
 }
 /// <summary>
 /// Calls the appropriate method to activate the inputted powerup
 /// </summary>
 /// <param name="powerup">Input powerup to be activated</param>
 public void activatePowerup(Powerup powerup)
 {
     switch (powerup.getType ())
     {
         case PowerupType.ATTACK:
             activateAttackBoost();
             break;
         case PowerupType.AGILITY:
             activateAgilityBoost();
             break;
         case PowerupType.HEALTH:
             activateHealthBoost();
             break;
         case PowerupType.SPECIAL:
             activateSpecialBoost();
             break;
     }
 }
Пример #14
0
    public void CollectPowerup(Powerup p)
    {
        Destroy(p.gameObject);

        // Assuming a powerup that destroys enemies/restores life has no other benefits
        if (p.destroyEnemies) {
            Game.DestroyEnemies(p.effectRadius);
        }

        else if (p.stunEnemies) {
            Game.StunEnemies(p.durationInSeconds, p.effectRadius);
        }

        else if (p.healthRestorePercent > 0) {
            health += healthMax*(p.healthRestorePercent/100);
            if (health > healthMax) health = healthMax;
        }

        // Powerups with duration
        else {
            powerups.Add(p);
            if (powerups.Count == 1) InvokeRepeating("PowerupTick", 1, 1);

            armorModifier 	 *= p.armorModifier;
            speedModifier 	 *= p.speedModifier;
            strengthModifier *= p.damageModifier;
            regenModifier 	 *= p.regenModifier;
            xpModifier 		 *= p.xpModifier;

            sizeModifier 	 *= p.sizeModifier;
            transform.localScale *= p.sizeModifier;

            if (IsInvoking("HealthTick")) {
                CancelInvoke("HealthTick");
                InvokeRepeating("HealthTick", healthRegenRate/regenModifier, healthRegenRate/regenModifier);
            }

            boidComponent.turningSpeed *= p.speedModifier;

            // don't use invincible = p.invincibility; will cause powerups to cancel invincibility granted by other powerups
            if (p.invincibility) invincible = true;
        }
    }
    public void Initialize(Powerup type_in = Powerup.Random)
    {
        if (type_in == Powerup.Random)
        {
            switch (Random.Range(0, 3))
            {
                case 0:
                    type = Powerup.Rifle;
                    break;
                case 1:
                    type = Powerup.Time;
                    break;
                case 2:
                    type = Powerup.Bomb;
                    break;
            }
        }
        else
        {
            type = type_in;
        }

        // set powerup specific view + behavior here
        Sprite[]  sprites = Resources.LoadAll<Sprite>("items");
        switch (type)
        {
            case Powerup.Rifle:
                sprite = sprites[1];
                powerup_action = ApplyRifle;
                break;
            case Powerup.Time:
                sprite = sprites[2];
                powerup_action = ApplyTime;
                break;
            case Powerup.Bomb:
                sprite = sprites[3];
                powerup_action = ApplyBomb;
                break;
        }

        SpriteRenderer sprite_renderer = GetComponent<SpriteRenderer>();
        sprite_renderer.sprite = sprite;
    }
Пример #16
0
    void CollectedPowerup(Powerup powerup)
    {
        int type = powerup.type;
        AudioManager.getInstance().Play(AudioManager.POWERUP_PICKUP);
        print ("Collected Powerup " + type.ToString ());
        switch (type) {
            case Powerup.TYPE_LASER:
                foreach(Gun gun in stageZeroGuns)
                    gun.modifier *= .9f;
                foreach(Gun gun in stageOneGuns)
                        gun.modifier *= .9f;
                foreach(Gun gun in stageTwoGuns)
                        gun.modifier *= .9f;
                powerup.OnCollected();
            break;
            case Powerup.TYPE_BULLET:
                foreach(Gun gun in stageZeroGuns)
                    gun.modifier *= .9f;
                foreach(Gun gun in stageOneGuns)
                        gun.modifier *= .9f;
                foreach(Gun gun in stageTwoGuns)
                        gun.modifier *= .9f;

                powerup.OnCollected();
            break;
            case Powerup.TYPE_ARMOR:
                if(stage == 0)
                {
                    SwitchStage(stage + 1);
                    powerup.OnCollected();
                }

            break;
            case Powerup.TYPE_ARMORTWO:
                if(stage == 1)
                {
                    SwitchStage(stage + 1);
                    powerup.OnCollected();

                }break;
        }
    }
Пример #17
0
 public void ApplyPowerup(Powerup powerup)
 {
     Debug.Log("Applied: " + powerup.PowerupType.ToString());
     activePowerup = powerup;
     touch.Reset();
     switch (activePowerup.PowerupType)
     {
         case PowerupType.PROJECTILE:
             touch.RendererWidth = 1f;
             break;
         case PowerupType.EXPLOSION:
             touch.ExplosionPowerup = true;
             break;
         case PowerupType.SHOOTER:
             touch.Shooting = true;
             break;
         case PowerupType.SHAPE:
             StartCoroutine(touch.DrawShape());
             break;
     }
 }
Пример #18
0
    // Get powerups
    public void OnTriggerEnter(Collider other)
    {
        /*
        if (other.name == "ChurchEntrance") {
            you.position = GameObject.Find("ChurchSpawn").transform.position;
            print("test");
        }
        else if (other.name == "ChurchSpawn") {
            you.position = GameObject.Find("ChurchEntrance").transform.position;
        }
        */

        // Detect water
        if (other.tag == "water") {
            water = true;
        }

        // Get powerup
        if (other.tag == "powerup") {
            powerup = (Powerup)values.GetValue(RAND.Next(values.Length - 1));
        }
    }
Пример #19
0
 public static void UnequipPowerup(int playerIndex, bool active, Powerup powerup)
 {
     Powerup[] powerups = null;
     if (active)
         powerups = powerupLists[playerIndex].actives;
     else
         powerups = powerupLists[playerIndex].passives;
     for (int i = 0; i < powerups.Length; i++)
     {
         if (powerups[i] == powerup)
         {
             powerups[i] = null;
             if (powerup.Active)
                 storageGrid[playerIndex][i].SetPowerup(null);
             else
                 storageGrid[playerIndex][i + MAX_ACTIVE_POWERUPS].SetPowerup(null);
             break;
         }
     }
 }
Пример #20
0
 // Called from the powerup when it ends
 public void OnPowerupEnd()
 {
     currentPowerup = null;
     powerupActive  = false;
 }
Пример #21
0
        public static void ProcessLevelForCarmageddonMaxDamage()
        {
            if (SceneManager.Current.Models.Count == 0)
            {
                return;
            }

            ModelBoneCollection bones = SceneManager.Current.Models[0].Bones[0].AllChildren();

            SceneManager.Current.UpdateProgress("Applying Carmageddon: Max Damage scale");

            ModelManipulator.Scale(bones, Matrix4D.CreateScale(6.9f, 6.9f, -6.9f), true);
            ModelManipulator.FlipFaces(bones, true);

            SceneManager.Current.UpdateProgress("Fixing material names");

            foreach (Material material in SceneManager.Current.Materials)
            {
                if (material.Name.Contains("."))
                {
                    material.Name = material.Name.Substring(0, material.Name.IndexOf("."));
                }
                material.Name = material.Name.Replace("\\", "");

                MATMaterial m = (material.SupportingDocuments["Source"] as MATMaterial);
                if (!m.HasTexture)
                {
                    using (Bitmap bmp = new Bitmap(16, 16))
                        using (Graphics g = Graphics.FromImage(bmp))
                        {
                            g.FillRectangle(new SolidBrush(Color.FromArgb(m.DiffuseColour[3], m.DiffuseColour[0], m.DiffuseColour[1], m.DiffuseColour[2])), 0, 0, 16, 16);

                            Texture t = new Texture();
                            t.CreateFromBitmap(bmp, string.Format("{4}_R{0:x2}G{1:x2}B{2:x2}A{3:x2}", m.DiffuseColour[0], m.DiffuseColour[1], m.DiffuseColour[2], m.DiffuseColour[3], material.Name));
                            material.Texture = t;
                        }
                }
            }

            SceneManager.Current.UpdateProgress("Processing powerups and accessories");

            for (int i = bones.Count - 1; i >= 0; i--)
            {
                ModelBone bone = bones[i];

                if (bone.Name.StartsWith("&"))
                {
                    if (bone.Name.StartsWith("&£"))
                    {
                        C2Powerup pup     = Powerups.LookupID(int.Parse(bone.Name.Substring(2, 2)));
                        Powerup   powerup = new Powerup();

                        if (pup.InMD)
                        {
                            powerup.Name = $"pup_{pup.Name}";
                            powerup.Tag  = pup.Model;
                        }
                        else
                        {
                            powerup.Name = "pup_Credits";
                            powerup.Tag  = pup.Model;
                        }

                        powerup.Transform = bone.CombinedTransform;

                        SceneManager.Current.Entities.Add(powerup);
                    }
                    else
                    {
                        Accessory accessory = new Accessory
                        {
                            Name = $"C2_{bone.Mesh.Name.Substring(3)}"
                        };

                        SceneManager.Current.Entities.Add(accessory);
                    }

                    SceneManager.Current.Models[0].RemoveBone(bone.Index);
                }
            }

            if (SceneManager.Current.Models[0].SupportingDocuments.ContainsKey("TXT"))
            {
                Map map = SceneManager.Current.Models[0].GetSupportingDocument <Map>("TXT");

                StartingGrid grid = new StartingGrid
                {
                    Transform = Matrix4D.CreateTranslation(map.GridPosition.X * 6.9f, map.GridPosition.Y * 6.9f, map.GridPosition.Z * -6.9f)
                };

                SceneManager.Current.Entities.Add(grid);
            }

            SceneManager.Current.UpdateProgress("Processing complete!");

            SceneManager.Current.SetCoordinateSystem(CoordinateSystem.LeftHanded);

            SceneManager.Current.Change(ChangeType.Munge, ChangeContext.Model, -1);

            SceneManager.Current.SetContext("Carmageddon Max Damage", ContextMode.Level);
        }
Пример #22
0
 public void CreatePopup(float number, Powerup powerup)
 {
     CreatePopup(string.Format("+ {0:0} {1}", number, powerup.Affix), powerup.EffectColor);
 }
 public void SetPowerup(Powerup powerup)
 {
     this.powerup    = powerup;
     gameObject.name = powerup.name;
 }
Пример #24
0
 public void Remove(Powerup powerup)
 {
 }
Пример #25
0
 public void AddPowerUp(Powerup powerup)
 {
     powerup.OnPowerUp();
 }
Пример #26
0
    public void Update()
    {
        if (beginCount < beginTime)
        {
            beginCount      += UnityEngine.Time.deltaTime;
            clock.percentage = 1.0f;
        }
        else if (beginningLabel.alpha > 0)
        {
            beginningLabel.alpha      -= .3f * UnityEngine.Time.deltaTime;
            beginningLabelShadow.alpha = beginningLabel.alpha;
        }
        enemyClock.percentage = (playerList.Count - 1) / startNumPlayers;
        if (playerList.Count == 1)
        {
            clock.disableClock();
            if (endScreen == null)
            {
                FSoundManager.PlaySound("win");
                endScreen = new LevelOverScreen(true, currentLevelNum + 1 >= enemiesOnLevel.Length);
                gui.AddChild(endScreen);
            }
            else
            {
                if (endScreen.readyToStart)
                {
                    Futile.instance.SignalUpdate -= Update;
                    Futile.stage.RemoveAllChildren();
                    if (this.currentLevelNum + 1 < enemiesOnLevel.Length)
                    {
                        World newWorld = new World(++this.currentLevelNum);
                        Futile.instance.SignalUpdate += newWorld.Update;
                    }
                    else
                    {
                        TitleScreen titleScreen = new TitleScreen();
                        Futile.stage.AddChild(titleScreen);
                    }
                }
            }
        }
        else if (clock.percentage <= 0)
        {
            if (endScreen == null)
            {
                FSoundManager.PlaySound("lose");
                endScreen = new LevelOverScreen(false);
                gui.AddChild(endScreen);
            }
            else
            {
                endScreen.MoveToFront();
                if (endScreen.readyToStart)
                {
                    Futile.instance.SignalUpdate -= Update;
                    Futile.stage.RemoveAllChildren();

                    World newWorld = new World(this.currentLevelNum);
                    Futile.instance.SignalUpdate += newWorld.Update;
                }
            }
        }
        for (int ind = 0; ind < powerups.Count; ind++)
        {
            Powerup powerup = powerups[ind];
            foreach (Player p in playerList)
            {
                if (p.isControlled)
                {
                    if (powerup.checkCollision(p))
                    {
                        FSoundManager.PlaySound("powerup");
                        p.collectPowerUp(powerup.PType);
                        powerup.RemoveFromContainer();
                        powerups.Remove(powerup);
                        ind--;
                    }
                }
            }
        }
        for (int ind = 0; ind < bulletList.Count; ind++)
        {
            Bullet b = bulletList[ind];
            b.Update();
            for (int playerInd = 0; playerInd < playerList.Count; playerInd++)
            {
                Player p = playerList[playerInd];
                if (clock.percentage > 0 && b.checkCollision(p))
                {
                    p.setScale(p.scale - 1.0f, false);
                    if (p.scale <= 0)
                    {
                        FSoundManager.PlaySound("dead", .3f);
                        p.RemoveFromContainer();
                        playerList.Remove(p);
                        playerInd--;
                        FloatIndicator floatInd = new FloatIndicator("+00:00:0" + p.secondValue, p.GetPosition());
                        playerLayer.AddChild(floatInd);
                        clock.percentage += p.secondValue / 10.0f;      //Add the seconds to the clock
                        if (p.secondValue == 3)
                        {
                            float   powerupChance = RXRandom.Float();
                            Powerup powerup       = null;
                            if (powerupChance < .4f)
                            {
                                powerup = new Powerup(Powerup.PowerupType.MACHINEGUN);
                            }
                            else if (powerupChance < .8f)
                            {
                                powerup = new Powerup(Powerup.PowerupType.SHOTGUN);
                            }
                            if (powerup != null)
                            {
                                powerups.Add(powerup);
                                powerup.SetPosition(p.GetPosition());
                                playerLayer.AddChild(powerup);
                            }
                        }
                    }
                    else
                    {
                        FSoundManager.PlaySound("hit", .3f);
                    }
                    b.RemoveFromContainer();
                    bulletList.Remove(b);
                    ind--;
                    break;
                }
                else
                if (tilemap.getFrameNum((int)(b.x / tilemap._tileWidth), (int)(-b.y / tilemap._tileHeight)) == 1)
                {
                    b.RemoveFromContainer();
                    bulletList.Remove(b);
                    ind--;
                    break;
                }
            }
        }
    }
 public void removeItem()
 {
     this.current    = null;
     this.slot.color = new Color(1, 1, 1, 0);
 }
Пример #28
0
 public void Remove(Powerup powerup)
 {
     powerup.OnDeactivate(data);
     powerups.Remove(powerup);
 }
    // when player enters range of something
    void OnTriggerEnter(Collider obj)
    {
        if (obj.tag == "Powerup")
        {
            Powerup pup = obj.GetComponent <Powerup>();
            // movement speed boost
            if (pup.powerupType == 0)
            {
                movementModifier     *= 1.25f;
                movementModifierTimer = 10f;
            }
            // hp restore
            else if (pup.powerupType == 1)
            {
                if (currentHealth >= maxHealth)
                {
                    // do nothing
                }
                else
                {
                    // heal for 20% of missing health
                    float missingHP = maxHealth - currentHealth;
                    currentHealth += missingHP * 0.2f;
                }
            }
            // invis
            else if (pup.powerupType == 2)
            {
                transform.GetComponent <PhotonView>().RPC("InvisC", PhotonTargets.AllBuffered, 0.2f, 1f);
                invisDuration = 15f;
            }
            // exp boost
            else if (pup.powerupType == 3)
            {
                currentEXP += 100f;
            }
            //Debug.Log("destroy " + obj);
            //transform.GetComponent<PhotonView>().RPC("destroyPU", PhotonTargets.MasterClient, obj);
            if (PhotonNetwork.isMasterClient)
            {
                PhotonNetwork.Destroy(obj.gameObject);
            }
        }
        // put spikes here because we dont want spikes displacing the player
        if (obj.tag == "Spike")
        {
            onSpikes = true;
            canMove  = false;
        }
        if (obj.tag == "Stomp")
        {
            // player gets knocked down for 1.5 seconds
            TakeDamage(10f);
            transform.GetComponent <PhotonView>().RPC("PlayAnim", PhotonTargets.All, "Unarmed-Death1");
            WaitForAnimation(1.5f);
        }
        // if gets hit by a dart
        if (obj.tag == "Dart")
        {
            transform.GetComponent <PhotonView>().RPC("Asleep", PhotonTargets.AllBuffered);
            PhotonNetwork.Destroy(obj.gameObject);
        }
        // if steps on a mine
        if (obj.tag == "Mine")
        {
            isGrounded = true;
            Mine mine = obj.gameObject.GetComponent <Mine>();
            if (mine.exploded == false)
            {
                TakeDamage(mine.mineSize * 50f);
            }

            mine.transform.GetComponent <PhotonView>().RPC("explode", PhotonTargets.MasterClient, 2f);
            // if mine hasnt been exploded already then take damage
        }
    }
Пример #30
0
 public void PlayPowerupFX(Powerup powerup)
 {
     StartCoroutine(PowerUpFXRoutine());
 }
Пример #31
0
    public void Update()
    {
        timeSinceLastStun += Time.deltaTime;

        if (stunTimeLeft > 0)
        {
            stunTimeLeft -= Time.deltaTime;
        }
        if (stunTimeLeft < 0)
        {
            animator.SetBool("stunned", false);
            stunTimeLeft = 0;
        }


        if (energy > 0)
        {
            energy -= energyDecayRate * Time.deltaTime;
        }

        if (energy < 0)
        {
            energy = 0;
        }

        if (powerupDurationLeft > 0)
        {
            powerupDurationLeft -= Time.deltaTime;
        }
        if (powerupDurationLeft <= 0)
        {
            powerup = Powerup.None;
            overlay.setPowerup(0);
            powerupDurationLeft = 0;
        }

        gravityModifier = 1;
        numExtraJumps   = 0;
        speedMultiplier = 1;

        switch (powerup)
        {
        case Powerup.DoubleJump:
            numExtraJumps = extraJumpsPowerupFactor;
            break;

        case Powerup.ExtraSpeed:
            speedMultiplier = speedPowerupFactor;
            break;

        case Powerup.LowGravity:
            gravityModifier = lowGravityPowerupFactor;
            break;
        }

        m_Rigidbody2D.gravityScale = (float)gravityModifier;

        bonusForce = energyStrength * Mathf.Log((float)energy + 1, 2);

        distanceBehindCamera = _camera.position.x - transform.position.x;
        catchupSpeed         = catchupFactor * (distanceBehindCamera - MIN_DISTANCE_BEHIND_CAMERA) / (MAX_DISTANCE_BEHIND_CAMERA - MIN_DISTANCE_BEHIND_CAMERA);

        if (stunTimeLeft == 0)
        {
            horizontalMove = Input.GetAxisRaw(horizontalAxis) * (runSpeed + (float)bonusForce + (float)catchupSpeed) * ((float)speedMultiplier);

            if (horizontalMove != 0)
            {
                mute = false;
            }

            if (Input.GetButtonDown(jumpAxis))
            {
                mute = false;
                jump = true;
            }
        }
        else
        {
            horizontalMove = 0;
            jump           = false;
        }
    }
Пример #32
0
            public void SetPowerup(Powerup powerup)
            {
                this.Powerup = powerup;

                Powerup[] powerups = null;
                int index = -1;
                if (rowIndex < RetroGame.MAX_PLAYERS){
                    if (Active)
                    {
                        powerups = powerupLists[rowIndex].actives;
                        index = iconIndex;
                    }
                    else
                    {
                        powerups = powerupLists[rowIndex].passives;
                        index = iconIndex - MAX_ACTIVE_POWERUPS;
                    }
                    powerups[index] = powerup;
                }
            }
Пример #33
0
    private bool HandlePickup()
    {
        m_Pickupable = null;

        int hitCount = Physics2D.OverlapCircleNonAlloc(transform.position, 4, m_PickupScanResults, Layers.PickupMask);

        if (hitCount == 0)
        {
            return(false);
        }

        Collider2D bestColl = m_PickupScanResults[0];
        float      bestDist = Vector2.Distance(transform.position, bestColl.transform.position);

        for (int i = 1; i < hitCount; i++)
        {
            Collider2D coll = m_PickupScanResults[i];
            float      dist = Vector2.Distance(transform.position, coll.transform.position);
            if (dist < bestDist)
            {
                bestColl = coll;
                bestDist = dist;
            }
        }

        Pickup pickup = bestColl.GetComponent <Pickup>();

        if (pickup == null)
        {
            return(false);
        }

        m_Pickupable = pickup.Value;

        Weapon weapon = pickup.Value as Weapon;

        if (weapon != null)
        {
            int equipSlot = -1;
            if (Input.GetButtonDown(m_Equip0InputButton))
            {
                equipSlot = 0;
            }
            else if (Input.GetButtonDown(m_Equip1InputButton))
            {
                equipSlot = 1;
            }
            else if (Input.GetButtonDown(m_Equip2InputButton))
            {
                equipSlot = 2;
            }
            else if (Input.GetButtonDown(m_Equip3InputButton))
            {
                equipSlot = 3;
            }
            if (equipSlot < 0)
            {
                return(false);
            }

            Weapon oldWeapon = m_WeaponSlots[equipSlot].Weapon;
            m_WeaponSlots[equipSlot].Weapon = weapon;
            pickup.Value = oldWeapon;

            if (pickup.Value == null)
            {
                pickup.gameObject.Free();
            }
        }

        Powerup powerup = pickup.Value as Powerup;

        if (powerup != null)
        {
            if (!Input.GetButtonDown(m_Equip0InputButton))
            {
                return(false);
            }

            powerup.Activate(this);
            pickup.gameObject.Free();
        }

        return(true);
    }
Пример #34
0
    void PowerupRemoved(Powerup p)
    {
        //if a letter is not on the list, nothing has to be done when it is removed
        switch (p.letter.letter)
        {
        case "D":
            jumpCountMax--;
            break;

        case "E":
            break;

        case "F":

            break;

        case "G":

            break;

        case "H":
            break;

        case "I":
            pphysics.IceMove = false;
            break;

        case "J":
            pphysics.jumpSpeed /= 1.75f;
            break;

        case "K":
            break;

        case "L":
            break;

        case "M":
            break;

        case "N":
            break;

        case "O":
            oppositeInputs = false;
            break;

        case "P":
            break;

        case "Q":
            pphysics.movespeed /= 2f;
            mstrail.gameObject.SetActive(false);
            break;

        case "R":
            break;

        case "S":
            pphysics.movespeed *= 2f;
            break;

        case "T":
            timer.StopTimer();
            break;

        case "U":
            break;

        case "V":
            StartCoroutine(mainCamera.StopVapor());
            break;

        case "W":
            break;

        case "X":
            break;

        case "Y":
            break;

        case "Z":
            mainCamera.restoreCamera(false);
            break;

        default:
            break;
        }
    }
Пример #35
0
 private void Awake()
 {
     player = GameObject.FindWithTag("Player").GetComponent <Player>();
     p      = GameObject.FindWithTag("GameManager").GetComponent <Powerup>();
 }
Пример #36
0
    IEnumerator harvestLetter()
    {
        //signal the start of the harvest process
        bool colliding = pphysics.CheckLetterCollision();          //the rays haven't been updated after fixedUpdate...we have to make sure we're still on a letter

        if (!harvesting && harvestableLetter != null && !harvestableLetter.Rotating && colliding)
        {
            pphysics.horizontal_move(0, true, false);
            setPlayerActive(false);

            harvesting = true;
            anim.SetBool("harvesting", true);
            harvestableLetter.setAsHarvested();

            float startTime = Time.time;
            while (Time.time - startTime < 1f)
            {
                if (harvestableLetter.HasDisappeared)
                {
                    break;
                }
                yield return(new WaitForEndOfFrame());
            }

            anim.SetBool("harvesting", false);

            //if the letter disappeared while we were harvesting
            if (!harvestableLetter.HasDisappeared)
            {
                bool   newPowerup    = false;
                string l             = harvestableLetter.letter;
                int    powerup_count = 1;
                bool   check_if_POTD = GameManager.IsPOTD(l);                //add checks for all POTD items
                if (check_if_POTD && IncrementPOTDIfExists(l) != null)       //include all place once and destroy objects
                {
                    EventHandler <NewLetterEvent> handler = PowerupChange;
                    if (handler != null)
                    {
                        handler(this, new NewLetterEvent(harvestableLetter, 1));
                    }
                }
                else                   //permanent buffs
                {
                    Letter eventLetter = harvestableLetter;

                    //can only replicate the item in slot 1
                    //need to switch the letter to the powerup[0] slot before we send the event
                    if (harvestableLetter.letter == "C")
                    {
                        sendHandlerEvent(eventLetter, powerups [0].count > 1 ? powerups [0].count : 0);
                        if (powerups.Count > 0 && powerups [0] != null)
                        {
                            eventLetter.letter = powerups [0].letter.letter;
                            powerup_count      = powerups [0].count;
                            newPowerup         = true;
                        }
                    }
                    //can only use the N powerup with an item in slot 1
                    else if (harvestableLetter.letter == "N")
                    {
                        if (powerups.Count > 0)
                        {
                            while (powerups.Count > 0)
                            {
                                PowerupRemoved(powerups [powerups.Count - 1]);
                                powerups.RemoveAt(powerups.Count - 1);
                            }
                        }
                        sendHandlerEvent(eventLetter, 0);
                    }
                    else if (harvestableLetter.letter == "X")
                    {
                        foreach (Powerup p in powerups)
                        {
                            if (GameManager.IsPOTD(p.letter.letter))
                            {
                                p.count++;
                            }
                        }
                        sendHandlerEvent(eventLetter, 0);
                    }
                    else if (harvestableLetter.letter == "P")
                    {
                        sendHandlerEvent(eventLetter, -2);
                        transform.position = originalPosition;
                        List <Letter> letters = GameObject.FindGameObjectsWithTag("Letter").Select(a => a.GetComponent <Letter> ()).ToList();
                        foreach (Letter a in letters)
                        {
                            if (a != pphysics.collisionLetter)
                            {
                                a.ResetLetter();
                            }
                        }

                        //should we also destroy in air throwables?
                    }
                    //we're picking up a new powerup
                    else
                    {
                        newPowerup = true;
                        sendHandlerEvent(eventLetter, 0);
                    }
                }

                if (newPowerup)
                {
                    Powerup power = new Powerup(harvestableLetter);
                    power.count = powerup_count;
                    PowerupAdded(power);
                    if (powerups.Count > 1 && powerups [0] == null)
                    {
                        //if item2 is defined but item1 is null (POTD was used)
                        powerups [0] = power;
                    }
                    else
                    {
                        powerups.Insert(0, power);
                    }

                    while (powerups.Count > 2)
                    {
                        PowerupRemoved(powerups [powerups.Count - 1]);
                        powerups.RemoveAt(powerups.Count - 1);
                    }

                    //if something is already mapped to x, store mapping as y
                    if (getIndexFromMapping("X") >= 0)
                    {
                        powerups [0].buttonMapping = "Y";
                    }
                    else
                    {
                        powerups [0].buttonMapping = "X";
                    }
                }
            }

            harvestableLetter = null;
            harvesting        = false;

            if (GameManager.letters_active > 0)
            {
                setPlayerActive(true);
            }
        }
        yield return(null);
    }
Пример #37
0
 public override void Start()
 {
     base.Start();
     powerup = this.GetComponent <Powerup>();
 }
Пример #38
0
    void PowerupAdded(Powerup p)
    {
        //if a letter is not on the list, nothing has to be done when it is added
        switch (p.letter.letter)
        {
        case "D":
            jumpCountMax++;
            break;

        case "E":
            break;

        case "F":

            //mstrail.gameObject.SetActive(true);
            break;

        case "G":

            break;

        case "H":
            break;

        case "I":
            pphysics.IceMove = true;
            break;

        case "J":
            pphysics.jumpSpeed *= 1.75f;
            break;

        case "K":
            break;

        case "L":
            break;

        case "M":
            break;

        case "N":
            break;

        case "O":
            oppositeInputs = true;
            break;

        case "P":
            break;

        case "Q":
            pphysics.movespeed *= 2f;
            break;

        case "R":
            break;

        case "S":
            pphysics.movespeed *= 0.5f;
            break;

        case "T":
            timer.SetTimer();
            break;

        case "U":
            break;

        case "V":
            StartCoroutine(mainCamera.StartVapor());
            break;

        case "W":
            break;

        case "X":
            break;

        case "Y":
            break;

        case "Z":
            break;

        default:
            break;
        }
    }
Пример #39
0
 public void GeneratePowerup(Powerup powerUp)
 {
     this.powerUp = powerUp;
 }
Пример #40
0
        public void Draw_Load()
        {
            string imgname = "";

            foreach (Entity ship in gameCtrl.current_Enemies)
            {
                if (ship is Asteroid)
                {
                    imgname = "asteroid.png";
                }
                else if (ship is AI)
                {
                    if (ship is Mine)
                    {
                        imgname = "mine.png";
                    }
                    else if (ship is Tracker)
                    {
                        imgname = "ship 4.png";
                    }
                    else
                    {
                        imgname = "Ship 1.png";
                    }
                }
                else if (ship is Bullet)
                {
                    imgname = "C_bullet.png";
                }

                else if (ship is Powerup)
                {
                    Powerup power = ship as Powerup;
                    switch (power.type)
                    {
                    case PowerUp.ExtraLife:
                    { imgname = "Powerup\\life.png"; }
                    break;

                    case PowerUp.Invincible:
                    { imgname = "Powerup\\shield.png"; }
                    break;

                    case PowerUp.ExtraSpeed:
                    { imgname = "Powerup\\power.png"; }
                    break;

                    default:
                    { imgname = "Powerup\\star.png"; }
                    break;
                    }
                }


                if (ship != null)
                {
                    Image img = new Image()
                    {
                        Source = new BitmapImage(new Uri("Images/" + imgname, UriKind.Relative))
                    };
                    img.Width  = ship.hitbox.Width;
                    img.Height = ship.hitbox.Height;
                    WorldCanvas.Children.Add(img);
                    icons.Add(new Icon()
                    {
                        i = img, e = ship
                    });
                }
            }
            foreach (Entity b in gameCtrl.player_fire)
            {
                Image img = new Image()
                {
                    Source = new BitmapImage(new Uri("images/" + "P_bullet", UriKind.Relative))
                };
                img.Width  = b.hitbox.Width;
                img.Height = b.hitbox.Height;
                WorldCanvas.Children.Add(img);
                icons.Add(new Icon()
                {
                    i = img, e = b
                });
            }
        }
Пример #41
0
 public void PickupWeapon(Powerup powerup)
 {
     baseAnim.SetTrigger("PickupPowerup");
 }
Пример #42
0
 public void AddPowerup(Powerup powerup)
 {
     powerups.Add(powerup);
 }
Пример #43
0
    // Update is called once per frame
    void Update()
    {
        if (isSticky) {
            //Increase timer of sticky status
            stickyTimer += Time.deltaTime;
        }
        if (stickyTimer > stickyTime) {
            Debug.Log("Finished Sticky");
            stickyTimer = 0.0f;
            isSticky = false;
            Rigidbody2D playerBdy = (Rigidbody2D)GameObject.Find("Character").GetComponent("Rigidbody2D");
            playerBdy.isKinematic = false;
        }

        if (Input.GetKeyDown (KeyCode.E)) {
            //Normal powerup
            powerType = Powerup.normal;
        } else if (Input.GetKeyDown (KeyCode.R)) {
            //Ghost powerup
            powerType = Powerup.ghost;
        } else if (Input.GetKeyDown (KeyCode.T)) {
            //Sticky powerup
            powerType = Powerup.sticky;
        }
    }
Пример #44
0
 private void MakePowerups()
 {
     for (int i = 0; i < 25; i++)
     {
         Powerup p = new Powerup(new Vector2(getRandom(-22000, 22000), getRandom(-22000, 22000)), Content);
         powerupList.Add(p);
     }
 }
Пример #45
0
        public static bool StorePowerup(Powerup powerup)
        {
            int initialRow = 0;
            int maxRow = 0;
            if (powerup.Active)
            {
                initialRow = RetroGame.MAX_PLAYERS;
                maxRow = RetroGame.MAX_PLAYERS + STORAGE_ACTIVE_ROWS;
            }
            else
            {
                initialRow = RetroGame.MAX_PLAYERS + STORAGE_ACTIVE_ROWS;
                maxRow = RetroGame.MAX_PLAYERS + STORAGE_ACTIVE_ROWS + STORAGE_PASSIVE_ROWS;
            }

            Point firstOpenSpace = new Point(-1, -1);
            for (int i = initialRow; i < maxRow; i++)
                for (int j = 0; j < storageGrid[i].Length; j++)
                {
                    if (!storageGrid[i][j].HasPowerup && firstOpenSpace.X < 0)
                    {
                        firstOpenSpace = new Point(i, j);
                    }
                    if (storageGrid[i][j].HasPowerup && storageGrid[i][j].Powerup.GetType() == powerup.GetType())
                        return false;
                }
            storageGrid[firstOpenSpace.X][firstOpenSpace.Y].SetPowerup(powerup);
            allCurrentlyOwnedPowerupTypes = null; //recalculate list
            flashAcquiredPowerup(storageGrid[firstOpenSpace.X][firstOpenSpace.Y]);
            return true;
        }
Пример #46
0
 public void SetCurrentPowerup(Powerup newPowerup)
 {
     currentPowerup = newPowerup;
 }
Пример #47
0
 public InventoryPowerupIcon(int rowIndex, int iconIndex, bool active, Powerup powerup, InputAction? action)
 {
     this.Powerup = powerup;
     this.action = action;
     this.iconIndex = iconIndex;
     this.rowIndex = rowIndex;
     this.Active = active;
 }
Пример #48
0
 // Make a bomb in the specified location with the ability to transform simple chips in a bomb
 public Chip AddPowerup(int x, int y, Powerup p)
 {
     SlotForChip slot = GetSlot (x, y).GetComponent<SlotForChip> ();
     Chip chip = slot.chip;
     int id;
     if (chip)
         id = chip.id;
     else
         id = Random.Range(0, LevelProfile.main.chipCount);
     if (chip)
         Destroy (chip.gameObject);
     switch (p) {
         case Powerup.SimpleBomb: chip = FieldAssistant.main.GetNewBomb(slot.slot.x, slot.slot.y, slot.transform.position, id); break;
         case Powerup.CrossBomb: chip = FieldAssistant.main.GetNewCrossBomb(slot.slot.x, slot.slot.y, slot.transform.position, id); break;
         case Powerup.ColorBomb: chip = FieldAssistant.main.GetNewColorBomb(slot.slot.x, slot.slot.y, slot.transform.position, id); break;
     }
     return chip;
 }
 void UsePowerup()
 {
     if (_availablePowerup)
     {
         if (Input.GetButtonDown("FireP1"))
         {
             switch (_powerUp)
             {
                 case Powerup.Boost:
                     GameObject.FindObjectOfType<Player1LevelScript>().IncreaseSpeed = true;
                     GameObject.FindGameObjectWithTag("SpeedUp").GetComponent<AudioSource>().Play();
                     break;
                 case Powerup.Drill:
                     GameObject.FindObjectOfType<RocketDrill>().RocketDrillP1 = true;
                     GameObject.FindGameObjectWithTag("DrillExplosion").GetComponent<AudioSource>().Play();
                     break;
                 case Powerup.Invulnerability:
                     _inVulnerable = true;
                     GameObject.FindGameObjectWithTag("Shield").GetComponent<AudioSource>().Play();
                     break;
             }
             _powerUp = Powerup.Empty;
             _availablePowerup = false;
         }
     }
 }
 public bool Update(Powerup powerup)
 {
     return(pm.Merge <Powerup>(powerup));
 }
Пример #51
0
        // Applies the powerup to our player
        public void ApplyPowerup(Powerup.PowerupType type)
        {
            if (type == Powerup.PowerupType.FasterShots)
            {
                ShotSpeedModifier = 2.0f;
                PowerupTime = 10000.0f;
            }
            else if (type == Powerup.PowerupType.FourWayShooter)
            {
                directions = Math.PI * 2;
                PowerupTime = 10000.0f;
            }

            StartRumble(1.0f, 200.0f);
        }
Пример #52
0
    // Update is called once per frame
    void Update()
    {
        if (nextPowerUpTime < 0 && !winScreen)
        {
            int x = Random.Range(1, levelWidth - 1);
            int y = Random.Range(1, levelHeight - 1);

            Powerup p = Instantiate(powerup, new Vector3((-(int)(levelWidth / 2) + x) * Level.GRID_WIDTH, (-(int)(levelHeight / 2) + y) * Level.GRID_WIDTH, -0.1f), Quaternion.Euler(270, 0, 0)) as Powerup;
            p.level = this;

            nextPowerUpTime = Random.Range(4f, 6f);
        }
        else
        {
            nextPowerUpTime -= Time.deltaTime;
        }

        if (boxTime < 0)
        {
            boxTime = 10;

            for (int i = 0; i < 3; i++)
            {
                int x = Random.Range(1, levelWidth - 1);
                int y = Random.Range(1, levelHeight - 1);

                while (!isFree(x, y))
                {
                    x = Random.Range(1, levelWidth - 1);
                    y = Random.Range(1, levelHeight - 1);
                }

                x -= levelWidth / 2;
                y -= levelHeight / 2;

                int type = Random.Range(0, 10);

                if (type < 5)
                {
                    LevelObject l = (LevelObject)Instantiate(cookie, new Vector3(x * Level.GRID_WIDTH, y * Level.GRID_WIDTH, 0), Quaternion.Euler(270, 0, 0)) as Cookie;
                    l.setGridLocation(x + (int)(levelWidth / 2), y + (int)(levelHeight / 2));
                    l.setLevel(this);

                    levelObjects.Add(l);
                }
                else if (type < 8)
                {
                    LevelObject l = (LevelObject)Instantiate(bacon, new Vector3(x * Level.GRID_WIDTH, y * Level.GRID_WIDTH, 0), Quaternion.Euler(270, 0, 0)) as Bacon;
                    l.setGridLocation(x + (int)(levelWidth / 2), y + (int)(levelHeight / 2));
                    l.setLevel(this);

                    levelObjects.Add(l);
                }
                else
                {
                    LevelObject l = (LevelObject)Instantiate(candy, new Vector3(x * Level.GRID_WIDTH, y * Level.GRID_WIDTH, 0), Quaternion.Euler(270, 0, 0)) as Candy;
                    l.setGridLocation(x + (int)(levelWidth / 2), y + (int)(levelHeight / 2));
                    l.setLevel(this);

                    levelObjects.Add(l);
                }
            }
        }
        else
        {
            boxTime -= Time.deltaTime;
        }

        if (nextGumTime < 0 && !winScreen)
        {
            int x = Random.Range(1, levelWidth - 1);
            int y = Random.Range(1, levelHeight - 1);

            while (isGate(x, y))
            {
                x = Random.Range(1, levelWidth - 1);
                y = Random.Range(1, levelHeight - 1);
            }

            Gum g = Instantiate(gum, new Vector3((-(int)(levelWidth / 2) + x) * Level.GRID_WIDTH, (-(int)(levelHeight / 2) + y) * Level.GRID_WIDTH, -0.1f), Quaternion.Euler(270, 0, 0)) as Gum;
            g.level = this;

            nextGumTime = Random.Range(6f, 8f);
        }
        else
        {
            nextGumTime -= Time.deltaTime;
        }

        if (playersAliveList.Count <= 1 && !winScreen)
        {
            winScreen = true;

            for (int i = 0; i < levelObjects.Count; i++)
            {
                Destroy(((MonoBehaviour)levelObjects[i]).gameObject);
            }

            Player winnerWinnerChickenDinner = Instantiate(playersAliveList[0], new Vector3(0, 0, 0), Quaternion.Euler(270, 0, 0)) as Player;
            ((MonoBehaviour)winnerWinnerChickenDinner).transform.localScale = new Vector3(5, 1, 5);

            for (int i = 0; i < endGameText.Length; i++)
            {
                endGameText[i].gameObject.active = true;
            }

            endGameText[0].text = "Player " + winnerWinnerChickenDinner.playerNumber + " Wins!";
        }

        if (winScreen)
        {
            if (Input.GetButton("Start"))
            {
                Application.LoadLevel("Menu");
            }
        }
    }
Пример #53
0
        public override void applyPowerup(Powerup p)
        {
            resetPowerupState();

            powerupTimer = p.Duration;

            if (p is Powerups.SpeedBoostPowerup)
            {
                this.powerupState = powerupstate.SpeedBoost;

                this.MaxVel = Powerups.SpeedBoostPowerup.SPEED_BOOST_SPEED;
                this.MaxVelDash = Powerups.SpeedBoostPowerup.SPEED_BOOST_DASH_SPEED;
                this.MaxAcc = Powerups.SpeedBoostPowerup.SPEED_BOOST_ACCEL;
                this.MaxAccDash = Powerups.SpeedBoostPowerup.SPEED_BOOST_DASH_ACCEL;
            }
            else if (p is Powerups.RapidFirePowerup)
            {
                this.powerupState = powerupstate.RapidFire;

                this.meleeCooldown = Powerups.RapidFirePowerup.RAPID_FIRE_MELEE_COOLDOWN;
                this.fireCooldown = Powerups.RapidFirePowerup.RAPID_FIRE_FIRE_COOLDOWN;
                this.SpearCost = Powerups.RapidFirePowerup.RAPID_FIRE_COST;
            }
            else if (p is Powerups.SharkRepellentPowerup)
            {
                this.powerupState = powerupstate.SharkRepellent;
            }
            else if (p is Powerups.SpearDeflectionPowerup)
            {
                this.powerupState = powerupstate.SpearDeflection;
            }
            else if (p is Powerups.ChumPowerup)
            {
                this.powerupState = powerupstate.Chum;
                AudioManager.getSound("Chum_Fart").Play();
                return;
            }
            else if (p is Powerups.MultishotPowerup)
            {
                this.powerupState = powerupstate.Multishot;
                this.SpearCost = Powerups.MultishotPowerup.MULTISHOT_SPEAR_COST;
            }

            AudioManager.getSound("Power_Up").Play();
        }
Пример #54
0
 private void Awake()
 {
     PU = GetComponentInParent <Powerup>();
 }
 public void AddPowerup(Powerup powerup)
 {
     powerups.Add(powerup);
 }
Пример #56
0
    void ResolveCollisions(RaycastHit2D hit, CollisionType collisionType, ref Vector2 velocity, float moveDir, ref float rayLength)
    {
        collisions.collided = true;

        if (collisionType == CollisionType.HORIZONTAL && hit.distance == 0)
        {
            if (hit.transform.tag != "Hazard")
            {
                return;
            }
        }

        if (hit.transform.tag != "Gravity Switch")
        {
            if (!canFlipGravity)
            {
                canFlipGravity = true;
            }
        }

        switch (hit.transform.tag)
        {
        case "Hazard":
            if (!collisions.hitHazard)     //fix after making collisions end after 1 ray... doesn't really make sense to continue w/o slopes
            {
                if (!invincible)
                {
                    OnHazard();
                    collisions.hitHazard = true;
                }
            }
            break;

        case "Powerup":
            Powerup pw = hit.collider.GetComponent <Powerup>();
            powerups.AddLast(pw.GetPowerupType());
            if (powerups.Count > powerupSize && !greedy)
            {
                powerups.RemoveFirst();
            }
            UpdatePowerupUI();
            pw.Consume();
            return;

        case "Goal":
            EntityManager.instance.levelComplete = true;
            hit.collider.GetComponent <Goal>().GoalComplete();
            return;

        case "Through":
            if (collisionType == CollisionType.VERTICAL)
            {
                if (moveDir == 1 || hit.distance == 0 || userInput.y == -1)     //watch for bugs from removing fallingThroughPlat, invoke after .5 sec delay (seblague)
                {
                    return;
                }
                break;
            }
            else
            {
                return;
            }

        case "Yoku":
            if (collisionType == CollisionType.VERTICAL)
            {
                if (hit.distance == 0)
                {
                    return;
                }
            }
            break;

        case "Ice":
            if (collisionType == CollisionType.VERTICAL)
            {
                groundAcceleration = 0.75f;
            }
            break;

        case "Gravity Switch":
            if (canFlipGravity)
            {
                FlipGravity();
                canFlipGravity = false;
                return;
            }
            else
            {
                return;
            }

        case "Entity Switch":
            hit.collider.GetComponent <Switch>().Consume();
            return;

        case "Quicksand":
            inQuicksand = true;
            return;

        case "Water":
            if (!inWater)
            {
                inWater         = true;
                this.velocity.y = Mathf.Clamp(this.velocity.y, -2f, 10f);
            }
            collisions.collidedWater = true;
            return;

        case "Checkpoint":
            spawnPoint = hit.transform.position;
            hit.collider.GetComponent <Goal>().GoalComplete();
            return;

        default:
            break;
        }

        if (collisionType == CollisionType.VERTICAL)
        {
            velocity.y = (hit.distance - SKIN_WIDTH) * moveDir;
            rayLength  = hit.distance;

            if (!gravityFlipped)
            {
                collisions.below = moveDir == -1;
                collisions.above = moveDir == 1;
            }
            else
            {
                collisions.below = moveDir == 1;
                collisions.above = moveDir == -1;
            }
        }
        else
        {
            velocity.x = Mathf.Min(Mathf.Abs(velocity.x), (hit.distance - SKIN_WIDTH)) * moveDir;
            rayLength  = Mathf.Min(Mathf.Abs(velocity.x) + SKIN_WIDTH, hit.distance);

            collisions.left  = moveDir == -1;
            collisions.right = moveDir == 1;
        }
    }
Пример #57
0
 // Create a bomb with the possibility of transformation of simple chips in bomb
 public void AddPowerup(Powerup p)
 {
     SimpleChip[] chips = GameObject.FindObjectsOfType<SimpleChip>();
     if (chips.Length == 0) return;
     SimpleChip chip = null;
     while (chip == null || chip.matching)
         chip = chips[Random.Range(0, chips.Length - 1)];
     SlotForChip slot = chip.chip.parentSlot;
     if (slot)
         AddPowerup (slot.slot.x, slot.slot.y, p);
 }
Пример #58
0
 //sets powerup spawn point to be true
 public void SetPosMakeTrue(Powerup pow, int p)
 {
     pow.SetPosition(p);
     SetStateAtPos(p, true);
 }
Пример #59
0
        /// <summary>
        /// Checks if any player has collected a powerup
        /// </summary>
        private void CheckPowerups()
        {
            lock (_clients)
            {
                foreach (Client cl in _clients)
                {
                    Point gridPos = Util.ToGridCoordinates(new Point(cl.LocalPlayer.X, cl.LocalPlayer.Y));

                    Powerup powerup = _level.GetPowerup(gridPos);

                    Player[] players = null;

                    lock (_clients)
                    {
                        players = (from client in _clients select client.LocalPlayer).ToArray();
                    }

                    if (powerup != Powerup.None)
                    {
                        Console.WriteLine((string)("Player " + cl.LocalPlayer.Color + " collected " + powerup));

                        switch (powerup)
                        {
                        case Powerup.BombRange:
                            cl.LocalPlayer.BombRange++;
                            Console.WriteLine("[" + cl.LocalPlayer.Color + "] Bomb range " + cl.LocalPlayer.BombRange);
                            break;

                        case Powerup.AdditionalBomb:
                            cl.LocalPlayer.BombNumber++;
                            Console.WriteLine("[" + cl.LocalPlayer.Color + "] Number of bombs: " + cl.LocalPlayer.BombNumber);
                            break;

                        case Powerup.ManualTrigger:
                            cl.LocalPlayer.ManualTrigger = true;
                            Console.WriteLine("[" + cl.LocalPlayer.Color + "] Has manual trigger. ");
                            break;

                        case Powerup.ScrambledControls:
                            Console.WriteLine("[" + cl.LocalPlayer.Color + "] Has scrambled controls. ");
                            break;

                        default:
                            Console.WriteLine("[" + cl.LocalPlayer.Color + "] Unimplemented powerup.");
                            break;
                        }

                        _level.SetPowerup(gridPos, Powerup.None);

                        if (powerup == Powerup.ScrambledControls)
                        {
                            cl.SendStatusUpdate(new GameStatusUpdate(players, Command.ScrambleControls, gridPos.X, gridPos.Y));

                            foreach (Client otherCl in _clients)
                            {
                                if (cl == otherCl)
                                {
                                    continue;
                                }

                                Client ocl = otherCl;
                                ThreadPool.QueueUserWorkItem(o => ocl.SendStatusUpdate(new GameStatusUpdate(players, Command.ClearPowerup, gridPos.X, gridPos.Y)));
                            }
                        }
                        else
                        {
                            foreach (Client otherCl in _clients)
                            {
                                Client ocl = otherCl;
                                ThreadPool.QueueUserWorkItem(o => ocl.SendStatusUpdate(new GameStatusUpdate(players, Command.ClearPowerup, gridPos.X, gridPos.Y)));
                            }
                        }
                    }
                }
            }
        }
Пример #60
0
 public void Setup()
 {
     powerup = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Tests/Prefabs/Pickups/Powerup")).GetComponent <Powerup>();
 }