Ejemplo n.º 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;
    }