コード例 #1
0
 private void SelectJump(bool jump, bool shortHop)
 {
     if (!m_Grounded && jump && airHops > 0)
     {
         airHops--;
         fastFall      = false;
         verticalSpeed = dJumpSpeed;
         currentJump   = doubleJump;
     }
     if (m_Grounded && jump)
     {
         airHops       = defaultAirHops;
         airTime       = 0;
         m_Grounded    = false;
         fastFall      = false;
         verticalSpeed = jumpSpeed;
         currentJump   = normalJump;
     }
     if (m_Grounded && shortHop)
     {
         airHops       = defaultAirHops;
         airTime       = 0;
         m_Grounded    = false;
         fastFall      = false;
         verticalSpeed = shortHopSpeed;
         currentJump   = shortHopJump;
     }
 }
コード例 #2
0
 void Start()
 {
     controller      = GetComponent <CharacterController>();
     actions         = GetComponent <PlayerActionController>();
     currentMoveMode = MoveMode.normal;
     currentJumpMode = JumpMode.grounded;
 }
コード例 #3
0
 void Update()
 {
     canMove        = canCharMove();
     inputDirection = new Vector2(Input.GetAxisRaw(HorizontalAxis), Input.GetAxisRaw(VerticalAxis));
     if (controller.isGrounded)
     {
         currentJumpMode = (currentJumpMode == JumpMode.jumpstart) ? JumpMode.jumpstart: JumpMode.grounded;
         currentMoveMode = moveModeFromInput(inputDirection);
         currentVelocity = velocityFromMoveMode(inputDirection);
         currentVelocity = transform.TransformDirection(currentVelocity);
         if (Input.GetButton(Jump))
         {
             if (currentJumpMode != JumpMode.jumpstart && Time.time > lastFallingTime + jumpCoolDown && lastFallingTime != 0)
             {
                 lastJumpPress   = Time.time;
                 currentJumpMode = JumpMode.jumpstart;
             }
         }
         currentVelocity.y -= gravity * Time.deltaTime;
     }
     else
     {
         currentVelocity.y -= gravity * Time.deltaTime;
         currentJumpMode    = (currentVelocity.y > jumpHeight / 2) ? JumpMode.jump : JumpMode.fall;
     }
     if (currentJumpMode == JumpMode.jumpstart && Time.time > lastJumpPress + jumpDelay)
     {
         currentVelocity.y = jumpHeight;
     }
     if (currentJumpMode == JumpMode.fall)
     {
         lastFallingTime = Time.time;
     }
     controller.Move(currentVelocity * Time.deltaTime);
 }//E N D  M E T H O D Update
コード例 #4
0
ファイル: CodeChecker.cs プロジェクト: bencz/Zinnia-lang
        public OnEnterLeaveResult Jump(IdContainer JumpTo, JumpMode Mode = JumpMode.Enter)
        {
            var Common  = Container.GetCommonContainer(JumpTo);
            var TryComm = Container.GetParent <Command>(x =>
                                                        x.Type == CommandType.Try && x.FinallyScope != null, Common);

            if (TryComm != null)
            {
                Container   = TryComm.FinallyScope;
                FinallyJump = new JumpDestination(JumpTo, Mode);
                return(OnEnterLeaveResult.EnterNew);
            }
            else
            {
                Container = JumpTo;
                if (Mode == JumpMode.Enter)
                {
                    return(OnEnterLeaveResult.EnterNew);
                }
                else if (Mode == JumpMode.Leave)
                {
                    return(OnEnterLeaveResult.LeaveNew);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Mode");
                }
            }
        }
コード例 #5
0
 public void Deactivate()
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     if (adornmentMgr != null)
     {
         adornmentMgr.view.LostAggregateFocus -= OnTextViewFocusLost;
     }
     StopListening2Keyboard();
     TryEnableVsVim();
     TryEnableViEmu();
     adornmentMgr?.Reset();
     adornmentMgr   = null;
     activeJumpMode = JumpMode.InvalidMode;
     statusBar.Clear();
 }
コード例 #6
0
        private int JumpIf(JumpMode jumpMode, int[] program, int currentPosition, int opAndModes)
        {
            var mode1 = (opAndModes / 100) % 10 == 0 ? Mode.Position : Mode.Immediate;
            var mode2 = (opAndModes / 1000) % 10 == 0 ? Mode.Position : Mode.Immediate;

            var p1Value = mode1 == Mode.Immediate ? program[++currentPosition] : program[program[++currentPosition]];
            var p2Value = mode2 == Mode.Immediate ? program[++currentPosition] : program[program[++currentPosition]];

            if (
                (jumpMode == JumpMode.NonZero && p1Value == 0) ||
                (jumpMode == JumpMode.Zero && p1Value != 0)
                )
            {
                return(currentPosition);
            }

            return(p2Value - 1);
        }
コード例 #7
0
        private void ExecuteTwoCharJump(object o, EventArgs e)
        {
            ShowNotificationsIfAny();

            activeJumpMode = JumpMode.TwoCharJump;

            textMgr.GetActiveView(1, null, out IVsTextView vsTextView);
            if (vsTextView == null)
            {
                Debug.Fail("MenuItemCallback: could not retrieve current view"); return;
            }

            IWpfTextView wpfTextView = editor.GetWpfTextView(vsTextView);

            if (wpfTextView == null)
            {
                Debug.Fail("failed to retrieve current view"); return;
            }

            #if MEASUREEXECTIME
            var watch2 = System.Diagnostics.Stopwatch.StartNew();
            #endif
            TryDisableVsVim();
            #if MEASUREEXECTIME
            watch2.Stop();
            Trace.WriteLine($"PeasyMotion ExecuteTwoCharJump - TryDisableVsVim: {watch2.ElapsedMilliseconds} ms");
            #endif

            #if MEASUREEXECTIME
            var watch7 = System.Diagnostics.Stopwatch.StartNew();
            #endif
            TryDisableViEmu();
            #if MEASUREEXECTIME
            watch7.Stop();
            Trace.WriteLine($"PeasyMotion ExecuteTwoCharJump - TryDisableViEmu: {watch7.ElapsedMilliseconds} ms");
            #endif

            setStatusBarText("Two character jump activated. Waiting for two keys to execute search >");

            ThreadHelper.ThrowIfNotOnUIThread();
            CreateInputListenerUserQueryPhase(vsTextView, wpfTextView);
            wpfTextView.LostAggregateFocus += OnTextViewFocusLost;
        }
コード例 #8
0
    /// <summary>
    /// Check the different action change buttons
    /// </summary>
    void CheckActionChange()
    {
        // Attack actions
        if (inputManager.SwitchWeaponButton && gameManager.playerAttributes.unlockedAttackActions > 0)
        {
            //
            attackMode = (AttackMode)(int)attackMode + 1;
            attackMode = (attackMode == AttackMode.Count ||
                          (int)attackMode >= gameManager.playerAttributes.unlockedAttackActions) ?
                         (AttackMode)0 : attackMode;

            // TODO: Habrá que trabajar esto con la carga variable
            EnemyAnalyzer.RecalculatePenetration();
        }
        // Defensive actions
        if (inputManager.SwitchDefenseButton && gameManager.playerAttributes.unlockedDefenseActions > 0)
        {
            //
            defenseMode = (DefenseMode)(int)defenseMode + 1;
            defenseMode = (defenseMode == DefenseMode.Count ||
                           (int)defenseMode >= gameManager.playerAttributes.unlockedDefenseActions) ?
                          (DefenseMode)0 : defenseMode;
        }
        // Jump actions
        if (inputManager.SwitchJumpButton && gameManager.playerAttributes.unlockedJumpActions > 0)
        {
            //
            jumpMode = (JumpMode)(int)jumpMode + 1;
            jumpMode = (jumpMode == JumpMode.Count ||
                        (int)jumpMode >= gameManager.playerAttributes.unlockedJumpActions) ?
                       (JumpMode)0 : jumpMode;
        }
        // Sprint actions
        if (inputManager.SwitchSprintButton && gameManager.playerAttributes.unlockedSprintActions > 0)
        {
            //
            sprintMode = (SprintMode)(int)sprintMode + 1;
            sprintMode = (sprintMode == SprintMode.Count ||
                          (int)sprintMode >= gameManager.playerAttributes.unlockedSprintActions) ?
                         (SprintMode)0 : sprintMode;
        }
    }
コード例 #9
0
ファイル: PlayerView.cs プロジェクト: zigaosolin/ludumdare44
    public void SetJumpMode(JumpMode jumpMode)
    {
        switch (jumpMode)
        {
        case JumpMode.InJump:
            spriteRenderer.color = Color.blue;
            SetEmission(inJumpParticles);
            break;

        case JumpMode.Normal:
            spriteRenderer.color = Color.white;
            SetEmission(normalParticles);
            break;

        case JumpMode.WaitingForJumpSequence:
            spriteRenderer.color = Color.yellow;
            SetEmission(waitingForJumpParticles);
            break;
        }
    }
コード例 #10
0
 //始点、終点、射角、シューター番号、色の設定
 public void SetParameter(Vector3 start, Vector3 end, float angle, int shooterNum,
                          JumpMode mode = JumpMode.NormalJump, TargetCategory category = TargetCategory.Connecter, bool isAttackable = false)
 {
     m_start                 = start;
     m_end                   = end;
     m_angle                 = angle;
     m_shooterNum            = shooterNum;
     m_LineRenderer.material = m_Materials[0];
     m_LineRenderer.material.SetColor("_TintColor", m_Colors[(int)mode]);
     m_isCursorActive = (category == TargetCategory.Enemy || category == TargetCategory.JumpableTree);
     if (category == TargetCategory.None || (category == TargetCategory.Enemy && !isAttackable))
     {
         m_LineRenderer.material = m_Materials[1];
         m_LineRenderer.material.SetColor("_TintColor", m_Colors[(int)mode] / 2);
     }
     if (category != TargetCategory.Enemy)
     {
         m_AttackableImage[0].SetActive(false);
         m_AttackableImage[1].SetActive(false);
         return;
     }
     m_AttackableImage[0].SetActive(isAttackable);
     m_AttackableImage[1].SetActive(!isAttackable);
 }
コード例 #11
0
ファイル: Assembler.cs プロジェクト: seeseekey/Structura
 static Int64[] GetJumpInstruction(AdressInterpretation adressInterpretation, JumpCondition jumpCondition, JumpMode jumpMode, Int64 target)
 {
     Int64[] instruction=new Int64[5];
     instruction[0]=0;
     instruction[1]=(Int64)adressInterpretation;
     instruction[2]=(Int64)jumpCondition;
     instruction[3]=(Int64)jumpMode;
     instruction[4]=target;
     return instruction;
 }
コード例 #12
0
ファイル: Player.cs プロジェクト: NHGC20172H02/Game
    //ジャンプ
    private void Jump(Ray ray, RaycastHit hit)
    {
        isFlyable = false;
        bool  jump     = false;
        bool  bodyBlow = false;
        float addLimit = 0;

        //糸を狙うのかどうか
        if (Input.GetKeyUp(KeyCode.K) || Input.GetButtonDown("LB"))
        {
            //m_enemy = null;
            isTargetString = !isTargetString;
            m_AudioSource.PlayOneShot(m_AudioClips[6]);
        }
        if (hit.collider.tag == "Tree")
        {
            var tree = hit.collider.GetComponent <Tree>();
            if (tree.m_SideNumber == m_Shooter.m_SideNumber)
            {
                addLimit = tree.m_TerritoryRate;
            }
        }
        else if (hit.collider.tag == "String")
        {
            var s = hit.collider.GetComponent <StringUnit>();
            addLimit = Vector3.Distance(s.m_PointA, s.m_PointB);
        }

        List <GameObject> jumpable_tree = new List <GameObject>();

        jumpable_tree.Add(m_Enemy);
        foreach (GameObject g in m_trees)
        {
            if (Vector3.Distance(transform.position, g.transform.position) < m_JumpLimit + addLimit &&
                g != m_hitinfo.collider.gameObject)
            {
                jumpable_tree.Add(g);
            }
        }

        if (isTargetString)
        {
            if (!(jump = Physics.Raycast(ray, out jump_target, m_JumpLimit + addLimit, m_NetLayer)))
            {
                jump = Physics.SphereCast(ray, 1f, out jump_target, m_JumpLimit + addLimit, m_StringLayer);
            }
        }
        else
        {
            jump = Physics.Raycast(ray, out jump_target, m_JumpLimit + addLimit, m_TreeLayer);
        }

        if (Input.GetKeyDown(KeyCode.J) || Input.GetButtonDown("RB"))
        {
            m_AudioSource.PlayOneShot(m_AudioClips[5]);
            if (m_jumpableNum == -1)
            {
                m_category = TargetCategory.Enemy;
                m_jumpableNum++;
            }
            else if (jumpable_tree.Count >= m_jumpableNum)
            {
                if (jumpable_tree.Count - 1 == m_jumpableNum)
                {
                    m_category    = TargetCategory.Connecter;
                    m_jumpableNum = -1;
                    m_Prediction.SetActive(false);
                    return;
                }
                else
                {
                    m_category = TargetCategory.JumpableTree;
                    m_jumpableNum++;
                }
            }
        }
        if (Input.GetAxis("Horizontal2") != 0 || Input.GetAxis("Vertical2") != 0)
        {
            m_category    = TargetCategory.Connecter;
            m_jumpableNum = -1;
            m_Prediction.SetActive(false);
            return;
        }
        if (m_category == TargetCategory.Enemy)
        {
            bodyBlow   = true;
            jump       = false;
            m_JumpMode = JumpMode.Bodyblow;
            Vector3 dir = m_Enemy.transform.position - m_center;
            m_CameraPivot.transform.rotation = Quaternion.LookRotation(Vector3.Lerp(m_CameraPivot.transform.forward, dir, 0.1f), Vector3.up);
        }
        else if (m_category == TargetCategory.JumpableTree)
        {
            bodyBlow = false;
            jump     = true;
            if (jumpable_tree.Count > m_jumpableNum)
            {
                Vector3 posY = new Vector3(0, 10f, 0);
                Vector3 dir  = (jumpable_tree[m_jumpableNum].transform.position + posY) - m_center;
                m_CameraPivot.transform.rotation = Quaternion.LookRotation(Vector3.Lerp(m_CameraPivot.transform.forward, dir, 0.1f), Vector3.up);
                Ray   ableRay = new Ray(m_center, dir);
                float dis     = Vector3.Distance(m_center, jumpable_tree[m_jumpableNum].transform.position + posY);
                jump = Physics.Raycast(ableRay, out jump_target, dis, m_TreeLayer);
            }
        }

        if (jump)
        {
            if (hit.collider.gameObject == jump_target.collider.gameObject)
            {
                if (Vector3.Distance(transform.position, jump_target.point) < jumpLower)
                {
                    m_Prediction.SetActive(false);
                    return;
                }
            }
            if (jump_target.transform.tag == "String" || jump_target.transform.tag == "Net")
            {
                if (jump_target.transform.GetComponent <Connecter>().m_SideNumber != m_Shooter.m_SideNumber)
                {
                    return;
                }
            }

            float dis = Vector3.Distance(transform.position, jump_target.point);
            if (dis > m_JumpLimit)
            {
                if (hit.collider.tag == "Tree")
                {
                    m_JumpMode = JumpMode.CapturingJump;
                }
                else if (hit.collider.tag == "String")
                {
                    m_JumpMode = JumpMode.StringJump;
                }
            }
            else
            {
                m_JumpMode = JumpMode.NormalJump;
            }
            //予測線、カーソル表示
            m_Prediction.SetActive(true);
            m_Prediction.SetParameter(transform.position, jump_target.point, m_Angle, m_Shooter.m_SideNumber, m_JumpMode, m_category);
            m_Prediction.Calculation();
            isFlyable = true;
            //ジャンプ
            if (Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown("Jump"))
            {
                m_WindLine.Play();
                m_AudioSource.PlayOneShot(m_AudioClips[4]);
                m_Prediction.SetActive(false);
                TreeRateMinus();
                move_start = transform.position;
                move_end   = jump_target.point;
                m_Animator.SetTrigger("Jump");
                m_Animator.SetBool("IsJump", true);
                m_escapeInterval = 0;
                isFlyable        = false;
                if (m_hitinfo.collider != jump_target.collider)
                {
                    m_treeWaitTime = 0;
                }
                JumpCalculation(move_start, move_end, m_Angle);
                m_StateManager.StateProcassor.State = m_StateManager.JumpTp;
            }
            return;
        }
        else if (bodyBlow)
        {
            //体当たり
            float len          = Vector3.Distance(m_Enemy.transform.position, m_center);
            var   enemy        = m_Enemy.GetComponent <EnemyAI4>();
            Ray   dirRay       = new Ray(m_center + transform.forward, (m_Enemy.transform.position - m_center));
            bool  isAttackable = len < m_JumpLimit && m_hitinfo.collider.gameObject != enemy.nearObj && !Physics.Raycast(dirRay, len - 1f, m_TreeLayer) && enemy.TreeDist();
            m_Prediction.SetActive(true);
            m_Prediction.SetParameter(transform.position, m_Enemy.transform.position, 1f, m_Shooter.m_SideNumber, JumpMode.NormalJump, m_category, isAttackable);
            m_Prediction.Calculation();
            if (isAttackable && (Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown("Jump")))
            {
                //体当たり実行
                m_WindLine.Play();
                m_AudioSource.PlayOneShot(m_AudioClips[4]);
                m_Prediction.SetActive(false);
                if (m_hitinfo.collider.tag == "Tree")
                {
                    m_hitinfo.collider.GetComponent <Tree>().m_TerritoryRate -= JumpDemeritRate;
                }
                move_start = transform.position;
                move_end   = m_Enemy.transform.position;
                m_Animator.SetTrigger("Jump");
                m_Animator.SetBool("IsJump", false);
                m_escapeInterval = 0;
                JumpCalculation(move_start, move_end, m_Angle);
                m_StateManager.StateProcassor.State = m_StateManager.BodyBlow;
            }
            return;
        }
        else if (!jump && Physics.Raycast(ray, m_JumpLimit + 100f, m_TreeLayer))
        {
            //届かない場合の予測線描画
            m_Prediction.SetActive(true);
            m_Prediction.SetParameter(
                transform.position,
                m_Camera.position + m_Camera.forward * (m_JumpLimit + addLimit),
                m_Angle, m_Shooter.m_SideNumber, m_JumpMode, TargetCategory.None);
            m_Prediction.Calculation();
            return;
        }
        m_Prediction.SetActive(false);
        m_Prediction.m_HitStringPoint = Vector3.zero;
        //m_enemy = null;
    }
コード例 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PeasyMotionEdAdornment"/> class.
        /// </summary>
        /// <param name="view">Text view to create the adornment for</param>
        public PeasyMotionEdAdornment(PeasyMotionEdAdornmentCtorArgs args)
        {
            this.jumpLabelKeyArray = GeneralOptions.Instance.AllowedJumpKeys;
#if MEASUREEXECTIME
            var watch0 = System.Diagnostics.Stopwatch.StartNew();
#endif
            jumpMode = args.jumpMode;

            var jumpLabelAssignmentAlgorithm = GeneralOptions.Instance.getJumpLabelAssignmentAlgorithm();
            var caretPositionSensivity       = Math.Min(Int32.MaxValue >> 2, Math.Abs(GeneralOptions.Instance.caretPositionSensivity));


            this.textStructureNavigator = args.textStructNav;

            this.vsTextView = args.vsTextView;
            this.view       = args.wpfView;

            this.layer = view.GetAdornmentLayer("PeasyMotionEdAdornment");
            //this.view.LayoutChanged += this.OnLayoutChanged;

            this.vsSettings = VsSettings.GetOrCreate(view);
            // subscribe to fmt updates, so user can tune color faster if PeasyMotion was invoked
            this.vsSettings.PropertyChanged += this.OnFormattingPropertyChanged;

            this.jumpLabelCachedSetupParams.fontRenderingEmSize = this.view.FormattedLineSource.DefaultTextProperties.FontRenderingEmSize;
            this.jumpLabelCachedSetupParams.typeface            = this.view.FormattedLineSource.DefaultTextProperties.Typeface;
            this.jumpLabelCachedSetupParams.labelFg             = this.vsSettings.JumpLabelFirstMotionForegroundColor;
            this.jumpLabelCachedSetupParams.labelBg             = this.vsSettings.JumpLabelFirstMotionBackgroundColor;
            this.jumpLabelCachedSetupParams.labelFinalMotionFg  = this.vsSettings.JumpLabelFinalMotionForegroundColor;
            this.jumpLabelCachedSetupParams.labelFinalMotionBg  = this.vsSettings.JumpLabelFinalMotionBackgroundColor;
            this.jumpLabelCachedSetupParams.Freeze();

            var jumpWords = new List <JumpWord>();
#if MEASUREEXECTIME
            watch0.Stop();
            Trace.WriteLine($"PeasyMotion Adornment ctor settings, members init, etc: {watch0.ElapsedMilliseconds} ms");
#endif


            if (jumpMode == JumpMode.VisibleDocuments)
            {
                SetupJumpToDocumentTabMode(jumpWords);
            }
            else
            {
                SetupJumpInsideTextViewMode(jumpWords, jumpLabelAssignmentAlgorithm, caretPositionSensivity, args.twoCharSearchJumpKeys);
            }

            if (JumpLabelAssignmentAlgorithm.CaretRelative == jumpLabelAssignmentAlgorithm)
            {
#if MEASUREEXECTIME
                var watch2 = System.Diagnostics.Stopwatch.StartNew();
#endif
                // sort jump words from closest to cursor to farthest
                jumpWords.Sort((a, b) => + a.distanceToCursor.CompareTo(b.distanceToCursor));
#if MEASUREEXECTIME
                watch2.Stop();
                Trace.WriteLine($"PeasyMotion Adornment sort words: {watch2.ElapsedMilliseconds} ms");
#endif
            }

#if MEASUREEXECTIME
            var watch3 = System.Diagnostics.Stopwatch.StartNew();
#endif
            _ = computeGroups(0, jumpWords.Count - 1, (jumpLabelKeyArray), "", jumpWords);

#if MEASUREEXECTIME
            watch3.Stop();
            Trace.WriteLine($"PeasyMotion Adornments group&create: {watch3?.ElapsedMilliseconds} ms");
#endif

#if MEASUREEXECTIME
            Trace.WriteLine($"PeasyMotion Adornments create: {adornmentCreateStopwatch?.ElapsedMilliseconds} ms");
            Trace.WriteLine($"PeasyMotion Adornments UI Elem create: {createAdornmentUIElem?.ElapsedMilliseconds} ms");
            Trace.WriteLine($"PeasyMotion Adornment total jump labels - {jumpWords?.Count}");
            createAdornmentUIElem    = null;
            adornmentCreateStopwatch = null;
#endif

            if (jumpMode == JumpMode.VisibleDocuments)
            {
                SetupJumpToDocumentTabFinalPhase();
            }
        }
コード例 #14
0
ファイル: CodeChecker.cs プロジェクト: bencz/Zinnia-lang
 public JumpDestination(IdContainer Container, JumpMode Mode = JumpMode.Enter)
 {
     this.Container = Container;
     this.Mode      = Mode;
 }
コード例 #15
0
 private void ExecuteSelectTextWordJump(object o, EventArgs e)
 {
     activeJumpMode = JumpMode.SelectTextJump;
     ExecuteCommonJumpCode();
 }
コード例 #16
0
 private void ExecuteLineJumpToWordEnding(object o, EventArgs e)
 {
     activeJumpMode = JumpMode.LineJumpToWordEnding;
     ExecuteCommonJumpCode();
 }
コード例 #17
0
 private void ExecuteJumpToDocTab(object o, EventArgs e)
 {
     activeJumpMode = JumpMode.VisibleDocuments;
     ExecuteCommonJumpCode();
 }
コード例 #18
0
 private void ExecuteJumpToLineBegining(object o, EventArgs e)
 {
     activeJumpMode = JumpMode.LineBeginingJump;
     ExecuteCommonJumpCode();
 }