コード例 #1
0
        public void Action(MyAI _player)
        {
            if (this.NPNumber == -1)
            {
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
            }

            if (_player.NavigationPoints[NPNumber].Complete == true)
            {
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
                this.StopMoving();
            }

            if ((this.Location == this.NPoint) &&
                (_player.CurrentTurn > _player.NavigationPoints[NPNumber].StartTurn) &&
                (_player.CurrentTurn < _player.NavigationPoints[NPNumber].EndTurn))
            {
                _player.NavigationPoints[NPNumber].Complete = true;
            }

            if (this.State == NanoBotState.WaitingOrders)
            {
                if (this.Location != this.NPoint)
                {
                    this.MoveTo(NPoint);
                    //this.MoveTo(_player.ePathfinder.FindPath(this.Location,this.NPoint));
                    return;
                }
            }
        }
コード例 #2
0
        public void Action(MyAI _player)
        {
            //NPNumber == -10 означает, что все NavigationObjectives уже выполнены
            if (this.NPNumber == -10)
            {
                this.ForceAutoDestruction();
                return;
            }

            //NPNumber == -1 означает, что навигатор только появился, и ему надо назначить цель
            if (this.NPNumber == -1)
            {
                //this.NPoint = _player.GetNearestUndoneNavPoint(this.Location, ref this.NPNumber);
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
                if (this.NPNumber == -10)
                {
                    this.ForceAutoDestruction();
                    return;
                }
            }

            //Если вдруг обнаруживаем, что цель, к которой идём, уже кем-то посещена, то запрашиваем новую и останавливаемся.
            if (_player.NavigationPoints[NPNumber].Complete == true)
            {
                //this.NPoint = _player.GetNearestUndoneNavPoint(this.Location, ref this.NPNumber);
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
                if (this.NPNumber == -10)
                {
                    this.ForceAutoDestruction();
                    return;
                }
                this.StopMoving();
            }

            //Если мы стоим на цели в нужное время, то помечаем её как выполненную и запрашиваем новую.
            if ((this.Location == this.NPoint) &&
                (_player.CurrentTurn > _player.NavigationPoints[NPNumber].StartTurn) &&
                (_player.CurrentTurn < _player.NavigationPoints[NPNumber].EndTurn))
            {
                _player.NavigationPoints[NPNumber].Complete = true;
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
                if (this.NPNumber == -10)
                {
                    this.ForceAutoDestruction();
                    return;
                }
            }

            //Если мы стоим, причём не на своей текущей цели, то идём к ней самой.
            if (this.State == NanoBotState.WaitingOrders)
            {
                if (this.Location != this.NPoint)
                {
                    //MoveTo(NPoint);
                    MoveTo(_player.ePathfinder.FindPath(this.Location, NPoint));
                    return;
                }
            }
        }