Ejemplo n.º 1
0
    public void Update(IM.Number deltaTime)
    {
        if (_animation == null || deltaTime == IM.Number.zero)
        {
            return;
        }

        //更新先前的动画
        foreach (PlayInfo prevInfo in _prevInfos)
        {
            if (!_ignoreCurrent)
            {
                prevInfo.blendWeight -= deltaTime;
            }
            UpdatePlayInfo(prevInfo, deltaTime);
        }
        //移除淡出完成
        List <PlayInfo> recycle = new List <PlayInfo>();

        foreach (PlayInfo playInfo in _prevInfos)
        {
            if (playInfo.blendWeight <= IM.Number.zero)
            {
                recycle.Add(playInfo);
                playInfo.Reset();
            }
        }
        foreach (PlayInfo playInfo in recycle)
        {
            _prevInfos.Remove(playInfo);
        }
        //更新当前动画
        if (_curInfo != null && !_ignoreCurrent)
        {
            UpdatePlayInfo(_curInfo, deltaTime);
            _curInfo.blendWeight = IM.Math.Min(CROSS_FADE_LENGTH, _curInfo.blendWeight + deltaTime);
        }
        _ignoreCurrent = false;

        //更新玩家数据(几个骨骼位置和球的位置)
        if (_player != null)
        {
            UpdatePlayer();
        }
    }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
0
    public int DetectZone(IM.Vector3 pos)
    {
        int zone = 0;

        IM.Vector3 dir = pos - basketCenter;
        dir.y = IM.Number.zero;
        IM.Number radialDist = dir.magnitude;
        IM.Number horiDist   = IM.Math.Abs(pos.x);
        dir.Normalize();
        IM.Number angle         = IM.Vector3.Angle(IM.Vector3.right, dir);
        int       radialSection = ((angle - ANGLE_SEG_SIDE) / ANGLE_SEG).floorToInt + 1;

        Debug.Log("player standing on section: " + radialSection);
        if (radialSection == 0 || radialSection == 4)
        {
            if (horiDist <= HORI_NEAR)
            {
                zone = 1;
            }
            else if (horiDist <= HORI_MIDDLE)
            {
                zone = pos.x > 0 ? 2 : 10;
            }
            else if (horiDist <= HORI_FAR)
            {
                zone = pos.x > 0 ? 3 : 11;
            }
        }
        else if (radialSection == 1 || radialSection == 2 || radialSection == 3)
        {
            if (radialDist <= RADIAL_NEAR)
            {
                zone = 1;
            }
            else if (radialDist <= RADIAL_MIDDLE)
            {
                zone = (radialSection + 1) * 2;
            }
            else if (radialDist <= RADIAL_FAR)
            {
                zone = (radialSection + 1) * 2 + 1;
            }
        }
        return(zone);
    }
Ejemplo n.º 4
0
    virtual public void OnExit()
    {
        m_rotateTo     = RotateTo.eNone;
        m_speed        = IM.Vector3.zero;
        m_accelerate   = IM.Vector3.zero;
        m_turningSpeed = IM.Number.zero;
        m_curExecSkill = null;
        m_time         = IM.Number.zero;

        if (m_onActionDone != null)
        {
            m_onActionDone();
        }

        m_player.m_blockable.Clear();

        m_lstActionId.Clear();
    }
    override public void Update(IM.Number fDeltaTime)
    {
        UBasketball ball = m_match.mCurScene.mBall;

        if (ball != null && ball.m_owner == null && ball.m_ballState != BallState.eUseBall_Pass)
        {
            m_system.SetTransaction(AIState.Type.ePractisePass_TraceBall);
            return;
        }

        if (m_player.m_bWithBall &&
            (!behaviour.in_tutorial || m_match.mainRole.m_StateMachine.m_curState.m_eState == PlayerState.State.eRequireBall))
        {
            m_system.SetTransaction(AIState.Type.ePractisePass_Pass);
        }

        m_timer.Update(fDeltaTime);
    }
Ejemplo n.º 6
0
 virtual protected void _StateGuade(IM.Number fDeltaTime)
 {
     if (!m_match.TimmingOnStarting())
     {
         m_stateMachine.SetState(MatchState.State.ePlaying);
     }
     else
     {
         m_match.ConstrainMovementOnBegin(m_fCurTime);
         IM.Number prepareTime = GameSystem.Instance.mClient.mCurMatch.m_ruler.prepareTime;
         m_fCurTime += fDeltaTime;
         if (m_fCurTime > prepareTime)
         {
             PlaySoundManager.Instance.PlaySound(MatchSoundEvent.ReadyGo);
             m_stateMachine.SetState(MatchState.State.ePlaying);
         }
     }
 }
 void OrientateObjects()
 {
     if (curStep.orientation == null)
     {
         return;
     }
     foreach (KeyValuePair <int, string> pair in curStep.orientation)
     {
         Player     player    = GetPlayer(pair.Key);
         GameObject faceToObj = GetSceneObject(pair.Value);
         //此处只用于PVE,使用从float转换为IM.Number不会有问题
         Vector3   faceToPoint = faceToObj.transform.position;
         IM.Number x           = IM.Number.Raw((int)faceToPoint.x * IM.Math.FACTOR);
         IM.Number y           = IM.Number.Raw((int)faceToPoint.y * IM.Math.FACTOR);
         IM.Number z           = IM.Number.Raw((int)faceToPoint.z * IM.Math.FACTOR);
         player.FaceTo(new IM.Vector3(x, y, z));
     }
 }
Ejemplo n.º 8
0
    public override bool ResetPlayerPos()
    {
        IM.Vector3 basketCenter = match.mCurScene.mBasket.m_vShootTarget;
        basketCenter.y          = IM.Number.zero;
        match.mainRole.position = basketCenter - IM.Vector3.forward * IM.Number.half;
        match.mainRole.forward  = -IM.Vector3.forward;
        IM.Number  angle = IM.Random.Range(new IM.Number(90), new IM.Number(270));
        IM.Vector3 dir   = IM.Quaternion.AngleAxis(angle, IM.Vector3.up) * IM.Vector3.forward;
        attacker.position = basketCenter + dir * new IM.Number(4, 500);

        if (match.mCurScene.mBall.m_owner != null)
        {
            match.mCurScene.mBall.m_owner.DropBall(match.mCurScene.mBall);
        }
        attacker.GrabBall(match.mCurScene.mBall);

        return(true);
    }
Ejemplo n.º 9
0
    public override void Update(IM.Number fDeltaTime)
    {
        base.Update(fDeltaTime);

        CastSkill();

        if (m_player.m_bWithBall)
        {
            Exit();
        }
        else if (m_player.m_StateMachine.m_curState.m_eState == PlayerState.State.ePickAndRoll &&
                 (m_player.m_StateMachine.m_curState as PlayerState_PickAndRoll).m_bOnCollide)
        {
            Exit();
        }

        timer.Update(fDeltaTime);
    }
Ejemplo n.º 10
0
 void OnShoot(UBasketball ball)
 {
     if (ball.m_actor == match.mainRole && !ball.m_isLayup)
     {
         IM.Number distToBasket = GameUtils.HorizonalDistance(match.mainRole.position, match.mCurScene.mBasket.m_vShootTarget);
         if (distToBasket > new IM.Number(9, 150))
         {
             ShowTip(CommonFunction.GetConstString("MATCH_GUIDE_ReviseShootDist"));
         }
         //else
         {
             if (ball.m_actor.shootStrength.rate_adjustment < IM.Number.zero)
             {
                 ShowTip(CommonFunction.GetConstString("MATCH_GUIDE_ReviseShootTimming"));
             }
         }
     }
 }
Ejemplo n.º 11
0
    public Area     GetLayupArea(Player player)
    {
        IM.Vector2 vPlayerPos = player.position.xz;
        GameMatch  match      = GameSystem.Instance.mClient.mCurMatch;

        IM.Number fDistance = GameUtils.HorizonalDistance(match.mCurScene.mBasket.m_vShootTarget, player.position);
        if (InFreeThrowLane(vPlayerPos))
        {
            return(Area.eNear);
        }
        return(Area.eMiddle);

        /*
         * else if( fDistance < player.m_LayupDistance )
         *      return Area.eMiddle;
         * return Area.eInvalid;
         */
    }
Ejemplo n.º 12
0
    override public void OnEnter(PlayerState lastState)
    {
        base.OnEnter(lastState);

        PlayerMovement pm = m_player.mMovements[(int)PlayerMovement.Type.eDefense];

        m_fSpeedDefense = pm.mAttr.m_curSpeed;
        m_turningSpeed  = pm.mAttr.m_TurningSpeed;
        m_lastMoveDir   = -1;

        _GetDefenseAction();

        m_animType = AnimType.N_TYPE_0;

        m_player.animMgr.CrossFade(m_mapAnimType[m_animType], false);

        m_player.m_moveType = MoveType.eMT_Defense;
    }
Ejemplo n.º 13
0
    void _DoCollision_BackBoard(IM.Number fBounceBackboard, ShootSolution.SShootCurve shootCurve, IM.Number fTime, ref IM.Vector3 vecResultPos, ref IM.Vector3 vecResultVel)
    {
        IM.Vector3 vecBallPos = new IM.Vector3(
            shootCurve.fX_a * fTime * fTime + shootCurve.fX_b * fTime + shootCurve.fX_c,
            shootCurve.fY_a * fTime * fTime + shootCurve.fY_b * fTime + shootCurve.fY_c,
            shootCurve.fZ_a * fTime * fTime + shootCurve.fZ_b * fTime + shootCurve.fZ_c);

        IM.Vector3 vecBallVel = new IM.Vector3(
            vecBallVel.x = IM.Number.two * shootCurve.fX_a * fTime + shootCurve.fX_b,
            vecBallVel.y = IM.Number.two * shootCurve.fY_a * fTime + shootCurve.fY_b,
            vecBallVel.z = IM.Number.two * shootCurve.fZ_a * fTime + shootCurve.fZ_b);

        //vecBallVel.x = -0.7f * vecBallVel.x;
        vecBallVel.z = -fBounceBackboard * vecBallVel.z;

        vecResultPos = vecBallPos;
        vecResultVel = vecBallVel;
    }
Ejemplo n.º 14
0
    public GameMatch_BlockStorm(Config config)
        : base(config)
    {
        string[] tokens = gameMode.additionalInfo.Split('&');
        specialBallRate  = IM.Number.Parse(tokens[0]);
        normalBallScore  = int.Parse(tokens[1]);
        specialBallScore = int.Parse(tokens[2]);
        if (!string.IsNullOrEmpty(gameMode.extraLevelInfo))
        {
            tokens            = gameMode.extraLevelInfo.Split('&');
            npcAttackInterval = IM.Number.Parse(tokens[0]);
            oneStarScore      = int.Parse(tokens[1]);
            twoStarScore      = int.Parse(tokens[2]);
            threeStarScore    = int.Parse(tokens[3]);
        }

        GameSystem.Instance.mNetworkManager.ConnectToGS(config.type, "", 1);
    }
Ejemplo n.º 15
0
    public override void Update(IM.Number fDeltaTime)
    {
        base.Update(fDeltaTime);
        if (!m_bActing && m_ball.m_ballState == BallState.eUseBall_Pass &&
            GameUtils.HorizonalDistance(m_ball.m_interceptedPos, m_ball.position) < m_fActDistance)
        {
            m_curAction = m_cachedAction;
            m_player.animMgr.Play(m_curAction, true);
            m_bActing = true;
            m_time    = IM.Number.zero;
        }

        if (m_bActing && m_time > m_fEventTime && !m_bOnEvent)
        {
            m_bOnEvent = true;
            _OnBlock();
        }
    }
Ejemplo n.º 16
0
    bool CrossOver()
    {
        Player defenser = m_player.m_defenseTarget;

        if (defenser != null)
        {
            if (m_player.IsDefended(m_system.AI.devAngleAttacker, m_system.AI.devDistAOD))
            {
                IM.Vector3 dirToMoveTarget = (m_moveTarget - m_player.position).normalized;
                IM.Vector3 vBasket         = m_basket.m_vShootTarget;
                IM.Vector3 dirToBasket     = (vBasket - m_player.position).normalized;

                IM.Number fAngleToMoveTarget            = IM.Vector3.Angle(dirToMoveTarget, m_player.forward);
                IM.Number fAngleBetweenBasketMoveTarget = IM.Vector3.Angle(dirToMoveTarget, dirToBasket);
                IM.Number fDistToBasket = GameUtils.HorizonalDistance(m_player.position, vBasket);
                //if (fAngleToMoveTarget < 45.0f && fAngleBetweenBasketMoveTarget < 60.0f && fDistToBasket > 3.0f)
                if (m_player.m_stamina.m_curStamina >= AI_CrossOver.STAMINA_COST)
                {
                    IM.Number crossOverWeight = new IM.Number(30);
                    switch (m_player.m_position)
                    {
                    case PositionType.PT_PG:
                        crossOverWeight += new IM.Number(50);
                        break;

                    case PositionType.PT_C:
                    case PositionType.PT_PF:
                        crossOverWeight += new IM.Number(20);
                        break;

                    case PositionType.PT_SF:
                    case PositionType.PT_SG:
                        crossOverWeight += new IM.Number(100);
                        break;
                    }
                    m_system.SetTransaction(AIState.Type.eCrossOver, crossOverWeight);
                }
                m_system.SetTransaction(AIState.Type.ePositioning, new IM.Number(20), true);
                m_system.SetTransaction(AIState.Type.eFakeShoot, new IM.Number(10));
                return(true);
            }
        }
        return(false);
    }
Ejemplo n.º 17
0
    override public void OnEnter(PlayerState lastState)
    {
        base.OnEnter(lastState);

        IM.Vector3 dirPasserToCatcher = GameUtils.HorizonalNormalized(m_catcher.position, m_passer.position);
        if (m_bSendMsg)
        {
            m_player.forward = -dirPasserToCatcher;
        }

        m_player.m_enablePickupDetector = false;
        m_player.animMgr.GetRootMotion(m_curAction).Reset();

        m_player.m_enableMovement = false;
        m_player.m_enableAction   = false;

        PlayerAnimAttribute.AnimAttr animAttr = m_player.m_animAttributes.GetAnimAttrById(Command.Interception, m_curAction);
        if (animAttr == null)
        {
            Debug.LogError("Can not find animAttr: " + m_curAction);
        }

        PlayerAnimAttribute.KeyFrame keyFrame = animAttr.GetKeyFrame("OnBlock");
        IM.Number frameRate = m_player.animMgr.GetFrameRate(m_curAction);
        m_fEventTime = keyFrame.frame / frameRate;

        IM.Vector3 ballPosWhenBlocked;
        if (!m_player.GetNodePosition(SampleNode.Ball, m_curAction, m_fEventTime, out ballPosWhenBlocked))
        {
            Debug.LogError("Can not get bone position");
        }

        Debugger.Instance.DrawSphere("block", (Vector3)ballPosWhenBlocked, Color.yellow);

        m_fActDistance = m_passer.m_speedPassBall * m_fEventTime;
        m_bOnEvent     = false;
        m_bActing      = false;

        m_cachedAction = m_curAction;
        m_curAction    = "";

        Debug.Log("animType: " + m_animType);
        ++m_player.mStatistics.data.interception;
    }
Ejemplo n.º 18
0
    IM.Vector3 GetPositionWithOutBall()
    {
        int colomn = RoadPathManager.Instance.m_AngleList.Count;

        IM.Vector2 dirRim2Player = (m_player.position - m_basket.m_rim.center).normalized.xy;
        int        sectorIdx     = 0;
        int        iCol          = 0;

        if (IM.Vector2.Dot(dirRim2Player, IM.Vector2.right) > IM.Number.zero)
        {
            iCol = IM.Random.Range(0, (int)m_player.m_favorSectors.range.x / 2);
        }
        else
        {
            iCol = IM.Random.Range((int)m_player.m_favorSectors.range.x / 2, (int)m_player.m_favorSectors.range.x);
        }

        int iRow = (int)m_player.m_favorSectors.start.y + IM.Random.Range(0, (int)m_player.m_favorSectors.range.y);

        sectorIdx = colomn * iRow + iCol;

        RoadPathManager.Sector sector = RoadPathManager.Instance.m_Sectors[sectorIdx];
        IM.Number dev   = m_system.AI.devFavArea;
        int       count = 0;

        do
        {
            IM.Vector3 pos = new IM.Vector3(sector.center.x + IM.Random.Range(-dev, dev), IM.Number.zero, sector.center.y + IM.Random.Range(-dev, dev));
            sectorIdx = RoadPathManager.Instance.CalcSectorIdx(pos);
        } while (sectorIdx == -1 && count++ < 10);
        if (sectorIdx != -1)
        {
            sector = RoadPathManager.Instance.m_Sectors[sectorIdx];
        }
        else
        {
            Debug.LogError("AI_Positioning, sector(-1). Name:" + m_player.m_name +
                           " SectorIdx:" + sector.idx + " Center:" + sector.center + " Dev:" + dev);
        }
        RoadPathManager.Instance.AddDrawSector(m_player.m_id + "_ToSector", sector);

        return(sector.center.x0z);
    }
Ejemplo n.º 19
0
    public HeightRate GetHeightRange(int sector, IM.Number rate)
    {
        List <HeightRate> rates = GetHeightRates(sector);

        if (rates != null)
        {
            IM.Number totalRate = IM.Number.zero;
            foreach (HeightRate heightRate in rates)
            {
                totalRate += heightRate.rate;
                if (rate < totalRate)
                {
                    return(heightRate);
                }
            }
        }

        return(null);
    }
Ejemplo n.º 20
0
    public void ReadShootSolution()
    {
        string text = ResourceLoadManager.Instance.GetConfigText(name + "shootsolutionset");

        if (text == null)
        {
            Debug.LogError("LoadConfig failed: " + name + "shootsolutionset");
            return;
        }

        //读取以及处理XML文本的类
        XmlDocument xmlDoc = CommonFunction.LoadXmlConfig(name + "shootsolutionset", text);
        //解析xml的过程
        XmlNode root = xmlDoc.ChildNodes[0];

        if (root == null)
        {
            return;
        }

        //ShootSolutionData shootSolutionData = new ShootSolutionData();
        //解析xml的过程
        XmlNodeList nodelist = xmlDoc.SelectNodes("root/distance_range/distance");

        foreach (XmlElement elem in nodelist)
        {
            IM.Number distance = IM.Number.Parse(elem.InnerText);
            shootSolutionData.distanceList.Add(distance);
        }

        nodelist = xmlDoc.SelectNodes("root/angle_range/angle");
        foreach (XmlElement elem in nodelist)
        {
            IM.Number fAngle = IM.Number.Parse(elem.InnerText);
            shootSolutionData.angleList.Add(fAngle);
        }

        for (int i = 0; i < 36; i++)
        {
            string path = string.Format("shoot_{0}", i);
            ReadShootSolutionSector(i, path);
        }
    }
Ejemplo n.º 21
0
 public IM.Number CalcReductionIndex(IM.Vector3 pos, Type type)
 {
     IM.Number dis   = IM.Number.zero;
     IM.Number index = IM.Number.one;
     dis = (pos.magnitude - new IM.Number(1, 900) < 1) ? IM.Number.one : (pos.magnitude - new IM.Number(1, 900));
     if (type == Type.Layup)
     {
         index = dis / 100 * dis * new IM.Number(0, 200);
     }
     else if (type == Type.Shoot)
     {
         index = dis / 100 * dis * new IM.Number(0, 500);
     }
     else
     {
         index = IM.Number.one;
     }
     return(index);
 }
Ejemplo n.º 22
0
    public Zone GetStateByPos(IM.Vector3 defTargetPos, IM.Number devAngle, IM.Number devDist)
    {
        Zone tmpZone = Zone.eInvalid;

        GameMatch match = GameSystem.Instance.mClient.mCurMatch;

        if (match == null)
        {
            return(tmpZone);
        }
        if (match.mCurScene == null)
        {
            return(tmpZone);
        }

        IM.Vector3 vDirToBasket    = GameUtils.HorizonalNormalized(match.mCurScene.mBasket.m_vShootTarget, owner.position);
        IM.Vector3 vDirPlayerToDef = GameUtils.HorizonalNormalized(defTargetPos, owner.position);

        IM.Number fAngle = IM.Vector3.Angle(vDirPlayerToDef, vDirToBasket);
        fAngle *= (IM.Number.one - devAngle);
        if (fAngle > angle * IM.Number.half)
        {
            tmpZone = Zone.eInvalid;
        }
        else
        {
            IM.Number distPlayerToDef = GameUtils.HorizonalDistance(defTargetPos, owner.position);
            distPlayerToDef *= (IM.Number.one - devDist);
            if ((bestDefenseRadius < distPlayerToDef) && (distPlayerToDef < validDefenseRadius))
            {
                tmpZone = Zone.eValid;
            }
            else if (distPlayerToDef < bestDefenseRadius)
            {
                tmpZone = Zone.eBest;
            }
            else
            {
                tmpZone = Zone.eInvalid;
            }
        }
        return(tmpZone);
    }
Ejemplo n.º 23
0
    public void Update(IM.Number fDeltaTime)
    {
        foreach (KeyValuePair <SkillEffect, List <GameObject> > skillEffects in m_skillEffects)
        {
            SkillEffect se = skillEffects.Key;
            if (m_time > (new IM.Number((int)se.startFrame) / m_actionFramerate))
            {
                foreach (GameObject goEffects in skillEffects.Value)
                {
                    if (se.moveWithTagPoint == 1)
                    {
                        if (se.spawned)
                        {
                            continue;
                        }
                        GameObject goEffect = GameObject.Instantiate(goEffects) as GameObject;
                        goEffect.transform.localScale = Vector3.one;
                        goEffect.transform.rotation   = Quaternion.identity;
                        goEffect.transform.position   = goEffects.transform.position;

                        goEffect.AddComponent <UEffectSelfDestroy>();

                        goEffect.SetActive(true);
                        se.spawned = true;
                    }
                    else
                    {
                        goEffects.SetActive(true);
                    }
                }
            }
            if (m_time > (new IM.Number((int)se.endFrame) / m_actionFramerate))
            {
                foreach (GameObject goEffects in skillEffects.Value)
                {
                    goEffects.SetActive(false);
                }
            }
        }


        m_time += fDeltaTime;
    }
Ejemplo n.º 24
0
    void _BuildShootCurves()
    {
        m_shootCurveKeys.Clear();

        if (mBall.m_shootSolution != null)
        {
            mBall.m_shootSolution.m_vStartPos = mBall.position;
        }

        IM.Number  fTime = IM.Number.zero;
        IM.Number  fStep = new IM.Number(0, 01);
        IM.Vector3 curPos;

        while (mBall.m_shootSolution.GetPosition(fTime, out curPos))
        {
            m_shootCurveKeys.Add((Vector3)curPos);
            fTime += fStep;
        }
    }
Ejemplo n.º 25
0
    virtual public void OnEnter(PlayerState lastState)
    {
        m_rotateTo     = RotateTo.eNone;
        m_rotateType   = RotateType.eDirect;
        m_speed        = IM.Vector3.zero;
        m_accelerate   = IM.Vector3.zero;
        m_turningSpeed = IM.Number.zero;
        m_bMoveForward = true;

        m_playbackSpeed = IM.Number.one;

        m_curExecSkill = m_player.m_toSkillInstance;
        if (m_curExecSkill != null)
        {
            m_player.m_stamina.ConsumeStamina(new IM.Number((int)m_curExecSkill.skill.levels[m_curExecSkill.level].stama));
        }

        m_time = IM.Number.zero;
    }
Ejemplo n.º 26
0
    /**消耗体力*/
    public bool     ConsumeStamina(IM.Number value)
    {
        if (IM.Number.Approximately(value, IM.Number.zero))
        {
            return(false);
        }
        IM.Number imValue = value;
        if (m_curStamina < imValue)
        {
            return(false);
        }

        m_curStamina     -= imValue;
        m_curStamina      = IM.Math.Clamp(m_curStamina, IM.Number.zero, m_maxStamina);
        m_recover         = false;
        m_recoverWaitTime = IM.Number.zero;

        return(true);
    }
Ejemplo n.º 27
0
 virtual public void LateUpdate(IM.Number fDeltaTime)
 {
     /*
      * //TODO 这段代码不知道什么意思,待探讨
      *      if( !m_player.m_bOnGround )
      *      {
      *              IM.Number fDelta = new IM.Number((m_player.m_pelvis.position.y - m_player.model.root.position.y)) * (IM.Number.one / m_player.scale.y - IM.Number.one);
      *              m_player.model.root.position += (IM.Vector3.up * fDelta).ToUnity();
      *
      *              //m_player.m_pelvis.position = new Vector3( m_player.m_pelvis.position.x, m_player.m_pelvis.position.y / m_player.localScale.y, m_player.m_pelvis.position.z );
      *              //m_player.m_ballSocket.position = new Vector3( m_player.m_ballSocket.position.x, m_player.m_ballSocket.position.y / m_player.localScale.y, m_player.m_ballSocket.position.z );
      *      }
      *      else
      *      {
      *              IM.Vector3 vPos = new IM.Vector3(m_player.gameObject.transform.position);
      *              m_player.gameObject.transform.position = new IM.Vector3(vPos.x, IM.Number.zero, vPos.z).ToUnity();
      *      }
      */
 }
Ejemplo n.º 28
0
    public bool CanIntercept(SkillInstance intercept, Player passer, Player catcher, out IM.Vector3 ballPosWhenIntercepted)
    {
        ballPosWhenIntercepted = IM.Vector3.zero;

        PlayerState.State curState = m_player.m_StateMachine.m_curState.m_eState;
        if (curState != State.eRun && curState != State.eStand && curState != State.eDefense && curState != State.eRush)
        {
            return(false);
        }

        IM.Vector3 dirPasserToCatcher = GameUtils.HorizonalNormalized(catcher.position, passer.position);
        IM.Vector3 dirOriginFace      = m_player.forward;

        m_player.forward = -dirPasserToCatcher;

        string action = _ParseAction(intercept.curAction.action_id, intercept.matchedKeyIdx);

        PlayerAnimAttribute.AnimAttr animAttr = m_player.m_animAttributes.GetAnimAttrById(Command.Interception, action);
        if (animAttr == null)
        {
            Debug.LogError("Can not find animAttr: " + m_curAction);
        }

        PlayerAnimAttribute.KeyFrame keyFrame = animAttr.GetKeyFrame("OnBlock");
        IM.Number frameRate          = m_player.animMgr.GetFrameRate(action);
        IM.Number fEventTime         = keyFrame.frame / frameRate;
        IM.Number fBallFlyDistance   = passer.m_speedPassBall * fEventTime;
        IM.Number fDistPlayer2Passer = GameUtils.HorizonalDistance(passer.position, m_player.position);
        if (fDistPlayer2Passer < fBallFlyDistance)
        {
            m_player.forward = dirOriginFace;
            return(false);
        }

        if (!m_player.GetNodePosition(SampleNode.Ball, action, fEventTime, out ballPosWhenIntercepted))
        {
            m_player.forward = dirOriginFace;
            return(false);
        }

        m_player.forward = dirOriginFace;
        return(true);
    }
Ejemplo n.º 29
0
    public override void GameUpdate(IM.Number deltaTime)
    {
        base.GameUpdate(deltaTime);

        if (uiMatch != null)
        {
            if (m_stateMachine.m_curState != null && m_stateMachine.m_curState.m_eState == MatchState.State.ePlaying)
            {
                m_gameMatchCountStop = false;
            }
            else
            {
                m_gameMatchCountStop = true;
            }
        }

        if (firstTime &&
            m_stateMachine.m_curState != null && m_stateMachine.m_curState.m_eState == MatchState.State.ePlaying &&
            !shooter.m_bWithBall && shooter.m_StateMachine.m_curState.m_eState == PlayerState.State.eStand)
        {
            FetchBall(shooter);
            firstTime = false;
        }

        //TODO 针对PVP修改
        if (mainRole != null && npc != null)
        {
            if (refreshOnReboundOver &&
                mainRole.m_StateMachine.m_curState.m_eState != PlayerState.State.eRebound &&
                npc.m_StateMachine.m_curState.m_eState != PlayerState.State.eRebound)
            {
                Refresh();
            }
        }
        //添加倒计时相关的代码
        if (m_gameMathCountTimer != null && !m_gameMatchCountStop && m_gameMathCountEnable)
        {
            if (uiMatch != null)
            {
                uiMatch.timerBoard.UpdateTime((float)m_gameMathCountTimer.Remaining());
            }
        }
    }
Ejemplo n.º 30
0
        public IM.Vector3 GetPosition(IM.Number fEclipseTime)
        {
            if (fEclipseTime < IM.Number.zero)
            {
                fEclipseTime = IM.Number.zero;
            }

            if (fEclipseTime > fTime)
            {
                fEclipseTime = fTime;
            }

            IM.Vector3 vecBallPos = new IM.Vector3(
                fX_a * fEclipseTime * fEclipseTime + fX_b * fEclipseTime + fX_c,
                fY_a * fEclipseTime * fEclipseTime + fY_b * fEclipseTime + fY_c,
                fZ_a * fEclipseTime * fEclipseTime + fZ_b * fEclipseTime + fZ_c);

            return(vecBallPos);
        }