Beispiel #1
0
    internal void Walk(Vector3 point, Vector3 afterDest, Vector3 moveNowTo, HPers goingTo)
    {
        _agent.enabled             = false;
        _person.transform.position = moveNowTo;

        _destWasSet    = false;
        Destiny        = point;
        _afterDestiny  = afterDest;
        _nextDest      = point;
        _agent.enabled = true;

        //Debugg(point);

        if (_person.Body != null)
        {
            _person.Body.Show();
        }

        if (goingTo == HPers.InWork && _person.ProfessionProp != null &&
            _person.ProfessionProp.ProfDescription == Job.Builder)
        {
            _agent.obstacleAvoidanceType = ObstacleAvoidanceType.HighQualityObstacleAvoidance;
        }
        else
        {
            _agent.obstacleAvoidanceType = ObstacleAvoidanceType.LowQualityObstacleAvoidance;//low
        }
    }
Beispiel #2
0
    public CryRouteManager(Structure ini, Structure fin, Person person,
                           HPers routeType = HPers.None, bool iniDoor = true, bool finDoor = true, DateTime askDateTime = new DateTime())
    {
        //so profession routes are not redone everytime
        //if (askDateTime == new DateTime())
        //{
        //    askDateTime=DateTime.Now;
        //}

        _askDateTime = askDateTime;
        _originKey   = ini.MyId;
        _destinyKey  = fin.MyId;

        _iniDoor = iniDoor;
        _finDoor = finDoor;

        _routeType = routeType;
        _person    = person;

        DefineOneAndTwo(ini, fin);

        _ini = ini;
        _fin = fin;

        if (ini == fin)
        {
            //Debug.Log("Same ini-fin:"+ini.MyId+" . "+person.MyId);
        }

        ClearOldVars();
        Init();
    }
Beispiel #3
0
 /// <summary>
 /// Will address the comming back to office action in where if _isRouterBackUsed will use a diff route
 /// to go back
 ///
 /// and if is not marked will use the _inverse of _router
 /// </summary>
 protected void ComingBackToOffice()
 {
     if (_isRouterBackUsed)
     {
         //bz in wheelbarrower the back is use to do the route Source to Destination
         if (IsAHomerCreator())
         {
             //they will just use a Homer to go home
             if (!IsNewHomerCreatorUsingAnInWorkRoute())
             {
                 _person.Body.WalkRoutine(_routerBack.TheRoute, HPers.WheelBarrow);
             }
             else
             {
                 _person.Body.WalkRoutine(_router.TheRoute, HPers.WheelBarrow, true);
             }
             _workerTask = HPers.DoneAtWheelBarrow;
         }
         else if (ProfDescription == Job.Homer)
         {
             _person.Body.WalkRoutine(_routerBack.TheRoute, HPers.Home);
             _workerTask = HPers.DoneAtHome; //so reset the cycle
         }
         else
         {
             _person.Body.WalkRoutine(_routerBack.TheRoute, HPers.FoodSource);
             _workerTask = HPers.DoneAtFoodScr; //so reset the cycle
         }
     }
     else
     {
         //_person.Body.WalkRoutine(_router.TheRoute, HPers.Work, true);
         //_workerTask = HPers.DoneAtWork; //so reset the cycle
     }
 }
Beispiel #4
0
    public override void WorkAction(HPers p)
    {
        //        Debug.Log("WorkAction called insider:" + _person.MyId);

        _person.Brain.CurrentTask = p;
        ExecuteNow = true;
    }
Beispiel #5
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);
    }
Beispiel #6
0
    /// <summary>
    /// Idle Action that is to perform the animation of work
    /// </summary>
    /// <param name="nextTask">The task will have after Idle is done</param>
    private void Idle(HPers nextTask, float idleTime)
    {
        if (startIdleTime == 0)
        {
            var lookAtWork = DefineLookAt();

            //this is recreateing the initial point
            var t = Vector3.MoveTowards(_finRoutePoint, lookAtWork, -_moveTowOrigin);

            if (_person.Work != null && ProfDescription == Job.Builder &&
                _constructing != null)
            {
                _person.transform.LookAt(new Vector3(_constructing.MiddlePoint().x, _person.transform.position.y,
                                                     _constructing.MiddlePoint().z));
            }
            else
            {
                _person.transform.LookAt(t);
            }
            startIdleTime = Time.time;
        }

        if (IsGameSpeedIsZero())
        {
            return;
        }

        if (Time.time > startIdleTime + idleTime // / Program.gameScene.GameSpeed
            )
        {
            _workerTask   = nextTask;
            startIdleTime = 0;
        }
    }
Beispiel #7
0
 //Called when the last point of a route was reached
 void WalkDone()
 {
     _location  = GoingTo;
     _movingNow = false;
     SetCurrentAni("isIdle", _currentAni);//_current ani could be walk or carry
     _walkDoneAt = Time.time;
 }
Beispiel #8
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);
    }
Beispiel #9
0
    public BridgeRouter(Structure ini, Structure fin, Person person, HPers routeType)
    {
        _ini    = ini;
        _fin    = fin;
        _iniPos = _ini.SpawnPoint.transform.position;

        _finPos = _fin.SpawnPoint.transform.position;

        _person     = person;
        _routeType  = routeType;
        _currentIni = _iniPos;
        _currentFin = _finPos;

        Init();
    }
Beispiel #10
0
    private void ConvertWheelBarrow()
    {
        if (!IsAHomerCreator())
        {
            return;
        }
        var a = _person.Name;

        //so work Profession Mini States
        _person.Body.Location = HPers.Work;
        _workerTask           = HPers.None;

        //_person.HomerFoodSrc = _sourceBuildKey;
        _person.CreateProfession(Job.Homer);
    }
Beispiel #11
0
    public CryBridgeRoute(Structure ini, Structure fin, Person person, string destinyKey, HPers routeType)
    {
        _origenKey  = ini.MyId;
        _destinyKey = destinyKey;
        _person     = person;
        _one        = ini.LandZone1[0];
        _two        = fin.LandZone1[0];

        _ini = ini;
        _fin = fin;

        RouteType = routeType;

        Init();
    }
Beispiel #12
0
    private void CleanOldVars()
    {
        _workerTask = HPers.None;

        //_profDescription = Job.None;
        _person           = null;
        _workTime         = 4f;
        _readyToWork      = false;
        _workingNow       = false;
        _isRouterBackUsed = false;
        _routerActive     = false;
        _finRoutePoint    = new Vector3();

        _router     = null;
        _routerBack = null;
    }
Beispiel #13
0
    internal void Walk(Vector3 point, Vector3 afterDest, Vector3 moveNowTo, HPers goingTo)
    {
        _agent.enabled = false;
        _person.transform.position = moveNowTo;

        _destWasSet = false;
        Destiny = point;
        _afterDestiny = afterDest;
        _nextDest = point;
        _agent.enabled = true;

        //Debugg(point);

        //if person is:
        //hidden
        //close enough to the destiny spawnpoint
        //destiny is a:
        //Dock
        //Library
        //Dont show
        if (_person.Body != null)
        {
            if (UPerson.IsThisPersonTheSelectedOne(_person))
            {
                var a = 1;
            }

            if (_person.Body.IsHidden() && _person.Body.IsNearBySpawnPointOfInitStructure() &&
                (_person.Body.IsDestinyOrOrigin(H.Library) || _person.Body.IsDestinyOrOrigin(H.Dock)))
            {
            }
            else
                _person.Body.Show();
        }

        if (goingTo == HPers.InWork && _person.ProfessionProp != null
            && _person.ProfessionProp.ProfDescription == Job.Builder)
        {
            _agent.obstacleAvoidanceType = ObstacleAvoidanceType.HighQualityObstacleAvoidance;
        }
        else
        {
            _agent.obstacleAvoidanceType = ObstacleAvoidanceType.LowQualityObstacleAvoidance;//low
        }
    }
Beispiel #14
0
    /// <summary>
    /// Work Action is called from brain when person is actually in job site
    /// </summary>
    public virtual void WorkAction(HPers p)
    {
        var others = ProfDescription != Job.Forester && _readyToWork;

        //if cant take anything out of work should it go
        var forester = ProfDescription == Job.Forester && _readyToWork && _person.Work.CanTakeItOut(_person);

        CheckIfHasWorkInputOrder();

        if (others || forester)
        {
            //Debug.Log("workingNow:" + _person.MyId);
            _workingNow = true;
        }
        else
        {
            _person.Brain.CurrentTask = p;
        }
    }
Beispiel #15
0
    public RouterManager(Structure ini, Structure fin, Person person, HPers routeType,
                         bool useIniBehind = true, bool useFinBehind = true, DateTime askDateTime = new DateTime())
    {
        _iniBehind   = new Vector3();
        _finBehind   = new Vector3();
        _askDateTime = askDateTime;

        _ini          = ini;
        _fin          = fin;
        _routeType    = routeType;
        _person       = person;
        _useIniBehind = useIniBehind;
        _useFinBehind = useFinBehind;

        InitBehinds();
        ClearOldVars();

        Init();
    }
Beispiel #16
0
    public CryRoute(Structure ini, Structure fin, Person person, string destinyKey, bool iniDoor = true, bool finDoor = true,
                    HPers routetype = HPers.None)
    {
        _origenKey  = ini.MyId;
        _destinyKey = destinyKey;

        _iniDoor = iniDoor;
        _finDoor = finDoor;

        _person = person;
        _one    = ini.LandZone1[0];
        _two    = fin.LandZone1[0];

        _ini = ini;
        _fin = fin;

        RouteType = routetype;

        ClearOldVars();
        Init();
    }
Beispiel #17
0
    public CryRoute(VectorLand uno, VectorLand dos, Person person, bool iniDoor = true, bool finDoor = true,
                    HPers routeType = HPers.None)
    {
        _origenKey  = uno.MyBuild().MyId;
        _destinyKey = dos.MyBuild().MyId;

        _iniDoor = iniDoor;
        _finDoor = finDoor;

        _person = person;
        _one    = uno;
        _two    = dos;

        _ini = uno.MyBuild();
        _fin = dos.MyBuild();

        RouteType = routeType;

        ClearOldVars();
        Init();
    }
Beispiel #18
0
 public void SetFlag(HPers which, bool val)
 {
     if (which == HPers.FoodSource)
     {
         _isfoodSourceChange = val;
     }
     else if (which == HPers.Work)
     {
         _isWorkChanged = val;
     }
     else if (which == HPers.Home)
     {
         _isHouseSpaceChanged = val;
     }
     else if (which == HPers.Religion)
     {
         IsNewReligion = val;
     }
     else if (which == HPers.Chill)
     {
         IsNewChill = val;
     }
 }
Beispiel #19
0
 void UpdateCurrent(HPers which)
 {
     if (which == HPers.Home)
     {
         HousesWithSpace = current;
         //print("HouseWithSpaceList Count Up:" + HousesWithSpace.Count);
     }
     else if (which == HPers.FoodSource)
     {
         FoodSources = current;
     }
     else if (which == HPers.Work)
     {
         //WorkOpenPos = current;
     }
     else if (which == HPers.Religion)
     {
         ReligiousBuilds = current;
     }
     else if (which == HPers.Chill)
     {
         ChillBuilds = current;
     }
 }
Beispiel #20
0
 void ResetMiniMindState()
 {
     _workingNow = false;
     _workerTask = HPers.None;
     //Debug.Log("resetMIniMindTstae:"+_person.MyId);
 }
Beispiel #21
0
 void WalkRoutineTail(HPers goingTo, HPers whichRouteP = HPers.None)
 {
     GoingTo     = goingTo;
     _movingNow  = true;
     _whichRoute = whichRouteP;
 }
Beispiel #22
0
 public void WalkRoutineLoad(TheRoute route, HPers goingTo, int loadInitCurrentPoint,
                             bool inverse, HPers whichRouteP)
 {
     InitWalk(route, inverse, loadInitCurrentPoint);
     WalkRoutineTail(goingTo, whichRouteP);
 }
Beispiel #23
0
 List <string> current = new List <string>(); //current list of buildiings being edited
 /// <summary>
 /// Will start to routine to add or remove an Build from its list
 /// </summary>
 public void EditBuildRoutine(string MyIdP, H action, H hTypeP)
 {
     buildFunc = SelectCurrentList(hTypeP);
     EditBuildAction(MyIdP, action);
 }
Beispiel #24
0
    /// <summary>
    /// If _workingNow = true this method will be called from derived class.
    ///  This is called once upon person is already on JobSite
    /// </summary>
    protected void WorkNow()
    {
        stuckedForester = _person.Body.Location == HPers.Work &&
                          ProfDescription == Job.Forester && _person.Body.GoingTo == HPers.InWork &&
                          _workerTask == HPers.WalkingToJobSite && _person.Body.BodyAgent.IsStuck()
        ;

        if (stuckedForester)
        {
            foresterStuck++;
            _person.Body.Location = HPers.Work;
            _workerTask           = HPers.DoneAtWork;
            _person.Body.GoingTo  = HPers.Work;
            StillElementId        = "";
            _person.OrderRedoWhenGetsHome();

            //_person.Body.Location = HPers.Work;
            //_workerTask = HPers.None;
            //_person.Body.GoingTo = HPers.Work;

            Debug.Log("unstuck forester: " + _person.name);



            //if(foresterStuck > 1)
            //{
            //    _person.Work.ChangeMaxAmoutOfWorkers("Less");
            //}

            //_person.Body.Location = HPers.Work;
            //_workerTask = HPers.None;
        }

        //walking toward the job site for forester walking towards a tree
        if (_person.Body.Location == HPers.Work && _workerTask == HPers.None)
        {
            if (_router != null && _router.TheRoute.OriginKey != _router.TheRoute.DestinyKey &&
                IsAnExistingBuilding(_router.TheRoute))
            //so doesnt go in and out in the same building
            //the is not booked to avoid people staying in the same House when grow older in same place
            {
                _person.Body.WalkRoutine(_router.TheRoute, HPers.InWork);
                _workerTask = HPers.WalkingToJobSite;
            }
            //when is importing something
            //so the Work is the same as _sourceBuild
            //to avoid go in and out again in the Dock
            else
            {
                //Debug.Log("Person had same Destiny and OriginKey was sent back to office :"+_person.MyId);
                PreparePersonToGetBackToOffice();
            }
        }
        //called here so animation of iddle can be fully transitioned to
        else if ((_person.Body.Location == HPers.InWork && _workerTask == HPers.WalkingToJobSite && !_person.Body.MovingNow)
                 // || stuckedForester
                 )
        {
            Idle(HPers.AniFullyTrans, 1f);
        }
        //for forester //ChopWood
        else if (_workerTask == HPers.AniFullyTrans)
        {
            var forester = ProfDescription == Job.Forester && (ElementWasCut() || LoadedDifferentElement()
                                                               //|| !_person.Work.CanTakeItOut(_person)
                                                               );

            var builder = ProfDescription == Job.Builder && CurrentConstructionIsNullOrDone();
            if (forester || builder)
            {
                StillElementId = "";
                PreparePersonToGetBackToOffice();
                return;
            }

            //so its doesnt play 'isWheelBarrow' ani in the midle of nothing tht sometimes
            //wheel lead to wheelBarrowers that have not a WheelBarrpw to play the ani while carrying a box
            if (ProfDescription != Job.WheelBarrow && ProfDescription != Job.Docker &&
                _person.Body.CurrentAni != _myAnimation)//we need to pass it only once. dont keep doing it
            {
                _person.Body.TurnCurrentAniAndStartNew(_myAnimation);
                //Debug.Log("_myAnimation sent on siteWork:"+_myAnimation+ " .profDesc:"+ProfDescription);
            }
            Idle(HPers.WorkingInPlaceNow, _workTime);
        }
        //called here so animation of iddle can be fully transitioned to
        else if (_workerTask == HPers.WorkingInPlaceNow)
        {
            PreparePersonToGetBackToOffice();
        }
        else if (_workerTask == HPers.WalkingBackToOffice)
        {
            _executeNow  = true;
            _doneWorkNow = true;//set here once the ani is fully transioned to

            //so it will get right animation . bz homer walks first and then drop/gets load
            //there fore can have an animation of carrying with empty inv
            if (ProfDescription == Job.Homer)
            {
                return;
            }
            ComingBackToOffice();
        }
        else if (_person.Body.Location == HPers.FoodSource && _workerTask == HPers.DoneAtFoodScr &&
                 _person.Body.GoingTo == HPers.FoodSource)
        {
            //so in brain all gets retarted again
            _person.Brain.CurrentTask = HPers.Walking;
            ResetMiniMindState();
        }
        else if (_person.Body.Location == HPers.Work && _workerTask == HPers.DoneAtWork &&
                 _person.Body.GoingTo == HPers.Work)
        {
            DoneWork();
        }
        //for wheelbarrowers alone and dockers..
        else if (_person.Body.Location == HPers.WheelBarrow &&
                 _workerTask == HPers.DoneAtWheelBarrow && _person.Body.GoingTo == HPers.WheelBarrow)
        {
            //so in brain all gets retarted again
            _person.Brain.CurrentTask = HPers.WheelBarrow;
            WheelBarrowDropLoad();
            ConvertWheelBarrow();
        }
        //for loading stuck Homer that was Farmer only
        else if (_person.Body.Location == HPers.WheelBarrow &&
                 ProfDescription == Job.Homer && _person.PrevJob == Job.Farmer && _workerTask == HPers.None &&
                 _person.Body.GoingTo == HPers.WheelBarrow)
        {
            //so in brain all gets retarted again
            _person.Brain.CurrentTask = HPers.WheelBarrow;
            ConvertToHomer();//called here bz need to restart
        }
        //for homers so they can start all over again at home just as had finished Work
        else if (_person.Body.Location == HPers.Home && _workerTask == HPers.DoneAtHome &&
                 _person.Body.GoingTo == HPers.Home)
        {
            _person.Brain.CurrentTask = HPers.Walking;
            _person.Body.Location     = HPers.Home;
            _person.Body.GoingTo      = HPers.Home;

            ResetMiniMindState();
        }
    }
Beispiel #25
0
 void ConvertToHomer()
 {
     //so work Profession Mini States
     _person.Body.Location = HPers.Work;
     _workerTask           = HPers.None;
 }
Beispiel #26
0
 protected void FakeWheelBarrowToRouteBack()
 {
     _person.Body.Location = HPers.WheelBarrow;
     _workerTask           = HPers.DoneAtWheelBarrow;
     _person.Body.GoingTo  = HPers.WheelBarrow;
 }