Beispiel #1
0
 public WeightAnalizer(Program program, Config config, CargoManager cargoManager, SystemManager systemManager)
 {
     _program       = program;
     _config        = config;
     _cargoManager  = cargoManager;
     _systemManager = systemManager;
 }
    /// <summary>
    /// Process selling cargo to a merchant
    /// </summary>
    /// <param name="ship">The ship doing the selling</param>
    /// <param name="warehouse">The merchant doing the buying</param>
    /// <param name="assets">The player's wealth</param>
    /// <param name="id">The cargo to sell</param>
    /// <param name="count">The amount to sell</param>
    /// <returns>Successfulness</returns>
    public static bool ProcessSell(CargoHold ship, Warehouse warehouse, PlayerAssets assets, Cargoes id, int count)
    {
        int price = warehouse.GetBuyPrice(id, count);

        if (warehouse.cash < price)
        {
            return(false);
        }

        if (warehouse.GetWantQuantity(id) == 0)
        {
            return(false);
        }

        if (ship.GetItemCount(id) < count)
        {
            return(false);
        }

        ship.Remove(id, count);
        warehouse.ModifyBuyingWare(id, -count);

        assets.ModifyCash(price);
        warehouse.ModifyCash(-price);

        if (!CargoManager.GetCargo(id).legal)
        {
            assets.ModifyReputation(price);
        }

        return(true);
    }
Beispiel #3
0
        public ActionResult GetAll(string partial_view)
        {
            manager = new CargoManager();
            var result = manager.Get();

            #region PreparandoArchivoDescarga
            string fileName = "Cargos.csv";
            //Areglando lista.
            var dataReport = (from a in result
                              select new
            {
                Id_Cargo = a.Id_Cargo.ToString(),
                Nombre = a.Nombre,
                EsAccionista = a.EsAccionista.ToString(),
                EsGerencial = a.EsGerencial.ToString()
            }
                              ).ToList();
            Create_Excel_Reports(fileName, dataReport);
            #endregion
            if (string.IsNullOrEmpty(partial_view))
            {
                return(View(result));
            }
            return(PartialView(partial_view, result));
        }
Beispiel #4
0
        public ActionResult Get(int Id_Rol, string partial_view)
        {
            manager = new CargoManager();
            var result = manager.Get(Id_Rol);

            return(PartialView(partial_view, result));
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            PrintTitle();
            System.Console.WriteLine("This a simple application for Scheduling Flights and Orders by Transport.ly");
            System.Console.WriteLine("Press Enter to continue...");
            System.Console.Read();

            try
            {
                var parsed       = JSONParser.ParseFromFile <Dictionary <string, Dictionary <string, string> > >(Constant.FILE_PATH);
                var cargoManager = new CargoManager();
                cargoManager.InitializeData(parsed);

                Application = new Application(cargoManager);

                Application.Run();

                System.Console.WriteLine("Thank you for using the application! Bye.");
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Unable to run the application properly.");
                System.Console.WriteLine($"Error: {e.Message}");
                System.Console.WriteLine($"Error Stack Trace: {e.StackTrace}");
            }
        }
Beispiel #6
0
 public void setupCopter(string[,] copterArray, int copterNumber)
 {
     /*for (int h = 1; h < 10; h++) {
      *      Debug.Log (int.Parse(copterArray[copterNumber,h]));
      * }
      * Debug.Log(gameManager.getPlatformLevel());*/
     splash            = manager.levelSplash;
     maxHealth         = int.Parse(copterArray[copterNumber, 15]);
     copterBody.mass   = int.Parse(copterArray[copterNumber, 10]);
     tiltSpeed         = int.Parse(copterArray[copterNumber, 16]);
     returnSpeed       = tiltSpeed / 40;
     maxTilt           = int.Parse(copterArray[copterNumber, 17]);
     maxFuel           = int.Parse(copterArray[copterNumber, 8]) + (((int.Parse(copterArray[copterNumber, 9]) - int.Parse(copterArray[copterNumber, 8])) / 10) * int.Parse(copterArray[copterNumber, 5]));
     maxPower          = int.Parse(copterArray[copterNumber, 6]) + (((int.Parse(copterArray[copterNumber, 7]) - int.Parse(copterArray[copterNumber, 6])) / 10) * int.Parse(copterArray[copterNumber, 4]));
     ropeDurability    = int.Parse(copterArray[copterNumber, 13]) + (((int.Parse(copterArray[copterNumber, 14]) - int.Parse(copterArray[copterNumber, 13])) / 10) * int.Parse(copterArray[copterNumber, 12]));
     reFuelPerSecond   = maxFuel / 2 /*((14 - gameManager.getPlatformLevel()) / 2)*/;
     healPerSecond     = maxHealth / 2 /*((14 - gameManager.getPlatformLevel()) / 2)*/;
     manager.cargoSize = int.Parse(copterArray[copterNumber, 11]);
     currentHealth     = maxHealth;
     currentFuel       = maxFuel;
     cargo             = GetComponent <CargoManager>();
     hookJoint         = GetComponent <DistanceJoint2D> ();
     hookJoint.anchor  = hookAnchor.transform.localPosition;
     copterScale       = gameObject.transform.localScale.x;
     resetPower();
 }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        maxLifeTimeInSeconds = lifeTimeInSeconds;
        if (!inMenu)
        {
            Time.timeScale = 1f;
            manager        = GameObject.Find("LevelManagerO").GetComponent <LevelManager> ();
            copterScript   = GameObject.Find("Copter").GetComponent <CopterManagerTouch> ();
            cargoScript    = GameObject.Find("Copter").GetComponent <CargoManager> ();
        }
        crate    = gameObject.transform.parent.gameObject;
        animator = gameObject.transform.parent.GetComponent <Animator>();
        //Debug.Log(animator.name);
        //spriteRenderer = crate.GetComponent<SpriteRenderer> ();

        /*if (crate.transform.FindChild ("BackGround") != null)
         *      bgRenderer = crate.transform.FindChild ("BackGround").GetComponent<SpriteRenderer> ();*/

        if (animator.GetInteger("status") == 0)
        {
            stationary = true;
        }
        else if (animator.GetInteger("status") == 1)
        {
            twoPhases = true;
        }
        else if (animator.GetInteger("status") == 3)
        {
            fourPhases = true;
        }

        floatyValue = gameObject.transform.parent.GetComponent <Rigidbody2D> ().mass * 30f;
        hinge       = GetComponent <HingeJoint2D> ();
    }
Beispiel #8
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Beispiel #9
0
	// Use this for initialization
	void Awake () {
		_instance = this;

		//new WindField();

		_cargoManager = new CargoManager();
		_timeManager = new TimeManager();
		_cargo = new CargoHold();
		_assets = new PlayerAssets();

		_settlements = FindObjectsOfType<Settlement>();

		var ais = FindObjectsOfType<AIController>();
		var list = new List<Ship>();

		foreach (var ai in ais) {
			list.Add(ai.GetComponent<Ship>());
		}

		_ais = list.ToArray();

		_playerStartPos = _playerShip.transform.position;
		_playerStartRot = _playerShip.transform.rotation;
		_cameraStartPos = Camera.main.transform.position;
		_cameraStartRot = Camera.main.transform.rotation;
	}
Beispiel #10
0
    public void SetCargo(Cargoes type, int amount)
    {
        var info = CargoManager.GetCargo(type);

        nameLabel.text  = info.name;
        countLabel.text = amount.ToString();
        illegalIcon.SetActive(!info.legal);
    }
Beispiel #11
0
 void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(gameObject);
     }
     _instance = this;
 }
Beispiel #12
0
        public void RefreshDisplay()
        {
            var cargo = CargoManager.GetCargo(_ware.id);

            _nameLabel.text  = cargo.name;
            _countLabel.text = "x" + _ware.count;
            _priceLabel.text = _warehouse.GetPrice(_ware.id, 1) + "G";
        }
Beispiel #13
0
 public ExcavOSContext(Program program, Config config, MyIni storage)
 {
     _program        = program;
     _config         = config;
     _storage        = storage;
     _cargoManager   = new CargoManager(_program, _config);
     _systemmanager  = new SystemManager(_program, _config);
     _weightAnalizer = new WeightAnalizer(_program, _config, _cargoManager, _systemmanager);
     _utilitymanager = new UtilityManager(_program, _config, _cargoManager, _systemmanager, _storage);
 }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Beispiel #15
0
    public CargoManager()
    {
        _instance = this;

        TextAsset cargoDef = Resources.Load("Data/cargos") as TextAsset;
        CargoList cargos   = JsonUtility.FromJson <CargoList>(cargoDef.text);

        foreach (var cargo in cargos.cargos)
        {
            _cargos.Add((Cargoes)System.Enum.Parse(typeof(Cargoes), cargo.id), cargo);
        }
    }
Beispiel #16
0
        private void UpdateSelectedItem()
        {
            if (_selectedItem < _itemList.Count)
            {
                PurchaseItem         item  = _itemList[_selectedItem];
                CargoList.CargoEntry cargo = CargoManager.GetCargo(item.ware.id);

                _selectedWareNameLabel.text = cargo.name;
                _sellerHoldLabel.text       = item.ware.count.ToString();
                _playerHoldLabel.text       = _ship.GetItemCount(cargo.cargo).ToString();
            }
        }
Beispiel #17
0
    /// <summary>
    /// Returns if the hold is completely legal
    /// </summary>
    /// <returns>Whether the conents of the hold is fully legal</returns>
    public bool IsLegal()
    {
        foreach (var item in _hold)
        {
            if (item.Value > 0 && !CargoManager.GetCargo(item.Key).legal)
            {
                return(false);
            }
        }

        return(true);
    }
Beispiel #18
0
        public JsonResult agregarCargos(Cargos cargo)
        {
            var seguridad = new CargoManager();

            return(Json(new
            {
                Success = "OK",
                Result = seguridad.agregarCargo(
                    cargo,
                    (long)HttpContext.Session["IdSesion"]
                    )
            }));
        }
Beispiel #19
0
        /// <summary>
        /// Returns the price the warehouse buys a cargo for
        /// </summary>
        /// <param name="id">Id of the cargo to buy</param>
        /// <param name="count">Optional cargo count</param>
        /// <returns>The buying price</returns>
        public int GetBuyPrice(Cargoes id, int count = 1)
        {
            Ware ware = GetBuyWare(id);

            if (ware == null)
            {
                return(0);
            }

            int basePrice = Mathf.RoundToInt(ware.priceMod * CargoManager.GetCargo(id).price);

            return(basePrice * count);
        }
    public int GetIllegalCargoValue()
    {
        var cargos    = _target.cargoHold.GetIllegalCargo();
        int totalFine = 0;

        foreach (var item in cargos)
        {
            var desc = CargoManager.GetCargo(item.Key);

            totalFine += desc.price * item.Value;
        }

        return(totalFine);
    }
Beispiel #21
0
    public int GetIllegalCount()
    {
        int count = 0;

        foreach (var item in _hold)
        {
            var cargo = CargoManager.GetCargo(item.Key);

            if (!cargo.legal)
            {
                count += item.Value;
            }
        }

        return(count);
    }
Beispiel #22
0
    public Dictionary <Cargoes, int> GetIllegalCargo()
    {
        var list = new Dictionary <Cargoes, int>();

        foreach (var item in _hold)
        {
            var cargo = CargoManager.GetCargo(item.Key);

            if (!cargo.legal)
            {
                list.Add(item.Key, item.Value);
            }
        }

        return(list);
    }
Beispiel #23
0
    public int GetHidingCount()
    {
        float count = 0;

        foreach (var item in _hold)
        {
            var cargo = CargoManager.GetCargo(item.Key);

            if (cargo.legal)
            {
                count += item.Value / cargo.hideRatio;
            }
        }

        return(Mathf.RoundToInt(count));
    }
Beispiel #24
0
        public ActionResult Delete(Cargo model)
        {
            try
            {
                manager = new CargoManager();
                manager.Del(model);

                ViewBag.Success = "Datos Actualizados Satisfactoriamente";
                return(Content("Datos Actualizados Satisfactoriamente"));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }

            return(Content(ViewBag.Error));
        }
Beispiel #25
0
 public UtilityManager(Program program, Config config, CargoManager cargoManager, SystemManager systemManager, MyIni storage)
 {
     _program       = program;
     _config        = config;
     _storage       = storage;
     _cargoManager  = cargoManager;
     _systemManager = systemManager;
     _gyros         = new BlockFinder <IMyGyro>(_program);
     _sorters       = new BlockFinder <IMyConveyorSorter>(_program);
     _controllers   = new BlockFinder <IMyShipController>(_program);
     _batteries     = new BlockFinder <IMyBatteryBlock>(_program);
     _hydrogenTanks = new BlockFinder <IMyGasTank>(_program);
     _reactors      = new BlockFinder <IMyReactor>(_program);
     thrustPID.Kp   = ThrustKp;
     thrustPID.Ti   = ThrustTi;
     thrustPID.Td   = ThrustTd;
     Initialize();
 }
Beispiel #26
0
        protected IEnumerable <SelectListItem> GetDrpCargo()
        {
            List <SelectListItem> ls = new List <SelectListItem>();

            try
            {
                CargoManager _man = new CargoManager();

                var result = _man.Get();
                foreach (var temp in result)
                {
                    ls.Add(new SelectListItem()
                    {
                        Text = temp.Nombre.ToString(), Value = temp.Id_Cargo.ToString()
                    });
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message.ToString();
            }
            return(ls);
        }
Beispiel #27
0
    private void UpdateTab()
    {
        CargoManager cm = CargoManager.Instance;

        if (cm.ShuttleStatus == ShuttleStatus.OnRouteCentcom ||
            cm.ShuttleStatus == ShuttleStatus.OnRouteStation)
        {
            if (cm.CurrentFlyTime > 0)
            {
                string min = Mathf.FloorToInt(cm.CurrentFlyTime / 60).ToString();
                string sec = (cm.CurrentFlyTime % 60).ToString();
                sec = sec.Length >= 10 ? sec : "0" + sec;

                shuttleButtonText.SetValue = min + ":" + sec;
            }
            else
            {
                shuttleButtonText.SetValue = "ARRIVING";
            }
            SetShuttleStatus(statusTransitImage);
        }
        else
        {
            if (cm.ShuttleStatus == ShuttleStatus.DockedStation)
            {
                SetShuttleStatus(statusCargoImage);
            }
            else
            {
                SetShuttleStatus(statusCentcomImage);
            }
            shuttleButtonText.SetValue = "SEND";
        }

        messageText.SetValue = cm.CentcomMessage;
        creditsText.SetValue = cm.Credits.ToString();
    }
Beispiel #28
0
    /// <summary>
    /// Hiding factor is a number representing how well any illegal cargo is hidden
    /// </summary>
    /// <returns></returns>
    public int GetHidingFactor()
    {
        float totalIllegal    = 0;
        float totalHideVolume = 0;
        int   factor          = 0;

        foreach (var item in _hold)
        {
            var cargo = CargoManager.GetCargo(item.Key);

            if (cargo.legal)
            {
                totalHideVolume += item.Value / cargo.hideRatio;
            }
            else
            {
                totalIllegal += item.Value;
            }
        }

        factor = Mathf.RoundToInt((totalHideVolume / totalIllegal) * 75);

        return(factor);
    }
Beispiel #29
0
 void Start()
 {
     Instance = this;
 }
Beispiel #30
0
 void Start()
 {
     Instance = this;
 }
Beispiel #31
0
        public JsonResult ObtenerCargos()
        {
            var seguridad = new CargoManager();

            return(Json(seguridad.obtenerCargos(), JsonRequestBehavior.AllowGet));
        }