Exemplo n.º 1
0
    public void EnablePowerUp(Pickup.PickupType type)
    {
        switch (type)
        {
        case Pickup.PickupType.THIEF:
            thief.enabled = true;
            break;

        case Pickup.PickupType.MURDERER:
            murderer.enabled = true;
            break;

        case Pickup.PickupType.CHEATER:
            cheater.enabled = true;
            break;

        case Pickup.PickupType.ADDICT:
            addict.enabled = true;
            break;

        case Pickup.PickupType.LIAR:
            liar.enabled = true;
            break;
        }
        numPowerUps++;
        Vector3 sackScale = sack.transform.localScale;

        sack.transform.localScale = new Vector3(sackScale.x + .5f, sackScale.y + .5f, sackScale.z + .5f);
    }
Exemplo n.º 2
0
    /// -------------------------------------------
    ///
    ///     Pickups
    ///
    /// -------------------------------------------

    public void OnItemPickup(Pickup.PickupType pickupType)
    {
        switch (pickupType)
        {
        // Spread fire
        case Pickup.PickupType.Spread:
            _weapon          = WEAPON.SPREAD;
            _HasPickupSpread = true;
            break;

        // Rapid fire
        case Pickup.PickupType.RapidFire:
            _currentFireDelay  *= _reduceFiringDelay;
            _HasPickupRapidFire = true;
            break;

        // Speed boost
        case Pickup.PickupType.SpeedBoost:
            _currentSpeedBonus  += _speedBonus;
            _HasPickupSpeedboost = true;
            break;

        // Health pack
        case Pickup.PickupType.Healthpack:
            _currentHealth += _addHealthAmount;
            break;

        default: break;
        }
    }
Exemplo n.º 3
0
    public void DisablePowerUp(Pickup.PickupType type)
    {
        switch (type)
        {
        case Pickup.PickupType.THIEF:
            thief.enabled = true;
            break;

        case Pickup.PickupType.MURDERER:
            murderer.enabled = true;
            break;

        case Pickup.PickupType.CHEATER:
            cheater.enabled = true;
            break;

        case Pickup.PickupType.ADDICT:
            addict.enabled = true;
            break;

        case Pickup.PickupType.LIAR:
            liar.enabled = true;
            break;
        }
        numPowerUps--;
    }
Exemplo n.º 4
0
    /// <summary>
    /// Call after enable depths for more than 1 enemy
    /// Set enemy pickup drop type
    /// </summary>
    /// <param name="type"></param>
    public void setPickupEnemy(Pickup.PickupType type)
    {
        pickupType = type;

        //Quickens are a little faster
        if (pickupType == Pickup.PickupType.Quicken)
        {
            forceStrength += 1;
        }
        int pickUpIndex = random.Next(0, enabledChildren.Count);

        for (int i = 0; i < enabledChildren.Count; i++)
        {
            if (i == pickUpIndex)
            {
                enabledChildren[i].tag = Game.instance.TAG_ENEMY_PICKUP;
                switch (type)
                {
                case Pickup.PickupType.Score: enabledChildren[i].GetComponent <Renderer>().material = greenMaterial; break;

                case Pickup.PickupType.DoubleScore: enabledChildren[i].GetComponent <Renderer>().material = goldmaterial; break;

                case Pickup.PickupType.Quicken: enabledChildren[i].GetComponent <Renderer>().material = purpleMaterial; break;

                case Pickup.PickupType.Multiplier: enabledChildren[i].GetComponent <Renderer>().material = blueMaterial; break;
                }
                break;
            }
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Set enemy type determines behaviour
    /// </summary>
    /// <param name="type"></param>
    public void setEnemyType(EnemyType type)
    {
        enemyType = type;
        switch (type)
        {
        case EnemyType.DropPickup:
            Pickup.PickupType enemyPickupType = Pickup.PickupType.Score;
            int doubleChance = random.Next(0, 100);
            if (doubleChance > 75)
            {
                enemyPickupType = Pickup.PickupType.DoubleScore;
            }
            setPickupEnemy(enemyPickupType);
            break;

        case EnemyType.Exploder:

            int explodeIndex = random.Next(0, enabledChildren.Count);
            for (int i = 0; i < enabledChildren.Count; i++)
            {
                if (i == explodeIndex)
                {
                    enabledChildren[i].tag = Game.instance.TAG_ENEMY_PICKUP;
                    enabledChildren[i].GetComponent <Renderer>().material = redMaterial; break;
                }
            }

            break;
        }
    }
Exemplo n.º 6
0
    // Server
    public void OnPickupInteraction(uint _playerId, Pickup.PickupType _pType, int _spawnIndex)
    {
        Debug.Log("Player " + _playerId.ToString() + " has interacted with a pickup!");
        this.hasPickup[_spawnIndex] = false;

        // Find player
        int index = 0;

        for (int i = 0; i < this.playerInfoList.Count; i++)
        {
            if (this.playerInfoList[i].playerObjectId == _playerId)
            {
                index = i;
            }
        }

        // send msg for speed - its controlled on the client side
        if (_pType == Pickup.PickupType.Damage)
        {
            this.hasDamagePowerup.Add((int)_playerId);
        }

        // Send msg
        PickupMessage msg = new PickupMessage();

        msg.playerId   = _playerId;
        msg.pType      = (int)_pType;
        msg.isStarting = true;

        NetworkServer.SendToClient(this.playerInfoList[index].connectionId, CustomMsgType.Pickup, msg);

        this.StartCoroutine(this.ResetPlayer(this.playerInfoList[index].connectionId, _playerId, (int)_pType));
    }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        pickupType  = Pickup.PickupType.Null;
        CanActivate = true;
        Canvas      = GameObject.FindGameObjectsWithTag("MainCanvas")[0];



        lastTimeSinceActivation = Time.time;
        m_Rigidbody2D           = GetComponent <Rigidbody2D>();
        health     = GetComponent <PlayerHealth>();
        MainCamera = Camera.main.gameObject;
        if (source == null || MainCamera != source.gameObject)
        {
            source = MainCamera.AddComponent <AudioSource>();
        }
        CarDead   = Canvas.transform.FindChild("CarDestroyed").gameObject.GetComponent <Canvas>();
        Dead      = Canvas.transform.FindChild("Died").gameObject.GetComponent <Canvas>();
        OtherDead = Canvas.transform.FindChild("OtherDied").gameObject.GetComponent <Canvas>();
        OnSwitchLight(lightOn);
        if (isLocalPlayer)
        {
            if (FindObjectsOfType <Player>().Length > 1)
            {
                this.gameObject.GetComponent <Animator>().runtimeAnimatorController = Player2;
                CmdSwitchAnimation();
            }

            Camera.main.gameObject.GetComponent <CameraScript>().SetPlayer(this.gameObject);
        }
        revive = GetComponentInChildren <PlayerRevive>();
        revive.gameObject.SetActive(false);
    }
Exemplo n.º 8
0
    // Server
    private IEnumerator PickupSpawnRoutine()
    {
        yield return(new WaitUntil(() => this.isPlayingGame == true));

        float count = 0.0f;

        while (this.isPlayingGame)
        {
            if (this.isWaitingToSpawnPickup == false)
            {
                count += Time.deltaTime;

                if (count >= this.pickupSpawnInterval)
                {
                    count = 0.0f;
                    this.isWaitingToSpawnPickup = true;
                }
            }
            else
            {
                int ranSpawn = Random.Range(0, this.pickupSpawnTransforms.Count);

                while (this.hasPickup[ranSpawn])
                {
                    ranSpawn = Random.Range(0, this.pickupSpawnTransforms.Count);
                    yield return(null);
                }

                this.hasPickup[ranSpawn] = true;

                yield return(new WaitForSeconds(3.0f));

                GameObject clone = Instantiate(
                    pickupPrefab,
                    this.pickupSpawnTransforms[ranSpawn].position,
                    this.pickupSpawnTransforms[ranSpawn].rotation);

                int ranType             = Random.Range(0, 2);
                Pickup.PickupType pType = ranType == 0 ? Pickup.PickupType.Damage : Pickup.PickupType.Speed;

                clone.GetComponent <Pickup>().Initialize(this, pType, ranSpawn);

                NetworkServer.Spawn(clone);

                // Send msg to client pickups
                SpawnPickupMessage msg = new SpawnPickupMessage();
                msg.pickupId = clone.GetComponent <NetworkIdentity>().netId.Value;
                msg.type     = ranType;

                NetworkServer.SendToAll(CustomMsgType.SpawnPickup, msg);

                this.isWaitingToSpawnPickup = false;
            }

            yield return(null);
        }

        yield return(null);
    }
Exemplo n.º 9
0
    public void ApplyEffect(Pickup.PickupType pickupType)
    {
        //Debug.Log("Applying effect of Pickup: " + pickupType.ToString());
        switch (pickupType)
        {
        case (Pickup.PickupType.Glue): StartCoroutine(ActivateGlue()); break;

        case (Pickup.PickupType.Life): ActivateLife(); break;

        case (Pickup.PickupType.Laser): StartCoroutine(ActivateLaser()); break;

        case (Pickup.PickupType.Multiple): ActivateMultiple(); break;

        case (Pickup.PickupType.Enlarge): StartCoroutine(ActivateEnlarge()); break;

        case (Pickup.PickupType.Fireball): StartCoroutine(ActivateFireball()); break;
        }
    }
Exemplo n.º 10
0
 GameObject GetPickupDisplay(Pickup.PickupType pickup)
 {
     if (pickup == Pickup.PickupType.APPLE)
     {
         return(displayApple);
     }
     if (pickup == Pickup.PickupType.WATER)
     {
         return(displayWater);
     }
     if (pickup == Pickup.PickupType.HONEY)
     {
         return(displayHoney);
     }
     if (pickup == Pickup.PickupType.THUNDER)
     {
         return(displayThunder);
     }
     return(new GameObject());
 }
Exemplo n.º 11
0
 private FlashingPickup(ContentManager Content,
                        GameUnit centerX, GameUnit centerY,
                        TileUnit sourceX, TileUnit sourceY,
                        Rectangle rectangle,
                        int value, Pickup.PickupType type)
 {
     sprite = new Sprite(Content, SpriteName,
                         Units.TileToPixel(sourceX), Units.TileToPixel(sourceY),
                         Units.TileToPixel(1), Units.TileToPixel(1));
     flashSprite = new Sprite(Content, SpriteName,
                              Units.TileToPixel(sourceX + 1), Units.TileToPixel(sourceY),
                              Units.TileToPixel(1), Units.TileToPixel(1));
     dissipatingSprite = new Sprite(Content, SpriteName,
                                    Units.TileToPixel(DissipatingSourceX), Units.TileToPixel(DissipatingSourceY),
                                    Units.TileToPixel(1), Units.TileToPixel(1));
     x              = centerX - Units.HalfTile;
     y              = centerY - Units.HalfTile;
     timer          = new Timer(LifeTime, true);
     flashPeriod    = StartPeriod;
     this.rectangle = rectangle;
     this.value     = value;
     this.type      = type;
 }
Exemplo n.º 12
0
 private FlashingPickup(ContentManager Content,
     GameUnit centerX, GameUnit centerY,
     TileUnit sourceX, TileUnit sourceY,
     Rectangle rectangle,
     int value, Pickup.PickupType type)
 {
     sprite = new Sprite(Content, SpriteName,
         Units.TileToPixel(sourceX), Units.TileToPixel(sourceY),
         Units.TileToPixel(1), Units.TileToPixel(1));
     flashSprite = new Sprite(Content, SpriteName,
         Units.TileToPixel(sourceX + 1), Units.TileToPixel(sourceY),
         Units.TileToPixel(1), Units.TileToPixel(1));
     dissipatingSprite = new Sprite(Content, SpriteName,
         Units.TileToPixel(DissipatingSourceX), Units.TileToPixel(DissipatingSourceY),
         Units.TileToPixel(1), Units.TileToPixel(1));
     x = centerX - Units.HalfTile;
     y = centerY - Units.HalfTile;
     timer = new Timer(LifeTime, true);
     flashPeriod = StartPeriod;
     this.rectangle = rectangle;
     this.value = value;
     this.type = type;
 }
 public void UpdateInventory(Pickup.PickupType pickup)
 {
     inventory[pickup]++;
     Debug.Log("Picked up " + pickup + " - You now have " + inventory[pickup]);
 }
Exemplo n.º 14
0
 public void NewItem(Pickup.PickupType type)
 {
     GameManager.Instance.PickupItem(type);
 }
Exemplo n.º 15
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "SafeZone")
        {
            SafeZone safeZone = (SafeZone)other.gameObject.GetComponent(typeof(SafeZone));
            safeZone.Entered();
            isSafe = true;
            lastSafeZone = other.transform.position;
            soundEffect.enterSafeZone();
        }

        if (other.gameObject.name == "SafeZone Top")
        {
            //Application.LoadLevel(Application.loadedLevel);
            soundEffect.enterSafeZone();
            Success();
        }

        if (other.gameObject.tag == "Enemy" && !isSafe)
        {
            Dead();
            //Application.LoadLevel(Application.loadedLevel);
        }
        if(other.gameObject.tag == "Pickup"){
            soundEffect.pickup();
            Debug.Log(other.gameObject.GetComponent<Pickup>().pickup);
            if(other.gameObject.GetComponent<Pickup>().pickup == Pickup.PickupType.speedUp
               && currentPickup!=Pickup.PickupType.speedUp){
                doubleSpeedBuff.ApplyBuff();
                currentPickup = Pickup.PickupType.speedUp;
            }
            if(other.gameObject.GetComponent<Pickup>().pickup == Pickup.PickupType.speedDown
               && currentPickup!=Pickup.PickupType.speedDown){
                halfSpeedBuff.ApplyBuff();
                currentPickup = Pickup.PickupType.speedDown;
            }
            Invoke("RemoveBuffs",buffDecayTime);
            Destroy(other.gameObject);
        }
    }
Exemplo n.º 16
0
 void RemoveBuffs()
 {
     buffable.Speed = originalSpeed;
     buffable.Size = originalSize;
     currentPickup = Pickup.PickupType.none;
     spriteRenderer.sprite = originalSprite;
     Debug.Log("Buffs removed");
 }
Exemplo n.º 17
0
 public void PickupItem(Pickup.PickupType pickup)
 {
     pickups[pickup] = true;
     RespawnPlayer();
 }