Exemple #1
0
 void AddSteps(BeginPos Pos, ref int Count, ref bool Isfinish)
 {
     Count++;
     Steps.Add(new BeginPos());
     Steps[Count] = Pos;
     Isfinish     = false;
 }
Exemple #2
0
    bool CheckisSame(BeginPos Pos)
    {
        bool isSame = false;

        for (int i = 0; i < Steps.Count; i++)
        {
            if (Pos.IndexPosX == Steps[i].IndexPosX && Pos.IndexPosZ == Steps[i].IndexPosZ)
            {
                isSame = true;
                break;
            }
        }

        return(isSame);
    }
Exemple #3
0
    public override void ResetPlayerPos()
    {
        bool r = IM.Random.value < IM.Number.half;

        Team leftTeam = null;

        if (m_offenseTeam != null)
        {
            leftTeam = m_offenseTeam;
        }
        else
        {
            leftTeam = m_homeTeam;
        }

        foreach (Player member in leftTeam.members)
        {
            BeginPos beginPos = GameSystem.Instance.MatchPointsConfig.BeginPos;
            if (member.m_bWithBall)
            {
                member.position = beginPos.offenses_transform[0].position;
                if (member.m_defenseTarget != null)
                {
                    member.m_defenseTarget.position = beginPos.defenses_transform[0].position;
                }
            }
            else
            {
                member.position = beginPos.offenses_transform[r ? 1 : 2].position;
                if (member.m_defenseTarget != null)
                {
                    member.m_defenseTarget.position = beginPos.defenses_transform[r ? 1 : 2].position;
                }
                r = !r;
            }
        }

        foreach (Player player in GameSystem.Instance.mClient.mPlayerManager)
        {
            if (player.m_defenseTarget == null)
            {
                player.forward = IM.Vector3.forward;
                continue;
            }
            player.FaceTo(player.m_defenseTarget.position);
        }
    }
    private void OnGrab(UBasketball ball)
    {
        if (m_stateMachine.m_curState != null && m_stateMachine.m_curState.m_eState == MatchState.State.ePlaying)
        {
            BeginPos beginPos = GameSystem.Instance.MatchPointsConfig.BeginPos;
            if (mainRole.m_team.m_role == MatchRole.eOffense)
            {
                if (ball.m_owner != mainRole)                   //球被对方抢了
                {
                    mainRole.m_inputDispatcher.m_enable = false;
                    //mainRole.m_aiMgr = mainRolePositioningAISystem;
                    if (mainRole.m_aiAssist != null)
                    {
                        mainRole.m_aiAssist.Disable();
                    }
                    mainRoleAIState.moveTarget = beginPos.defenses_transform[0].position;
                    //npc.m_aiMgr = npcPositioningAISystem;
                    npcAIState.moveTarget = beginPos.offenses_transform[0].position;
                    m_inPositioning       = true;
                    m_ruler.SwitchRole();
                    m_needSwitchRole = false;

                    mainRoleAIState.arrived = false;
                    npcAIState.arrived      = false;

                    ShowAnimTip("gameInterface_text_ChangeBall");
                    timerReset.SetTimer(new IM.Number(6));
                    timerReset.stop = false;
                }
                else if (m_criticalShoot)                       //球被自己抢了,但已经是绝杀球
                {
                    m_stateMachine.SetState(MatchState.State.eFoul);
                }
            }
            else if (mainRole.m_team.m_role == MatchRole.eDefense)
            {
                if (ball.m_owner == mainRole)                 //球被对方抢了
                {
                    mainRole.m_inputDispatcher.m_enable = false;
                    //mainRole.m_aiMgr = mainRolePositioningAISystem;
                    if (mainRole.m_aiAssist != null)
                    {
                        mainRole.m_aiAssist.Disable();
                    }
                    mainRoleAIState.moveTarget = beginPos.offenses_transform[0].position;
                    //npc.m_aiMgr = npcPositioningAISystem;
                    npcAIState.moveTarget = beginPos.defenses_transform[0].position;
                    m_inPositioning       = true;
                    m_ruler.SwitchRole();
                    m_needSwitchRole = false;

                    mainRoleAIState.arrived = false;
                    npcAIState.arrived      = false;

                    ShowAnimTip("gameInterface_text_ChangeBall");
                    timerReset.SetTimer(new IM.Number(6));
                    timerReset.stop = false;
                }
                else if (m_criticalShoot)                       //球被自己抢了,但已经是绝杀球
                {
                    m_stateMachine.SetState(MatchState.State.eFoul);
                }
            }
        }
    }
Exemple #5
0
    public void SetFindObj()
    {
        int StepCount = 0;

        Steps.Add(HolePos);
        bool isFinish = false;

        while (true)
        {
            isFinish = true;
            if (Steps[StepCount].IndexPosX + 1 < GameManager.ins.grassSpawner.Grass[Steps[StepCount].IndexPosZ].Count)
            {
                if (GameManager.ins.grassSpawner.Grass[Steps[StepCount].IndexPosZ][Steps[StepCount].IndexPosX + 1].tag == GameManager.stringTag.NullCamp.ToString())
                {
                    BeginPos NewPos = new BeginPos();
                    NewPos.IndexPosX = Steps[StepCount].IndexPosX + 1;
                    NewPos.IndexPosZ = Steps[StepCount].IndexPosZ;
                    Steps.Add(NewPos);
                    break;
                }
                else if (GameManager.ins.grassSpawner.Grass[Steps[StepCount].IndexPosZ][Steps[StepCount].IndexPosX + 1].tag == GameManager.stringTag.Stone.ToString())
                {
                    BeginPos NewPos = new BeginPos();
                    NewPos.IndexPosX = Steps[StepCount].IndexPosX + 1;
                    NewPos.IndexPosZ = Steps[StepCount].IndexPosZ;
                    bool isSame = CheckisSame(NewPos);

                    if (!isSame)
                    {
                        AddSteps(NewPos, ref StepCount, ref isFinish);
                    }
                }
            }


            if (Steps[StepCount].IndexPosX - 1 >= 0)
            {
                if (GameManager.ins.grassSpawner.Grass[Steps[StepCount].IndexPosZ][Steps[StepCount].IndexPosX - 1].tag == GameManager.stringTag.NullCamp.ToString())
                {
                    BeginPos NewPos = new BeginPos();
                    NewPos.IndexPosX = Steps[StepCount].IndexPosX - 1;
                    NewPos.IndexPosZ = Steps[StepCount].IndexPosZ;
                    Steps.Add(NewPos);
                    break;
                }
                else if (GameManager.ins.grassSpawner.Grass[Steps[StepCount].IndexPosZ][Steps[StepCount].IndexPosX - 1].tag == GameManager.stringTag.Stone.ToString())
                {
                    BeginPos NewPos = new BeginPos();
                    NewPos.IndexPosX = Steps[StepCount].IndexPosX - 1;
                    NewPos.IndexPosZ = Steps[StepCount].IndexPosZ;
                    bool isSame = CheckisSame(NewPos);

                    if (!isSame)
                    {
                        AddSteps(NewPos, ref StepCount, ref isFinish);
                    }
                }
            }


            if (Steps[StepCount].IndexPosZ + 1 < GameManager.ins.grassSpawner.Grass.Count)
            {
                if (GameManager.ins.grassSpawner.Grass[Steps[StepCount].IndexPosZ + 1][Steps[StepCount].IndexPosX].tag == GameManager.stringTag.NullCamp.ToString())
                {
                    BeginPos NewPos = new BeginPos();
                    NewPos.IndexPosX = Steps[StepCount].IndexPosX;
                    NewPos.IndexPosZ = Steps[StepCount].IndexPosZ + 1;
                    Steps.Add(NewPos);
                    break;
                }
                if (GameManager.ins.grassSpawner.Grass[Steps[StepCount].IndexPosZ + 1][Steps[StepCount].IndexPosX].tag == GameManager.stringTag.Stone.ToString())
                {
                    BeginPos NewPos = new BeginPos();
                    NewPos.IndexPosX = Steps[StepCount].IndexPosX;
                    NewPos.IndexPosZ = Steps[StepCount].IndexPosZ + 1;
                    bool isSame = CheckisSame(NewPos);


                    if (!isSame)
                    {
                        AddSteps(NewPos, ref StepCount, ref isFinish);
                    }
                }
            }


            if (Steps[StepCount].IndexPosZ - 1 >= 0)
            {
                if (GameManager.ins.grassSpawner.Grass[Steps[StepCount].IndexPosZ - 1][Steps[StepCount].IndexPosX].tag == GameManager.stringTag.NullCamp.ToString())
                {
                    BeginPos NewPos = new BeginPos();
                    NewPos.IndexPosX = Steps[StepCount].IndexPosX;
                    NewPos.IndexPosZ = Steps[StepCount].IndexPosZ - 1;
                    Steps.Add(NewPos);
                    break;
                }
                else if (GameManager.ins.grassSpawner.Grass[Steps[StepCount].IndexPosZ - 1][Steps[StepCount].IndexPosX].tag == GameManager.stringTag.Stone.ToString())
                {
                    BeginPos NewPos = new BeginPos();
                    NewPos.IndexPosX = Steps[StepCount].IndexPosX;
                    NewPos.IndexPosZ = Steps[StepCount].IndexPosZ - 1;
                    bool isSame = CheckisSame(NewPos);


                    if (!isSame)
                    {
                        AddSteps(NewPos, ref StepCount, ref isFinish);
                    }
                }
            }


            if (isFinish)
            {
                break;
            }
        }


        //Debug.Log(GameManager.ins.grassSpawner.Grass[8][4].name);
    }