コード例 #1
0
        //This method will only be called when the player is stopped
        public override Action GetAction(Tile CurrentTile)
        {
            Action CurAction = new Action();

            //if (info.AgentStep == true || !(info.StepOn))
            //{
            DSearch.AddNodes(agentX, agentY, CurrentTile._breeze, CurrentTile._stench);
            if (CurrentTile._stench)
            {
            }
            if ((Plan.Peek().Equals(new Action()) || CurrentTile._gold && !hasFound) && (!isSameTile(CurrentTile, LastTile) && !hasFound))
            {
                if (CurrentTile._gold)
                {
                    hasFound = true;
                }

                Plan = DSearch.GetRoute(CurrentTile._gold);
            }
            else if (isSameTile(CurrentTile, LastTile))
            {
                DSearch.CloseNode(agentX, agentY);
                CurAction = StopPlan();
                LastTile  = OlderTile;
            }

            //info.AgentStep = false;
            //}

            //If Action, return it
            if (!Plan.Peek().Equals(new Action()))
            {
                CurAction = Plan.Pop();
                if (CurAction.CurrentCommand != Action.Command.PickUp && !CurAction.IsFiringAction())
                {
                    OlderTile = LastTile;
                    LastTile  = CurrentTile;
                    UpdateLocation(CurAction);
                }
            }


            return(CurAction);
        }