static int InitState(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        PlayerState_DefenseCross obj = (PlayerState_DefenseCross)LuaScriptMgr.GetNetObjectSelf(L, 1, "PlayerState_DefenseCross");

        obj.InitState();
        return(0);
    }
    void _DoDefenseCross(Player defender)
    {
        PlayerState_DefenseCross state = defender.m_StateMachine.GetState(State.eDefenseCross) as PlayerState_DefenseCross;

        state.targetPos = targetPos;
        state.time      = m_player.animMgr.GetDuration(m_curAction) / m_player.animMgr.GetSpeed(m_curAction) - m_time;
        state.crosser   = m_player;

        state.InitState();
        defender.m_StateMachine.SetState(state);

        m_bDefenderOp = true;
    }
Exemplo n.º 3
0
    //public override bool PreEnter()
    //{
    //	if (m_player.m_vVelocity == Vector3.zero)
    //	{
    //		return false;
    //	}
    //	else
    //	{
    //		Vector3 dirPlayerToBasket = GameUtils.HorizonalNormalized(m_match.mCurScene.mBasket.m_vShootTarget, m_player.position);
    //		float moveAngle = Quaternion.FromToRotation(dirPlayerToBasket, m_player.m_vVelocity).eulerAngles.y;
    //		if (135f < moveAngle && moveAngle < 225f)
    //		{
    //			return false;
    //		}
    //	}
    //	return true;
    //}

    override public void OnEnter(PlayerState lastState)
    {
        base.OnEnter(lastState);

        m_player.forward = GameUtils.HorizonalNormalized(m_basket.m_vShootTarget, m_player.position);

        IM.Vector3 targetPos = GetEndPos();
        Debugger.Instance.DrawSphere("CutInEndPos", (Vector3)targetPos, Color.green);

        Player defender = m_player.GetDefender();

        if (defender != null &&
            (defender.m_StateMachine.m_curState.m_eState == State.eStand ||
             defender.m_StateMachine.m_curState.m_eState == State.eDefense ||
             defender.m_StateMachine.m_curState.m_eState == State.eRun ||
             defender.m_StateMachine.m_curState.m_eState == State.eRush))
        {
            IM.Number crossRate  = CalcCrossRate(m_player, defender);
            bool      sumValue   = random.AdjustRate(ref crossRate);
            IM.Number crossValue = IM.Random.value;
            bool      crossed    = crossValue < crossRate;
            Debugger.Instance.m_steamer.message = "CutIn succeed: " + crossed + " Rate: " + crossRate + " Value: " + crossValue;

            //should use sendmessage
            if (crossed)
            {
                if (sumValue)
                {
                    random.SumValue();
                }
                m_player.mStatistics.SkillUsageSuccess(m_curExecSkill.skill.id, true);
            }
            else
            {
                PlayerState_DefenseCross state = defender.m_StateMachine.GetState(State.eDefenseCross) as PlayerState_DefenseCross;
                state.targetPos = targetPos;
                state.time      = m_player.animMgr.GetDuration(m_curAction) / m_player.animMgr.GetSpeed(m_curAction);
                state.crosser   = m_player;
                state.InitState();
                defender.m_StateMachine.SetState(state);
            }
        }

        m_player.animMgr.Play(m_curAction, true);
    }