public void ErasePath()
    {
        if(_CurrentIndex == 0)
        {
            _WayPoints = new List<WayPoints>();
            _CurrentDebug = null;
            _CurrentIndex = 0;
            WayPoints pWP = new WayPoints();
            pWP.AddPoint(28.0f,0.0f);
            pWP.AddPoint(26.0f,0.0f);
            pWP.AddPoint(-26.0f,0.0f);
            pWP.AddPoint(-28.0f,0.0f);
            AddWayPoints(pWP);
            _CurrentDebug = _WayPoints[_CurrentIndex];
            return;
        }

        _WayPoints.RemoveAt(_CurrentIndex);

        if(_CurrentIndex > _WayPoints.Count-1)
        {
            _CurrentIndex = _WayPoints.Count-1;
        }

        _CurrentDebug = _WayPoints[_CurrentIndex];
    }
Beispiel #2
0
 void Start()
 {
     wp     = GetComponentInParent <WayPoints>();
     rb     = GetComponent <Rigidbody2D>();
     colBox = GetComponent <BoxCollider2D>();
     audioS = GetComponent <AudioSource>();
 }
 public DialogEditWP(Waypoint_Path_Gen wpg, GMAP gmap, int path_index, int wp_index)
 {
     _wpg      = wpg;
     _gmap     = gmap;
     _wp_index = wp_index;
     _path     = _wpg.PathAt(path_index);
     _wp_list  = _path.waypoints;
     _wp       = _wp_list.ElementAt(wp_index);
     InitializeComponent();
     txtWPIndex.Text        = Convert.ToString(wp_index);
     txtwplat.Text          = Convert.ToString(_wp.lat);
     txtwplon.Text          = Convert.ToString(_wp.lon);
     txtwpalt.Text          = Convert.ToString(_wp.alt);
     txtwphead.Text         = Convert.ToString(_wp.head);
     txtwpcurvesize.Text    = Convert.ToString(_wp.curvesize);
     txtwprotdirection.Text = Convert.ToString(_wp.rotationdir);
     txtwpgimblemode.Text   = Convert.ToString(_wp.gimblemode);
     txtgimblepitch.Text    = Convert.ToString(_wp.gimblepitch);
     trkHeading.Value       = Convert.ToInt16(_wp.head);
     trkCurveSize.Value     = Convert.ToInt16(_wp.curvesize);
     for (int i = 0; i < _wpg.ActionCount(); i++)
     {
         cmbActions.Items.Add(_wpg.ActionAt(i).name);
     }
     cmbActions.SelectedIndex = 0;
 }
Beispiel #4
0
        void Forward(Grid grid, Architech arch)
        {
            WayPoints.Clear();
            //check if can move forward
            Vector2 a_nextLocation = Position;

            Point gridLocation = Grid.ToGridPosition(Position, Grid.GetTileSize);
            Tile  nextTile     = grid.GetTile(new Point(gridLocation.X + 1, gridLocation.Y));

            if (nextTile != null)
            {
                if (nextTile.State != TileStates.Blocked && nextTile.State != TileStates.Immpassable)
                {
                    a_nextLocation = nextTile.Position;
                    WayPoints.Add(new Vector2(Position.X + 64, Position.Y));
                    Ai_States = Ai_States.Moving;
                }

                else
                {
                    Ai_States         = Ai_States.Target;
                    waypointsReached += 15;
                    this.Speed        = norm_speed;
                }
            }

            else
            {
                Ai_States         = Ai_States.Target;
                waypointsReached += 15;
                this.Speed        = norm_speed;
            }
        }
 void Awake()
 {
     player       = GameObject.FindGameObjectWithTag(Tags.player).transform;
     wayPoints    = transform.Find("waypoints").GetComponent <WayPoints> ();
     targetIndex  = wayPoints.points.Length - 2;
     envGenerator = Camera.main.GetComponent <EnvGenrator> ();
 }
    public void Update()
    {
        eulerAngZ = transform.localEulerAngles.z;

        if (target != null)
        {
            Vector2 dir = target.position - transform.position;
            transform.Translate(dir.normalized * EN.speed * Time.deltaTime, Space.World);
        }
        else
        {
            WP     = GameObject.FindWithTag("WayPoints").GetComponent <WayPoints>();
            target = WP.wpoints[0];
        }

        if (Vector2.Distance(transform.position, target.position) <= 0.2f)
        {
            GetNextWaypoint();
        }

        Vector3 dirL  = WP.wpoints[wavepointIndex].position - transform.position;
        float   angle = Mathf.Atan2(dirL.y, dirL.x) * Mathf.Rad2Deg;

        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

        EN.speed = EN.startSpeed;
    }
Beispiel #7
0
    public Vector3 GetNextWayPoint()
    {
        while (true)
        {
            Debug.Log("player.position.z :" + player.position.z);
            // if (waypoints.waypoints[targetWayPointIndex].position.z - player.position.z < 0.5f) {
            if (Vector3.Distance(waypoints.waypoints[targetWayPointIndex].position, player.position) < 1f)
            {
                targetWayPointIndex--;

                if (targetWayPointIndex < 0)
                {
                    targetWayPointIndex = 0;
                    //Destroy(this.gameObject);
                    //Camera.main.SendMessage("UpdateForest", SendMessageOptions.DontRequireReceiver);
                    GameObject forest2 = GameObject.FindGameObjectWithTag("Forest2");
                    waypoints = forest2.transform.Find("wayPoints").GetComponent <WayPoints>();
                    return(waypoints.waypoints[0].position);
                }
            }
            else
            {
                return(waypoints.waypoints[targetWayPointIndex].position);
            }
        }
    }
 private void Awake()
 {
     player       = GameObject.FindWithTag(Tags.player).transform;
     env          = GameObject.FindWithTag(Tags.gameController).GetComponent <EnvGenerate>();
     way          = GetComponentInChildren <WayPoints>();
     currentIndex = way.points.Length - 2;
 }
Beispiel #9
0
    internal override void OptionExtensions_OnLEFTCLICK(bool hold)
    {
        if (!hold)
        {
            if (movingUnitState == OPTIONS.MoveTo)
            {
                MoveToPoint     = MouseEvents.State.Position.AsWorldPointOnMap;
                MovingDirection = MoveToPoint;
                SetKinematic();
                IsMoving = true;

                UNIT.Options.UnlockFocus();
            }
            else if (movingUnitState == OPTIONS.Guard)
            {
                if (UNIT.IsAllied(MouseEvents.State.Position.AsUnitUnderCursor.gameObject))
                {
                    Target      = MouseEvents.State.Position.AsUnitUnderCursor.SetInteracting(this.gameObject);
                    MoveToPoint = Target.transform.position;
                    IsGuarding  = true;
                    UNIT.Options.UnlockAndDestroyFocus();
                }
            }
            else if (movingUnitState == OPTIONS.Patrol)
            {
                WayPoints.Add(MouseEvents.State.Position.AsWorldPointOnMap);
                IsMoving = true;

                UNIT.Options.UnlockAndDestroyFocus();
            }
        }
    }
Beispiel #10
0
        bool CheckTarget(Overseer os)
        {
            if (os.Ais.ContainsKey(target))
            {
                if (os.IsInRange(Corners, target, (float)Stats.Range) && os.Ais[target].Ai_States != Ai_States.Dead)
                {
                    Ai_States = Ai_States.Attacking;
                    return(true);
                }
                else if (os.Ais[target].Ai_States == Ai_States.Dead)
                {
                    Ai_States = Ai_States.Target; keepTarget = !keepTarget; target = new Guid(); projectile.Clear();
                }
                else if (WayPoints.Count == 0 && Ai_States != Ai_States.Moving)
                {
                    Ai_States = Ai_States.Target; keepTarget = !keepTarget;
                }
            }

            else if (Ai_States != Ai_States.Moving)
            {
                Ai_States = Ai_States.Target; target = new Guid(); WayPoints.Clear(); keepTarget = false;
            }

            return(false);
        }
Beispiel #11
0
 public void initializeEverything()
 {
     Commands.initializeCommands();
     PathFindingCore.Utilities.initializeTileExceptionList();
     ExecutionCore.TaskMetaDataHeuristics.initializeToolCostDictionary();
     WayPoints.initializeWaypoints();
 }
Beispiel #12
0
        public Junction(IEnumerable <WayPoint> wayPoints)
        {
            Location            = wayPoints.First().Point;
            WayPoints           = ImmutableList.ToImmutableList(wayPoints);
            ThroughWayPoints    = ImmutableList.ToImmutableList(wayPoints.Where(wayPoint => wayPoint.IsMiddle));
            TerminatedWayPoints = ImmutableList.ToImmutableList(wayPoints.Where(wayPoint => !wayPoint.IsMiddle));

            if (ThroughWayPoints.Count == 0 && TerminatedWayPoints.Count == 2)
            {
                var extraAngle1 = TerminatedWayPoints[0].IsFirst ? Angle.HalfTurn : Angle.Zero;
                var extraAngle2 = TerminatedWayPoints[1].IsLast ? Angle.HalfTurn : Angle.Zero;
                var angleRad    = Angle.Average(
                    Angle.Add(TerminatedWayPoints[0].Point.Angle, extraAngle1),
                    Angle.Add(TerminatedWayPoints[1].Point.Angle, extraAngle2)
                    );
                TerminatedWayPoints[0].Point.Angle = Angle.Add(angleRad, extraAngle1);
                TerminatedWayPoints[1].Point.Angle = Angle.Add(angleRad, extraAngle2);
            }
            else if (WayPoints.All(wp => wp.Way.Tags.GetValueOrDefault("oneway", "no") == "yes"))
            {
                var angleRad = Angle.Average(
                    WayPoints.Select(wp => wp.Point.Angle).ToArray()
                    );
                foreach (var wp in WayPoints)
                {
                    wp.Point.Angle = angleRad;
                }
            }
        }
Beispiel #13
0
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag (Tags.player).transform;
     wayPoints = transform.Find ("waypoints").GetComponent<WayPoints>();
     targetWayPointIndex = wayPoints.points.Length-1;
     envGenerator=Camera.main.GetComponent<EnvGenerator>();
 }
Beispiel #14
0
 public void StopMoving()
 {
     WholePath.Clear();
     WayPoints.Clear();
     _currentMovingPoinIndex = 0;
     IsMoving = false;
 }
Beispiel #15
0
        protected void Moving(GameTime gt)
        {
            bool reached = MoveTo(WayPoints[0], gt, true);

            if (reached)
            {
                WayPoints.RemoveAt(0);
                waypointsReached++;
                noRetaliate = false;
            }

            if (waypointsReached > 15 && marcher)
            {
                WayPoints.Clear();
                Ai_States  = Ai_States.Target;
                this.Speed = norm_speed;
                marcher    = false;
            }

            else if (waypointsReached <= 15 && WayPoints.Count > 0)
            {
                Ai_States = Ai_States.Moving;
            }

            else if (waypointsReached <= 15 && WayPoints.Count == 0)
            {
                Ai_States = Ai_States.Marching;
            }
        }
Beispiel #16
0
 public XElement ToElement()
 {
     return(new XElement("path",
                         WayPoints.Select(v2 => new XElement("point",
                                                             new XAttribute("X", (int)v2.X),
                                                             new XAttribute("Y", (int)v2.Y)))));
 }
        public DialogKMLPath(Waypoint_Path_Gen wpg, GMAP gmap, TreeView treeview, double lat, double lon)
        {
            _lat                = lat;
            _lon                = lon;
            _wpg                = wpg;
            _gmap               = gmap;
            _treeview           = treeview;
            _current_path_index = -1;
            _path               = new Models.Path();
            _wp = new WayPoints();

            InitializeComponent();

            // Fill POI combobox

            cmbKLMPOI.Items.Clear();
            for (int i = 0; i < _wpg.POICount(); i++)
            {
                cmbKLMPOI.Items.Add(_wpg.POIPointAt(i).name);
            }

            // Generate EMpty Path

            _path.Add_Empty_Path(_wpg, _gmap, "Empty Path", "KML");
            _current_path_index = _wpg.PathCount() - 1;
        }
Beispiel #18
0
        public void LoadWayPoints()
        {
            if (HBProfile != null && HBProfile.GrindArea != null && HBProfile.GrindArea.Hotspots != null)
            {
                var myLoc = StyxWoW.Me.Location;
                WayPoints = HBProfile.GrindArea.Hotspots.ConvertAll(hs => hs.Position);
                //Logger.WriteDebug("LoadWayPoints: WayPoints " + WayPoints.Count);
                WoWPoint closestPoint =
                    WayPoints.OrderBy(u => u.DistanceSqr(myLoc)).FirstOrDefault();
                _currentIndex = WayPoints.FindIndex(w => w == closestPoint);
                return;
            }
            string what = "LoadWaypoints: ";

            if (HBProfile == null)
            {
                what += "HBprofile";
            }
            else if (HBProfile.GrindArea == null)
            {
                what += "GrindArea";
            }
            else if (HBProfile.GrindArea.Hotspots == null)
            {
                what += "Hotspots";
            }
            what += " empty";
            //Logger.WriteDebug(what);
            WayPoints = new List <WoWPoint>();
        }
Beispiel #19
0
 public Wave(GameObject unitType, int count, float timePerSpawn, WayPoints waypoints, float moveSpeed)
 {
     m_unit         = unitType;
     m_count        = count;
     m_timePerSpawn = timePerSpawn;
     m_wp           = waypoints;
     m_moveSpeed    = moveSpeed;
 }
Beispiel #20
0
 public EnemyMovement(IMoveable moveable, WayPoints waypoints) : base(moveable)
 {
     horizontalState = Direction.none;
     verticalState   = Direction.none;
     m_moveable      = moveable;
     m_waypoints     = waypoints;
     m_index         = 0;
 }
Beispiel #21
0
        public void CycleToNearest()
        {
            var      myLoc        = StyxWoW.Me.Location;
            WoWPoint closestPoint =
                WayPoints.OrderBy(u => u.DistanceSqr(myLoc)).FirstOrDefault();

            _currentIndex = WayPoints.FindIndex(w => w == closestPoint);
        }
Beispiel #22
0
 void Awake()
 {
     if (forests.Length > 0)
     {
         curForest = forests [0];
     }
     wayPoints = curForest.transform.Find("wayPoints").GetComponent <WayPoints>();
 }
Beispiel #23
0
 public Wave(GameObject unitType, int count, float timePerSpawn, WayPoints waypoints, float moveSpeed)
 {
     m_unit = unitType;
     m_count = count;
     m_timePerSpawn = timePerSpawn;
     m_wp = waypoints;
     m_moveSpeed = moveSpeed;
 }
Beispiel #24
0
 void Awake() {
     GameObject playerGo = GameObject.FindGameObjectWithTag(Tags.player);
     if (playerGo != null) {
         player = playerGo.transform;
     }
     waypoints = transform.Find("waypoints").GetComponent<WayPoints>();
     targetWayPointIndex = waypoints.waypoints.Length - 2;
 }
 public WayPointWalker()
 {
     _PathIndex = 999999;
     _WayPoints = null;
     _Dead = false;
     _Sprite = null;
     _DebugT = 0.0f;
     _T = 0.0f;
 }
Beispiel #26
0
	void Start () {
        player = GameObject.FindGameObjectWithTag(Tags.player).transform;
        waypoints = transform.Find("WayPoints").GetComponent<WayPoints>();
        CreateObs();
        TargetPos = waypoints.points.Length - 2;//初始化下一个点
       

        gameEnvCreater = Camera.main.GetComponent<GameEnvCreater>();
    }
Beispiel #27
0
        new protected void Moving(GameTime gt)
        {
            bool reached = MoveTo(WayPoints[0], gt);

            if (reached)
            {
                WayPoints.RemoveAt(0);
            }
        }
    private void Start()
    {
        _wayPoints = GetComponent <WayPoints>();

        if (activateSelf)
        {
            TriggerActivate();
        }
    }
 public void SpeedChange(Flamemove target)
 {
     //If the target is still changing, instantly change the speed to prevent getting stuck in the previous change enumerator
     if (target.isChanging)
     {
         WayPoints.HaltAllSpeedChanges();
     }
     StartCoroutine(Change(target));
 }
Beispiel #30
0
    void Start()
    {
        player    = GameObject.FindGameObjectWithTag(Tags.player).transform;
        waypoints = transform.Find("WayPoints").GetComponent <WayPoints>();
        CreateObs();
        TargetPos = waypoints.points.Length - 2;//初始化下一个点


        gameEnvCreater = Camera.main.GetComponent <GameEnvCreater>();
    }
 void Start()
 {
     flame          = GetComponentInChildren <FlameBehaviour>();
     flame.vitality = 0;
     isChanging     = false;
     isRunning      = false;
     wayPoints      = FindObjectOfType <WayPoints>();
     target         = wayPoints.points [0];
     rb             = GetComponent <Rigidbody>();
 }
    public void Start()
    {
        WP = GameObject.FindWithTag("WayPoints").GetComponent <WayPoints>();
        WS = GameObject.FindWithTag("GM").GetComponent <WaveSpawner>();
        ST = GameObject.FindWithTag("GM").GetComponent <PlayerStats>();

        target = WP.wpoints[0];

        EN = this.gameObject.GetComponent <Enemy_AI>();
    }
Beispiel #33
0
 private void SaveEvents_AfterLoad(object sender, EventArgs e)
 {
     // loadExceptionTiles();
     CheatCore.DoorsToWarps.makeAllDoorsWarps();
     WayPoints.setUpBedWaypoint();
     WayPoints.verifyWayPoints();
     UtilityCore.SeedCropUtility.setUpUserCropUtilityDictionary();  //Runs once
     UtilityCore.SeedCropUtility.setUpCropUtilityDictionaryDaily(); //Runs daily
     playerHasLoadedGame = true;
 }
    public WayPointWalker(float fSpeed, int iIndex)
    {
        _PathIndex = iIndex;
        _WayPoints = Director._Instance._WayPointDatabase.GetWayPoints(_PathIndex);
        _T = 0.0f;
        _Speed = fSpeed;
        _Dead = false;

        _Sprite = null;
        _DebugT = 0.0f;
    }
Beispiel #35
0
    void Awake()
    {
        GameObject playerGo = GameObject.FindGameObjectWithTag(Tags.player);

        if (playerGo != null)
        {
            player = playerGo.transform;
        }
        waypoints           = transform.Find("wayPoints").GetComponent <WayPoints>();
        targetWayPointIndex = waypoints.waypoints.Length - 2;
    }
        private void btnOutputCVS_Click(object sender, EventArgs e)
        {
            LinkedList <WayPoints> wp_list = _path.waypoints;

            WayPoints point    = new WayPoints();
            string    str      = "";
            string    filename = txtCSVFilePath.Text;

            int pcount      = 0;
            int point_count = wp_list.Count;

            if (point_count > 0)
            {
                do
                {
                    point = wp_list.ElementAt(pcount);
                    double lat      = point.lat;
                    double lon      = point.lon;
                    double altitude = point.alt;

                    double head        = point.head;
                    double curvesize   = point.curvesize;
                    double rotationdir = point.rotationdir;
                    int    gimblemode  = point.gimblemode;
                    double gimblepitch = point.gimblepitch;
                    if (!_options.units_metric)
                    {
                        altitude  = GPS.FeetToMeters(altitude);
                        curvesize = GPS.FeetToMeters(curvesize);
                    }

                    str = str + Convert.ToString(lat) + "," + Convert.ToString(lon);
                    str = str + ", " + Convert.ToString(altitude);
                    str = str + ", " + Convert.ToString(head);
                    str = str + ", " + Convert.ToString(curvesize);
                    str = str + ", " + Convert.ToString(rotationdir);
                    str = str + ", " + Convert.ToString(gimblemode);
                    str = str + ", " + Convert.ToString(gimblepitch);
                    for (int i = 0; i < 15; i++)
                    {
                        str = str + ", " + Convert.ToString(point.actions[i, 0]);
                        str = str + ", " + Convert.ToString(point.actions[i, 1]);
                    }
                    str = str + "\r\n";
                    pcount++;
                } while (pcount < point_count);

                // Write to File

                System.IO.File.WriteAllText(filename, str);
            }

            this.Close();
        }
Beispiel #37
0
        /// <summary>
        /// Apply the motion model to the vehicle. It corresponds to a
        /// 3D odometry model following the equation:
        ///
        /// x = x + q dx q* + N(0, Q)
        /// o = dq o dq* + N(0, Q')
        ///
        /// where q is the midrotation quaternion (halfway between the old and new orientations) and N(a, b) is a normal function
        /// with mean 'a' and covariance matrix 'b'.
        /// </summary>
        /// <param name="time">Provides a snapshot of timing values.</param>
        /// <param name="reading">Odometry reading (dx, dy, dz, dpitch, dyaw, droll).</param>
        public virtual void Update(GameTime time, double[] reading)
        {
            Pose         = Pose.AddOdometry(reading);
            OdometryPose = OdometryPose.AddOdometry(reading);

            double[] noise = time.ElapsedGameTime.TotalSeconds.Multiply(
                Util.RandomGaussianVector(new double[OdoSize],
                                          MotionCovariance));
            OdometryPose = OdometryPose.AddOdometry(noise);

            WayPoints.Add(Tuple.Create(time.TotalGameTime.TotalSeconds, Util.SClone(Pose.State)));
        }
Beispiel #38
0
    void Start()
    {
        playerCraft = Resources.Load("omega_fighter") as GameObject;
        p1 = new Player(playerCraft, startingLives);
        p1.spawn();

        EnemyType1 = Resources.Load("Enemy1") as GameObject;

        m_topLeftToBottomRight = new WayPoints(topLeftSpawn, Borders.bottomRight);
        m_rightVertical = new WayPoints(topRight1, botRight1);
        m_topLeftToBottomRight.addWayPoint(topRight1);
        m_wave1 = new Wave(EnemyType1, 4, 2, m_rightVertical, 0.75f);
        m_wave2 = new Wave(EnemyType1, 6, 1, m_topLeftToBottomRight);
    }
Beispiel #39
0
    public new void Awake()
    {
        agent = GetComponentInChildren<NavMeshAgent> ();
        lights = GetComponentsInChildren<Light> (includeInactive: true).ToList ();
        myRenderer = GetComponentInChildren<Renderer> ();
        wayPoints = FindObjectOfType<WayPoints> ();
        rigigBody = GetComponentInChildren<Rigidbody> ();

        allAgents = FindObjectsOfType<AgentProperties> ().ToList ();
        foundAgents = allAgents.Count;
        notreadyAgents = 0;
        waitingAgents = 0;
        startLocation = transform.position;

        base.Awake ();
    }
    public void SetDebug(int iIndex)
    {
        if(_WayPoints.Count == 0)
        {
            return;
        }

        if(iIndex > _WayPoints.Count)
        {
            return;
        }

        _CurrentDebug = _WayPoints[iIndex];
    }
 public void Previous()
 {
     if(_CurrentIndex != 0)
     {
         --_CurrentIndex;
         _CurrentDebug = _WayPoints[_CurrentIndex];
     }
 }
 public void Next()
 {
     if(_CurrentIndex < _WayPoints.Count-1)
     {
         ++_CurrentIndex;
         _CurrentDebug = _WayPoints[_CurrentIndex];
     }
 }
 public void NewInsert()
 {
     WayPoints pWP = new WayPoints();
     pWP.AddPoint(28.0f,0.0f);
     pWP.AddPoint(26.0f,0.0f);
     pWP.AddPoint(-26.0f,0.0f);
     pWP.AddPoint(-28.0f,0.0f);
     AddWayPointsInsert(pWP);
     _CurrentDebug = _WayPoints[_CurrentIndex+1];
     _CurrentIndex++;
 }
 public void New()
 {
     _CurrentIndex = _WayPoints.Count;
     WayPoints pWP = new WayPoints();
     pWP.AddPoint(28.0f,0.0f);
     pWP.AddPoint(26.0f,0.0f);
     pWP.AddPoint(-26.0f,0.0f);
     pWP.AddPoint(-28.0f,0.0f);
     AddWayPoints(pWP);
     _CurrentDebug = _WayPoints[_CurrentIndex];
 }
 public void AddWayPointsInsert(WayPoints pWaypoints)
 {
     _WayPoints.Insert(_CurrentIndex + 1, pWaypoints);
 }
Beispiel #46
0
 private static float CheckDistance(WayPoints st, WayPoints ed, float minDistance)
 {
     if ((st != null && ed != null) && (pathDistance[st.id, ed.id] + Vector3.Distance(st.GetFloorPosition(), startPosition) + Vector3.Distance(ed.GetFloorPosition(), destPosition)) < minDistance){
         minDistance = pathDistance[st.id, ed.id] + Vector3.Distance(st.GetFloorPosition(), startPosition) + Vector3.Distance(ed.GetFloorPosition(), destPosition);
         start = st;
         end = ed;
     }
     return minDistance;
 }
Beispiel #47
0
 public void setMovePoints(WayPoints waypoints)
 {
     m_waypoints = waypoints;
 }
Beispiel #48
0
 void FakeWayPoints()
 {
     // {"ResetHdg":0,"WayPoints":[[0, 1, 0],[1, 1, 0],[0, 1, 0],[0, 0, 0]]}
     Trace.t(cc.Good, "Loaded fake WayPoints");
     WayPoints = new WayPoints();
     // add in reverse order (FILO)
     WayPoints.Push(new WayPoint { X = 0, Y = 0, isAction = false });
     WayPoints.Push(new WayPoint { X = 0, Y = 1, isAction = false });
     WayPoints.Push(new WayPoint { X = 1, Y = 1, isAction = false });
     WayPoints.Push(new WayPoint { X = 0, Y = 1, isAction = false });
 }
Beispiel #49
0
 private void PublishReceived(object sender, MqttMsgPublishEventArgs e)
 {
     dynamic jsn = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(e.Message));
     Program.ResetHeading = jsn.ResetHdg;
     List<WayPoint> wps = new List<WayPoint>(jsn.WayPoints.Count);
     foreach (var t in jsn.WayPoints)
         wps.Add(new WayPoint { X = t[0], Y = t[1], isAction = (int)t[2] !=0 ? true : false });
     Program.WayPoints = new WayPoints();
     for (int i = wps.Count - 1; i >= 0; i--)    // pushed in reverse, FILO
         Program.WayPoints.Push(wps[i]);
     Trace.t(cc.Good, "WayPoint received and loaded");
 }
    public void NextPath()
    {
        WayPoints pWP = Director._Instance._WayPointDatabase.GetWayPoints(_PathIndex+1);

        if(pWP != null)
        {
            ++_PathIndex;
            _WayPoints = pWP;
        }
    }
 public void PreviousPath()
 {
     if(_PathIndex > 0)
     {
         --_PathIndex;
         _WayPoints = Director._Instance._WayPointDatabase.GetWayPoints(_PathIndex);
     }
 }
Beispiel #52
0
 void GetWayPoints()
 {
     wp = WayPointList.GetComponent<WayPoints>();
     Waypoints = wp._WayPoints;
 }
 void Start()
 {
     _WayPoints = new List<WayPoints>();
     _CurrentDebug = null;
     _CurrentIndex = 0;
     Load();
 }
 public void AddWayPoints(WayPoints pWaypoints)
 {
     _WayPoints.Add(pWaypoints);
 }
Beispiel #55
0
    public void Copy(WayPoints pWP)
    {
        _Points = new List<Vector3>();

        for(int i = 0; i < pWP._Points.Count; ++i)
        {
            Vector3 vPoint = new Vector3(pWP._Points[i].x,0.0f,pWP._Points[i].z);
            _Points.Add(vPoint);
        }

        _NumPaths = _Points.Count - 1;
        BuildDirection();
    }
    public void Load()
    {
        _WayPoints = new List<WayPoints>();
        _CurrentDebug = null;

        TextAsset pXMLText = Resources.Load("Paths") as TextAsset;

        //Debug.Log("XML = " + pXMLText.text);

        XmlDocument pXML = new XmlDocument();
        pXML.Load(new StringReader(pXMLText.text));

        string pName = "path";
        XmlNodeList pPaths = pXML.GetElementsByTagName(pName);

        //Debug.Log("Number of paths = " + pPaths.Count);

        for(int iNode = 0; iNode < pPaths.Count; ++iNode)
        {
            //Debug.Log("Node xml = " + pPaths[iNode].InnerXml);

            XmlNode pPath = pPaths[iNode];

            //Debug.Log("pPath XML = " + pPath.InnerXml);

            WayPoints pWayPoints = new WayPoints();

            for(int i = 0; i < pPath.ChildNodes.Count; ++i)
            {
                //Debug.Log("Name = " + pPath.ChildNodes[i].InnerXml);

                XmlNode pPoint = pPath.ChildNodes[i];

                XmlNode pX = pPoint.FirstChild;
                XmlNode pZ = pPoint.LastChild;

                //Debug.Log("X = " + pX.InnerText + " Z = " + pZ.InnerText);

                pWayPoints.AddPoint(float.Parse(pX.InnerText),float.Parse(pZ.InnerText));
            }

            AddWayPoints(pWayPoints);
        }
    }
Beispiel #57
0
    private void PathEditor()
    {
        if(_PatheEditor)
        {
            Ray ray;
            RaycastHit hit;

            Vector3 vPos = _CameraPos;
            vPos.y += 15.0f;
            _CameraTrans.position = vPos;

            Vector3 vPoint = _Walker.Walk(Time.deltaTime);
            _PF._X = vPoint.x;
            _PF._Z = vPoint.z;

            if(Input.GetMouseButton(0))
            {
                _WayPointDatabase.MouseDown();
            }
            else
            {
                _WayPointDatabase.MouseUp();
            }

            ray = _Camera.ScreenPointToRay(Input.mousePosition);

           		if(Physics.Raycast(ray, out hit, 200))
            {
                if(hit.transform.gameObject.name == "Ground")
                {
                    _WayPointDatabase.Mouse(hit.point.x,hit.point.z);

                }
            }

            if(Input.GetKeyDown(KeyCode.A))
            {
                _WayPointDatabase.AddPoint();
            }

            if(Input.GetKeyDown(KeyCode.D))
            {
                _WayPointDatabase.DeletePoint();
            }

            // Exit the path editor
            if(Input.GetKeyDown(KeyCode.P))
            {
                _PatheEditor = false;

                Sprite.Kill(_PF);
                _Walker = null;

                _Number.SetNumber(_LocalHiScore);
                SetScreen("TITLE");
                return;
            }

            /*
            if(Input.GetKeyDown(KeyCode.S))
            {
                _WayPointDatabase.Save();
            }

            if(Input.GetKeyDown(KeyCode.L))
            {
                //_WayPointDatabase.Load();
            }
            */

            if(Input.GetKeyDown(KeyCode.Z))
            {
                if(Input.GetKey(KeyCode.LeftShift))
                {
                    for(int i = 0; i < 10; ++i)
                    {
                        _WayPointDatabase.Previous();
                    }
                }
                else
                {
                    _WayPointDatabase.Previous();
                }

                _Walker = new WayPointWalker(0.3f,_WayPointDatabase._CurrentIndex);
            }

            if(Input.GetKeyDown(KeyCode.X))
            {

                if(Input.GetKey(KeyCode.LeftShift))
                {
                    for(int i = 0; i < 10; ++i)
                    {
                        _WayPointDatabase.Next();
                    }
                }
                else
                {
                    _WayPointDatabase.Next();
                }

                _Walker = new WayPointWalker(0.3f,_WayPointDatabase._CurrentIndex);
            }

            // Add a new path onto the end of the list
            if(Input.GetKeyDown(KeyCode.N))
            {
                _WayPointDatabase.New();
                _Walker = new WayPointWalker(0.3f,_WayPointDatabase._CurrentIndex);
            }

            if(Input.GetKeyDown(KeyCode.I))
            {
                _WayPointDatabase.NewInsert();
                _Walker = new WayPointWalker(0.3f,_WayPointDatabase._CurrentIndex);
            }

            if(Input.GetKeyDown(KeyCode.E))
            {
                _WayPointDatabase.ErasePath();
                _Walker = new WayPointWalker(0.3f,_WayPointDatabase._CurrentIndex);
            }

            if(Input.GetKeyDown(KeyCode.C))
            {
                _WPCopyBuffer = _Walker._WayPoints;
            }

            if(Input.GetKeyDown(KeyCode.V))
            {
                if(_WPCopyBuffer == null)
                {
                    return;
                }

                _WayPointDatabase.NewInsert();
                _Walker = new WayPointWalker(0.3f,_WayPointDatabase._CurrentIndex);
                _Walker._WayPoints.Copy(_WPCopyBuffer);
            }

            if(Input.GetKeyDown(KeyCode.B))
            {
                if(_WPCopyBuffer == null)
                {
                    return;
                }

                _WayPointDatabase.New();
                _Walker = new WayPointWalker(0.3f,_WayPointDatabase._CurrentIndex);
                _Walker._WayPoints.Copy(_WPCopyBuffer);
            }

            if(Input.GetKey(KeyCode.UpArrow))
            {
                if(_Walker != null)
                {
                    if(Input.GetKey(KeyCode.LeftShift))
                    {
                        _Walker._WayPoints.MarchUp(1.0f);
                    }
                    else
                    {
                        _Walker._WayPoints.MarchUp(10.0f);
                    }

                }
            }

            if(Input.GetKey(KeyCode.DownArrow))
            {
                if(_Walker != null)
                {
                    if(Input.GetKey(KeyCode.LeftShift))
                    {
                        _Walker._WayPoints.MarchDown(1.0f);
                    }
                    else
                    {
                        _Walker._WayPoints.MarchDown(10.0f);
                    }
                }
            }

            if(Input.GetKey(KeyCode.LeftArrow))
            {
                if(_Walker != null)
                {
                    if(Input.GetKey(KeyCode.LeftShift))
                    {
                        _Walker._WayPoints.MarchLeft(1.0f);
                    }
                    else
                    {
                        _Walker._WayPoints.MarchLeft(10.0f);
                    }

                }
            }

            if(Input.GetKey(KeyCode.RightArrow))
            {
                if(_Walker != null)
                {
                    if(Input.GetKey(KeyCode.LeftShift))
                    {
                        _Walker._WayPoints.MarchRight(1.0f);
                    }
                    else
                    {
                        _Walker._WayPoints.MarchRight(10.0f);
                    }
                }
            }

            if(Input.GetKeyDown(KeyCode.R))
            {
                _Walker._WayPoints.Reverse();
            }

            if(Input.GetKeyDown(KeyCode.F))
            {
                _Walker._WayPoints.Reverse();
                _Walker._WayPoints.MirrorX();
            }

            if(Input.GetKeyDown(KeyCode.G))
            {
                _Walker._WayPoints.MirrorZ();
            }

            _WayPointDatabase.DebugDraw();

            _Number.SetNumber(_WayPointDatabase._CurrentIndex);
        }
    }