public virtual void Update()
 {
     targetCameraPos        = camera.localPosition;
     targetCameraQuatRot    = cameraLook.GetCameraTargetRot();
     targetCameraEulerRot   = targetCameraQuatRot.eulerAngles;
     targetCameraEulerRot.y = 0;
     if (UInput.GetButton(INC.RIGHT_TILT))
     {
         targetCameraPos.x      = Mathf.SmoothStep(targetCameraPos.x, outputRange, outputSpeed * Time.deltaTime);
         targetCameraEulerRot.z = -angle;
         targetCameraQuatRot    = Quaternion.Euler(targetCameraEulerRot);
         isTilt = true;
     }
     else if (UInput.GetButton(INC.LEFT_TILT))
     {
         targetCameraPos.x      = Mathf.SmoothStep(targetCameraPos.x, -outputRange, outputSpeed * Time.deltaTime);
         targetCameraEulerRot.z = angle;
         targetCameraQuatRot    = Quaternion.Euler(targetCameraEulerRot);
         isTilt = true;
     }
     else if (!UInput.GetButton(INC.RIGHT_TILT) && !UInput.GetButton(INC.LEFT_TILT))
     {
         targetCameraPos.x      = Mathf.SmoothStep(targetCameraPos.x, originalOutput, outputSpeed * Time.deltaTime);
         targetCameraEulerRot.z = -originalAngle;
         targetCameraQuatRot    = Quaternion.Euler(targetCameraEulerRot);
         isTilt = false;
     }
     camera.localPosition = targetCameraPos;
     cameraLook.SetCameraTargetRot(Quaternion.Slerp(cameraLook.GetCameraTargetRot(), targetCameraQuatRot, rotateSpeed * Time.deltaTime));
 }
Example #2
0
    //public static MouseInBorderRTS Create(string root, Vector3 origen, Vector3 moveTo, Transform cam)
    //{
    //    MouseInBorderRTS obj = null;
    //    obj = (MouseInBorderRTS)Resources.Load(root, typeof(MouseInBorderRTS));
    //    obj = (MouseInBorderRTS)Instantiate(obj, origen, Quaternion.identity);
    //    return obj;
    //}

    public Dir ReturnMouseDirection()
    {
        direction = Dir.None;

        //create single dir rectagles
        var recdown  = new Rect(0, 0, Screen.width, gUIsizeUpDown);
        var recup    = new Rect(0, Screen.height - gUIsizeUpDown, Screen.width, gUIsizeUpDown);
        var recleft  = new Rect(0, 0, gUIsize, Screen.height);
        var recright = new Rect(Screen.width - gUIsize, 0, gUIsize, Screen.height);

        //create composite dir rectagles
        var rectDownLeft  = new Rect(0, 0, cornerSize, cornerSize);
        var rectDownRight = new Rect(Screen.width - cornerSize, 0, cornerSize, cornerSize);
        var rectUpLeft    = new Rect(0, Screen.height - cornerSize, cornerSize, cornerSize);
        var rectUpRight   = new Rect(Screen.width - cornerSize, Screen.height - cornerSize, cornerSize, cornerSize);

        //if mouse is not on top of gui ...
        if (!MiniMapRTS.isMouseOnGUI)
        {
            direction = ReturnComposeDirection(rectDownLeft, rectDownRight,
                                               rectUpLeft, rectUpRight);

            if (direction == Dir.None)
            {
                direction = ReturnSingleDirection(recdown, recup, recleft, recright);

                if (UInput.IfCursorKeyIsPressed())
                {
                    direction = ReturnComposeDirectionWithKeyBoard(direction);
                }
            }
        }
        GlobalDir = direction;
        return(direction);
    }
        /// <summary>
        /// Weapon sway then camera rotation.
        /// </summary>
        /// <param name="weapon"></param>
        /// <param name="speed"></param>
        protected virtual void RotationSwayProcessing(Transform weapon)
        {
            float factorX = -UInput.GetAxis(INC.CAM_VERTICAL) * positionSensitivity;
            float factorY = -UInput.GetAxis(INC.CAM_HORIZONTAL) * positionSensitivity;

            if (factorX > maxPositionSensitivity)
            {
                factorX = maxPositionSensitivity;
            }

            if (factorX < -maxPositionSensitivity)
            {
                factorX = -maxPositionSensitivity;
            }

            if (factorY > maxPositionSensitivity)
            {
                factorY = maxPositionSensitivity;
            }

            if (factorY < -maxPositionSensitivity)
            {
                factorY = -maxPositionSensitivity;
            }

            Vector3 final = new Vector3(originalPostion.x + factorX, originalPostion.y + factorY, originalPostion.z);

            weapon.localPosition = Vector3.Lerp(weapon.localPosition, final, Time.deltaTime * smoothPosition);

            float      tiltAroundZ = UInput.GetAxis(INC.CAM_VERTICAL) * rotationSensitivity;
            float      tiltAroundX = UInput.GetAxis(INC.CAM_HORIZONTAL) * rotationSensitivity;
            Quaternion target      = Quaternion.Euler(weapon.localRotation.x + tiltAroundX, originalYAxis, weapon.localRotation.z + tiltAroundZ);

            weapon.localRotation = Quaternion.Slerp(weapon.localRotation, target, Time.deltaTime * smoothRotation);
        }
Example #4
0
    // 작동 될 때
    private void OnEnable()
    {
        if (f_rigid == null)
        {
            transform.SetParent(null);                                          // 부모를 없애어, 플레이어의 시각으로부터 자유로워진다.
            f_rigid      = GetComponent <Rigidbody>();
            tf           = GameObject.Find("LookChecker");
            obm          = GameObject.Find("ObjectManager");
            aiState      = GameObject.Find("BelugaAxis").GetComponent <AIStateController>();
            veTF         = GameObject.Find("BelugaAxis").GetComponent <Transform>();
            uu           = GameObject.Find("Main Camera").GetComponent <UInput>();
            foodParticle = GameObject.Find("Particle").transform.Find("Eating");
        }

        uu.fakeFish.SetActive(false);
        if (AI.success + AI.fail < 5 && UInput.uIState == UInput.UIState.Feed && Vector3.Distance(tf.transform.position, veTF.position) < 0.4f)         // 벨루가위치와 던짐 목표 위치를 비교하여 일정 거리 이하일 경우만
        {
            aiState.StartCoroutine(aiState.FeedFeed());
        }
        f_rigid.velocity = Vector3.zero;
        Vector3 foodVelo = Throwing(obm.transform.position, tf.transform.position + Vector3.up, degree);

        Throw(foodVelo);

        StartCoroutine("DestroyFood");
    }
 public WeaponActionState GetActiveState()
 {
     if (UInput.GetButton(INC.SIGHT))
     {
         return(WeaponActionState.Sight);
     }
     else if (!characterController.isGrounded)
     {
         return(WeaponActionState.InAir);
     }
     else if (controller.GetCrouchSystem().IsCrouch())
     {
         return(WeaponActionState.Crouch);
     }
     else if (animator.GetInteger(SPEED_HASH) == 3)
     {
         return(WeaponActionState.Sprint);
     }
     else if (animator.GetInteger(SPEED_HASH) == 2)
     {
         return(WeaponActionState.Run);
     }
     else if (animator.GetInteger(SPEED_HASH) == 1)
     {
         return(WeaponActionState.Walk);
     }
     else
     {
         return(WeaponActionState.Idle);
     }
 }
Example #6
0
File: Ball.cs Project: hnjog/ArPets
    // 작동 될 때
    private void OnEnable()
    {
        if (b_rigid == null)
        {
            transform.SetParent(null);                                          // 부모를 없애어, 플레이어의 시각으로부터 자유로워진다.
            b_rigid = GetComponent <Rigidbody>();
            //tf = GameObject.Find("LookChecker");
            //tf.transform.SetParent(null);                           // 부모를 없애어, 플레이어가 어디를 보고 치던 벨루가에게 날아가도록 한다.
            //player = GameObject.Find("Camera Container");
            veluga  = GameObject.Find("BelugaAxis");
            aiState = GameObject.Find("BelugaAxis").GetComponent <AIStateController>();
            input   = GameObject.Find("Main Camera").GetComponent <UInput>();
            caTF    = GameObject.Find("Main Camera").GetComponent <Transform>();
            //catchTF = GameObject.Find("CatchPoint");
            ballHit = GameObject.Find("Particle").transform.Find("Ball");
        }

        // off 한 후의 힘 초기화
        b_rigid.velocity = Vector3.zero;
        BallVelo         = Throwing(transform.position, veluga.transform.position + Vector3.up * 0.5f, degree);
        Throw(BallVelo);

        if (UInput.uIState == UInput.UIState.Ball)
        {
            //catchTF.transform.position = caTF.position;
            //catchTF.transform.SetParent(null);
            aiState.StartCoroutine(aiState.BallBall());
            StartCoroutine("DestroyBall");
        }
    }
Example #7
0
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        protected virtual void Update()
        {
            if (groups.Count == 0)
            {
                return;
            }

            switch (switchMode)
            {
            case SwitchWeaponMode.ByKey:
                SelectWeaponByKey();
                break;

            case SwitchWeaponMode.ByMouseWheel:
                SelectWeaponByMouseWheel();
                break;

            case SwitchWeaponMode.Both:
                SelectWeaponByKey();
                SelectWeaponByMouseWheel();
                break;
            }

            if (UInput.GetButtonDown(INC.DROP))
            {
                Drop();
            }
        }
Example #8
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.F1))
        {
            freeFly = !freeFly;
        }

        float scroll = Input.mouseScrollDelta.y;

        if (scroll != 0f)
        {
            cameraZoom -= scroll;
            cameraZoom  = Mathf.Clamp(cameraZoom, minZoom, maxZoom);
        }

        if (freeFly)
        {
            cameraTransform.RotateAround(_target.position, cameraTransform.right, UInput.RotateY() * sensetive.y);
            cameraTransform.RotateAround(_target.position, _target.forward, UInput.RotateX() * -sensetive.x);
        }
        else
        {
            cameraTransform.RotateAround(_target.position, cameraTransform.right, UInput.RotateY() * sensetive.y);
            cameraTransform.RotateAround(_target.position, _target.up, UInput.RotateX() * sensetive.x);
        }

        NormalizeCamera();
    }
Example #9
0
        protected virtual void OnGUI()
        {
            if (hideWhileSight)
            {
                showCrosshair = !UInput.GetButton(INC.SIGHT);
            }

            if (showCrosshair && verticalTexture && horizontalTexture)
            {
                GUI.color = crosshairColor;
                switch (preset)
                {
                case Preset.Default:
                    GUIUtility.RotateAroundPivot(angle, center);
                    GUI.DrawTexture(new Rect((Screen.width - width) / 2, (Screen.height - spread) / 2 - height, width, height), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - width) / 2, (Screen.height + spread) / 2, width, height), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - spread) / 2 - height, (Screen.height - width) / 2, height, width), verticalTexture);
                    GUI.DrawTexture(new Rect((Screen.width + spread) / 2, (Screen.height - width) / 2, height, width), verticalTexture);
                    break;

                case Preset.Shotgun:
                    GUIUtility.RotateAroundPivot(angle, center);
                    GUI.DrawTexture(new Rect((Screen.width - height) / 2, (Screen.height - spread) / 2 - width, height, width), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - height) / 2, (Screen.height + spread) / 2, height, width), horizontalTexture);
                    GUI.DrawTexture(new Rect((Screen.width - spread) / 2 - width, (Screen.height - height) / 2, width, height), verticalTexture);
                    GUI.DrawTexture(new Rect((Screen.width + spread) / 2, (Screen.height - height) / 2, width, height), verticalTexture);
                    break;

                case Preset.Triangle:
                    GUIUtility.RotateAroundPivot(angle, center);
                    GUI.DrawTexture(new Rect((Screen.width - 2) / 2, (Screen.height - spread) / 2 - 14, width, height), horizontalTexture);
                    GUIUtility.RotateAroundPivot(45, center);
                    GUI.DrawTexture(new Rect((Screen.width + spread) / 2, (Screen.height - 2) / 2, height, width), horizontalTexture);
                    GUIUtility.RotateAroundPivot(0, center);
                    GUI.DrawTexture(new Rect((Screen.width - 2) / 2, (Screen.height + spread) / 2, width, height), horizontalTexture);
                    break;
                }
                GUI.color = Color.white;
            }

            if (hitEffectIsActive && hitEffectTexture)
            {
                if (!UMathf.Approximately(hitEffectColor.a, 0, 0.001f))
                {
                    hitEffectColor.a = Mathf.SmoothStep(hitEffectColor.a, 0, hitEffectHideSpeed * Time.deltaTime);
                }
                GUI.color = hitEffectColor;
                GUIUtility.RotateAroundPivot(hitEffecntAngle, center);
                GUI.DrawTexture(new Rect((Screen.width - hitEffectWidth) / 2, (Screen.height - hitEffectSpread) / 2 - hitEffectHeight, hitEffectWidth, hitEffectHeight), hitEffectTexture);
                GUI.DrawTexture(new Rect((Screen.width - hitEffectWidth) / 2, (Screen.height + hitEffectSpread) / 2, hitEffectWidth, hitEffectHeight), hitEffectTexture);
                GUI.DrawTexture(new Rect((Screen.width - hitEffectSpread) / 2 - hitEffectHeight, (Screen.height - hitEffectWidth) / 2, hitEffectHeight, hitEffectWidth), hitEffectTexture);
                GUI.DrawTexture(new Rect((Screen.width + hitEffectSpread) / 2, (Screen.height - hitEffectWidth) / 2, hitEffectHeight, hitEffectWidth), hitEffectTexture);
            }
        }
Example #10
0
    /// <summary>
    /// return         //mouse and key directions only if they dont conflict...
    /// if mouse going right and keyboard up will return an 'UpRight' direction
    /// </summary>
    /// <param name="dir"></param>
    /// <returns></returns>
    private Dir ReturnComposeDirectionWithKeyBoard(Dir dir)
    {
        if (UInput.IfHorizontalKeysIsPressed() && dir == Dir.Up)
        {
            if (UInput.HorizVal() > 0)
            {
                dir = Dir.UpRight;
            }
            else if (UInput.HorizVal() < 0)
            {
                dir = Dir.UpLeft;
            }
        }
        else if (UInput.IfHorizontalKeysIsPressed() && dir == Dir.Down)
        {
            if (UInput.HorizVal() > 0)
            {
                dir = Dir.DownRight;
            }
            else if (UInput.HorizVal() < 0)
            {
                dir = Dir.DownLeft;
            }
        }

        if (UInput.IfVerticalKeyIsPressed() && dir == Dir.Right)
        {
            if (UInput.VertiVal() > 0)
            {
                dir = Dir.UpRight;
            }
            else if (UInput.VertiVal() < 0)
            {
                dir = Dir.DownRight;
            }
        }
        else if (UInput.IfVerticalKeyIsPressed() && dir == Dir.Left)
        {
            if (UInput.VertiVal() > 0)
            {
                dir = Dir.UpLeft;
            }
            else if (UInput.VertiVal() < 0)
            {
                dir = Dir.DownLeft;
            }
        }
        return(dir);
    }
Example #11
0
 public void Update()
 {
     foreach (var c in components.Where(c => Input.GetKeyDown(c.key)))
     {
         ui.UpdateGroup(actions.component, g => g.UnMarkAsSelected());
         actions.component = c.component;
         ui.UpdateGroup(actions.component, g => g.MarkAsSelected());
         UpdateView();
         break;
     }
     if (UInput.key1())
     {
         Act(c => c.Enable());
     }
     if (UInput.key2())
     {
         Act(c => c.Disable());
     }
 }
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        protected virtual void Update()
        {
            if (controller == null)
            {
                return;
            }

            if (controller.IsSprinting())
            {
                animator.SetInteger(SPEED_HASH, 3);
            }
            else if (controller.IsRunning())
            {
                animator.SetInteger(SPEED_HASH, 2);
            }
            else if (controller.IsWalking())
            {
                animator.SetInteger(SPEED_HASH, 1);
            }
            else if (!UInput.GetButton(INC.ATTACK) && !UInput.GetButton(INC.JUMP))
            {
                animator.SetInteger(SPEED_HASH, 0);
            }

            if (UInput.GetButtonDown(INC.SIGHT))
            {
                animator.SetBool(SIGHT_HASH, true);
            }
            else if (UInput.GetButtonUp(INC.SIGHT))
            {
                animator.SetBool(SIGHT_HASH, false);
            }

            if (useRotationSway)
            {
                RotationSwayProcessing(transform);
            }

            if (useJumpSway)
            {
                JumpSwayProcessing(transform);
            }
        }
Example #13
0
        /// <summary>
        /// Shooting system processing.
        /// </summary>
        protected virtual IEnumerator ShootingProcessing()
        {
            WaitForSeconds    updateDelay = new WaitForSeconds(delay);
            WaitForEndOfFrame endOfFrame  = new WaitForEndOfFrame();

            while (true)
            {
                if (!weaponReloading.BulletsIsEmpty() && !weaponReloading.IsReloading())
                {
                    if (fireMode == Mode.Free && UInput.GetButton(INC.ATTACK) || fireMode == Mode.Single && UInput.GetButtonDown(INC.ATTACK))
                    {
                        DoShoot();
                        yield return(updateDelay);
                    }
                    else if (fireMode == Mode.Queue && UInput.GetButtonDown(INC.ATTACK))
                    {
                        for (int i = 0; i < queueCount; i++)
                        {
                            DoShoot();
                            weaponAnimator.SetAttack(1);
                            yield return(endOfFrame);

                            weaponAnimator.SetAttack(-1);
                            yield return(updateDelay);
                        }
                    }
                }
                else if (UInput.GetButtonDown(INC.ATTACK))
                {
                    AudioClip sound = soundProperties.GetRandomEmptySound();
                    if (sound != null)
                    {
                        audioSource.PlayOneShot(sound);
                    }
                    weaponAnimator.SetAttack(0);
                    yield return(endOfFrame);

                    weaponAnimator.SetAttack(-1);
                }
                yield return(null);
            }
        }
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        protected virtual void Update()
        {
            if (UInput.GetButtonDown(INC.RELOAD) &&
                !ClipsIsEmpty() &&
                !isReloading &&
                bulletCount < maxBulletCount)
            {
                isReloading = true;
                switch (reloadMode)
                {
                case ReloadMode.Default:
                    DefaultReload();
                    break;

                case ReloadMode.Sequential:
                    SequentialReload();
                    break;
                }
            }
        }
Example #15
0
        private void AnimatorStateProcessing()
        {
            if (fireMode == Mode.Free && UInput.GetButton(INC.ATTACK) && !weaponReloading.BulletsIsEmpty())
            {
                weaponAnimator.SetAttack(1);
            }
            else if (fireMode == Mode.Free && !UInput.GetButton(INC.ATTACK))
            {
                weaponAnimator.SetAttack(-1);
            }

            if (fireMode == Mode.Single && UInput.GetButtonDown(INC.ATTACK) && !weaponReloading.BulletsIsEmpty())
            {
                weaponAnimator.SetAttack(1);
            }
            else if (fireMode == Mode.Single && !UInput.GetButtonDown(INC.ATTACK))
            {
                weaponAnimator.SetAttack(-1);
            }
        }
 /// <summary>
 /// Update is called every frame, if the MonoBehaviour is enabled.
 /// </summary>
 protected virtual void Update()
 {
     if (!isAttacking)
     {
         if (UInput.GetButtonDown(INC.ATTACK))
         {
             weaponAnimator.SetAttack(1);
             StartCoroutine(DoAttack(normalAttack));
         }
         else if (Input.GetKeyDown(specialAttackKey))
         {
             weaponAnimator.SetAttack(2);
             StartCoroutine(DoAttack(specialAttack));
         }
     }
     else if (isAttacking && (Time.time - delayTimer) >= currentDelay)
     {
         isAttacking = false;
     }
 }
Example #17
0
    public static float ResponsiveInputAxisTo(float normalizeTo, Dir axis, float currentValue, Dir direction)
    {
        if (
            direction == Dir.Left || direction == Dir.Right ||
            (UInput.IfHorizontalKeysIsPressed() && axis == Dir.Horizontal && direction == Dir.None))
        {
            currentValue = FindMathSign(currentValue, normalizeTo, direction);
        }
        else if (
            direction == Dir.Up || direction == Dir.Down ||
            (UInput.IfVerticalKeyIsPressed() && axis == Dir.Vertical && direction == Dir.None))
        {
            currentValue = FindMathSign(currentValue, normalizeTo, direction);
        }
        else
        {
            currentValue = 0;
        }

        return(currentValue);
    }
Example #18
0
    /// <summary>
    /// Will return in which Axis the move is happening based on Direction first
    /// pased from  MouseInBorder.cs obj, then if that is equal D.None will then
    /// look at the keyboard input
    /// </summary>
    /// <param name="horVal">horizontal axis change value </param>
    /// <param name="vertVal">vertical axis change value</param>
    /// <param name="dir">direction pased from  MouseInBorder.cs obj</param>
    /// <returns></returns>
    private Dir ReturnAxisToMove(float horVal, float vertVal, Dir dir = Dir.None)
    {
        //VerticHorizo
        //mouse
        if ((dir == Dir.UpLeft || dir == Dir.UpRight ||
             dir == Dir.DownLeft || dir == Dir.DownRight) && !IsMouseMiddle)
        {
            dir = Dir.VerticHorizo;
        }
        //keyboard
        else if ((horVal != 0 && vertVal != 0 && UInput.IfCursorKeyIsPressed()) && dir == Dir.None)
        {
            dir = Dir.VerticHorizo;
        }

        //Horizontal
        //mouse
        if (((dir == Dir.Right || dir == Dir.Left) && !IsMouseMiddle))
        {
            dir = Dir.Horizontal;
        }
        //keyobard
        else if (horVal != 0 && dir == Dir.None)
        {
            dir = Dir.Horizontal;
        }

        //Vertical
        //mouse
        if ((dir == Dir.Up || dir == Dir.Down) && !IsMouseMiddle)
        {
            dir = Dir.Vertical;
        }
        //keyobard
        else if (vertVal != 0 && dir == Dir.None)
        {
            dir = Dir.Vertical;
        }
        return(dir);
    }
Example #19
0
    public static void Main()
    {
        Console.Title = "MiniConsole 1.0 by Kat21";
        bool   trueValue  = true;
        bool   promptTime = false;
        string prompt     = "(" + Environment.CurrentDirectory + ")>";
        string prompt2    = "";

        Console.WriteLine("MiniConsole 1.0 by Kat21. Coded in C#");
        Console.WriteLine("Currently running on a " + Environment.OSVersion.VersionString);
        Console.ResetColor();
        while (trueValue == true)
        {
            string UInput;
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write("");
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.Write(prompt);
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write("");
            Console.ResetColor();
            UInput = Console.ReadLine();
            if (promptTime == true)
            {
                prompt = prompt2.Replace("$prompt", prompt).Replace("$time", DateTime.Now.ToString("h:mm:ss tt")).Replace("$hi", "Hello!").Replace("$path", Environment.CurrentDirectory);
            }
            if (UInput == "hi")
            {
                Console.WriteLine("Hello!");
            }
            else if (UInput == "")
            {
                WriteError("input", "No input recieved");
            }
            else if (UInput.Contains("help"))
            {
                if (UInput == "help")
                {
                    WriteInfo("Help usage: \"help (command)\" where \"(command)\" is the command ex. \"help draw\"");
                    WriteHelp("Help menu:");
                    Console.WriteLine("clear         Clear the screen (remove all the text)");
                    Console.WriteLine("draw [arg]    Draw to the screen (help draw)");
                    Console.WriteLine("help          Show help menu");
                    Console.WriteLine("hi            Say hi");
                    Console.WriteLine("time          Displays the time");
                    Console.WriteLine("path          Displays the current path of the executable");
                    Console.WriteLine("prompt [arg]  Change prompt (help prompt)");
                }
                else if (UInput == "help prompt")
                {
                    Console.WriteLine("Usage: prompt [time/path/default]");
                    Console.WriteLine("Supports command output (ex. prompt $path, prompt $time, prompt $hi)");
                    Console.WriteLine("Also supports strings (prompt Hello World, it's $time)");
                    Console.WriteLine("Examples: (prompt $time) returns the time ex. (12:05:00 PM)>");
                }
                else if (UInput == "help draw")
                {
                    Console.WriteLine("Usage: draw [string]");
                    Console.WriteLine("Supports command output (ex. draw $path, draw $time, draw $hi)");
                    Console.WriteLine("Also supports strings (draw Hello World, it's $time)");
                    Console.WriteLine("Examples: (draw $time) returns the time ex. 12:05:00 PM");
                }
                else if (UInput.StartsWith("help "))
                {
                    WriteHelp("No help was found for " + UInput.Substring(5) + ".");
                }
                else
                {
                    WriteError("invalid", "Did you mean 'help'?");
                }
            }
            else if (UInput.Contains("draw"))
            {
                if (UInput.StartsWith("draw "))
                {
                    UInput = UInput.Replace("$prompt", prompt).Replace("$time", DateTime.Now.ToString("h:mm:ss tt")).Replace("$hi", "Hello!").Replace("$path", Environment.CurrentDirectory);
                    Console.WriteLine(UInput.Substring(5));
                }
                else
                {
                    WriteError("invalid", "Did you mean 'draw'?");
                }
            }
            else if (UInput == "time")
            {
                Console.WriteLine(DateTime.Now.ToString("h:mm:ss tt"));
            }
            else if (UInput == "path")
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("Path: ");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine(Environment.CurrentDirectory);
                Console.ResetColor();
                WriteInfo("You can use \"help path\" to get more information about the path command.");
                promptTime = false;
            }
            else if (UInput.StartsWith("prompt"))
            {
                if (UInput == "prompt")
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("Prompt: ");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.WriteLine(prompt);
                    Console.ResetColor();
                    WriteInfo("You can use \"help prompt\" to get more information about the prompt command.");
                    if (promptTime == true)
                    {
                        WriteInfo("Time prompt is activated. Use any other prompt to stop. (ex. prompt $path)");
                    }
                    else
                    {
                        promptTime = false;
                    }
                }
                else
                {
                    if (UInput.Contains("$time"))
                    {
                        promptTime = true;
                        prompt2    = UInput.Substring(7);
                    }
                    else
                    {
                        promptTime = false;
                    }
                    UInput = UInput.Replace("$prompt", prompt).Replace("$time", DateTime.Now.ToString("h:mm:ss tt")).Replace("$hi", "Hello!").Replace("$path", Environment.CurrentDirectory);
                    prompt = UInput[7..];
Example #20
0
 /// <summary>
 /// Calls updates
 /// </summary>
 private void UpdateCaller()
 {
     inputMouse.Update();
     UInput.Update();//needs to be call
 }
Example #21
0
        protected virtual void SelectWeaponByMouseWheel()
        {
            if (UInput.GetAxisRaw(INC.MOUSE_WHEEL) == 0 || (switchWeaponAnimation != null || hideWeaponAnimation != null))
            {
                return;
            }

            int sign        = UInput.GetAxisRaw(INC.MOUSE_WHEEL) > 0 ? 1 : -1;
            int weaponIndex = 0;
            int weaponGroup = 0;

            if (currentWeaponKey != KeyCode.None && cacheKeyToID.ContainsKey(currentWeaponKey))
            {
                string currentGroup = cacheKeyToID[currentWeaponKey].GetGroup();
                if (!cacheGroupToSlots.ContainsKey(currentGroup))
                {
                    return;
                }
                List <InventorySlot> slots = cacheGroupToSlots[currentGroup];

                for (int i = 0, length = groups.Count; i < length; i++)
                {
                    InventoryGroup group = groups[i];
                    if (group.GetName() == currentGroup)
                    {
                        weaponGroup = i;
                        slots       = group.GetInventorySlots();
                        break;
                    }
                }

                if (slots != null)
                {
                    int s_length = slots.Count;
                    for (int i = 0; i < s_length; i++)
                    {
                        InventorySlot slot = slots[i];
                        if (slot.GetKey() == currentWeaponKey)
                        {
                            weaponIndex = i;
                        }
                    }
                    if (sign == 1)
                    {
                        if (weaponIndex - 1 >= 0)
                        {
                            KeyCode acivateKey = slots[weaponIndex - 1].GetKey();
                            if (acivateKey != currentWeaponKey)
                            {
                                ActivateWeapon(acivateKey);
                            }
                            return;
                        }
                        else if (weaponIndex - 1 < 0 && groups.Count == 1)
                        {
                            KeyCode acivateKey = slots[slots.Count - 1].GetKey();
                            if (acivateKey != currentWeaponKey)
                            {
                                ActivateWeapon(acivateKey);
                            }
                            return;
                        }
                        else if (weaponIndex - 1 < 0 && weaponGroup - 1 < 0)
                        {
                            List <InventorySlot> _slots = groups[groups.Count - 1].GetInventorySlots();
                            for (int i = 0, length = _slots.Count; i < length; i++)
                            {
                                InventorySlot slot = _slots[i];
                                if (slot.GetWeapon() != null)
                                {
                                    ActivateWeapon(slot.GetKey());
                                    return;
                                }
                            }
                        }
                        else if (weaponIndex - 1 < 0 && weaponGroup - 1 >= 0)
                        {
                            List <InventorySlot> _slots = groups[weaponGroup - 1].GetInventorySlots();
                            for (int i = 0, length = _slots.Count; i < length; i++)
                            {
                                InventorySlot slot = _slots[i];
                                if (slot.GetWeapon() != null)
                                {
                                    ActivateWeapon(slot.GetKey());
                                    return;
                                }
                            }
                        }
                    }
                    else if (sign == -1)
                    {
                        if (weaponIndex + 1 <= slots.Count - 1)
                        {
                            KeyCode acivateKey = slots[weaponIndex + 1].GetKey();
                            if (acivateKey != currentWeaponKey)
                            {
                                ActivateWeapon(acivateKey);
                            }
                            return;
                        }
                        else if (weaponIndex + 1 > (slots.Count - 1) && groups.Count == 1)
                        {
                            KeyCode acivateKey = slots[0].GetKey();
                            if (acivateKey != currentWeaponKey)
                            {
                                ActivateWeapon(acivateKey);
                            }
                            return;
                        }
                        else if (weaponIndex + 1 > (slots.Count - 1) && weaponGroup + 1 < (groups.Count - 1))
                        {
                            List <InventorySlot> _slots = groups[0].GetInventorySlots();
                            for (int i = 0, length = _slots.Count; i < length; i++)
                            {
                                InventorySlot slot = _slots[i];
                                if (slot.GetWeapon() != null)
                                {
                                    ActivateWeapon(slot.GetKey());
                                    return;
                                }
                            }
                        }
                        else if (weaponIndex + 1 > (slots.Count - 1) && weaponGroup + 1 <= (groups.Count - 1))
                        {
                            List <InventorySlot> _slots = groups[weaponGroup + 1].GetInventorySlots();
                            for (int i = 0, length = _slots.Count; i < length; i++)
                            {
                                InventorySlot slot = _slots[i];
                                if (slot.GetWeapon() != null)
                                {
                                    ActivateWeapon(slot.GetKey());
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            else if (currentWeaponKey == KeyCode.None)
            {
                List <InventorySlot> _slots = groups[0].GetInventorySlots();
                for (int i = 0, _s_length = _slots.Count; i < _s_length; i++)
                {
                    InventorySlot _slot = _slots[i];
                    if (_slot.GetWeapon() != null)
                    {
                        ActivateWeapon(_slot.GetKey());
                        break;
                    }
                }
            }
        }
 private void Start()
 {
     UInput  = FindObjectOfType <UInput>();
     Spawner = FindObjectOfType <ObjectSpawner>();
 }
Example #23
0
    public override void SlowUpdate()
    {
        base.SlowUpdate();

        ski.Update();
        if (Input.GetKeyDown(KeyCode.F12))
        {
            ui.ShowHide();
        }
        if (Input.GetMouseButtonDown(3))
        {
            if (lockCamera)
            {
                watcher.sensetive = Vector2.one;
            }
            lockCamera = !lockCamera;
        }
        if (lockCamera)
        {
            SetAim(new Vector2(Mathf.Clamp(aimPoint.x + UInput.RotateX() * .02f / Screen.width * Screen.height, .1f, .9f), Mathf.Clamp(aimPoint.y + UInput.RotateY() * -.02f / Screen.height * Screen.width, .1f, .9f)));
            watcher.sensetive = new Vector2(Mathf.Abs(aimPoint.x - .5f) / .4f, Mathf.Abs(aimPoint.y - .5f) / .4f);
            watcher.sensetive = Vector2.Scale(watcher.sensetive, watcher.sensetive);
        }

        bFire   = UInput.Fire() != 0 || everyTimeFire;
        bRotate = UInput.Fire2() != 0 || everyTimeRotate;

        watcher.Update(); // rotate camera manually because else it does bad
        ui.Update();      // Same reason as ^
        moveDirection = camera.transform.rotation;

        firePoints.Clear();

        var point = new Vector3(Screen.width * aimPoint.x, Screen.height * aimPoint.y);

        var ray = camera.ScreenPointToRay(point);

        Debug.DrawRay(ship.tempTransform.position, BattleBehaviour.current.navigation.GetMovePoint(ship.tempTransform.position, ship.tempTransform.position + ray.direction * 10000) - ship.tempTransform.position, Color.blue);
        RaycastHit hit;

        if (Physics.SphereCastAll(ray, 10f, 100000).WithMin(h => (h.point - camera.transform.position).sqrMagnitude, h => !ShipIdentification.IsThisShip(h.transform, ship), out hit))
        {
            float distance = Vector3.Distance(hit.point, ship.transform.position);
            if (UInput.Fire() != 0)
            {
                firePoints.AddPoint(hit.point);
            }
            var si = hit.transform.GetComponentInParent <ShipIdentification>();
            if (si != null)
            {
                var s = si.ship;

                if (!s.alive)
                {
                    ui.GetAim().SetTarget(AimTarget.Neutral, distance);
                }
                else if (s.team != ship.team)
                {
                    ui.GetAim().SetTarget(AimTarget.Enemy, distance);
                    if (Input.GetKeyDown(KeyCode.Space))
                    {
                        lockedEnemy = s;
                    }
                }
                else
                {
                    ui.GetAim().SetTarget(AimTarget.Friend, distance);
                }
            }
            else
            {
                ui.GetAim().SetTarget(AimTarget.Neutral, distance);
            }
        }
        else
        {
            ui.GetAim().SetTarget(AimTarget.None, 0);
        }

        if (lockedEnemy != null && lockedEnemy.alive)
        {
            firePoints.AddPoint(lockedEnemy.tempTransform.position);
        }
        uiBehaviour.targetView.SetTargets(firePoints.GetFirePoints().Select(p => p.point));

        SetAim();


        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            everyTimeFire = !everyTimeFire;
        }
        if (Input.GetKeyDown(KeyCode.LeftAlt))
        {
            everyTimeRotate = !everyTimeRotate;
        }
    }