Example #1
0
    //Movement

    //
    public void GiveMovementOrders(Point _destination)
    {
        //Debug.Log ("myPos: " + crewPos.X + ", " + crewPos.Y + ", " + crewPos.Z);
        //Debug.Log ("destination: " + _destination.X + ", " + _destination.Y + ", " + _destination.Z);

        TileScript _tile = LevelManager.Instance.Tiles [_destination];

        if (_tile.Walkable)
        {
            //bool _foundDestination = false;

            /*
             * if (_tile.Manned) {
             *      //Debug.Log ("manned");
             * }
             *
             * if (_tile.IsDestination) {
             *      //Debug.Log ("is destined");
             * }
             */


            if (!_tile.Manned && !_tile.IsDestination)
            {
                //removes previous destination
                reachable = ReachabilityCheck(_tile);

                //_foundDestination = true;
                GiveGoAhead(true, _tile);
            }
            else
            {
                //checks rest of the room
                //TileScript _roomOri = _tile.FindRoomOrirgin ();
                //TileScript _roomOri = _tile.transform.GetChild (0).GetChild(0).GetComponent<RoomScript> ().OriginObj.GetComponent<RoomScript> ();

                //gets the originObj of any room
                RoomScript _roomOri = _tile.transform.GetChild(0).GetChild(0).GetComponent <RoomScript> ().OriginObj.GetComponent <RoomScript> ();
                //checks for the best available alternative
                _roomOri.RoomComponentFree(_tile, this, false);


                /*
                 * Point _oriPoint = _roomOri.GridPosition;
                 *
                 * for (int i = 0; i < _roomOri.GetRoomLength (); i += 2) {
                 *      Point _point = new Point (_oriPoint.X + i, _oriPoint.Y, _oriPoint.Z);
                 *      TileScript _otherTile = LevelManager.Instance.Tiles [_point];
                 *
                 *      if (!_otherTile.Manned && !_otherTile.IsDestination && _otherTile.Walkable) {
                 *              //removes previous destination
                 *              reachable = DoDestination (_otherTile);
                 *
                 *              _foundDestination = true;
                 *              break;
                 *      }
                 * }
                 */
            }
        }
    }