コード例 #1
0
ファイル: Inventory.cs プロジェクト: Cdrix/SM
    /// <summary>
    /// The add of an item to the Inventory
    /// </summary>
    /// <param name="key"></param>
    /// <param name="amt"></param>
    public void Add(P key, float amt, MDate expiration = null)
    {
        if (key == P.None || key == P.Food || amt == 0)
        {
            //Debug.Log("ret Tried to add to inv:"+ key +" amt:"+ amt);
            return;
        }
        if (key == P.RandomMineOutput || key == P.RandomFoundryOutput)
        {
            //Debug.Log("trace random");
            DealWithRandomOutput(key, amt);
            return;
        }

        //in this way a new expiration date is going to be set as soon a prod is
        //added to a new inventory. is not pefect bz doesnt carry old expiration date
        //foward but at the same time the majority of the product expires as stays behind and
        //gets check in the inventory
        var     expireCalc = ExpirationDate(key, expiration);
        InvItem curr       = null;

        if (IsItemOnInv(key))
        {
            float intT = ReturnAmtOfItemOnInv(key) + amt;
            curr = SetAmtWithKey(key, intT);
        }
        else
        {
            AddToCategory(key);
            _inventItems.Add(new InvItem(key, amt));
            curr = SetAmtWithKey(key, amt);
        }
        SetAmtExpiration(curr, amt, expireCalc);
        AddressGameInventory(key, amt, true);
    }
コード例 #2
0
    // Update is called once per frame
    public void Update()
    {
        //correcting bug where kids stay in front of storage with path completed
        if ((_destWasSet && _agent.isOnNavMesh && _agent.enabled && !_person.IsMajor &&
             !UMath.nearEqualByDistance(_agent.destination, Destiny, 0.1f) &&
             _agent.pathStatus == NavMeshPathStatus.PathComplete)
            ||
            (_agent.pathStatus == NavMeshPathStatus.PathInvalid && _agent.enabled && _agent.isOnNavMesh)
            )
        {
            //so i set the destination again to the real one so they move towards it
            _agent.SetDestination(Destiny);
        }

        if (_nextDest != new Vector3() && !_destWasSet && _agent.isOnNavMesh && _agent.enabled)
        {
            _destWasSet = true;
            _agent.SetDestination(Destiny);
            _startDate = Program.gameScene.GameTime1.CurrentDate();
        }
        CheckIfGoingIntoBuild();
        RadiusForHeavyLoaders();

        CheckVelocity();
        CheckIfTempSpeed();
        CheckIfPathPending();

        CheckIfStuck();
    }
コード例 #3
0
    public int ElapsedDateInDays(MDate first, MDate last)
    {
        var days1st = FromMDateToDays(first);
        var days2nd = FromMDateToDays(last);

        return(days2nd - days1st);
    }
コード例 #4
0
        public IHttpActionResult GetFlightsByDepartureDate([FromBody] MDate dateAndTime)
        {
            try
            {
                DateTime dateTime = new DateTime(Convert.ToInt32(dateAndTime.mDate.Substring(0, 4)), Convert.ToInt32(dateAndTime.mDate.Substring(5, 2)), Convert.ToInt32(dateAndTime.mDate.Substring(8, 2)));

                List <Flight> result = (List <Flight>)facade.GetFlightsByDepartureDate(dateTime);

                if (result == null)
                {
                    return(StatusCode(HttpStatusCode.NoContent));
                }
                else
                {
                    return(Ok(result));
                }
            }

            catch (AirlinesManagerException ex)
            {
                return(BadRequest(ex.Message));
            }

            catch (SystemException ex)
            {
                return(InternalServerError(new Exception("Unexpected error. Please contact support.")));
            }
        }//CHECKED
コード例 #5
0
    /// <summary>
    /// Here the last param is current date
    /// </summary>
    /// <param name="first"></param>
    /// <returns></returns>
    public int ElapsedDateInDaysToDate(MDate first)
    {
        var days1st = FromMDateToDays(first);
        var days2nd = FromMDateToDays(CurrentDate());

        return(days2nd - days1st);
    }
コード例 #6
0
    /// <summary>
    /// When at 10x, and over 100ppl may take a while for the agent get the requested path
    /// </summary>
    private void CheckIfPathPending()
    {
        if (UPerson.IsThisPersonTheSelectedOne(_person))
        {
            var a = 1;
        }

        //if is waiting for a path and suppose to be movung already, then will be promt to Iddle
        if (_savedAniPathPending == "" && _agent.pathPending && _person.Body.IAmShown())
        {
            _savedAniPathPending = _person.Body.CurrentAni;
            _person.Body.TurnCurrentAniAndStartNew("isIdle");
            _startDate = null;
        }
        //once is ready will retake its ani
        else if (_savedAniPathPending != "" && !_agent.pathPending)
        {
            if (UPerson.IsThisPersonTheSelectedOne(_person))
            {
                var a = 1;
            }

            _person.Body.TurnCurrentAniAndStartNew(_savedAniPathPending);
            _savedAniPathPending = "";
            _startDate = Program.gameScene.GameTime1.CurrentDate();
        }
    }
コード例 #7
0
    public void SavePlant(Plant plant)
    {
        _type = plant.Type;       //type of plant. ex : Bean

        _growGen = plant.GrowGen; //btw 90-100 will indicate how farr will go a plant just by genes

        //the duration of a plant in days
        _lifeDuration = plant.LifeDuration;//120 is for corn

        //when was seeded
        _seedDate = plant.SeedDate;

        //at wht step of growing is,  0.1-1
        _currentGrowStep = plant.CurrentGrowStep;

        //the amout will grow the gameObj created so it happens nie and smotth the grow
        _amtToGrow = plant.AmtToGrow;

        _isReadyToHarvest = plant.IsReadyToHarvest;

        _readyToHarvestDate = plant.ReadyToHarvestDate;
        _daysToRotten       = plant.DaysToRotten;
        _isRotten           = plant.IsRotten;

        _localScale = plant.gameObject.transform.localScale;
    }
コード例 #8
0
    private void CheckIfStuck()
    {
        //For Heavy Haulers stuck on Load, if they were saved in a Storage in the way of exporting something to the port
        if (_person.Work != null && _person.Work.HType == H.HeavyLoad && _person.Body.MovingNow &&
            !_agent.hasPath && _agent.pathStatus == NavMeshPathStatus.PathInvalid && _agent.enabled && _agent.isOnNavMesh)
        {
            if (_startDate == null)
                _startDate = Program.gameScene.GameTime1.CurrentDate();
            if (_startDate != null && Program.gameScene.GameTime1.ElapsedDateInDaysToDate(_startDate) > 3)
            {
                Debug.Log(_person.Name + " - stuck. restarts the routing => isCart");

                _person.Body.TurnCurrentAniAndStartNew("isCart");
                _startDate = null;
            }
        }

        if (_startDate != null && Program.gameScene.GameTime1.ElapsedDateInDaysToDate(_startDate) > 30)
        {
            //so restarts the routing
            Debug.Log(_person.Name + " - stuck. restarts the routing => _destWasSet = false");
            _destWasSet = false;
            _startDate = null;
        }
    }
コード例 #9
0
 public Militar(Building building)
 {
     // TODO: Complete member initialization
     _building = building;
     _nextDate = Program.gameScene.GameTime1.CurrentDate();
     _nextDate = Program.gameScene.GameTime1.ReturnCurrentDatePlsAdded(360);
 }
コード例 #10
0
        public ActionResult GetFlightsByLadningDate([FromBody] MDate dateAndTime)
        {
            try
            {
                DateTime dateTime = new DateTime(Convert.ToInt32(dateAndTime.mDate.Substring(0, 4)), Convert.ToInt32(dateAndTime.mDate.Substring(5, 2)), Convert.ToInt32(dateAndTime.mDate.Substring(8, 2)));

                List <Flight> result = (List <Flight>)facade.GetFlightsByLandingDate(dateTime);

                if (result == null)
                {
                    return(NoContent());
                }
                else
                {
                    return(Ok(result));
                }
            }

            catch (AirlinesManagerException ex)
            {
                return(BadRequest(ex.Message));
            }

            catch (SystemException ex)
            {
                return(Problem("Unexpected error. Please contact support."));
            }
        }//CHECKED
コード例 #11
0
 public void Update()
 {
     if (GameTime.IsPastOrNow(_nextDate))
     {
         _nextDate = Program.gameScene.GameTime1.ReturnCurrentDatePlsAdded(360);
         YearEffectOnPirateThreat();
     }
 }
コード例 #12
0
ファイル: SubBulletinFinance.cs プロジェクト: Cdrix/SM
 public ExportData(MDate mDate, string building, string prod, float amt, float money)
 {
     MDate    = mDate;
     Building = building;
     Prod     = prod;
     Amt      = amt;
     Money    = money;
 }
コード例 #13
0
ファイル: MoveNow.cs プロジェクト: Cdrix/SM
 private void ResetThis()
 {
     //Debug.Log("ResetThis: " + _person.name);
     _destroyedAt              = null;
     _destroyedAtGameTime      = 0;
     _fiveSecAfterDestroyedPos = new Vector3();
     _router = null;
 }
コード例 #14
0
ファイル: Inventory.cs プロジェクト: Cdrix/SM
    private void SetAmtExpiration(InvItem item, float amt, MDate expiration)
    {
        if (expiration == null || item == null)
        {
            return;
        }

        item.AddExpirationDate(amt, expiration, this);
    }
コード例 #15
0
 public static bool IsPastOrNow(MDate leaveDate)
 {
     if (leaveDate.Month1 <= Program.gameScene.GameTime1.Month1 &&
         leaveDate.Year <= Program.gameScene.GameTime1.Year)
     {
         return(true);
     }
     return(false);
 }
コード例 #16
0
    public MDate ElapsedDate(MDate first, MDate last)
    {
        var days1st = FromMDateToDays(first);
        var days2nd = FromMDateToDays(last);

        var diff = days2nd - days1st;

        return(FromDaysToMDate(diff));
    }
コード例 #17
0
ファイル: ShipManager.cs プロジェクト: Cdrix/SM
 private void CheckIfTimeToVisit()
 {
     if (_nextVisit != null && IsTheVisitPastOrNow() &&
         BuildingPot.Control.DockManager1.AtLeastOneDockHasSpace1More(_ships.Count))
     {
         _nextVisit = null;
         NewShipComingToUs();
     }
 }
コード例 #18
0
 private void CheckIfStuck()
 {
     if (_startDate != null && Program.gameScene.GameTime1.ElapsedDateInDaysToDate(_startDate) > 30)
     {
         //so restarts the routing
         //Debug.Log(_person.Name + " - stuck. restarts the routing");
         _destWasSet = false;
         _startDate  = null;
     }
 }
コード例 #19
0
ファイル: Docker.cs プロジェクト: naaturaz/SM
 private bool NewAct(string act)
 {
     if (_lastAct != null && Program.gameScene.GameTime1.ElapsedDateInDaysToDate(_lastAct) < 15)
     {
         return(false);
     }
     _lastAct = Program.gameScene.GameTime1.CurrentDate();
     _act     = act;
     return(true);
 }
コード例 #20
0
    private void MarkToHarvest()
    {
        if (_isReadyToHarvest)
        {
            return;
        }

        _isReadyToHarvest = true;
        _fieldFarm.HarvestCheck();
        _readyToHarvestDate = Program.gameScene.GameTime1.CurrentDate();
    }
コード例 #21
0
    /// <summary>
    /// The action of getting a new Swaped in tree ready
    /// </summary>
    /// <param name="oldTree"></param>
    internal void SwapIn(TerrainRamdonSpawner oldTree)
    {
        var oldP = oldTree.transform.position;

        MyId = oldTree.MyId;
        name = oldTree.name;

        //hiding in deep into terrain
        transform.position = new Vector3(oldP.x, oldP.y - howDeepInY, oldP.z);
        transform.rotation = oldTree.transform.rotation;
        IndexAllVertex     = oldTree.IndexAllVertex;
        SeedDate           = Program.gameScene.GameTime1.CurrentDate();
        ReplantedTree      = true;
    }
コード例 #22
0
ファイル: ShipManager.cs プロジェクト: Cdrix/SM
    private void SetNextVisit()
    {
        var unit = 6000;

#if UNITY_EDITOR
        unit = 60;
#endif
        //+1 in case is too low or zero
        //so if is 10 the PortRep 3600 / 10 is 1 year
        //so if is 100 the PortRep 3600 / 100 is 36 days
        //with 6000 is every 60 days, 2 month with 100 as PortRep
        var daysFromNow = unit / (BuildingPot.Control.DockManager1.PortReputation + 1);
        _nextVisit = Program.gameScene.GameTime1.ReturnCurrentDatePlsAdded(daysFromNow);
    }
コード例 #23
0
ファイル: Inventory.cs プロジェクト: Cdrix/SM
    /// <summary>
    /// Will calcluate the expiration date of a product
    ///
    /// if already has one will return that one that has already
    ///
    /// if product doestn have expiration will return null
    /// </summary>
    /// <param name="prod"></param>
    /// <param name="current"></param>
    /// <returns></returns>
    public static MDate ExpirationDate(P prod, MDate current = null)
    {
        if (current != null)
        {
            return(current);
        }

        var days = Program.gameScene.ExportImport1.ReturnExpireDays(prod);

        if (days == -1)
        {
            return(null);
        }
        return(Program.gameScene.GameTime1.ReturnCurrentDatePlsAdded(days));
    }
コード例 #24
0
ファイル: MoveNow.cs プロジェクト: Cdrix/SM
    // Update is called once per frame
    public void Update()
    {
        return;

        if (_person == null || _person.Home == null || !_person.IsMajor)
        {
            var a = _person.name;
            return;
        }
        else if (_person.Home.Instruction == H.WillBeDestroy && _destroyedAt == null)
        {
            _destroyedAt         = Program.gameScene.GameTime1.CurrentDate();
            _destroyedAtGameTime = Time.time;
        }
        else if (_destroyedAt != null && Time.time > _destroyedAtGameTime + 5 && _fiveSecAfterDestroyedPos == new Vector3())
        {
            _fiveSecAfterDestroyedPos = _person.transform.position;
        }
        else if (_router == null &&
                 _destroyedAt != null && Program.gameScene.GameTime1.ElapsedDateInDaysToDate(_destroyedAt) > 90)
        {
            //_person.Brain.Partido = true;
            //return;
            //if (UMath.nearEqualByDistance(_person.transform.position, _fiveSecAfterDestroyedPos, .1f))
            //{
            //    CreateRoute();
            //}
            //else
            //{
            //    ResetThis();
            //}
        }
        //else if(_router != null && !_router.IsRouteReady)
        //{
        //    _router.Update();
        //}
        //else if(_router != null && _router.IsRouteReady && _person.Body.GoingTo != HPers.NowToNewHome)
        //{
        //    //reached the house
        //    if (_person.Body.GoingTo == HPers.MovingToNewHome)
        //    {
        //        ResetThis();
        //        return;
        //    }
        //    MoveNowToNewHouse();
        //}
    }
コード例 #25
0
    public TerrainRamdonSpawner RetTerraSpawn(Vector3 origen, Vector3 rotation,
                                              int indexAllVertex, H hType,
                                              string name    = "", Transform container = null, bool replantedTree = false,
                                              float height   = 0, MDate seedDate       = null, float maxHeight    = 0,
                                              Quaternion rot = new Quaternion())
    {
        TerrainRamdonSpawner obj = OneByType(hType);

        if (obj == null)
        {
            //Debug.Log("needed on Pool: " + hType);
            return(obj);
        }

        var still = (StillElement)obj;

        still.enabled = true;
        obj.enabled   = true;

        if (name != "")
        {
            obj.name = name;
        }
        obj.IndexAllVertex = indexAllVertex;
        obj.HType          = hType;
        obj.Category       = obj.DefineCategory(hType);
        obj.MyId           = obj.Rename(name, obj.Id, obj.HType);
        obj.transform.name = obj.MyId;

        //here to avoid rotating object after spwaned
        //for loading
        obj.transform.rotation = rot;
        //for new obj
        obj.transform.Rotate(rotation);
        obj.transform.position = origen;

        obj.ReplantedTree = replantedTree;
        obj.Height        = height;
        obj.SeedDate      = seedDate;

        if (container != null)
        {
            obj.transform.SetParent(container);
        }

        return(obj);
    }
コード例 #26
0
ファイル: SpawnedData.cs プロジェクト: Cdrix/SM
    public SpawnedData(Vector3 posP, Quaternion rotP, H typeP, int rootStringIndexP,
                       int allVertexIndexP, float treeHeight = 0, MDate seedDate = null, float maxHeight = 0,
                       bool treeFall = false, float weight = 0, int region = -1)
    {
        Pos             = posP;
        Rot             = rotP;
        Type            = typeP;
        RootStringIndex = rootStringIndexP;
        AllVertexIndex  = allVertexIndexP;

        TreeHeight = treeHeight;
        SeedDate   = seedDate;
        MaxHeight  = maxHeight;

        TreeFall = treeFall;
        Weight   = weight;

        Region = region;
    }
コード例 #27
0
    static public TerrainRamdonSpawner CreateTerraSpawn(string root, Vector3 origen, Vector3 rotation,
                                                        int indexAllVertex, H hType,
                                                        string name    = "", Transform container = null, bool replantedTree = false,
                                                        float height   = 0, MDate seedDate       = null, float maxHeight    = 0,
                                                        Quaternion rot = new Quaternion())
    {
        WAKEUP = true;
        TerrainRamdonSpawner obj = null;

        obj = (TerrainRamdonSpawner)Resources.Load(root, typeof(TerrainRamdonSpawner));

        if (obj == null)
        {
            Debug.Log("null:" + root);
        }

        obj = (TerrainRamdonSpawner)Instantiate(obj, origen, Quaternion.identity);
        if (name != "")
        {
            obj.name = name;
        }
        if (container != null)
        {
            obj.transform.SetParent(container);
        }
        obj.IndexAllVertex = indexAllVertex;
        obj.HType          = hType;
        obj.Category       = obj.DefineCategory(hType);
        obj.MyId           = obj.Rename(name, obj.Id, obj.HType);
        obj.transform.name = obj.MyId;

        //here to avoid rotating object after spwaned
        //for loading
        obj.transform.rotation = rot;
        //for new obj
        obj.transform.Rotate(rotation);

        obj.ReplantedTree = replantedTree;
        obj.Height        = height;
        obj.SeedDate      = seedDate;
        return(obj);
    }
コード例 #28
0
    private void GatherReport()
    {
        People    = PersonPot.Control.All.Count;
        GameDate  = Program.gameScene.GameTime1.CurrentDate();
        Emigrate  = PersonPot.Control.EmigrateController1.Emigrates.Count;
        Food      = GameController.ResumenInventory1.ReturnAmountOnCategory(PCat.Food);
        Happy     = PersonPot.Control.OverAllHappiness();
        PortRep   = BuildingPot.Control.DockManager1.PortReputation;
        PirateThr = BuildingPot.Control.DockManager1.PirateThreat;
        Dollar    = Program.gameScene.GameController1.Dollars;
        Buildings = BuildingPot.Control.Registro.StringOfAllBuildings();
        ResumeInv = GameController.ResumenInventory1.GameInventory;

        //fps average
        var ttlTemp = 0f;

        for (int i = 0; i < FPS.Count; i++)
        {
            ttlTemp += FPS[i];
        }
        AverageFPS = ttlTemp / FPS.Count;

        TimeSec = Time.time;
        TimeMin = Time.time / 60;

        // average
        var tempSpeedTtl = 0;

        for (int i = 0; i < Speed.Count; i++)
        {
            tempSpeedTtl += Speed[i];
        }
        AverageSpeed = (float)tempSpeedTtl / Speed.Count;

        Difficulty         = PersonPot.Control.Difficulty;
        ScreenSize         = " Screen: Width: " + Screen.width + ". Height: " + Screen.height;
        InitialRegionIndex = MeshController.CrystalManager1.InitialRegionIndex;
        TypeOfGame         = Program.TypeOfGame;
        Quality            = QualitySettings.GetQualityLevel();
    }
コード例 #29
0
ファイル: Inventory.cs プロジェクト: Cdrix/SM
    internal void AddExpirationDate(float amt, MDate expiration, Inventory inv)
    {
        //no expiration needed for this 2 below
        if (inv.HType == H.Person || inv.HType == H.None || inv.HType == H.YearReport || !Program.IsFood)
        {
            return;
        }

        //found is lumping expiration dates by month and year so if day is not the same
        //will be still lumped toghether
        var found = _expiresAmts.Find(a => a.Expires.Month1 == expiration.Month1 &&
                                      a.Expires.Year == expiration.Year);

        if (found != null)
        {
            found.Amt += amt;
        }
        else
        {
            _expiresAmts.Add(new SubInvItem(amt, expiration));
        }
    }
コード例 #30
0
ファイル: Emigrate.cs プロジェクト: Cdrix/SM
 public void DetermineDeathDate(int yearsToAddToToday)
 {
     _deathDate = Program.gameScene.GameTime1.ReturnCurrentDatePlsAdded(yearsToAddToToday * 360);
 }