//Get a Ressourcesprite
 public Sprite getSprite(Ressources r)
 {
     if (r != (int)Ressources.None)
         return getSprite(r.ToString());
     else
         return null;
 }
Esempio n. 2
0
        // GET: api/Balance/customerId
        public JsonResult <Ressources> Get(string id)
        {
            var errString = "The client does not exist. Please retry with a valid client id.";
            var balance   = ServiceDictionary.AppService;

            try
            {
                var client = new Ressources
                {
                    //CPU = id,
                    //Memory = ,
                    //Message = "SUCCESS!"
                };

                return(Json(client)); // return ClientBalance Object
            }
            catch (Exception ex)
            {
                return(Json(new Ressources
                {
                    //CPU = id,
                    //Memory = null,
                    //Message = "FAILURE! " + errString + " " + ex.Message
                })); // return ClientBalance Object
            }
        }
Esempio n. 3
0
        public static Int32 currentRessources(Ressources f)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                String           search = "select * from ressources where code = '" + f.Code + "' and libelle = '" + f.Libelle + "'";
                NpgsqlCommand    Lcmd   = new NpgsqlCommand(search, con);
                NpgsqlDataReader lect   = Lcmd.ExecuteReader();
                Int32            id     = new Int32();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        id = (Int32)((lect["id"] != null) ? (!lect["id"].ToString().Trim().Equals("") ? lect["id"] : 0) : 0);
                    }
                }
                return(id);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(0);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Esempio n. 4
0
        public override void Render(RenderArgs args)
        {
            var prot    = args.Prototype;
            var context = args.Context;
            var bounds  = args.Bounds;
            var fg      = Ressources.GetBrush((Color)prot.Parameter["ForeColor"].Value);
            var bg      = Ressources.GetBrush((Color)prot.Parameter["BackColor"].Value);

            if (bg != null)
            {
                context.FillEllipse(
                    new Ellipse(
                        new Vector2(bounds.X + bounds.Width * 0.5f, bounds.Y + bounds.Height * 0.5f),
                        bounds.Width * 0.5f, bounds.Height * 0.5f),
                    bg);
            }
            if (fg != null)
            {
                context.DrawEllipse(
                    new Ellipse(
                        new Vector2(bounds.X + bounds.Width * 0.5f, bounds.Y + bounds.Height * 0.5f),
                        bounds.Width * 0.5f, bounds.Height * 0.5f),
                    fg);
            }
        }
Esempio n. 5
0
        public static List <Ressources> listRessources(string query)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                NpgsqlCommand     Lcmd = new NpgsqlCommand(query, con);
                NpgsqlDataReader  lect = Lcmd.ExecuteReader();
                List <Ressources> l    = new List <Ressources>();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        Ressources y = oneRessources((Int32)((lect["id"] != null) ? (!lect["id"].ToString().Trim().Equals("") ? lect["id"] : 0) : 0));
                        l.Add(y);
                    }
                }
                return(l);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Esempio n. 6
0
        public static Ressources oneRessources(Int32 id)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                String           search = "select * from ressources where id = " + id;
                NpgsqlCommand    Lcmd   = new NpgsqlCommand(search, con);
                NpgsqlDataReader lect   = Lcmd.ExecuteReader();
                Ressources       y      = new Ressources();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        y.Id      = id;
                        y.Code    = lect["code"].ToString();
                        y.Libelle = lect["libelle"].ToString();
                    }
                }
                return(y);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Esempio n. 7
0
 private void dgv_ress_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (dgv_ress.Rows.Count > 0)
         {
             if (dgv_ress.CurrentRow.Cells["id_ress_"].Value != null)
             {
                 Int32 id = (Int32)dgv_ress.CurrentRow.Cells["id_ress_"].Value;
                 if (id > 0)
                 {
                     Ressources            r = new Ressources(id);
                     bool                  b = (bool)dgv_ress.CurrentRow.Cells[e.ColumnIndex].Value;
                     AutorisationRessource a = AutorisationRessourceBLL.One(AutorisationRessourceBLL.Current(new AutorisationRessource(current, r, b)));
                     if (a != null ? a.Id > 0 : false)
                     {
                         AutorisationRessourceBLL.Update(new AutorisationRessource(a.Id, current, r, b));
                     }
                     else
                     {
                         AutorisationRessourceBLL.Save(new AutorisationRessource(current, r, b));
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Messages.Exception(ex);
     }
 }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Ressources R = Ressources.Instance;

            // the number of factories
            // Graph graph = new Graph(factoryCount);

            // Game Initialization
            // -------------------

            R.initGame();
            // Game Loop
            // ---------
            while (true)
            {
                // Start Turn
                // ----------
                {
                }

                // Write an action using Console.WriteLine()
                // To debug: Console.Error.WriteLine("Debug messages...");

                // Any valid action, such as "WAIT" or "MOVE source destination cyborgs"
                Console.WriteLine("WAIT");


                // End of the turn
                // ---------------
                graph.clean();
            }
        }
Esempio n. 9
0
        public void Mine()
        {
            // wait until acess to the mine is granted
            currentMine.EnteranceKey.WaitOne();
            GameWorld.RemoveGameObject.Add(this);
            if (Bank.UpgradeTwo)
            {
                Thread.Sleep(2000);
            }
            else
            {
                Thread.Sleep(3000);//simulates the worker mining
            }
            foreach (GameObject item in GameWorld.GameObjectList)
            {
                if (item is Bank)
                {
                    // i the case the was expanded to hold more than one bank add some code that desides the bank which bank is the neares
                    GetBankDestination(item as Bank);
                }
            }
            carryingResource = true;
            carry            = currentMine.Resources;
            position.X       = currentMine.OriginPoint.X;
            position.Y       = currentMine.OriginPoint.Y + (currentMine.OriginPoint.Y - currentMine.Position.Y);
            GameWorld.AddGameObject.Add(this);
            // releaser key so ohter members ca acces the mine

            currentMine.EnteranceKey.Release();
        }
Esempio n. 10
0
    /*
     * Add ressources to the inventory.
     * If the the final value is out of the bounds of the inventory, the difference is given back
     * The bounds are not important for money
     */
    public int addRessource(Ressources ressource, int number)
    {
        int currentNumber = ressources[(int)ressource];

        ressources[(int)ressource] += number;

        if (ressource != Ressources.Money && ressources[(int)ressource] > capacity)
        {
            ressources[(int)ressource] = capacity;
            return(ressources[(int)ressource] + number - capacity);
        }
        else if (ressources[(int)ressource] < 0)
        {
            ressources[(int)ressource] = 0;
            return(currentNumber + number);
        }

        //Update the textFields
        for (int i = 0; i < numberRessourceTextFields; i++)
        {
            if (ressourcesTextFields1[(int)ressource] != null)
            {
                ressourcesTextFields1[(int)ressource].text = formatNumber(ressources[(int)ressource]);
            }
            if (ressourcesTextFields2[(int)ressource] != null)
            {
                ressourcesTextFields2[(int)ressource].text = formatNumber(ressources[(int)ressource]);
            }
        }

        return(0);
    }
Esempio n. 11
0
 void Awake()
 {
     logger = Logger.GetInstance();
     jobsData = Jobs.GetInstance();
     ressources = Ressources.GetInstance();
     pView = GameObject.FindWithTag("Attackers").GetComponent<PhotonView>();
 }
 private void _listView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
 {
     _ressources        = (Ressources)e.SelectedItem;
     _idRessources.Text = _ressources.id.ToString();
     _titreEntry.Text   = _ressources.titre;
     _contenuEntry.Text = _ressources.contenu;
 }
    private int storeSize = 0; //Size of store

    #endregion Fields

    #region Methods

    public void actualizeText(Ressources id)
    {
        switch(id){
            //Buildressources
            case Ressources.Wood:
                woodText.text = "" + getNumberOfRessource(id);
                woodText2.text = "" + getNumberOfRessource(id);
                break;
            case Ressources.Stone:
                stoneText.text = "" + getNumberOfRessource(id);
                stoneText2.text = "" + getNumberOfRessource(id);
                break;

            //Food
            case Ressources.Apple:
                appleText.text = "" + getNumberOfRessource(id);
                break;
            case Ressources.Fish:
                fishText.text = "" + getNumberOfRessource(id);
                break;
            case Ressources.Crop:
                cropText.text = "" + getNumberOfRessource(id);
                break;
            case Ressources.Flour:
                flourText.text = "" + getNumberOfRessource(id);
                break;
        }
    }
Esempio n. 14
0
 public Bot()
 {
     Champ           = new Champ();
     Ressources      = new Ressources();
     CentreDuVillage = new CentreDuVillage();
     Carte           = new Carte();
 }
Esempio n. 15
0
 public static Ressources GetInstance()
 {
     if (instance == null)
     {
         instance = new Ressources();
     }
     return instance;
 }
Esempio n. 16
0
 new void Awake()
 {
     base.Awake();
     logger = Logger.GetInstance();
     ressources = Ressources.GetInstance();
     timerDeath = 0;
     this.RessourceName = Data.FOOD;
 }
Esempio n. 17
0
 public bool consommer(Ressources r, float quantite)
 {
     if (reserves [r] >= quantite) {
         reserves [r] -= quantite;
         return true;
     } else {
         return false;
     }
 }
Esempio n. 18
0
    public void postPushResources(Ressources r, RessourceReceiver pickUpModule)
    {
        Order o = new Order(null, r);

        o.pickUpModule = pickUpModule;
        orders.Add(o);

        ++amounts[r];
    }
Esempio n. 19
0
 private bool ReserveRessource(Ressources cost, bool reserve = false)
 {
     currentRessources -= cost;
     if (reserve)
     {
         reservedRessources += cost;
     }
     return(true);
 }
Esempio n. 20
0
        public override void Render(RenderArgs args)
        {
            var url    = args.Prototype.Parameter.ContainsKey("Url") ? args.Prototype.Parameter["Url"].Value as string : null;
            var bitmap = url == null ? null : Ressources.GetBitmap(url);

            if (bitmap != null)
            {
                args.Context.DrawBitmap(bitmap, args.Bounds, 1.0f, BitmapInterpolationMode.Linear);
            }
        }
Esempio n. 21
0
 public static Int32 Current(Ressources y)
 {
     try
     {
         return(RessourcesDAO.currentRessources(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Retour Impossible", ex);
     }
 }
Esempio n. 22
0
 public static Ressources Save(Ressources y)
 {
     try
     {
         return(RessourcesDAO.saveRessources(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Insertion Impossible", ex);
     }
 }
Esempio n. 23
0
 public static bool Update(Ressources y)
 {
     try
     {
         return(RessourcesDAO.updateRessources(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Modification Impossible", ex);
     }
 }
Esempio n. 24
0
 public static bool Delete(Ressources y)
 {
     try
     {
         return(RessourcesDAO.deleteRessources(y));
     }
     catch (Exception ex)
     {
         throw new Exception("Suppression Impossible", ex);
     }
 }
Esempio n. 25
0
 private ContainerController getContainerWith(Ressources r)
 {
     foreach (ContainerController cc in containers)
     {
         if (cc.hasResource(r))
         {
             return(cc);
         }
     }
     return(null);
 }
Esempio n. 26
0
        public void SaveButtonClickExecute(object obj)
        {
            string path = obj as string;

            if (path == null)
            {
                return;
            }
            System.IO.File.WriteAllText(path, Text);
            Ressources.reloadScript(path);
        }
Esempio n. 27
0
    public bool takeRessource(Ressources r, int amount)
    {
        if (amounts[r] >= amount)
        {
            amounts[r] -= amount;
            //Debug.Log("Gave " + amount + " " + r);
            return(true);
        }

        return(false);
    }
Esempio n. 28
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Ressources.LoadImages(Content);
            Ressources.LoadSounds(Content);
            Ressources.LoadFonts(Content);

            gameOver    = Ressources.Images["GameOver"];
            mainMenuGfx = Ressources.Images["MainMenu"];

            mainLevel.Load(Content);
        }
Esempio n. 29
0
    void Start()
    {
        List <string> all_ressources = Ressources.getAllRessources();

        for (int i = 0; i < all_ressources.Count; i++)
        {
            ressourcesNeeded.Add(all_ressources[i], 0);
        }

        particule_system = GetComponentInChildren <ParticleSystem>();
        current_obj      = Instantiate(buildingEtapes[startingIndex.ToString()], transform.position, Quaternion.identity);
    }
Esempio n. 30
0
    private CrateBehavior getCrateOf(Ressources r)
    {
        foreach (CrateBehavior c in crates)
        {
            if (c.r == r)
            {
                return(c);
            }
        }

        return(null);
    }
        private async void _button_Clicked(object sender, EventArgs e)
        {
            var        db         = new SQLiteConnection(_dbPath);
            Ressources ressources = new Ressources()
            {
                id      = Convert.ToInt32(_idRessources.Text),
                titre   = _titreEntry.Text,
                contenu = _contenuEntry.Text,
            };

            db.Update(ressources);
            await Navigation.PopAsync();
        }
Esempio n. 32
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Content.RootDirectory = "Content";

            // Charge les ressources (doit être fait après l'appel à BindGraphicsClients()).$
            Ressources.LoadRessources(GraphicsDevice, Content);
            Ressources.ScreenSize = GetScreenSize();

            m_batch = new SpriteBatch(Ressources.Device);
            m_renderer.ServerRemote = new ServerStateSnapshot(m_server);
            m_renderer.Viewport     = new Rectangle(0, 0, (int)GameClient.GetScreenSize().X, (int)GameClient.GetScreenSize().Y);
            m_renderer.LoadContent();
            m_controler.LoadContent();
        }
Esempio n. 33
0
        public void LoadButtonClickExecute(object obj)
        {
            OpenFileDialog dial = new OpenFileDialog();
            string         path = null;

            dial.Filter = "Lua Script|*.lua";
            dial.Title  = "Select a Script";

            if (System.Windows.Forms.DialogResult.OK == dial.ShowDialog())
            {
                path = dial.FileName;
            }
            Ressources.loadScript(path);
        }
Esempio n. 34
0
        public void AddButtonClickExecute(object obj)
        {
            OpenFileDialog dial = new OpenFileDialog();
            string         path = null;

            dial.Filter = "All Files|*";
            dial.Title  = "Select a Texture";

            if (System.Windows.Forms.DialogResult.OK == dial.ShowDialog())
            {
                path = dial.FileName;
            }
            Ressources.addTexture(path);
        }
Esempio n. 35
0
        public override void Render(RenderArgs args)
        {
            var prot    = args.Prototype;
            var context = args.Context;
            var bounds  = args.Bounds;
            var x2      = prot.Parameter.ContainsKey("X2") ? (ScreenPos)prot.Parameter["X2"].Value : new ScreenPos();
            var y2      = prot.Parameter.ContainsKey("Y2") ? (ScreenPos)prot.Parameter["Y2"].Value : new ScreenPos();
            var fg      = Ressources.GetBrush((Color)prot.Parameter["ForeColor"].Value);

            if (fg != null)
            {
                context.DrawLine(bounds.TopLeft, new Vector2(args.Transform(x2, false), args.Transform(y2, true)), fg);
            }
        }
Esempio n. 36
0
        private void EventUnitAdded(IUnit unit)
        {
            lock (_orders) {
                foreach (var o in _orders)
                {
                    if (o.Unit?.UnitId != unit.UnitType)
                    {
                        continue;
                    }
                    if (o.Status != ProductionOrder.OrderStatus.Commissioned)
                    {
                        continue;
                    }
                    switch (o.Type)
                    {
                    case ProductionOrder.BuildType.AddOn:
                        o.Status      = ProductionOrder.OrderStatus.Producing;
                        o.OrderedUnit = unit;
                        return;

                    case ProductionOrder.BuildType.Structure:
                        o.Status            = ProductionOrder.OrderStatus.Producing;
                        o.OrderedUnit       = unit;
                        reservedRessources -= o.Unit;
                        return;

                    case ProductionOrder.BuildType.Unit:
                        if (o.Position != null)
                        {
                            MoveUnit(unit, o.Position);
                        }
                        o.Status = ProductionOrder.OrderStatus.Built;
                        return;

                    case ProductionOrder.BuildType.Morphed:
                        if (!IsStructure(o.Unit) && o.Position != null)
                        {
                            MoveUnit(unit, o.Position);
                        }
                        o.Status = ProductionOrder.OrderStatus.Built;
                        return;

                    case ProductionOrder.BuildType.Unknown:
                    case ProductionOrder.BuildType.Research:
                        throw new System.FormatException("Unexpected type!");
                    }
                }
            }
        }
    public void addRessources(Ressources id, int value)
    {
        int idInt = (int)id;
        ressources[idInt] += value;

        //Die Anzahl einer Ressource darf nicht kleiner als 0 und nicht größer als die Lagergröße sein
        if(ressources[idInt] < 0)
            ressources[idInt] = 0;
        else if(ressources[idInt] > storeSize){
            ressources[idInt] = storeSize;
        }

        //Actualize the text for the ressource id
        actualizeText(id);
    }
 public int getNumberOfRessource(Ressources id)
 {
     return ressources[(int)id];
 }
Esempio n. 39
0
 public Need(Ressources need, float numberPerInhabitant)
 {
     this.ressource = need;
     this.numberPerInhabitant = numberPerInhabitant;
 }
 public EffetProduire(XmlNode node)
 {
     quantite = float.Parse(node.SelectSingleNode ("Quantite").InnerText);
     ressource = (Ressources) Enum.Parse (typeof(Ressources), node.SelectSingleNode ("Ressource").InnerText);
 }
Esempio n. 41
0
 public Cost(Ressources ressource, int number)
 {
     this.ressource = ressource;
     this.number = number;
 }
Esempio n. 42
0
 public void produire(Ressources r, float quantite)
 {
     reserves [r] += quantite;
     //Debug.Log ("Nouvelles réserves :" + reserves [r]);
 }
Esempio n. 43
0
 public float getQuantiteDeRessource(Ressources r)
 {
     return reserves[r];
 }
Esempio n. 44
0
 void Awake()
 {
     updater = this.gameObject.GetComponent<IUpdatingStrategy>();
     ressources = Ressources.GetInstance();
 }
Esempio n. 45
0
 void Start()
 {
     ressourcesData = Ressources.GetInstance();
     buildingsData = Buildings.GetInstance();
 }