Example #1
0
    public override void Begin()
    {
        if (GameManager.Rules.State == GlobalState.GAMEOVER)
        {
            return;
        }

        //m_Outline.enabled = true;
        BaseUIController.GlobalMask = true;
        DecidedMessage decideMsg = m_Decider.Decide(m_Collector.Collect());

        m_Executor.SetDecision(decideMsg);
    }
Example #2
0
 public void SetDecision(DecidedMessage _msg)
 {
     msg = _msg;
     if (msg.drag)
     {
         if (Random.Range(0, 3) <= 2)
         {
             behaviours.Enqueue(new ExecuteDragThink(msg, player));
         }
         behaviours.Enqueue(new ExecuteDrag(msg, player));
     }
     behaviours.Enqueue(new ExecuteThink(msg, player, Random.Range(1.1f, 1.5f)));
     for (int i = 0; i < 3; i++)
     {
         if (Random.Range(0, 3) <= 2)
         {
             behaviours.Enqueue(new ExecuteAimThink(msg, player));
         }
     }
     behaviours.Enqueue(new ExecuteAim(msg, player));
     behaviours.Enqueue(new ExecuteThink(msg, player));
     behaviours.Enqueue(new ExecuteFire(msg, player));
 }
Example #3
0
 public ExecuteThink(DecidedMessage _msg, AIPlayer _player)
     : base(_msg, _player)
 {
     m_ThinkTime = Random.Range(2, 3);
 }
Example #4
0
 public ExecuteThink(DecidedMessage _msg, AIPlayer _player, float _thinkTime)
     : base(_msg, _player)
 {
     m_ThinkTime = _thinkTime;
 }
Example #5
0
 public ExecuteDragThink(DecidedMessage _msg, AIPlayer _player)
     : base(_msg, _player)
 {
     m_ThinkTime = 0.5f;
 }
Example #6
0
 public ExecuteFire(DecidedMessage _msg, AIPlayer _player)
     : base(_msg, _player)
 {
 }
Example #7
0
 public ExecuteAimThink(DecidedMessage _msg, AIPlayer _player)
     : base(_msg, _player)
 {
     m_ThinkTime = 1;
 }
Example #8
0
 public ExecuteBehaviour(DecidedMessage _msg, AIPlayer _player)
 {
     msg = _msg;
     player = _player;
 }
Example #9
0
        public DecidedMessage Decide(CollectedMessage _cMsg)
        {
            cMsg = _cMsg;
            DecidedMessage dMsg = new DecidedMessage();

            Dictionary<PoolBall, List<PocketTrigger>> considerBalls = GetConsiderBalls();
            List<KeyValuePair<PoolBall, Vector3>> shootableBalls = GetShootableBalls();
            dMsg.drag = GameManager.Rules.State == GlobalState.DRAG_WHITEBALL;
            dMsg.considerBalls = considerBalls;
            dMsg.shootableBalls = shootableBalls;
            PoolBall targetBall;
            PocketTrigger targetPocket;
            if (dMsg.drag)
                dMsg.hitPoint = ConsiderHitPointWithDrag(considerBalls, out dMsg.cueballPosition, out targetBall, out targetPocket);
            else
            {
                dMsg.cueballPosition = Pools.CueBall.GetPosition();
                dMsg.hitPoint = ConsiderHitPoint(considerBalls, dMsg.cueballPosition, out targetBall, out targetPocket);
            }
            if (dMsg.hitPoint != Vector3.zero)
            {
                dMsg.targetBall = targetBall;
                dMsg.targetPocket = targetPocket;
                dMsg.powerScale = ConsiderPowerScale(targetBall, targetPocket, dMsg.hitPoint, dMsg.cueballPosition);
            }
            else
            {
                if(dMsg.shootableBalls.Count != 0)
                {
                    int i = Mathf.Max(Random.Range(0, dMsg.shootableBalls.Count - 1), 0);
                    dMsg.targetBall = dMsg.shootableBalls[i].Key;
                    dMsg.hitPoint = dMsg.shootableBalls[i].Value;
                }
                else//如果目标类型的球无球可打,则随便找一个能打到的球
                {
                    int i = Mathf.Max(Random.Range(0, cMsg.ballList.Count - 1));
                    dMsg.targetBall = cMsg.ballList[i];
                    dMsg.hitPoint = dMsg.targetBall.transform.position;
                }
                int j = Random.Range(0, Pools.PocketTriggers.Count - 1);
                dMsg.targetPocket = Pools.PocketTriggers[j];
                dMsg.cueballPosition = Pools.CueBall.GetPosition();
                dMsg.powerScale = 1;
            }
            if(BaseUIController.Instance.debugAI)
            {
                BaseUIController.Instance.targetBallImage.transform.position = MathTools.World2UI(dMsg.targetBall.transform.position);
                BaseUIController.Instance.targetPocketImage.transform.position = MathTools.World2UI(dMsg.targetPocket.transform.position);
                BaseUIController.Instance.hitPointImage.transform.position = MathTools.World2UI(dMsg.hitPoint);
            }
            if (Random.Range(0, 100) > (int)AIPlayer.difficulty)
            {
                dMsg.hitPoint += new Vector3(Random.Range(-player.m_Deviation, player.m_Deviation), 0, Random.Range(-player.m_Deviation, player.m_Deviation));
            }
            if(BaseUIController.Instance.debugAI)
                BaseUIController.Instance.newHitPointImage.transform.position = MathTools.World2UI(dMsg.hitPoint);
            return dMsg;
        }
Example #10
0
 public void SetDecision(DecidedMessage _msg)
 {
     msg = _msg;
     if(msg.drag)
     {
             if (Random.Range(0, 3) <= 2)
                 behaviours.Enqueue(new ExecuteDragThink(msg, player));
         behaviours.Enqueue(new ExecuteDrag(msg, player));
     }
     behaviours.Enqueue(new ExecuteThink(msg, player, Random.Range(1.1f,1.5f)));
     for (int i = 0; i < 3; i++ )
     {
         if (Random.Range(0, 3) <=2)
             behaviours.Enqueue(new ExecuteAimThink(msg, player));
     }
     behaviours.Enqueue(new ExecuteAim(msg, player));
     behaviours.Enqueue(new ExecuteThink(msg, player));
     behaviours.Enqueue(new ExecuteFire(msg, player));
 }
Example #11
0
 public ExecuteFire(DecidedMessage _msg, AIPlayer _player) : base(_msg, _player)
 {
 }
Example #12
0
 public ExecuteBehaviour(DecidedMessage _msg, AIPlayer _player)
 {
     msg    = _msg;
     player = _player;
 }
Example #13
0
 public ExecuteAimThink(DecidedMessage _msg, AIPlayer _player) : base(_msg, _player)
 {
     m_ThinkTime = 1;
 }
Example #14
0
        public DecidedMessage Decide(CollectedMessage _cMsg)
        {
            cMsg = _cMsg;
            DecidedMessage dMsg = new DecidedMessage();

            Dictionary <PoolBall, List <PocketTrigger> > considerBalls  = GetConsiderBalls();
            List <KeyValuePair <PoolBall, Vector3> >     shootableBalls = GetShootableBalls();

            dMsg.drag           = GameManager.Rules.State == GlobalState.DRAG_WHITEBALL;
            dMsg.considerBalls  = considerBalls;
            dMsg.shootableBalls = shootableBalls;
            PoolBall      targetBall;
            PocketTrigger targetPocket;

            if (dMsg.drag)
            {
                dMsg.hitPoint = ConsiderHitPointWithDrag(considerBalls, out dMsg.cueballPosition, out targetBall, out targetPocket);
            }
            else
            {
                dMsg.cueballPosition = Pools.CueBall.GetPosition();
                dMsg.hitPoint        = ConsiderHitPoint(considerBalls, dMsg.cueballPosition, out targetBall, out targetPocket);
            }
            if (dMsg.hitPoint != Vector3.zero)
            {
                dMsg.targetBall   = targetBall;
                dMsg.targetPocket = targetPocket;
                dMsg.powerScale   = ConsiderPowerScale(targetBall, targetPocket, dMsg.hitPoint, dMsg.cueballPosition);
            }
            else
            {
                if (dMsg.shootableBalls.Count != 0)
                {
                    int i = Mathf.Max(Random.Range(0, dMsg.shootableBalls.Count - 1), 0);
                    dMsg.targetBall = dMsg.shootableBalls[i].Key;
                    dMsg.hitPoint   = dMsg.shootableBalls[i].Value;
                }
                else//如果目标类型的球无球可打,则随便找一个能打到的球
                {
                    int i = Mathf.Max(Random.Range(0, cMsg.ballList.Count - 1));
                    dMsg.targetBall = cMsg.ballList[i];
                    dMsg.hitPoint   = dMsg.targetBall.transform.position;
                }
                int j = Random.Range(0, Pools.PocketTriggers.Count - 1);
                dMsg.targetPocket    = Pools.PocketTriggers[j];
                dMsg.cueballPosition = Pools.CueBall.GetPosition();
                dMsg.powerScale      = 1;
            }
            if (BaseUIController.Instance.debugAI)
            {
                BaseUIController.Instance.targetBallImage.transform.position   = MathTools.World2UI(dMsg.targetBall.transform.position);
                BaseUIController.Instance.targetPocketImage.transform.position = MathTools.World2UI(dMsg.targetPocket.transform.position);
                BaseUIController.Instance.hitPointImage.transform.position     = MathTools.World2UI(dMsg.hitPoint);
            }
            if (Random.Range(0, 100) > (int)AIPlayer.difficulty)
            {
                dMsg.hitPoint += new Vector3(Random.Range(-player.m_Deviation, player.m_Deviation), 0, Random.Range(-player.m_Deviation, player.m_Deviation));
            }
            if (BaseUIController.Instance.debugAI)
            {
                BaseUIController.Instance.newHitPointImage.transform.position = MathTools.World2UI(dMsg.hitPoint);
            }
            return(dMsg);
        }
Example #15
0
 public ExecuteThink(DecidedMessage _msg, AIPlayer _player, float _thinkTime) : base(_msg, _player)
 {
     m_ThinkTime = _thinkTime;
 }
Example #16
0
 public ExecuteThink(DecidedMessage _msg, AIPlayer _player) : base(_msg, _player)
 {
     m_ThinkTime = Random.Range(2, 3);
 }
Example #17
0
 public ExecuteDragThink(DecidedMessage _msg, AIPlayer _player)
     : base(_msg, _player)
 {
     m_ThinkTime = 0.5f;
 }