Ejemplo n.º 1
0
		// guitexture is dragged, update indicator position & brush size variable in painter gameobject
		void OnMouseDrag()
		{
			float borderOffsetY = Mathf.Clamp((int)(Input.mousePosition.y),GetComponent<GUITexture>().pixelInset.y,GetComponent<GUITexture>().pixelInset.y+GetComponent<GUITexture>().pixelInset.height);
			painter.GetComponent<unitycoder_MobilePaint.MobilePaint>().brushSize = (int)Mathf.Clamp( ((borderOffsetY-GetComponent<GUITexture>().pixelInset.y)*sizeScaler), minSize, maxSize);
			indicator.pixelInset = new Rect(indicator.pixelInset.x,borderOffsetY,indicator.pixelInset.width,indicator.pixelInset.height);
		}
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        position = gameObject.transform.position;

        //Debug.Log(tempDepth);
        PlayerPrefs.SetFloat("TempDepth", tempDepth);

        pickSprite.GetComponent <SpriteRenderer> ().sprite  = pickImages [pickTier];
        armorSprite.GetComponent <SpriteRenderer> ().sprite = armorImages [armorTier];
        bootSprite.GetComponent <SpriteRenderer> ().sprite  = bootImages [bootTier];

        if (TickDebug)
        {
            GetData();
            TickDebug = false;
        }
        if (DoReset)
        {
            DoReset = false;
            ResetData();
        }
        if (!inFight)
        {
            playerRenderer.enabled = true;
            pickSprite.GetComponent <SpriteRenderer>().enabled  = true;
            armorSprite.GetComponent <SpriteRenderer>().enabled = true;
            bootSprite.GetComponent <SpriteRenderer>().enabled  = true;
            tempDepth += Time.deltaTime;//move the player "down" the shaft as time passes

            velocity = new Vector3(Input.acceleration.x, 0, 0);


            if (Input.GetKey("left"))
            {
                velocity.x = -.2f;
            }
            if (Input.GetKey("right"))
            {
                velocity.x = .2f;
            }
            if (Input.GetKey("right") && Input.GetKey("left"))
            {
                velocity.x = 0;
            }

            position += velocity;
            gameObject.transform.position = position;

            Vector3 pos = Camera.main.WorldToViewportPoint(transform.position);
            pos.x = Mathf.Clamp(pos.x, 0.1f, 0.9f);
            pos.y = Mathf.Clamp(pos.y, 0.1f, 0.9f);
            transform.position = Camera.main.ViewportToWorldPoint(pos);
        }
        if (inFight)
        {
            playerRenderer.enabled = false;
            pickSprite.GetComponent <SpriteRenderer>().enabled  = false;
            armorSprite.GetComponent <SpriteRenderer>().enabled = false;
            bootSprite.GetComponent <SpriteRenderer>().enabled  = false;
        }
    }
    public void Update()
    {
#if !UNITY_EDITOR && (UNITY_IOS || UNITY_ANDROID)
        UpdateTargetPositon();
#endif
        if (speed == Vector3.zero)
        {
            return;
        }
        var x = transform.position.x;
        var y = transform.position.y;
        x = x - speed.x;//向量偏移
        y = y - speed.y;

        if (Bounds)
        {
            float cameraHeight     = Camera.main.orthographicSize * 2;
            var   cameraSize       = new Vector2(Camera.main.aspect * cameraHeight, cameraHeight);
            var   cameraHalfWidth  = eyeCamera.orthographic ? cameraSize.x / 2 : 0;
            var   cameraHalfHeight = eyeCamera.orthographic ? cameraSize.y / 2 : 0;
            //保证不会移除包围盒

            x = Mathf.Clamp(x, minVec3.x + cameraHalfWidth, maxVec3.x - cameraHalfWidth);
            y = Mathf.Clamp(y, minVec3.y + cameraHalfHeight, maxVec3.y - cameraHalfHeight);
        }
        transform.position = new Vector3(x, y, transform.position.z);

        if (System.Math.Abs(speed.x) < 0.01f)
        {
            speed.x = 0;
        }
        else
        {
            if (speed.x > 0)
            {
                speed.x -= deceleration.x * Time.deltaTime;
                if (speed.x < 0)
                {
                    speed.x = 0;
                }
            }
            else
            {
                speed.x += deceleration.x * Time.deltaTime;
                if (speed.x > 0)
                {
                    speed.x = 0;
                }
            }
        }
        if (System.Math.Abs(speed.y) < 0.01f)
        {
            speed.y = 0;
        }
        else
        {
            if (speed.y > 0)
            {
                speed.y -= deceleration.y * Time.deltaTime;
                if (speed.y < 0)
                {
                    speed.y = 0;
                }
            }
            else
            {
                speed.y += deceleration.y * Time.deltaTime;
                if (speed.y > 0)
                {
                    speed.y = 0;
                }
            }
        }
        beginP = endP;
        if (speed.x == 0 && speed.y == 0)
        {
            speed = Vector3.zero;
        }
    }
Ejemplo n.º 4
0
    void LateUpdate()
    {
        if (target && !GameManager1.instance.paused)
        {
            shoulderZoom = GameManager1.instance.shoulderView;

            x += Input.GetAxis("Mouse X") * xSpeed * 0.05f;
            y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;

            desiredDistance = Mathf.Clamp(desiredDistance, distanceMin, distanceMax);

            distance = desiredDistance;

            y = ClampAngle(y, yMinLimit, yMaxLimit);

            if (!GameManager1.instance.talking)
            {
                //Debug.Log(y.ToString() + " " + x.ToString());
                rotation = Quaternion.Euler(y, x, 0);
            }
            else
            {
                rotation = Quaternion.Euler(13, target.rotation.x + 180, 0);
            }

            Vector3 position = new Vector3(0, 0, 0);
            Vector3 cameraTargetPosition;

            if (shoulderZoom)
            {
                target.rotation = Quaternion.Euler(0, transform.eulerAngles.y, 0);
                distance        = Mathf.Clamp(desiredDistance, distanceMin, 1.5f);

                position = target.position - (rotation * Vector3.forward * distance) + transform.right * aimRight + Vector3.up * aimHeight;
                //cameraTargetPosition = new Vector3(target.position.x, target.position.y + height + 3, target.position.z) + ((transform.right * 2));
                cameraTargetPosition = new Vector3(target.position.x, target.position.y + height, target.position.z);
            }
            else
            {
                // Collision Detection
                GameManager1.instance.shoulderView = false;
                position             = target.position - (rotation * Vector3.forward * distance) + Vector3.up * height;
                cameraTargetPosition = new Vector3(target.position.x, target.position.y + height, target.position.z);
            }

            if (GameManager1.instance.talking)
            {
                Vector3 angles = transform.eulerAngles;
                x        = angles.y;
                y        = angles.x;
                position = target.position - (rotation * Vector3.forward * distance) + transform.right * talkHeight + Vector3.up * talkRight;
            }


            RaycastHit collisionHit;

            Debug.DrawLine(cameraTargetPosition, position, Color.black);
            if (Physics.Linecast(cameraTargetPosition, position, out collisionHit))
            {
                position = collisionHit.point;
                distance = Vector3.Distance(target.position, position);
            }

            if (GameManager1.instance.talking)
            {
                transform.rotation = Quaternion.Lerp(transform.rotation, rotation, Time.deltaTime * 5);
            }
            else
            {
                transform.rotation = rotation;
            }

            int cameraSpeed = 25;
            if (GameManager1.instance.talking)
            {
                cameraSpeed = 5;
            }

            transform.position = Vector3.Lerp(transform.position, position, Time.deltaTime * cameraSpeed) /* + new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.1f),Random.Range(-0.1f, 0.1f))*/;

            shoulderDistance = 50;
            RaycastHit rayHit;
            Debug.DrawRay(transform.position, transform.forward * 50, Color.yellow);
            if (Physics.Raycast(transform.position, transform.forward, out rayHit, 50))
            {
                shoulderDistance = Vector3.Distance(transform.position, rayHit.point);
            }

            //Debug.Log(GameManager1.instance.shoulderView);


            if (Input.GetButtonDown("AimMode") && !GameManager1.instance.talking)
            {
                //shoulderZoom = !shoulderZoom;
            }
        }
    }
Ejemplo n.º 5
0
    //create a private function that activates on update
    void Update()
    {
        //if not in the custom menu
        if (!custom)
        {
            //Display Health
            //if healthbar slider doesn't equal curHealth divided by maxHealth
            //then make the healthBar equal curHealth divided by maxHealth
            //if (healthBar.value != Mathf.Clamp01(curHealth / maxHealth))
            {
                curHealth = Mathf.Clamp(curHealth, 0, maxHealth);
                //healthBar.value = Mathf.Clamp01(curHealth / maxHealth);
            }
            //display mana
            //if manabar slider doesn't equal curmana divided by maxmana
            //then make the manaBar equal curmana divided by maxmana
            //if (manaBar.value != Mathf.Clamp01(curMana / maxMana))
            {
                curMana = Mathf.Clamp(curMana, 0, maxMana);
                //manaBar.value = Mathf.Clamp01(curMana / maxMana);
            }
            //display stamina
            //if staminabar slider doesn't equal curstamina divided by maxstamina
            //then make the staminaBar equal curstamina divided by maxstamina
            //if (staminaBar.value != Mathf.Clamp01(curStamina / maxStamina))
            {
                curStamina = Mathf.Clamp(curStamina, 0, maxStamina);
                //staminaBar.value = Mathf.Clamp01(curStamina / maxStamina);
            }
            //dies when running out of health
            //when player is not dead and curhealth is less then or equal to 0
            //activate the Death function
            if (curHealth <= 0 && !isDead)
            {
                Death();
            }



            //shows when the character gets damaged
            //when the player is damaged and is not dead
            //set damaged to false
            //change damageimage color to flashcolour
            if (damaged && !isDead)
            {
                //damageImage.color = flashColour;
                damaged = false;
            }
            //make the damageImage fade over time to clear
            else
            {
                //damageImage.color = Color.Lerp(damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
            }
            //can heal under certain circumstances
            //if canHeal is false, curHealth is less then maxHealth and curHealth is greater then 0
            //increase healTimer over time
            //if healTimer is greater then 5 then set canHeal to true
            if (!canHeal && curHealth < maxHealth && curHealth > 0)
            {
                healTimer += Time.deltaTime;
                if (healTimer >= 5)
                {
                    canHeal = true;
                }
            }
        }
    }
Ejemplo n.º 6
0
    public void SetView(Entity[] entities)
    {
        ClearView();

        this.entities = entities;
        this.gameObject.GetComponent <RectTransform> ().sizeDelta = new Vector2(taskWidth, Mathf.Clamp(minTaskHight + itemHight * (entities.Length - 1), minTaskHight, maxTaskHight));

        G_content.GetComponent <RectTransform> ().sizeDelta = new Vector2(0, itemHight * entities.Length);


        for (int i = 0; i < entities.Length; i++)
        {
            GameObject item = Instantiate(G_Item) as GameObject;
            ItemList.Add(item);
            Entity entity = entities [i];
            item.GetComponent <ItemView> ().SetItemView(entity.id, entity.num, entity.name, entity.bRun, entity.bStartBack, entity.bWaterWork, entity.bStop);
            item.transform.transform.SetParent(G_content.transform);
            item.transform.localPosition = startPoint;
            startPoint += new Vector3(0, -itemHight, 0);

            item.GetComponent <Button> ().onClick.AddListener(delegate {
                this.OnItemClick(entity);
            });
        }

        G_content.GetComponent <RectTransform> ().sizeDelta = new Vector2(0, itemHight * entities.Length);
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (!satelliteMode)
        {
            rotation.y = Input.GetAxis("Mouse X") * mouseSpeed * Time.deltaTime;
            rotation.x = Input.GetAxis("Mouse Y") * mouseSpeed * Time.deltaTime;
        }

        translation.x = Input.GetAxis("Horizontal");
        if (onLadder == true)
        {
            translation.y = Input.GetAxis("Vertical");
        }
        else
        {
            translation.y = 0;
        }
        translation.z = Input.GetAxis("Vertical");
        translation   = transform.TransformDirection(translation);
        translation  *= speed;

        AnimationControl();
        if (hasSatellite)
        {
            SwitchToSatellite();
        }
        translation.y -= gravity;

        controller.Move(translation * Time.deltaTime);

        if (satelliteMode == false)
        {
            controller.transform.Rotate(0, rotation.y, 0);
        }

        cameraRotatedX -= rotation.x;
        //Max rotação da câmera
        cameraRotatedX   = Mathf.Clamp(cameraRotatedX, -60, 60);
        cameraRotation.x = cameraRotatedX;
        FirstPerson.transform.localEulerAngles = cameraRotation;
        //TopView.transform.Rotate(0, rotation.y, 0, Space.World);
        //quando aperta esc, mostra o cursor e destrava
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (!Cursor.visible)
            {
                Cursor.lockState = wantedMode = CursorLockMode.None;
            }
            else
            {
                Cursor.visible   = false;
                wantedMode       = CursorLockMode.Locked;
                Cursor.lockState = wantedMode;
            }

            if (isPaused)
            {
                isPaused = false;
            }
            else
            {
                isPaused = true;
            }

            /*
             * if (menu.gameObject.activeSelf == true)
             *  menu.gameObject.SetActive(false);
             * else
             *  menu.gameObject.SetActive(true);
             */
        }

        Cursor.visible = (CursorLockMode.Locked != wantedMode);

        if (isPaused)
        {
            Time.timeScale = 0.0f;
        }
        else
        {
            Time.timeScale = 1.0f;
        }
    }
Ejemplo n.º 8
0
 public void ChangeCarrot(int amount)
 {
     currentCarrot = Mathf.Clamp(currentCarrot + amount, 0, maxCarrot);
     Debug.Log(currentCarrot + "/" + maxCarrot);
 }
Ejemplo n.º 9
0
    private void move()
    {
        var deltaX = Input.GetAxis("Horizontal");
        var newXPos = transform.position.x + deltaX * Time.deltaTime * playerSpeed;
        
        var deltaY = Input.GetAxis("Vertical");
        var newYPos = transform.position.y + deltaY * Time.deltaTime * playerSpeed;

        transform.position = new Vector2(Mathf.Clamp(newXPos,xMin+padding,xMax-padding) , Mathf.Clamp(newYPos, yMin + padding, yMax - padding));

    }
Ejemplo n.º 10
0
 public void ChangeHealth(int amount)
 {
     currentHealth = Mathf.Clamp(currentHealth + amount, 0, maxHealth);
     Debug.Log(currentHealth + "/" + maxHealth);
 }
Ejemplo n.º 11
0
 // Nombre de graines
 public void ChangeSeed(int amount)
 {
     currentSeed = Mathf.Clamp(currentSeed + amount, 0, maxSeed);
     Debug.Log(currentSeed + "/" + maxSeed);
 }
Ejemplo n.º 12
0
        void Update()
        {
            var deltaTime = Time.unscaledDeltaTime;
            var offset    = CalculateOffset(currentScrollPosition);


            bool velocityIsZero = Mathf.Approximately(velocity, 0f);
            bool offsetNearZero = Mathf.Approximately(offset, 0f);


            if (autoScrollState.Enable)
            {
                var position = 0f;

                if (autoScrollState.Elastic)
                {
                    position = Mathf.SmoothDamp(currentScrollPosition, currentScrollPosition + offset, ref velocity,
                                                elasticity, Mathf.Infinity, deltaTime);

                    if (Mathf.Abs(velocity) < 0.01f)
                    {
                        position = Mathf.Clamp(Mathf.RoundToInt(position), 0, totalCount - 1);
                        velocity = 0f;
                        autoScrollState.Reset();
                    }
                }
                else
                {
                    var alpha = Mathf.Clamp01((Time.unscaledTime - autoScrollState.StartTime) /
                                              Mathf.Max(autoScrollState.Duration, float.Epsilon));
                    position = Mathf.LerpUnclamped(dragStartScrollPosition, autoScrollState.EndScrollPosition,
                                                   autoScrollState.EasingFunction(alpha));

                    if (Mathf.Approximately(alpha, 1f))
                    {
                        autoScrollState.Reset();
                    }
                }

                UpdatePosition(position);
            }
            else if ((!dragging) && (!velocityIsZero || !offsetNearZero))
            {
                var position = currentScrollPosition;

                if (movementType == MovementType.Elastic && !Mathf.Approximately(offset, 0f))
                {
                    autoScrollState.Reset();
                    autoScrollState.Enable  = true;
                    autoScrollState.Elastic = true;

                    UpdateSelection(Mathf.Clamp(Mathf.RoundToInt(position), 0, totalCount - 1));
                }
                else if (inertia)
                {
                    velocity *= Mathf.Pow(decelerationRate, deltaTime);

                    if (Mathf.Abs(velocity) < 0.001f)
                    {
                        velocity = 0f;
                    }

                    position += velocity * deltaTime;

                    if (snap.Enable && Mathf.Abs(velocity) < snap.VelocityThreshold)
                    {
                        ScrollTo(Mathf.RoundToInt(currentScrollPosition), snap.Duration, snap.Easing);
                    }
                }
                else
                {
                    velocity = 0f;
                }

                if (!Mathf.Approximately(velocity, 0f))
                {
                    if (movementType == MovementType.Clamped)
                    {
                        offset    = CalculateOffset(position);
                        position += offset;

                        if (Mathf.Approximately(position, 0f) || Mathf.Approximately(position, totalCount - 1f))
                        {
                            velocity = 0f;
                            UpdateSelection(Mathf.RoundToInt(position));
                        }
                    }

                    UpdatePosition(position);
                }
            }

            if (!autoScrollState.Enable && dragging && inertia)
            {
                var newVelocity = (currentScrollPosition - prevScrollPosition) / deltaTime;
                velocity = Mathf.Lerp(velocity, newVelocity, deltaTime * 10f);
            }

            prevScrollPosition = currentScrollPosition;
        }
Ejemplo n.º 13
0
        public WindowBase GetScreen(bool runtime = false)
        {
            if (this.storeType == StoreType.ReUseScreen)
            {
                var win = FlowSystem.GetWindow(this.screenWindowId);
                if (win == null)
                {
                    return(null);
                }

                return(win.GetScreen(runtime));
            }

            if (this.IsFunction() == true)
            {
                var func = FlowSystem.GetWindow(this.GetFunctionId());
                if (func != null)
                {
                    var win = FlowSystem.GetWindow(func.functionExitId);
                    if (win == null)
                    {
                        return(null);
                    }

                    return(win.GetScreen(runtime));
                }
            }

            if (this.screens == null || this.screens.Length == 0)
            {
                                #if UNITY_EDITOR
                if (Application.isPlaying == false)
                {
                    this.RefreshScreen();
                }
                                #endif

                if (this.screens == null)
                {
                    return(null);
                }

                return(this.screens.FirstOrDefault());
            }

            if (runtime == true)
            {
                WindowBase target = null;
                for (int i = 0; i < this.screens.Length; ++i)
                {
                    var screen = this.screens[i];
                    if (screen.targetPreferences.GetRunOnAnyTarget() == false)
                    {
                        if (screen.targetPreferences.IsValid() == true)
                        {
                            target = screen;
                            break;
                        }
                    }
                    else
                    {
                        target = screen;
                    }
                }

                return(target);

                //var screen = this.screens.FirstOrDefault(x => x.targetPreferences.GetRunOnAnyTarget() == false && x.targetPreferences.IsValid() == true);
                //if (screen == null) return this.screens.FirstOrDefault(x => x.targetPreferences.GetRunOnAnyTarget() == true);
            }

            this.selectedScreenIndex = Mathf.Clamp(this.selectedScreenIndex, 0, this.screens.Length - 1);
            return(this.screens[this.selectedScreenIndex]);
        }
Ejemplo n.º 14
0
        internal static void ShowPresets(ref UserPresetDrawer[] userPresets, ref bool canShow, ref SerializedProperty arrayProperty, bool isAppearance, bool isGlobal)
        {
            EditorGUI.BeginChangeCheck();

            StartVerticalToggleGroup(ref canShow, $"Create/edit {(isGlobal ? "global" : "local")} {(isAppearance ? "appearances" : "behaviors")} [{arrayProperty.arraySize} created]", docs_customInspectorPage);

            #region CanShow variable changed
            if (EditorGUI.EndChangeCheck())
            {
                //Resets "confirmation to delete effect" button
                for (int i = 0; i < userPresets.Length; i++)
                {
                    userPresets[i].wantsToRemove = false;
                }
            }
            #endregion

            #region Shows Preset
            if (canShow)
            {
                //Checks for error
                MatchPresetsDrawersWithComponent(ref userPresets, arrayProperty, isAppearance);

                for (int i = 0; i < userPresets.Length; i++)
                {

                    #region Header
                    if (userPresets[i].show)
                        GUI.backgroundColor = expandedColor;
                    else
                        GUI.backgroundColor = notExpandedColor;

                    //EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    GUI.backgroundColor = Color.white;

                    if (userPresets[i].show)
                    {
                        EditorGUILayout.BeginHorizontal();
                    }


                    #endregion

                    StartToggleGroup(ref userPresets[i].show, $"{userPresets[i].getName}", userPresets[i].show ? boldFoldout : EditorStyles.foldout);
                    #region Body

                    if (userPresets[i].show)
                    {
                        if (Application.isPlaying)
                            GUI.enabled = false;

                        if (GUILayout.Button(userPresets[i].wantsToRemove ? "Confirm?" : "Remove?", EditorStyles.miniButtonRight, GUILayout.Width(85)))
                        {
                            //Confirms remove
                            if (userPresets[i].wantsToRemove)
                            {
                                arrayProperty.DeleteArrayElementAtIndex(i);
                                MatchPresetsDrawersWithComponent(ref userPresets, arrayProperty, isAppearance);
                                break;
                            }
                            else //asks for remove
                            {
                                userPresets[i].wantsToRemove = true;
                            }
                        }

                        GUI.enabled = true;

                        EditorGUILayout.EndHorizontal();

                        GUI.backgroundColor = Color.white;

                        //can add modules only if it's a local effect or player is in edit mode
                        userPresets[i].Show();
                    }

                    #endregion

                    EndToggleGroup(userPresets[i].show);
                }

                #region Add New
                if (Application.isPlaying) //prevents adding new preset if in play mode
                    GUI.enabled = false;

                bool foldout = false;
                if (EditorGUILayout.Foldout(foldout, $"[+ Add new {(isAppearance ? "appearance" : "behavior")} effect]", true) && !Application.isPlaying)
                {
                    arrayProperty.InsertArrayElementAtIndex(Mathf.Clamp(arrayProperty.arraySize - 1, 0, arrayProperty.arraySize));
                    MatchPresetsDrawersWithComponent(ref userPresets, arrayProperty, isAppearance);
                    userPresets[userPresets.Length - 1].ResetValues();
                }

                GUI.enabled = true;
                #endregion
            }

            #endregion

            EndVerticalToggleGroup(canShow);
        }
    private void ConfigGUI()
    {
        GUILayout.Label("General", EditorStyles.boldLabel);
        EditorGUILayout.BeginVertical("box");
        EditorGUI.indentLevel++;

        // Capture Mode
        {
            string[] captureModes     = { "Realtime", "Offline" };
            int      captureModeIndex = 0;
            if (!_capture._isRealTime)
            {
                captureModeIndex = 1;
            }
            captureModeIndex     = EditorGUILayout.Popup("Mode", captureModeIndex, captureModes);
            _capture._isRealTime = (captureModeIndex == 0);
        }

        // File Name
        {
            EditorGUILayout.LabelField("File Name", EditorStyles.boldLabel);
            _capture._autoFilenamePrefix    = EditorGUILayout.TextField("Prefix", _capture._autoFilenamePrefix);
            _capture._autoFilenameExtension = EditorGUILayout.TextField("Extension", _capture._autoFilenameExtension);
            _capture._autoGenerateFilename  = EditorGUILayout.Toggle("Append Timestamp", _capture._autoGenerateFilename);
        }

        // File Path
        {
            EditorGUILayout.LabelField("File Path", EditorStyles.boldLabel);
            string[] outputFolders     = { "Project Folder", "Absolute Folder" };
            int      outputFolderIndex = 0;
            if (_capture._outputFolderType == AVProMovieCaptureBase.OutputPath.Absolute)
            {
                outputFolderIndex = 1;
            }
            int newOutputFolderIndex = EditorGUILayout.Popup("Relative to", outputFolderIndex, outputFolders);
            if (newOutputFolderIndex != outputFolderIndex)
            {
                _capture._outputFolderPath = string.Empty;
                outputFolderIndex          = newOutputFolderIndex;
            }
            if (outputFolderIndex == 0)
            {
                _capture._outputFolderType = AVProMovieCaptureBase.OutputPath.RelativeToProject;
                _capture._outputFolderPath = EditorGUILayout.TextField("SubFolder(s)", _capture._outputFolderPath);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                _capture._outputFolderType = AVProMovieCaptureBase.OutputPath.Absolute;
                _capture._outputFolderPath = EditorGUILayout.TextField("Path", _capture._outputFolderPath);
                if (GUILayout.Button(">", GUILayout.Width(22)))
                {
                    _capture._outputFolderPath = EditorUtility.SaveFolderPanel("Select Folder To Store Video Captures", System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, "../")), "");
                }
                EditorGUILayout.EndHorizontal();
            }
        }

        EditorGUI.indentLevel--;
        EditorGUILayout.EndVertical();

        GUILayout.Label("Video", EditorStyles.boldLabel);
        EditorGUILayout.BeginVertical("box");
        EditorGUI.indentLevel++;

        // Downscale
        {
            string[] downScales = { "Original", "Half", "Quarter", "Eighth", "Sixteenth", "Specific" };
            AVProMovieCaptureBase.DownScale[] downScaleEnums =
            {
                AVProMovieCaptureBase.DownScale.Original, AVProMovieCaptureBase.DownScale.Half,      AVProMovieCaptureBase.DownScale.Quarter,
                AVProMovieCaptureBase.DownScale.Eighth,   AVProMovieCaptureBase.DownScale.Sixteenth, AVProMovieCaptureBase.DownScale.Custom
            };
            int downScaleIndex = 0;
            for (int i = 0; i < downScaleEnums.Length; i++)
            {
                if (downScaleEnums[i] == _capture._downScale)
                {
                    downScaleIndex = i;
                    break;
                }
            }
            downScaleIndex = EditorGUILayout.Popup("Down Scale", downScaleIndex, downScales);
            if (downScaleIndex == 5)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("");
                _capture._maxVideoSize.x = EditorGUILayout.IntField((int)_capture._maxVideoSize.x);
                _capture._maxVideoSize.x = Mathf.Clamp((int)_capture._maxVideoSize.x, 1, AVProMovieCapturePlugin.MaxRenderWidth);
                EditorGUILayout.LabelField("x", GUILayout.ExpandWidth(false), GUILayout.Width(32));
                _capture._maxVideoSize.y = EditorGUILayout.IntField((int)_capture._maxVideoSize.y);
                _capture._maxVideoSize.y = Mathf.Clamp((int)_capture._maxVideoSize.y, 1, AVProMovieCapturePlugin.MaxRenderHeight);
                EditorGUILayout.EndHorizontal();
            }

            _capture._downScale = downScaleEnums[downScaleIndex];
        }


        // Frame Rate
        {
            _capture._frameRate = (AVProMovieCaptureBase.FrameRate)EditorGUILayout.EnumPopup("Frame Rate", _capture._frameRate);
        }

        EditorGUI.indentLevel--;
        EditorGUILayout.EndVertical();



        EditorGUI.BeginDisabledGroup(!_capture._isRealTime);
        GUILayout.Label("Audio", EditorStyles.boldLabel);
        EditorGUILayout.BeginVertical("box");
        EditorGUI.indentLevel++;

        // Capture Audio
        {
            _capture._noAudio = !EditorGUILayout.Toggle("Capture Audio", !_capture._noAudio);
        }

        // audio device
        // 1) from microphone, create list or force index
        // 2) from unity listener, easy

        // Capture Audio from Unity
        {
            EditorGUI.BeginDisabledGroup(_capture._forceAudioDeviceIndex == 1);            // TODO: fix this
            EditorGUILayout.ObjectField("Audio Capture", _capture._audioCapture, typeof(AVProUnityAudioCapture), true);
            EditorGUI.EndDisabledGroup();
        }

        EditorGUI.indentLevel--;
        EditorGUILayout.EndVertical();
        EditorGUI.EndDisabledGroup();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(_capture);
        }
    }
Ejemplo n.º 16
0
    void FixedUpdate()
    {
        inputY = Input.GetAxis("Vertical");
        inputX = Input.GetAxis("Horizontal");

        runSpeed = Input.GetAxis("Run");

        if (Input.GetButton("Vertical")) YSpeed += inputY / 10;
        else if (YSpeed > 0)
        {
            if (YSpeed > .1f) YSpeed -= .1f;
            else YSpeed = 0;
        }
        else if (YSpeed < 0)
        {
            if (YSpeed < -.1f) YSpeed += .1f;
            else YSpeed = 0;
        }

        YSpeed = Mathf.Clamp(YSpeed, -1, 1);
        YSpeed = (float)Math.Round(YSpeed, 2);



        if (Input.GetButton("Horizontal")) XSpeed += inputX / 10;
        else if (XSpeed > 0)
        {
            //Debug.Log("zmiejszanie predkosci");
            if (XSpeed > .1f) XSpeed -= .1f;
            else XSpeed = 0;
        }
        else if (XSpeed < 0)
        {
            if (XSpeed < -.1f) XSpeed += .1f;
            else XSpeed = 0;
        }

        if (Input.GetButton("Run") && (YSpeed >= .9f || XSpeed >= .9f || XSpeed <= -.9f)) RSpeed += runSpeed / 10;
        else if (RSpeed > 0)
        {
            if (RSpeed > .1f) RSpeed -= .1f;
            else RSpeed = 0;
        }

        RSpeed = Mathf.Clamp(RSpeed, 0, 1);
        RSpeed = (float)Math.Round(RSpeed, 2);


        XSpeed = Mathf.Clamp(XSpeed, -1, 1);
        XSpeed = (float)Math.Round(XSpeed, 2);

        if (YSpeed >= .9f && Input.GetButton("Vertical"))
        {
            //Debug.Log("Bieganie do przodu");
            YSpeed += RSpeed;
        }

        if (XSpeed >= .9f && Input.GetButton("Horizontal"))
        {
            //Debug.Log("Bieganie w prawo");
            XSpeed += RSpeed;
        }

        if (XSpeed <= -.9f && Input.GetButton("Horizontal"))
        {
            //Debug.Log("Bieganie w lewo");
            XSpeed -= RSpeed;
        }

        animator.SetFloat("InputY", YSpeed);
        animator.SetFloat("InputX", XSpeed);

        if (Input.GetButtonDown("Jump") && YSpeed >= .1) { animator.SetTrigger("RunJump"); /*Debug.Log("anim run");*/ }
        else if (Input.GetButtonDown("Jump")){ animator.SetTrigger("Jump"); /*Debug.Log("anim non");*/ }

        if (Input.GetButton("Crouch")) animator.SetBool("IsCrouching", true);
        else animator.SetBool("IsCrouching", false);

        if (InterfaceManager.instance.DrawSword)
        {
            if (!InterfaceManager.instance.isAnyActiveInterface)
            {
                if (Input.GetMouseButtonDown(0)) // Do refaktoryzacji to gowno xd /jk
                {
                    int xd = Random.Range(0, 2);// Dodac funkcje RandomAnimation() i przepisac ten kod dam
                    if (xd == 1) xd = 2;
                    animator.SetInteger("AttackNumber", xd);
                    animator.SetTrigger("BaseAttack");
                }
                if (Input.GetMouseButton(1)) animator.SetBool("ShieldBlock", true);
                else animator.SetBool("ShieldBlock", false);
            }
        }
    }
Ejemplo n.º 17
0
    void LateUpdate()
    {
        bool c = Main.playingmap != null &&
                 !Main.INSTANCE.pausePanel.isShowing() &&
                 !Main.INSTANCE.shapeSettingPanel.isShowing() &&
                 !Main.INSTANCE.couplerSettingPanel.isShowing() &&
                 !Main.INSTANCE.mapPinSettingPanel.isShowing() &&
                 !Main.INSTANCE.structureSettingPanel.isShowing() &&
                 !Main.INSTANCE.runPanel.isShowing(); // 操作可能か

        if (c && EventSystem.current.currentSelectedGameObject != null)
        {
            InputField input = EventSystem.current.currentSelectedGameObject.GetComponent <InputField>();
            if (input != null && input.isFocused)
            {
                c = false;
            }
        }
        if (c)
        {
            float   h    = Input.GetAxisRaw("Horizontal");
            float   v    = Input.GetAxisRaw("Vertical");
            Vector3 move = new Vector3(h, 0f, v);
            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            {
                move += Vector3.down;
            }
            if (Input.GetKey(KeyCode.Space))
            {
                move += Vector3.up;
            }
            transform.Translate(move * Main.cameraMoveSpeed * Time.deltaTime);

            if (Input.GetMouseButton(0))
            {
                if (Input.GetMouseButtonDown(0))
                {
                    Cursor.lockState = CursorLockMode.Confined;
                }
                else
                {
                    Vector3 m = (Input.mousePosition - lastMousePos) * Main.dragRotSpeed; // カメラの移動量
                    if (m != Vector3.zero)
                    {
                        dragging = true;
                        transform.eulerAngles = new Vector3(Mathf.Clamp(Mathf.Repeat(transform.eulerAngles.x + 180f - m.y, 360f) - 180f, -90f, 90f), transform.eulerAngles.y + m.x);
                    }
                }
                lastMousePos = Input.mousePosition;
            }
            else
            {
                dragging         = false;
                Cursor.lockState = CursorLockMode.None;
            }
        }
        else
        {
            Cursor.lockState = CursorLockMode.None;
        }
    }
Ejemplo n.º 18
0
 protected override void OnScroll(OnEditionMouseScroll e)
 {
     distance -= e.value * (distance / 3f);
     distance  = Mathf.Clamp(distance, distanceMin, distanceMax);
 }
Ejemplo n.º 19
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            dragOrigin = Input.mousePosition;
            return;
        }

        if (!Input.GetMouseButton(0))
        {
            return;
        }

        Vector3 pos  = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);
        Vector3 move = new Vector3(pos.x * dragSpeed, 0, pos.y * dragSpeed);

        transform.Translate(-move, Space.World);
        //transform.position = new Vector3(Mathf.Clamp(Time.time,-10f,10f), 10f, Mathf.Clamp(Time.time, -5f, 5f));
        transform.position = new Vector3(Mathf.Clamp(transform.position.x, -10f, 10f), 10f, Mathf.Clamp(transform.position.z, -5f, 5f));
    }
Ejemplo n.º 20
0
 public void DrawGizmos(Color color, int smoothness = 4)
 {
     drawGizmos = true;
     gizmoColor = color;
     gizmoStep  = 1f / (endPoints.Count * Mathf.Clamp(smoothness, 1, 30));
 }
Ejemplo n.º 21
0
 void PlayRandomSound(AudioClip[] clips)
 {
     PlaySound(clips[Mathf.Clamp(Random.Range(0, clips.Length), 0, clips.Length - 1)]);
 }
Ejemplo n.º 22
0
    //改变

    public void SetDodge(float value)
    {
        Dodge = Mathf.Clamp(value, DodgeMin, DodgeMax);
    }
Ejemplo n.º 23
0
	// Update is called once per frame
	void LateUpdate () {
		float x = Mathf.Clamp(player.transform.position.x, xMin, xMax);
		float y = Mathf.Clamp(player.transform.position.y, yMin, yMax);
		gameObject.transform.position = new Vector3(x, y, gameObject.transform.position.z);
	}
Ejemplo n.º 24
0
 public void SetBerserk(float value)
 {
     Berserk = Mathf.Clamp(value, BerserkMin, BerserkMax);
 }
Ejemplo n.º 25
0
 private void FixedUpdate()
 {
     rb.AddForce(new Vector2(Input.GetAxisRaw("Horizontal") * speed, 0), ForceMode2D.Impulse);
     rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -speed, speed), Mathf.Clamp(rb.velocity.y, -jumpForce, jumpForce));
     rb.velocity = new Vector2(rb.velocity.x / (Time.deltaTime * deceleration), rb.velocity.y);
 }
Ejemplo n.º 26
0
 public void SetFear(float value)
 {
     Fear = Mathf.Clamp(value, FearMin, FearMax);
 }
Ejemplo n.º 27
0
 protected virtual void FixedUpdate()
 {
     skillGlobalCooldown = Mathf.Clamp(skillGlobalCooldown - Time.fixedDeltaTime, 0, Int32.MaxValue);
 }
Ejemplo n.º 28
0
 public void SetRage(float value)
 {
     Rage = Mathf.Clamp(value, RageMin, RageMax);
 }
        internal MASComponentIntLight(ConfigNode config, InternalProp prop, MASFlightComputer comp)
            : base(config, prop, comp)
        {
            string lightName = string.Empty;

            if (!config.TryGetValue("lightName", ref lightName))
            {
                throw new ArgumentException("Missing 'lightName' in INT_LIGHT " + name);
            }

            Light[] availableLights = prop.part.internalModel.FindModelComponents <Light>();
            if (availableLights != null && availableLights.Length > 0)
            {
                List <Light> lights = new List <Light>(availableLights);
                for (int i = lights.Count - 1; i >= 0; --i)
                {
                    if (lights[i].name != lightName)
                    {
                        lights.RemoveAt(i);
                    }
                }
                if (lights.Count > 0)
                {
                    controlledLights = lights.ToArray();
                }
            }

            if (controlledLights == null)
            {
                Utility.LogError(this, "No lights named '{0}' found in internalModel '{1}'", lightName, prop.part.internalModel.internalName);
                return;
            }

            string variableName = string.Empty;

            if (!config.TryGetValue("variable", ref variableName) || string.IsNullOrEmpty(variableName))
            {
                throw new ArgumentException("Invalid or missing 'variable' in INT_LIGHT " + name);
            }

            string colorString = string.Empty;

            if (config.TryGetValue("color", ref colorString))
            {
                Color32 color32;
                if (comp.TryGetNamedColor(colorString, out color32))
                {
                    lightColor = color32;
                    UpdateColor();
                }
                else
                {
                    string[] colors = Utility.SplitVariableList(colorString);
                    if (colors.Length < 3 || colors.Length > 4)
                    {
                        throw new ArgumentException("'lightColor' does not contain 3 or 4 values in INT_LIGHT " + name);
                    }

                    variableRegistrar.RegisterVariableChangeCallback(colors[0], (double newValue) =>
                    {
                        lightColor.r = Mathf.Clamp01((float)newValue * (1.0f / 255.0f));
                        UpdateColor();
                    });

                    variableRegistrar.RegisterVariableChangeCallback(colors[1], (double newValue) =>
                    {
                        lightColor.g = Mathf.Clamp01((float)newValue * (1.0f / 255.0f));
                        UpdateColor();
                    });

                    variableRegistrar.RegisterVariableChangeCallback(colors[2], (double newValue) =>
                    {
                        lightColor.b = Mathf.Clamp01((float)newValue * (1.0f / 255.0f));
                        UpdateColor();
                    });

                    if (colors.Length == 4)
                    {
                        variableRegistrar.RegisterVariableChangeCallback(colors[3], (double newValue) =>
                        {
                            lightColor.a = Mathf.Clamp01((float)newValue * (1.0f / 255.0f));
                            UpdateColor();
                        });
                    }
                }
            }

            string intensityString = string.Empty;

            if (config.TryGetValue("intensity", ref intensityString))
            {
                variableRegistrar.RegisterVariableChangeCallback(intensityString, (double newValue) =>
                {
                    float intensity = Mathf.Clamp((float)newValue, 0.0f, 8.0f);
                    for (int i = controlledLights.Length - 1; i >= 0; --i)
                    {
                        controlledLights[i].intensity = intensity;
                    }
                });
            }

            currentState = false;
            for (int i = 0; i < controlledLights.Length; ++i)
            {
                controlledLights[i].enabled = currentState;
            }

            variableRegistrar.RegisterVariableChangeCallback(variableName, VariableCallback);
        }
Ejemplo n.º 30
0
 public override void OnGUI()
 {
     s_Radius.value       = EditorGUILayout.FloatField("Radius", s_Radius.value);
     s_Radius.value       = Mathf.Clamp(s_Radius.value, k_MinShapeDimensions.x, k_MaxShapeDimensions.x);
     s_Subdivisions.value = (int)EditorGUILayout.Slider("Subdivisions", s_Subdivisions, 0, 5);
 }