コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (!pic.isOperatingStation)
        {
            input = new Vector2(pic.GetHorizontal(), pic.GetVertical()) * MovementSpeed * Time.deltaTime;

            rb2d.MovePosition(new Vector2(rb2d.position.x + input.x, rb2d.position.y + input.y));
        }
    }
コード例 #2
0
    public void MoveReticle(PlayerInputContainer pcon)
    {
        Vector2 stickInput = new Vector2(pcon.GetHorizontal(), pcon.GetVertical());

        stickInput = Vector2.ClampMagnitude(stickInput, 1);   //clamp magnitude to keep circle boundary for x/y-axis, instead of square
        if (stickInput.magnitude < reticleDeadZone)
        {
            stickInput.x = 0;
            stickInput.y = 0;
        }

        if (stickInput.x == 0 && stickInput.y == 0)
        {
        }
        else
        {
            Quaternion eulerRot = Quaternion.Euler(0, 0, Mathf.Atan2(-stickInput.x, stickInput.y) * 180 / Mathf.PI);
            weaponAimControlCenter.transform.rotation = Quaternion.Slerp(weaponAimControlCenter.transform.rotation, eulerRot, Time.deltaTime * reticleRotationSpeed);
        }
    }
コード例 #3
0
 // Update is called once per frame
 void FixedUpdate()
 {
     transform.localRotation = Quaternion.Euler(Vector3.zero); //always keep player oriented with ship direction.
     if (!pic.isOperatingStation)                              //Player is not controlling a station.
     {
         if (!pic.isFrozen)                                    //If player is not currently frozen.
         {
             transform.localPosition += new Vector3(pic.GetHorizontal(), pic.GetVertical(), 0f) * MovementSpeed * 0.1f;
             playerCurPos             = transform.localPosition;
         }
         else                                        //Player is currently frozen.
         {
             transform.localPosition = playerCurPos; //freeze player position
         }
     }
     else                                        //Player is controlling a station
     {
         transform.localPosition = playerCurPos; //freeze player position
     }
 }
コード例 #4
0
    public void MoveShip(PlayerInputContainer pic)
    {
        if (pic.isOperatingStation && !isDeflecting)
        {
            if (pic.GetRTButton() == 1 && !GameController.instance.boostBroken)
            {
                GameController.instance.isBoosting = true;
                GameController.instance.SendMessage("UseBoost", usageAmt);
                timeStamp = Time.time + coolDownPeriod;
                if (boostTimeStamp == 0 && GameController.instance.GetCurrentBoost() == 0)
                {
                    boostTimeStamp = Time.time + GameController.instance.getTimeToBreak();
                }
                inputAcceleration = baseAccel + accelIncrease;
                velocityDrag      = baseDrag - dragDecrease;
                maxSpeed          = baseSpeed + maxSpeedIncrease;
                //Debug.Log("pressing RT, max speed: " + maxSpeed);
            }
            else
            {
                GameController.instance.isBoosting = false;
                //velocityDrag = baseDrag;
                inputAcceleration = baseAccel;
                maxSpeed          = baseSpeed;
            }
            if (Time.time > boostTimeStamp && GameController.instance.isBoosting && GameController.instance.GetCurrentBoost() == 0)
            {
                GameController.instance.boostBroken = true;
            }

            if (Time.time >= timeStamp && !GameController.instance.boostBroken)
            {
                GameController.instance.SendMessage("RegenerateBoost", regenAmt);
            }
            // apply forward input
            acceleration = new Vector3(pic.GetHorizontal() * inputAcceleration, pic.GetVertical() * inputAcceleration, 0f);
            velocity    += acceleration * Time.deltaTime;
        }
        velocityDrag      = baseDrag;
        inputAcceleration = baseAccel;
    }
コード例 #5
0
    public void MoveShip(PlayerInputContainer pic)
    {
        if (pic.isOperatingStation)
        {
            if (pic.GetXButton() && GameController.instance.GetCurrentBoost() > 0)
            {
                Debug.Log("pressing X");

                movementSpeed = baseSpeed + speedIncrease;
                GameController2.instance.SendMessage("UseBoost", usageAmt);
                timeStamp = Time.time + coolDownPeriod;
            }

            if (Time.time >= timeStamp)
            {
                GameController.instance.SendMessage("RegenerateBoost", regenAmt);
            }

            transform.position += new Vector3(pic.GetHorizontal(), pic.GetVertical(), 0f) * movementSpeed;
        }

        Debug.Log(movementSpeed);
        movementSpeed = baseSpeed;
    }