예제 #1
0
        public void TestGetCase()
        {
            Tuile tuile = new Tuile('c', 'e', @"exemple");

            Echange.SetSwap(tuile);
            Assert.AreEqual(tuile, Echange.GetSwap(0));
        }
예제 #2
0
        public void Echanger()
        {
            Joueur p = new Joueur(0, 0);

            Echange[] e = new Echange[]
            {
                new Echange(new Emeraude(1), new Boeuf_Cuit(1)),
                new Echange(new Boeuf_Cuit(1), new Emeraude(1))
            };

            Marchand m = new Marchand(0, 0, e);

            Assert.AreEqual(m.Echanges, e);

            m.Inventaire.AjouterItem(new Emeraude(1));
            m.Inventaire.AjouterItem(new Boeuf_Cuit(1));

            Assert.IsNull(p.Barre.GetItem(0));
            p.AjouterItem(new Emeraude(1));
            Assert.IsTrue(p.Barre.GetItem(0).Equals(new Emeraude(1)));
            Assert.IsFalse(p.Barre.GetItem(0).Equals(new Boeuf_Cuit(1)));

            m.Echanger(p, 0);
            Assert.IsFalse(p.Barre.GetItem(0).Equals(new Emeraude(1)));
            Assert.IsTrue(p.Barre.GetItem(0).Equals(new Boeuf_Cuit(1)));

            m.Echanger(p, 1);
            Assert.IsTrue(p.Barre.GetItem(0).Equals(new Emeraude(1)));
            Assert.IsFalse(p.Barre.GetItem(0).Equals(new Boeuf_Cuit(1)));

            m.Echanger(p, 1);
            Assert.IsTrue(p.Barre.GetItem(0).Equals(new Emeraude(1)));
            Assert.IsFalse(p.Barre.GetItem(0).Equals(new Boeuf_Cuit(1)));
        }
예제 #3
0
        public void EqualsEtClone()
        {
            Echange e1 = new Echange(new EpeeBois(), new PlastronCuire(), new BotteFer());
            Echange e2 = e1.Clone();

            Assert.IsTrue(e1.Equals(e2));
            e1 = new Echange(null, null);
            Assert.IsFalse(e1.Equals(e2));
            Assert.IsFalse(e1.Equals(null));
        }
예제 #4
0
        public void TestAddRemove()
        {
            Tuile tuile = new Tuile('c', 'e', @"exemple");

            Echange.SetSwap(tuile);
            Assert.AreEqual(1, Echange.GetNumeCase());

            Echange.ValiderSwap();
            Assert.AreEqual(0, Echange.GetNumeCase());
        }
예제 #5
0
    private void GenererEchanges()
    {
        List <Tribu> tribusAPortee = TrouverTribusAPortee();

        foreach (Tribu trib in tribusAPortee)
        {
            Echange nvlEchange = Instantiate(echange, trib.transform).GetComponent <Echange>();
            nvlEchange.tribuCible          = trib;
            nvlEchange.transform.position += new Vector3(0, 0, -3);
        }
    }
예제 #6
0
    public void OuvrirEchange(Echange mercosur)
    {
        echange = mercosur;

        platoEchangeCible.tribu = echange.tribuCible;
        platoEchangeCible.ActiverInteraction(true);

        platoEchangeJoueur.tribu = InfoTribus.TribukiJoue;
        platoEchangeJoueur.ActiverInteraction(true);

        banniereCible.sprite  = echange.tribuCible.banniere.sprite;
        banniereJoueur.sprite = InfoTribus.TribukiJoue.banniere.sprite;

        gameObject.SetActive(true);
    }
예제 #7
0
        public void Constructeur()
        {
            Echange ec = new Echange(new EpeeBois(), new BotteFer());

            Assert.AreEqual(ec.ItemVoulu.id(), new EpeeBois().id());
            Assert.IsNull(ec.ItemVoulu2);
            Assert.AreEqual(ec.ItemDonne.id(), new BotteFer().id());

            ec = new Echange(new EpeeBois(), new PlastronCuire(), new BotteFer());

            Assert.AreEqual(ec.ItemVoulu.id(), new EpeeBois().id());
            Assert.AreEqual(ec.ItemVoulu2.id(), new PlastronCuire().id());
            Assert.AreEqual(ec.ItemDonne.id(), new BotteFer().id());

            ec = new Echange(null, new EpeeBois(), new BotteFer());

            Assert.AreEqual(ec.ItemVoulu.id(), new EpeeBois().id());
            Assert.IsNull(ec.ItemVoulu2);
            Assert.AreEqual(ec.ItemDonne.id(), new BotteFer().id());
        }
예제 #8
0
        public void Test1(string input, string output)
        {
            var textWriter = new StringWriter();

            Console.SetOut(textWriter);
            var file = File.ReadAllText(input);

            Console.SetIn(new StringReader(file));
            Echange.MyMain(null);

            var expected = File.ReadAllText(output).Replace("\r\n", "\n");

            if (!expected.EndsWith("\n"))
            {
                expected = expected + "\n";
            }
            var actual = textWriter.ToString().Replace("\r\n", "\n");

            Assert.Equal(expected, actual);
        }
예제 #9
0
        public static IDBItem AddNewItem(DataClassesDataContext dataContext, ItemType type)
        {
            IDBItem dataItem = null;

            if (type == ItemType.Equipment)
            {
                dataItem = new Equipment();

                dataContext.Resource.InsertOnSubmit(dataItem as Equipment);
            }

            if (type == ItemType.Employee)
            {
                dataItem = new Employee();
                dataContext.Resource.InsertOnSubmit(dataItem as Employee);
            }

            if (type == ItemType.Location)
            {
                dataItem = new Location();
                dataContext.Location.InsertOnSubmit(dataItem as Location);
            }

            if (type == ItemType.Container)
            {
                dataItem = new Container();
                dataContext.Container.InsertOnSubmit(dataItem as Container);
            }

            if (type == ItemType.Product)
            {
                dataItem = new Product();
                dataContext.Product.InsertOnSubmit(dataItem as Product);
            }

            if (type == ItemType.ProductCategory)
            {
                dataItem = new ProductCategory();
                dataContext.ProductCategory.InsertOnSubmit(dataItem as ProductCategory);
            }

            if (type == ItemType.DemandeExpress)
            {
                dataItem = new DemandeExpress();
                dataContext.OrderHeader.InsertOnSubmit(dataItem as DemandeExpress);
            }

            if (type == ItemType.Echange)
            {
                dataItem = new Echange();
                dataContext.OrderHeader.InsertOnSubmit(dataItem as Echange);
            }
            if (type == ItemType.WorkOrder)
            {
                dataItem = new WorkOrder();
                dataContext.WorkOrder.InsertOnSubmit(dataItem as WorkOrder);
            }
            if (type == ItemType.WorkOrderRouting)
            {
                dataItem = new WorkOrderRouting();
                dataContext.WorkOrderRouting.InsertOnSubmit(dataItem as WorkOrderRouting);
            }
            if (type == ItemType.Workstation)
            {
                dataItem = new Workstation();
                //dataContext.WorkOrder.InsertOnSubmit(dataItem as WorkOrder);
                dataContext.Resource.InsertOnSubmit(dataItem as Workstation);
            }
            if (type == ItemType.Customer)
            {
                dataItem = new Customer();
                //dataContext.WorkOrder.InsertOnSubmit(dataItem as WorkOrder);
                dataContext.Customer.InsertOnSubmit(dataItem as Customer);
            }
            if (type == ItemType.Contact)
            {
                dataItem = new Contact();
                dataContext.Contact.InsertOnSubmit(dataItem as Contact);
            }


            return(dataItem);
        }
예제 #10
0
        /// <summary>
        /// liste d'echange d'un marchand
        /// </summary>
        public static void AfficherMarchand()
        {
            AfficherMap(Sauvegarde.joueur, Sauvegarde.monde);
            Graphics gfx = Graphics.FromImage(Memoire.form.backGround);

            int w = Memoire.form.ClientSize.Width;
            int h = Memoire.form.ClientSize.Height;

            gfx.DrawImage(Properties.Resources.Inventaire_Marchand
                          , w / 32, h / 32, w - (w / 32) * 2, h - (h / 32) * 2);
            Size itsize = new Size((int)((16f / 177f) * (w - (w / 32) * 2)), (int)((16f / 166f) * (h - (h / 32) * 2)));

            for (int i = 0; i < 5; i++)
            {
                if (i >= marchand.Echanges.Length)
                {
                    break;
                }

                Echange echange = marchand.Echanges[i];
                if (echange.ItemVoulu != null)
                {
                    Bitmap img = new Bitmap((Bitmap)Properties.Resources.ResourceManager.GetObject("Item_" + echange.ItemVoulu.id()),
                                            itsize);
                    Graphics g = Graphics.FromImage(img);
                    SizeF    s = g.MeasureString(echange.ItemVoulu.Quantite + "", SystemFonts.DefaultFont);
                    if (echange.ItemVoulu.Quantite > 1)
                    {
                        g.DrawString(echange.ItemVoulu.Quantite + "", SystemFonts.DefaultFont, Brushes.Black, new PointF(itsize.Width - s.Width, itsize.Height - s.Height));
                    }
                    Point start = Memoire.InvToScreen(84, 47 + i * 22);
                    gfx.DrawImage(img, start.X, start.Y, itsize.Width, itsize.Height);
                }
                if (echange.ItemVoulu2 != null)
                {
                    Bitmap img = new Bitmap((Bitmap)Properties.Resources.ResourceManager.GetObject("Item_" + echange.ItemVoulu2.id()),
                                            itsize);
                    Graphics g = Graphics.FromImage(img);
                    SizeF    s = g.MeasureString(echange.ItemVoulu2.Quantite + "", SystemFonts.DefaultFont);
                    if (echange.ItemVoulu2.Quantite > 1)
                    {
                        g.DrawString(echange.ItemVoulu2.Quantite + "", SystemFonts.DefaultFont, Brushes.Black, new PointF(itsize.Width - s.Width, itsize.Height - s.Height));
                    }
                    Point start = Memoire.InvToScreen(102, 47 + i * 22);
                    gfx.DrawImage(img, start.X, start.Y, itsize.Width, itsize.Height);
                }
                if (echange.ItemDonne != null)
                {
                    Bitmap img = new Bitmap((Bitmap)Properties.Resources.ResourceManager.GetObject("Item_" + echange.ItemDonne.id()),
                                            itsize);
                    Graphics g = Graphics.FromImage(img);
                    SizeF    s = g.MeasureString(echange.ItemDonne.Quantite + "", SystemFonts.DefaultFont);
                    if (echange.ItemDonne.Quantite > 1)
                    {
                        g.DrawString(echange.ItemDonne.Quantite + "", SystemFonts.DefaultFont, Brushes.Black, new PointF(itsize.Width - s.Width, itsize.Height - s.Height));
                    }
                    Point start = Memoire.InvToScreen(140, 47 + i * 22);
                    gfx.DrawImage(img, start.X, start.Y, itsize.Width, itsize.Height);
                }
            }
        }