Exemplo n.º 1
0
    /// <summary>
    /// 痉挛复位
    /// </summary>
    /// <param name="Pos">复位点位置</param>
    /// <param name="Speed">复位速度</param>
    /// <param name="Deviation">误差</param>
    /// <returns></returns>
    IEnumerator WaitForSpasmReset(Vector2 Pos, int Speed, int Deviation)
    {
        //如果有痉挛,清除痉挛
        if (CommandFunctions.IsCaution)
        {
            DynaLinkHS.CmdClearAlm();
        }
        float waittime = 0;

        do
        {
            yield return(new WaitForSeconds(0.5f));

            waittime += 0.5f;
            DynaLinkHS.CmdClearAlm();
        }while (CommandFunctions.IsCaution && waittime <= 2f);
        if (waittime > 2)
        {
            Debug.Log("清除痉挛失败");
            CommandFunctions.spasmState = CommandFunctions.SpasmState.Recovering;
            yield break;
        }
        DynaLinkHS.CmdServoOff();
        Ienumerator = CommandFunctions.WaitForResetting(Pos, Speed, Deviation);
        //等待复位到上一个点
        yield return(StartCoroutine(Ienumerator));

        //如果痉挛复位中出现断开连接或者急停,停止复位,并把状态重新切换为在痉挛复位阶段
        if (CommandFunctions.IsEmrgencyStop || !CommandFunctions.IsConnected || CommandFunctions.IsCaution)
        {
            Debug.Log("出现急停或者断开连接,ResettingFailed");
            //把状态重新切换为在痉挛复位阶段
            CommandFunctions.spasmState = CommandFunctions.SpasmState.Recovering;
            yield break;
        }
        if (CommandFunctions.IsFault)
        {
            if (CommandFunctions.IsCaution)
            {
                DynaLinkHS.CmdClearAlm();
            }
        }
        Debug.Log("痉挛复位完成");
        //复位完成,痉挛处理过程结束,切换标志位
        ControlSpasmAgain = false;
        //CommandFunctions.IsSpasmFinished = true;
        CommandFunctions.spasmState = CommandFunctions.SpasmState.NoSpasm;
    }
Exemplo n.º 2
0
    /// <summary>
    /// 游戏结束后复位
    /// </summary>
    /// <param name="Pos">复位点位置</param>
    /// <param name="Speed">复位速度</param>
    /// <param name="Deviation">误差</param>
    /// <returns></returns>
    IEnumerator WaitForEndReset(Vector2 Pos, int Speed, int Deviation)
    {
        //开始等待复位完成
        yield return(StartCoroutine(CommandFunctions.WaitForResetting(Pos, Speed, Deviation)));

        //如果是出现断开连接或者急停或者痉挛,停止复位,等故障清除后重新复位
        if (CommandFunctions.IsEmrgencyStop || !CommandFunctions.IsConnected || CommandFunctions.IsCaution || CommandFunctions.IsPause)
        {
            Debug.Log("出现急停或者断开连接,ResettingFailed");
            CommandFunctions.resettingState = CommandFunctions.ResettingState.EndResetting;
            yield break;
        }
        //复位结束,改变游戏结束复位标志位。
        Debug.Log("ResettingFinished");
        CommandFunctions.resettingState     = CommandFunctions.ResettingState.ResetFinshed;
        CommandFunctions.IsInReset          = false;
        CommandFunctions.IsResetEndFinished = true;
        MainCore.Instance.IsGaming          = false;
    }