void Update()
    {
        if (player.GetComponent <PlayerInventory>().HasAcquired("laser") && !acquired)
        {
            acquired = true;
        }

        if (acquired)
        {
            if (input.GetKey("shoot") && !holdShoot)
            {
                holdShoot = true;
            }

            if (!input.GetKey("shoot") && holdShoot && canShoot)
            {
                if (energy.UseEnergy(2))
                {
                    canShoot = false;
                    StartCoroutine(ActivateLaser());
                }
            }

            if (!input.GetKey("shoot"))
            {
                holdShoot = false;
            }
        }
    }
Example #2
0
    public void FireBullet()
    {
        // first check if you have enough energy
        if (energy > energyScript.currentEnergy)
        {
            return;
        }

        //if (Input.GetKeyDown(KeyCode.Z))
        if (Input.GetButtonDown("Fire2"))
        {
            for (int i = 0; i < pooledAmount; i++)
            {
                energyScript.UseEnergy(energy);
                if (!bullets[i].activeInHierarchy)
                {
                    bullets[i].transform.position = gameObject.transform.position;
                    Vector2 dir;
                    if (movementScript.currentDirection)
                    {
                        dir = Vector2.right;
                    }
                    else
                    {
                        dir = Vector2.left;
                    }
                    bullets[i].SetActive(true);
                    bullets[i].GetComponent <Rigidbody2D>().AddForce(dir * 15, ForceMode2D.Impulse);
                    return;
                }
            }
        }
    }
 void MegaType()
 {
     onCooldown = true;
     if (charge == maxLimit && megaAcquired)
     {
         if (energy.UseEnergy(3))
         {
             Debug.Log("Full MegaPunch");
             attackType = "FullMega";
             damage     = 5;
             StartCoroutine(DamageArea(2.5f));
             return;
         }
         else
         {
             Debug.Log("Not enough energy for Full MegaPunch");
             //No energy, play correct things
         }
     }
     else if (charge >= minLimit && megaAcquired)
     {
         if (energy.UseEnergy(1))
         {
             Debug.Log("Regular MegaPunch");
             attackType = "Mega";
             damage     = 3;
             StartCoroutine(DamageArea(2.2f));
             return;
         }
         else
         {
             Debug.Log("Not enough energy for Regular MegaPunch");
             //No energy, play correct things
         }
     }
     //if none of the above is executed reset cooldown;
     onCooldown = false;
 }
    // Update is called once per frame
    void Update()
    {
        myInputDevice = deviceAssigner.
                        GetComponent <DeviceAssigner>().GetPlayerDevice(playerIndex);
        if (myInputDevice == null)
        {
            return;
        }

        if (myInputDevice.Action1.WasPressed)
        {
            if (bulletPrefab != null && isCooledDown)
            {
                if (energySys.UseEnergy(energyConsume))
                {
                    // if we sucessfully used the energy, shoot wave
                    ShootWave();
                }
            }
        }

//		float triggerAxis = Input.GetAxis (shootTriggerName);
//		//Debug.Log (triggerAxis);
//		if(isPS4Controller){
//			// -1 ~ 1 -> 0 ~ 1
//			triggerAxis = triggerAxis / 2.0f + 0.5f;
//		}
//
//		if(Input.GetAxis(shootTriggerName) > 0.5f && !m_isAxisInUse){
//
//			m_isAxisInUse = true;
//			ShootWave ();
//
//		}
//		if(Input.GetAxis(shootTriggerName) == 0){
//			m_isAxisInUse = false;
//		}
    }
 public bool ConsumeEnergy()
 {
     return(playerEnergy.UseEnergy(energyConsume * Time.deltaTime));
 }
Example #6
0
 public void UseEnergy(int Energy)
 {
     _playerEnergy.UseEnergy(Energy);
 }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        myInputDevice = GetComponent <DeviceReceiver>().GetDevice();
        if (myInputDevice == null)
        {
            return;
        }



        /*/
         *      if(myInputDevice.Action1.IsPressed && !darting &&
         *              coolDown && energySys.UseEnergy(energyConsume)){
         * /*/

        // Ye change 2017/3/25 try to add charging

        ChargingDart x = gameObject.GetComponent <ChargingDart>();

        if ((x.Status == ChargingDart.chargingStatus.StartCharge || x.Status == ChargingDart.chargingStatus.Charging) && !darting &&
            coolDown && energySys.UseEnergy(energyConsume))
        {
            // CAUTION: starting the darting skill

            //ye added DartSound
            if (GetComponent <DartSound> ())
            {
                GetComponent <DartSound> ().StartDart();
            }


            darting = true;
            // AI can cut lines now
            linecut.couldCut = true;

            if (GetComponent <PlayerMovement>() != null)
            {
                // stop the player from moving around
                GetComponent <PlayerMovement> ().moveEnabled = false;
            }
            else
            {
                Debug.Log("DartSkill: Failed to Find PlayerMovement Script");
            }

            // get the dart Direction
            // dartDirection = myRigidbody.velocity.normalized;
            dartDirection = movement.faceDirection.normalized;


            // reset the timer
            timer = 0f;
            // amplify the size of the collider
            myCapsuleColl.size = new Vector2(newColliderWidth, myCapsuleColl.size.y);
            // reset the kill count
            killCount = 0;

            // start the immune buff
            if (healthSys)
            {
                healthSys.StartImmune();
                healthSys.StartHarmless();
            }

            if (hd)
            {
                hd.canHurtOther = false;
            }
        }

        timer += Time.deltaTime;

        /*/
         *      if(timer > dartDuration && darting){
         * /*/

        // stop dart
        if (darting && (((x.Status != ChargingDart.chargingStatus.Charging && x.Status != ChargingDart.chargingStatus.StartCharge) || timer > MaxDuration) || (x.Status == ChargingDart.chargingStatus.Release && x.ChargingSum < MinDuration && timer > MinDuration)))
        {
            // CAUTION: stop darting skill
            darting = false;

            // AI can no longer cut lines now
            linecut.couldCut = false;

            // Invoke StartMovement after delay
            Invoke("StartMovement", startMovementDelay);
            // stop the player
            myRigidbody.velocity = Vector3.zero;
            // start cooling down
            coolDown = false;
            if (killCount != 0)
            {
                Invoke("CoolDown", coolDownDelay);
            }
            else
            {
                Invoke("CoolDown", penaltyCoolDownDelay);
            }
            // reset the size of the collider
            myCapsuleColl.size = new Vector2(defaultColliderWidth, myCapsuleColl.size.y);

            // end the immune buff
            Invoke("EndImmune", extraImmuneTime);
        }
    }