Example #1
0
    /// <summary>
    /// Will keep ading a new value to _univCounter each iteration
    /// If all pople check then will Clear the queues
    /// </summary>
    /// <returns>True if collide with any building annchor queue</returns>
    public bool ContainAnyBuild(TheRoute theRoute, string personMyID, HPers which = HPers.None)
    {
        InitVal();
        if (_peopleChecked.Contains(personMyID))
        {
            return(false);
        }

        var onNewB = IsOnQueue(theRoute, _newBuildsQueue, personMyID);
        var onDesB = IsOnQueue(theRoute, _destroyBuildsQueue, personMyID);

        //print("onNewBlds:" + onNewB + ".elem.Count:" + _newBuildsAnchors.Elements.Count);
        //print("onDstBlds:" + onDesB + ".elem.Count:" + _destroyedBuildsAnchors.Elements.Count);

        if (which == HPers.Chill)//the last one
        {
            _peopleChecked.Add(personMyID);

            if (_peopleChecked.Count >= PersonPot.Control.All.Count)
            {
                ClearAllQueues();
            }
        }
        return(onNewB || onDesB);
    }
Example #2
0
    void NavMesh()
    {
        var iniH = (Structure)_ini;
        var finH = (Structure)_fin;

        //bz navmesh now this is all I needed
        List <CheckPoint> pts = new List <CheckPoint>()
        {
            new CheckPoint(iniH.BehindMainDoorPoint),
            new CheckPoint(iniH.SpawnPoint.transform.position),
            new CheckPoint(finH.SpawnPoint.transform.position),
            new CheckPoint(finH.BehindMainDoorPoint),
        };

        if (!_iniDoor)
        {
            pts.RemoveAt(0);
        }
        if (!_finDoor)
        {
            pts.RemoveAt(pts.Count - 1);
        }

        loop = false;
        _checkPoints.AddRange(pts);
        AddAnglesToRoute();

        TheRoute     = new TheRoute(_checkPoints, _ini.MyId, _fin.MyId);
        IsRouteReady = true;
    }
Example #3
0
    /// <summary>
    /// Created so chache will Check if anything new in the queue interfieres with thm
    ///
    /// Needed bz Homers will keep using old Cached ROutes and they will never get updated
    /// </summary>
    /// <param name="cachedRoute"></param>
    /// <returns></returns>
    public bool IsThisRouteOnAnyQueue(TheRoute cachedRoute)
    {
        var onNewB = IsOnQueue(cachedRoute, _newBuildsQueue);
        var onDesB = IsOnQueue(cachedRoute, _destroyBuildsQueue);

        return(onNewB || onDesB);
    }
Example #4
0
    public void Update()
    {
        if (_cryRoute != null && !_isRouteReady)
        {
            _cryRoute.Update();

            if (_cryRoute.IsRouteReady)
            {
                _isRouteReady = true;
                _theRoute     = _cryRoute.TheRoute;

                //calling here so at least is there already even if has not the inverse Route set
                PersonPot.Control.RoutesCache1.AddReplaceRoute(_theRoute);
                SetFinalRouteOnBrain();
            }
        }

        if (_cryBridgeRoute != null && !_isRouteReady)
        {
            _cryBridgeRoute.Update();

            if (_cryBridgeRoute.IsRouteReady)
            {
                _isRouteReady = true;
                _theRoute     = _cryBridgeRoute.TheRoute;

                //calling here so at least is there already even if has not the inverse Route set
                PersonPot.Control.RoutesCache1.AddReplaceRoute(_theRoute);
                SetFinalRouteOnBrain();
            }
        }

        FakeRealRoute();
    }
Example #5
0
    /// <summary>
    /// Init the Variables to walk
    ///
    /// If loading from file loadCurrentPoint will be specified
    /// </summary>
    /// <param name="route">The route to be walked</param>
    /// <param name="inverse">If we are coming back from the route</param>
    /// <param name="loadCurrentPoint">Use to load person last aprox position </param>
    void InitWalk(TheRoute route, bool inverse, int loadCurrentPoint = -1)
    {
        //FindIfAAniIsSaved();

        DefineSpeed();

        _inverse      = inverse;
        _currTheRoute = route;
        _routePoins   = route.CheckPoints;

        if (inverse)
        {
            sign           = -1;
            lastRoutePoint = 0;
            DefineCurrentRoutePoint(loadCurrentPoint, true);

            SetInitRoutePoint();
            DefineInversedRouteRot();
            _gameObject.transform.rotation = _routePoins[iniRoutePoint].QuaterniRotationInv;
        }
        else
        {
            sign           = 1;
            lastRoutePoint = _routePoins.Count - 1;
            DefineCurrentRoutePoint(loadCurrentPoint, false);

            SetInitRoutePoint();
            //GameScene.print("iniRoutePoint:" + iniRoutePoint + ".Count:" + _currRoute.Count );
            _gameObject.transform.rotation = _routePoins[iniRoutePoint].QuaterniRotation;
        }
        SetNextPoint();
    }
Example #6
0
    /// <summary>
    /// Bz a route that was collided for Profession needs to be removed from here
    /// </summary>
    /// <param name="theRoute"></param>
    public void RemoveRoute(TheRoute theRoute, DateTime askTime)
    {
        var key = ReturnKey(theRoute);

        if (!_items.ContainsKey(key))
        {
            return;
        }

        var item = _items[key];

        if (item == null)
        {
            return;
        }

        DateTime date1  = item.DateTime1;
        DateTime date2  = askTime;
        int      result = DateTime.Compare(date1, date2);

        //if the Current ITem date is bigger that askTime means we have the latest verstion of it
        if (result > 0)
        {
            return;
        }

        var was = _items.Remove(key);
        //Debug.Log("was remove:"+was+"."+key);
    }
Example #7
0
    public void AddReplaceRoute(TheRoute theRoute)
    {
        //if _checkOnQueues is b is checking we need to keep pure that revision.
        //after is done this will accept routes again
        if (_checkOnQueues || theRoute == null || theRoute.CheckPoints.Count == 0 ||
            theRoute.CheckPoints.Count == 0 || OriginDestinyContains(theRoute, "Dummy"))
        {
            return;
        }

        var key    = theRoute.OriginKey + "." + theRoute.DestinyKey;
        var haveIt = DoWeHaveThatRoute(theRoute.OriginKey, theRoute.DestinyKey);

        if (haveIt)
        {
            var isNewer = IsNewerOrSame(theRoute.DateTime1);
            if (isNewer)
            {
                _items[key] = theRoute;
            }
            //other wise we have the lastest one
        }
        else
        {
            _items.Add(key, theRoute);
            //Debug.Log("added to cache:" + key + " ct:" + _items.Count);
        }
    }
Example #8
0
    private TheRoute tempTheRoute;//will hold the route for a bit until is realeased on Fake()
    private void WeHaveAnExisitingRoute()
    {
        //so it doesnt reference
        tempTheRoute = new TheRoute();

        //GameScene.print("We have exisint route "+_person.MyId+" o:"+OriginKey + " d:"+DestinyKey + " askT:" +_askDateTime);
        tempTheRoute = PersonPot.Control.RoutesCache1.GiveMeTheNewerRoute();
        time         = Time.time;
    }
Example #9
0
    private TheRoute tempTheRoute;//will hold the route for a bit until is realeased on Fake()
    private void WeHaveAnExisitingRoute()
    {
        //GameScene.print("We have exisint route ");
        tempTheRoute = PersonPot.Control.RoutesCache1.GiveMeTheNewerRoute();

        time = Time.time;
        _iAmBridgeRouting = false;
        _iAmDeltaRouting  = false;
    }
Example #10
0
 public void CleanBean()
 {
     _isReacheable = false;
     _result       = -5;
     _validFrom    = new Vector3();
     _validToBot   = new Vector3();
     _deltaCapsule = new DeltaCapsule();
     _router       = new Router();
     _theRoute     = new TheRoute();
 }
Example #11
0
    internal static List <General> CreateHelpers(TheRoute route, string root)
    {
        List <General> res = new List <General>();

        for (int i = 0; i < route.CheckPoints.Count; i++)
        {
            res.Add(General.Create(root, route.CheckPoints[i].Point));
        }
        return(res);
    }
Example #12
0
    /// <summary>
    /// Will correct the last poinst of the route rotation
    ///
    /// Needed bz the last point of a route doesnt have any rotation since we didnt know wht was next
    /// here I know wht is next so it can be added
    /// </summary>
    /// <param name="cryRoute"></param>
    /// <param name="vector3"></param>
    private void CorrectLastPointRotationAndAddNextCheckPoint(TheRoute theRoute, Vector3 next)
    {
        var temp     = theRoute.CheckPoints[theRoute.CheckPoints.Count - 1];
        var newCheck = ReturnFacingTo(temp.Point, next);

        //removes the last
        theRoute.CheckPoints.RemoveAt(theRoute.CheckPoints.Count - 1);
        //adds the new one
        theRoute.CheckPoints.Add(newCheck);
    }
Example #13
0
 void PullRouteOfRouter()
 {
     if (_router.IsRouteReady)
     {
         _isRouteReady     = true;
         _theRoute         = _router.TheRoute;
         _iAmBridgeRouting = false;
         _iAmDeltaRouting  = false;
     }
 }
Example #14
0
    private void ConformRoute()
    {
        AddToBucket();
        AddFirtAndLastToBucket();
        ValidateRoute();
        _theRoute = new TheRoute(validCheckPoints, _ini.MyId, _currentBridge.MyId, _fin.MyId);
        AddPersonOnBridgeDict();

        _finalRouter.TheRoute     = _theRoute;
        _finalRouter.IsRouteReady = true;
    }
Example #15
0
    private void ConformFinalRoute(List <CheckPoint> checkPoints)
    {
        _theRoute = new TheRoute(checkPoints);

        OrderBridgePoints();
        _theRouteInBridge = RouteVector3s(_f4Points.ToList());

        //so the Bean gets reaad it and keeps going on the BrdigeRouter ..
        //so no Async dealing to conform route on BrdigeRouter
        _result = _keepResult;
    }
Example #16
0
    bool IsAnExistingBuilding(TheRoute theRoute)
    {
        var a = theRoute.DestinyKey.Substring(theRoute.DestinyKey.Length - 2);

        return
            (theRoute.DestinyKey.Contains("Dummy") ||
             theRoute.DestinyKey.Contains("Tree") ||
             theRoute.DestinyKey.Contains("Rock") ||
             Brain.GetStructureFromKey(theRoute.DestinyKey) != null ||
             theRoute.DestinyKey.Substring(theRoute.DestinyKey.Length - 2) == ".D");//in Work Route (farmer, fisheerman)
    }
Example #17
0
    public MoveThruPoints(Building Building1, GameObject gO, string myIDP)
    {
        //when is not lloading
        if (_currTheRoute.CheckPoints.Count == 0)
        {
            _currTheRoute = Building1.Dock1.CreateRoute(myIDP);
        }

        _gameObject = gO;
        Init();
    }
Example #18
0
 private void MindState()
 {
     if (_theRoute != null && _cryRouteManager.IsRouteReady && _person.Body.GoingTo == HPers.None)
     {
         _person.Body.WalkRoutine(_theRoute, HPers.Enemy);
     }
     else if (_person.Body.Location == HPers.Enemy)
     {
         _theRoute        = null;
         _cryRouteManager = null;
     }
 }
Example #19
0
File: TheRoute.cs Project: Cdrix/SM
    public TheRoute(TheRoute theRoute)
    {
        _destinyKey = theRoute.DestinyKey;
        _originKey  = theRoute.OriginKey;
        _bridgeKey  = theRoute.BridgeKey;

        CheckPoint[] array = new CheckPoint[theRoute.CheckPoints.Count];
        theRoute.CheckPoints.CopyTo(array);
        _checkPoints = array.ToList();

        _areaRect = theRoute.AreaRect;
        _dateTime = theRoute.DateTime1;
    }
Example #20
0
    private void ClearOldVars()
    {
        _isRouteReady = false;

        if (_theRoute != null)
        {
            _theRoute.CheckPoints.Clear();
        }
        _theRoute = null;

        _cryRoute       = null;
        _cryBridgeRoute = null;
    }
Example #21
0
    protected void Update()
    {
        if (_cryRouteManager != null && !_cryRouteManager.IsRouteReady)
        {
            _cryRouteManager.Update();
        }
        else if (_theRoute == null && _cryRouteManager != null && _cryRouteManager.IsRouteReady)
        {
            _theRoute = _cryRouteManager.TheRoute;
        }

        MindState();
    }
Example #22
0
    public void WalkRoutine(TheRoute route, HPers goingTo, bool inverse = false, HPers whichRouteP = HPers.None)
    {
        //for ships
        if (inverse)
        {
            SetCurrentAni("isOlasRouteBack", "isOlas");
            //so it makes the transitionm to isOlasRouteBack
            //_speed = 0;
        }

        //Show();//to show person whenh going from old home to shack to be built
        InitWalk(route, inverse);
        WalkRoutineTail(goingTo, whichRouteP);
    }
Example #23
0
    /// <summary>
    /// Says if we have a route with same Oring and Destiyny key
    ///
    /// sets '_current'
    /// </summary>
    /// <param name="theRoute"></param>
    /// <returns></returns>
    bool DoWeHaveThatRoute(string OriginKey, string DestinyKey)
    {
        var key = CreateRouteKey(OriginKey, DestinyKey);

        if (_items.ContainsKey(key))
        {
            if (_items[key].CheckPoints.Count > 0)
            {
                //only if has more than 0 bz they can reference clear the routes
                _current = new TheRoute(_items[key]);
                return(true);
            }
            _items.Remove(key);
        }
        return(false);
    }
Example #24
0
    private void NavMesh()
    {
        var iniH = (Structure)_ini;
        var finH = (Structure)_fin;

        //bz navmesh now this is all I needed
        List <CheckPoint> pts = new List <CheckPoint>()
        {
            new CheckPoint(iniH.BehindMainDoorPoint),
            new CheckPoint(iniH.SpawnPoint.transform.position),
            new CheckPoint(finH.SpawnPoint.transform.position),
            new CheckPoint(finH.BehindMainDoorPoint),
        };

        TheRoute     = new TheRoute(pts, _ini.MyId, _fin.MyId);
        IsRouteReady = true;
    }
Example #25
0
    /// <summary>
    /// Says if the param 'other' is contained in any _newBuildsAnchors
    ///
    /// and if the element on the queue was added after the route was created
    /// </summary>
    private bool IsOnQueue(TheRoute theRoute, QueueTask queueTask, string personID = "")
    {
        for (int i = 0; i < queueTask.Elements.Count; i++)
        {
            DateTime date1 = queueTask.Elements[i].DateTime1;
            DateTime date2 = theRoute.DateTime1;

            int result = DateTime.Compare(date1, date2);
            //can be called here bz a person when call the Queues to check in goes trhu all of them
            queueTask.Elements[i].CheckPersonIn(personID);

            //if they intersect and //the queue element was created later than the route then need to reroute
            if (queueTask.Contains(theRoute.AreaRect, i) && result > 0)
            {
                _currenTime = queueTask.Elements[i].DateTime1;
                return(true);
            }
        }
        return(false);
    }
Example #26
0
    /// <summary>
    /// MAIN METHOD for moving to nw Home
    ///
    /// It has the logic to build the route and everytjhing while moving to new house
    /// </summary>
    public void BuildRouteToNewHomeRoutine()
    {
        if (!buildRouteToNewHome)
        {
            return;
        }
        _newHomeRouter.Update();

        SearchForNewHome();
        if (!newHomeRouteStart)
        {
            //_person.Home == null person is in the proccess of getting a new house
            if (_person.Home == null)
            {
                return;
            }

            _newHomeRouter = new CryRouteManager(ReturnCorrectInitStructure(),
                                                 _person.Home, _person, HPers.NewHome);
            newHomeRouteStart = true;
        }
        //person getting ready to move to new home
        if (_newHomeRouter.IsRouteReady && _routeToNewHome.CheckPoints.Count == 0 &&
            _brain.IAmHomeNow())
        {
            //Debug.Log(_person.MyId + " setting to new home");
            _routeToNewHome = _newHomeRouter.TheRoute;
            GoMindTrue();
            _brain.RoutesWereStarted = false;
            //_person.Brain.MindState();

            //bz was overwritting that and people would be stuck on home after tey moved in
            if (_person.Body.Location != HPers.MovingToNewHome)
            {
                _person.Body.Location = HPers.Home;
            }
        }
    }
Example #27
0
 public void WalkRoutineLoad(TheRoute route, HPers goingTo, int loadInitCurrentPoint,
                             bool inverse, HPers whichRouteP)
 {
     InitWalk(route, inverse, loadInitCurrentPoint);
     WalkRoutineTail(goingTo, whichRouteP);
 }
Example #28
0
 void SetTheRoute(TheRoute val)
 {
     _router.TheRoute = val;
     _theRoute        = val;
 }
Example #29
0
File: Router.cs Project: Cdrix/SM
 void CreateTheRouteObj()
 {
     TheRoute = new TheRoute(_checkPoints, _originKey, _destinyKey);
 }
Example #30
0
 string ReturnKey(TheRoute theRoute)
 {
     return(theRoute.OriginKey + "." + theRoute.DestinyKey);
 }