示例#1
0
    void OnRebound(UBasketball ball)
    {
        ShootSolution.SShootCurve curve = ball.CompleteLastCurve();
        IM.Number ballMaxHeight         = curve.GetHighestPosition().y;
        //Debug.Log("Ball max height: " + ballMaxHeight);
        IM.Number npcReboundBallHeight = AIUtils.GetNPCReboundBallHeight(npcReboundAttr.maxHeight, playerReboundAttr.maxHeight, ballMaxHeight,
                                                                         match.npcHeightScale, match.playerHeightScale, match.ballHeightScale);
        //Debug.Log("NPC rebound ball height: " + npcReboundBallHeight);
        IM.Number time1, time2;
        curve.GetTimeByHeight(npcReboundBallHeight, out time1, out time2);
        IM.Number ballFlyTime = time2;
        //Debug.Log("Ball fly time: " + ballFlyTime);
        if (ballFlyTime < -new IM.Number(0, 1))
        {
            Debug.LogError("Ball fly time error.");
        }

        SkillInstance basicRebound  = m_player.m_skillSystem.GetBasicSkillsByCommand(Command.Rebound)[0];
        string        basicActionId = basicRebound.skill.actions[0].action_id;

        IM.Number frameRate = m_player.animMgr.GetFrameRate(basicActionId);
        Dictionary <string, PlayerAnimAttribute.AnimAttr> rebounds = m_player.m_animAttributes.m_rebound;
        int reboundKey = rebounds[m_player.animMgr.GetOriginName(basicActionId)].GetKeyFrame("OnRebound").frame;

        IM.Number reboundActionTime = reboundKey / frameRate;

        IM.Number reboundDelayTime = ballFlyTime - reboundActionTime;
        if (reboundDelayTime < IM.Number.zero)
        {
            reboundDelayTime = IM.Number.zero;
        }

        if (timerRebound == null)
        {
            timerRebound = new GameUtils.Timer(reboundDelayTime, DoRebound);
        }
        timerRebound.SetTimer(reboundDelayTime);
        timerRebound.stop = false;
    }
示例#2
0
    public void _DrawCurves()
    {
        //draw shoot solution
        ShootSolution solution = mBall.m_shootSolution;

        if (solution == null)
        {
            return;
        }
        if (solution.m_fTime > new IM.Number(1000))
        {
            return;
        }
        _BuildShootCurves();
        int iKeyCount = m_shootCurveKeys.Count;

        for (int idx = 0; idx != iKeyCount; idx++)
        {
            if (idx + 1 >= iKeyCount)
            {
                break;
            }
            if (solution.m_bSuccess)
            {
                Handles.color = Color.red;
            }
            else
            {
                if (ShootSimulator.instance != null && solution == ShootSimulator.instance.m_simulatingShootSolution)
                {
                    Handles.color = Color.red;
                }
                else
                {
                    Handles.color = Color.red;
                }
            }
            Handles.DrawLine(m_shootCurveKeys[idx], m_shootCurveKeys[idx + 1]);
        }

        if (!solution.m_bSuccess)
        {
            int iCurveCnt = solution.m_ShootCurveList.Count;
            if (iCurveCnt == 0)
            {
                return;
            }
            ShootSolution.SShootCurve curve = solution.m_ShootCurveList[iCurveCnt - 1];
            Vector3 vPosHighest             = (Vector3)curve.GetHighestPosition();

            GUIStyle style = new GUIStyle();
            style.normal.textColor = Color.red;
            Handles.Label(vPosHighest, vPosHighest.y.ToString(), style);

            const float    dotLineLength = 0.2f;
            List <Vector3> poly          = new List <Vector3>();
            while (vPosHighest.y > 0.0f)
            {
                poly.Add(vPosHighest);
                vPosHighest.y -= dotLineLength;
                poly.Add(vPosHighest);
                vPosHighest.y -= dotLineLength;
            }

            Handles.color = Color.red;
            Handles.DrawPolyLine(poly.ToArray());
        }
    }