Ejemplo n.º 1
0
 // Initialisation
 void Start()
 {
     forwardKey.text        = KeyBoardBindings.GetForwardKey().ToString();
     backwardKey.text       = KeyBoardBindings.GetBackwardKey().ToString();
     attackKey.text         = KeyBoardBindings.GetAttackKey().ToString();
     chargedAttackKey.text  = KeyBoardBindings.GetChargedAttackKey().ToString();
     pauseKey.text          = KeyBoardBindings.GetPauseKey().ToString();
     zoomInKey.text         = KeyBoardBindings.GetZoomInKey().ToString();
     zoomOutKey.text        = KeyBoardBindings.GetZoomOutKey().ToString();
     showScoreboardKey.text = KeyBoardBindings.GetScoreboardKey().ToString();
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        // Checks for overlay active done in Player.cs
        if (!isLocalPlayer)
        {
            return;
        }
#if UNITY_ANDROID
        if (touchID == -1)  // not touching the screen; not charging up yet
        {
            if (lightsource.intensity > 0)
            {
                lightsource.intensity -= Time.deltaTime * LightSourceIntensityMultilpier;
            }

            for (int i = 0; i < Input.touchCount; ++i)
            {
                if (Input.GetTouch(i).phase == TouchPhase.Began)    // if the touch just began, check if it's not on a GUI object
                {
                    PointerEventData ped = new PointerEventData(null);
                    ped.position = Input.GetTouch(i).position;
                    List <RaycastResult> results = new List <RaycastResult>();
                    raycaster.Raycast(ped, results);
                    if (results.Count == 0)
                    {
                        if (energy.currentEnergy >= energy.EnergyNeededToRun)
                        {
                            exceptionCharge = true;
                            touchID         = i;
                            break;
                        }
                    }
                }
            }
        }
        else
        {                                                          // there is a touch; start to charge up
            if (Input.GetTouch(touchID).phase == TouchPhase.Ended) // if the touch has ended, release the charged fireball
            {
                CmdChargedAttack(FireBallTarget());
                exceptionCharge = false;
                touchID         = -1;

                // reduce the energy
                energy.AmtenergyCharge   = 0;
                energy.recharging        = true;
                energy.timer             = 0;
                energy.ChargedReadyToUse = false;
            }
            else if (energy.currentEnergy >= energy.MinimumCharge || exceptionCharge)
            {
                energy.ChargeEnergy();
                if (lightsource.intensity <= MaxLightIntensity)
                {
                    lightsource.intensity = (energy.AmtenergyCharge / energy.MaxCharge) * MaxLightIntensity;
                }
            }
        }
#else
        // Debug text
        //if (energyMeterText != null)
        //    energyMeterText.text = energy.currentEnergy.ToString();

        if (Input.GetKeyDown(KeyBoardBindings.GetAttackKey()) && energy.readyToUse)
        {
            CmdFireBallAttack(FireBallTarget());
            energy.DecreaseEnergy();
        }
        else
        {
            keypress = false;
        }

        if (energy.currentEnergy >= energy.MinimumCharge)
        {
            exceptionCharge = true;
        }

        if (Input.GetKey(KeyBoardBindings.GetChargedAttackKey()) && (energy.currentEnergy >= energy.MinimumCharge || exceptionCharge))
        {
            energy.ChargeEnergy();
            if (lightsource.intensity <= MaxLightIntensity)
            {
                lightsource.intensity = (energy.AmtenergyCharge / energy.MaxCharge) * MaxLightIntensity;
            }
        }
        else
        {
            if (lightsource.intensity > 0)
            {
                lightsource.intensity -= Time.deltaTime * LightSourceIntensityMultilpier;
            }
        }
        if (Input.GetKeyUp(KeyBoardBindings.GetChargedAttackKey()))
        {
            if (energy.ChargedReadyToUse)
            {
                CmdChargedAttack(FireBallTarget());
                exceptionCharge = false;

                energy.AmtenergyCharge   = 0;
                energy.recharging        = true;
                energy.timer             = 0;
                energy.ChargedReadyToUse = false;
            }
            else
            {
                //energy.recharging = true;
                energy.unchargeEnergy = true;
                energy.readyToUse     = false;
                exceptionCharge       = false;
            }
        }
#endif
    }