Ejemplo n.º 1
0
 void Update()
 {
     UpdateSpecials();
     if (Input.GetButtonDown("Special") && _currentSpecialAttack != null)
     {
         Instantiate(_currentSpecialAttack, Vector3.zero, Quaternion.identity);
         _currentSpecialAttack = null;
         _energyManager.SpendEnergy(_currentStep);
     }
     else if (Input.GetButtonDown("Shield") && _currentShield != null)
     {
         Instantiate(_currentShield, Vector3.zero, Quaternion.identity);
         _currentShield = null;
         _energyManager.SpendEnergy(_currentStep);
     }
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!networkView.isMine)
        {
            return;
        }

        //Debug: Print out the names of the controllers detected -----------------------------
        bool activatePower = false;

        if (Application.platform == RuntimePlatform.OSXDashboardPlayer ||
            Application.platform == RuntimePlatform.OSXEditor ||
            Application.platform == RuntimePlatform.OSXPlayer ||
            Application.platform == RuntimePlatform.OSXWebPlayer)
        {
            activatePower = Input.GetButtonDown("Mac_B");
        }
        else if (Application.platform == RuntimePlatform.WindowsEditor ||
                 Application.platform == RuntimePlatform.WindowsPlayer ||
                 Application.platform == RuntimePlatform.WindowsWebPlayer)
        {
            activatePower = Input.GetButtonDown("Windows_B");
        }
        //--------------------------------------------------------------------------------------

        if ((activatePower || Input.GetKeyDown(KeyCode.LeftShift)) &&
            playerManager.powerState == PlayerManager.PowerState.Normal &&
            (rigidbody.velocity - new Vector3(0, rigidbody.velocity.y, 0)).magnitude > 1.5f &&
            myEnergyManager.SpendEnergy(playerManager.fireDashCost))
        {
            //print ("Power Up");
            playerManager.particleSize = 30f;
            //networkView.RPC ("ChangeParticleSize", RPCMode.All, 30f);
            //playerManager.particleSize = 30f;
            playerManager.powerState = PlayerManager.PowerState.Boost;
            prePowerVelocity         = rigidbody.velocity;
            rigidbody.velocity       = (rigidbody.velocity.normalized - new Vector3(0, rigidbody.velocity.normalized.y, 0)) * 20f;
            timer = 0f;
        }
        if (playerManager.powerState == PlayerManager.PowerState.Boost && timer < 0.2f)
        {
            timer += Time.deltaTime;
        }
        else if (playerManager.powerState == PlayerManager.PowerState.Boost && timer >= 0.2f)
        {
            playerManager.particleSize = 2f;
            //networkView.RPC ("ChangeParticleSize", RPCMode.All, 2f);
            //playerManager.particleSize = 2f;
            playerManager.powerState = PlayerManager.PowerState.Normal;
            rigidbody.velocity       = prePowerVelocity;
            timer = 0f;
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (!networkView.isMine)           //Skip this function if the object is not the player's
        {
            return;
        }

        UpdateControllerInput();
        UpdateKbInput();

        //Mouse Buttons: 0-->Left, 1-->right, 2-->wheel
        //launched: rightTriggerDown or rightBumperDown or leftBumperDown
        bool launched = rightTriggerDown || rightBumper || leftBumper;

        launched = k1active || k2active || k3active;
        //If the corresponding input is pressed, launch the corresponding projectile
        if (launched)
        {
            //Get the third person camera and it's target transform
            ThirdPersonCamera TPCamera        = GetComponentInChildren <ThirdPersonCamera>();
            Transform         targetTransform = TPCamera.cameraTarget.transform;
            //Get the start position of the projectile based on the direction of the camera target
            Vector3    projectileDirection = (targetTransform.position - TPCamera.transform.position).normalized;
            Vector3    projectionStartPos  = targetTransform.position + projectileDirection;
            RaycastHit rayHit;
            Vector3    projectileTargetPosition;
            //Raycast from the player to the target to see if we are target something
            if (Physics.Raycast(projectionStartPos, projectileDirection, out rayHit))
            {
                projectileTargetPosition = rayHit.point;
            }
            //If not targeting anything, set the target far in that direction
            else
            {
                projectileTargetPosition = projectionStartPos + (projectileDirection * 100f);
            }

            //Create a RPC call that creates the corresponding projectile
            GameObject fireBall;
            if (rightTriggerDown || k1active)
            {
                if (myEnergyManager.SpendEnergy(myPlayerManager.fireBulletCost))
                {
                    Vector3 direction = (projectileTargetPosition - transform.position).normalized;
                    networkView.RPC("CreateProjectile", RPCMode.AllBuffered, "Prefabs/Fire_Bullet", transform.position + (projectileDirection), new Quaternion(), direction.normalized, Network.player);
                }
            }
            else if (rightBumper || k2active)
            {
                if (myEnergyManager.SpendEnergy(myPlayerManager.fireGrenadeCost))
                {
                    Vector3 direction = (projectileTargetPosition - transform.position).normalized;
                    networkView.RPC("CreateProjectile", RPCMode.AllBuffered, "Prefabs/Fire_Grenade", transform.position + (projectileDirection), new Quaternion(), direction.normalized, Network.player);
                }
            }
            else if (leftBumper || k3active)
            {
                if (myEnergyManager.SpendEnergy(myPlayerManager.fireOrbCost))
                {
                    Vector3 direction = (projectileTargetPosition - transform.position).normalized;
                    networkView.RPC("CreateProjectile", RPCMode.AllBuffered, "Prefabs/Fire_Orb", transform.position + (projectileDirection), new Quaternion(), direction.normalized, Network.player);
                }
            }
//			//Mouse can only lauch one kind of projectile
//			else {
//				Vector3 direction = (projectileTargetPosition - transform.position).normalized;
//				networkView.RPC ("CreateProjectile", RPCMode.AllBuffered, "Prefabs/Fire_Orb", transform.position+(projectileDirection), new Quaternion(), direction.normalized, Network.player);
//			}
        }

        //Handles the zooming function with right mouse click or left trigger
        if (Input.GetMouseButton(1) || leftTrigger)
        {
            GetComponentInChildren <Camera>().fieldOfView -= 200f * Time.deltaTime;
            if (GetComponentInChildren <Camera>().fieldOfView < 30f)
            {
                GetComponentInChildren <Camera>().fieldOfView = 30f;
            }
        }
        else
        {
            GetComponentInChildren <Camera>().fieldOfView += 200f * Time.deltaTime;
            if (GetComponentInChildren <Camera>().fieldOfView > 60f)
            {
                GetComponentInChildren <Camera>().fieldOfView = 60f;
            }
        }
    }