コード例 #1
0
 void Update()
 {
     if (photonView.IsMine && Input.GetMouseButtonDown(0) && powerup != null)
     {
         powerup.Activate(this);
     }
 }
コード例 #2
0
    public IEnumerator HandlePowerup()
    {
        soundController.PlayPowerupSound();
        Powerup pu = null;
        int     i  = 0;

        do
        {
            i  = Random.Range(0, powerups.Length);
            pu = powerups[i];
        } while (remainingEscapeCards >= 1 && i == 1);

        GameObject prefabInst = Instantiate(powerupUIPrefab);

        prefabInst.transform.SetParent(uiController.canvas.transform, false);
        RectTransform rectTransform = prefabInst.GetComponent <RectTransform>();
        PowerupUI     powerupUI     = prefabInst.GetComponent <PowerupUI>();

        powerupUI.ApplyPowerup(pu);
        pu.Activate(this);
        yield return(new WaitForSeconds(5.5f));

        Destroy(prefabInst);
        CheckPlayerTurnStatus();
    }
コード例 #3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Powerup powerup = collision.gameObject.GetComponent <Powerup>();

        if (powerup != null)
        {
            powerup.Activate();
        }
    }
コード例 #4
0
    // This is called when a pickup is acquired by the pad
    public void OnPickup()
    {
        powerupActive = true;

        DestroyAllPickups();

        // Select a powerup at random
        currentPowerup = powerups[Random.Range(0, powerups.Length)];

        // Start the new powerup
        currentPowerup.Activate();
    }
コード例 #5
0
        private void Update()
        {
            if (powerup != null)
            {
                if (Input.GetButtonDown("Left Mouse Button"))
                {
                    hud.PowerupSlot.Useable = false;
                    powerup.Activate(this);
                }

                powerup.PlayerUpdate(this);
            }
        }
コード例 #6
0
    void EnableCheats()
    {
        if (Input.GetKeyUp(KeyCode.LeftControl) || Input.touchCount == 3)
        {
            powerupActive = true;

            currentPowerup = GameObject.Find("LazerGunPowerup").GetComponent <Powerup>();
            currentPowerup.Activate();
        }

        if (Input.GetKeyUp(KeyCode.LeftAlt))
        {
            powerupActive = true;

            currentPowerup = GameObject.Find("LifePowerup").GetComponent <Powerup>();
            currentPowerup.Activate();
        }

        if (Input.GetKeyUp(KeyCode.LeftShift) || Input.touchCount == 5)
        {
            powerupActive = true;

            currentPowerup = GameObject.Find("ExtraSpherePowerup").GetComponent <Powerup>();
            currentPowerup.Activate();
        }

        if (Input.GetKeyUp(KeyCode.Tab) || Input.touchCount == 4)
        {
            powerupActive = true;

            currentPowerup = GameObject.Find("PadResizePowerup").GetComponent <Powerup>();
            currentPowerup.Activate();
        }

        if (Input.GetKeyUp(KeyCode.E))
        {
            OnGameOver();
        }

        if (Input.GetKeyUp(KeyCode.P))
        {
            OnPickup();
        }
    }
コード例 #7
0
ファイル: Player.cs プロジェクト: fnuecke/LD41
    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);
    }
コード例 #8
0
    // This is called when a pickup is acquired by the pad
    public void OnPickup()
    {
        powerupActive = true;

        // All pickups are destroyed to prevent having muliple powerups active at the same time
        foreach ( GameObject pickup in GameObject.FindGameObjectsWithTag("Pickup")) {
            Destroy (pickup);
        }

        // Select a powerup at random
        currentPowerup = powerups[Random.Range (0, powerups.Length)];

        // Start the new powerup
        currentPowerup.Activate();
    }
コード例 #9
0
    void EnableCheats()
    {
        if(Input.GetKeyUp(KeyCode.LeftControl) || Input.touchCount == 3) {
            powerupActive = true;

            currentPowerup = GameObject.Find("LazerGunPowerup").GetComponent<Powerup>();
            currentPowerup.Activate();
        }

        if(Input.GetKeyUp(KeyCode.LeftAlt)) {
            powerupActive = true;

            currentPowerup = GameObject.Find("LifePowerup").GetComponent<Powerup>();
            currentPowerup.Activate();
        }

        if(Input.GetKeyUp(KeyCode.LeftShift) || Input.touchCount == 5) {
            powerupActive = true;

            currentPowerup = GameObject.Find("ExtraSpherePowerup").GetComponent<Powerup>();
            currentPowerup.Activate();
        }

        if(Input.GetKeyUp(KeyCode.Tab) || Input.touchCount == 4) {
            powerupActive = true;

            currentPowerup = GameObject.Find("PadResizePowerup").GetComponent<Powerup>();
            currentPowerup.Activate();
        }

        if(Input.GetKeyUp(KeyCode.P)) {
            OnPickup();
        }
    }