Пример #1
0
    public void TestDiamond1()
    {
        var expected = new StringBuilder();

        expected.Append("*\n");
        Assert.AreEqual(expected.ToString(), Diamond.print(1));
    }
Пример #2
0
        /// <summary>
        /// Add Single Diamond
        /// Return Result
        /// </summary>
        public Result AddDiamond(Diamond diamond)
        {
            try
            {
                //CSV file validation
                if (!IsCsvFileExist())
                {
                    return(CSVNotFounded());
                }


                var csvBuilder = new StringBuilder();
                var newLine    = string.Format("{0},{1},{2},{3},{4},{5}", diamond.Shape, diamond.Size, diamond.Color, diamond.Clarity, diamond.Price, diamond.ListPrice);
                csvBuilder.AppendLine(newLine);
                File.AppendAllText(GlobalConstants.CSV_FILE, csvBuilder.ToString());

                return(new ResultSuccess <DBNull>
                {
                    Success = true,
                    RequestName = GlobalConstants.ADD_DIAMOND,
                    Message = "Diamond inserted successfuly"
                });
            }
            catch (RapaportException ex)
            {
                return(new ResultError
                {
                    Success = false,
                    RequestName = GlobalConstants.ADD_DIAMOND,
                    ErrorCode = GlobalConstants.ERR_ADD_DIAMOND,
                    Message = ex.Message
                });
            }
        }
Пример #3
0
 public static void Main()
 {
     Console.WriteLine("[{0}]", Diamond.print(1));
     Console.WriteLine("[{0}]", Diamond.print(2));
     Console.WriteLine("[{0}]", Diamond.print(3));
     Console.WriteLine("[{0}]", Diamond.print(5));
 }
Пример #4
0
        public async Task <ActionResult <Diamond> > PostDiamond(Diamond diamond)
        {
            // check data is full
            BLDiamonds blDiamonds = new BLDiamonds();

            if (!blDiamonds.validation(diamond))
            {
                return(BadRequest("Missing Data"));
            }

            // generate unique id
            GeneralFunctions generalFunctions = new GeneralFunctions();

            diamond.Id = generalFunctions.genarateUniqueID();

            _context.Diamonds.Add(diamond);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (DiamondExists(diamond.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetDiamond", new { id = diamond.Id }, diamond));
        }
Пример #5
0
        public void SouldPrintLetterSequenceIdented()
        {
            var result = Diamond.Print("C");

            result.Should()
            .Be("\n   A\n  B B\n C   C\n  B B\n   A");
        }
Пример #6
0
        public void SouldPrintLetterBigSequenceIdented()
        {
            var result = Diamond.Print("J");

            result.Should()
            .Be("\n          A\n         B B\n        C   C\n       D     D\n      E       E\n     F         F\n    G           G\n   H             H\n  I               I\n J                 J\n  I               I\n   H             H\n    G           G\n     F         F\n      E       E\n       D     D\n        C   C\n         B B\n          A");
        }
Пример #7
0
    //Method that sends new diamonds
    private void SendNewDiamonds()
    {
        for (int column = 0; column < columns; column++)
        {
            //Calculates position for new diamond
            float positionX = column * 1.5f;
            float positionY = 0f;
            if (column % 2 != 0)
            {
                positionY = -1f;
            }

            //If no diamond exist on the location creates new diamond
            if (GameObject.Find(positionX + "," + positionY) == null)
            {
                //If score counter for the bomb is more than the score that bomb needs to be sent
                //Sends bomb diamond
                if (bombScoreCounter >= sendBombScore)
                {
                    BombDiamond newDiamond = Instantiate(bombTile, transform);
                    newDiamond.GetComponent <SpriteRenderer>().color = ColorChooser(); //Picks a random color
                    newDiamond.transform.position = new Vector2(positionX, positionY); //Sets the position
                    bombScoreCounter = 0;                                              //Resets the counter
                }
                //Sends regular diamond
                else
                {
                    Diamond newDiamond = Instantiate(tile, transform);
                    newDiamond.GetComponent <SpriteRenderer>().color = ColorChooser(); //Picks a rabdom color
                    newDiamond.transform.position = new Vector2(positionX, positionY); //Sets the position
                }
            }
        }
    }
Пример #8
0
 private static void CreateSuitsFromHand(long hand)
 {
     _clubs    = new Club(hand);
     _diamonds = new Diamond(hand);
     _spades   = new Spade(hand);
     _hearts   = new Heart(hand);
 }
Пример #9
0
        public void getBoard()
        {
            Color[] cl = new Color[5];

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    Point p = boardToPos(i, j);
                    cl[0] = Utils.GetPixelColor(p.X, p.Y);
                    cl[1] = Utils.GetPixelColor(p.X - 10, p.Y - 10);
                    cl[2] = Utils.GetPixelColor(p.X - 10, p.Y + 10);
                    cl[3] = Utils.GetPixelColor(p.X + 10, p.Y - 10);
                    cl[4] = Utils.GetPixelColor(p.X + 10, p.Y + 10);

                    Color sample = Utils.avgColor(cl);
                    //Utils.MouseMove(p.X, p.Y);
                    Color c = Utils.getCloseColorIndex(sample, validColors, 5000);
                    //c = sample;

                    board[i, j] = new Diamond(i, j, c, sample);
                    if (board[i, j].isWhite())
                    {
                        //txtDebug.AppendText("W " + i + " " + j + " " + sample.ToString() + " " + sample.ToArgb() + " " +  board[i, j].spacial + "\n");
                    }
                    else
                    {
                        //txtDebug.AppendText("" + i + " " + j + " " + c.ToString() + " " + c.ToArgb() + " " + board[i, j].spacial + "\n");
                    }
                }
            }
        }
Пример #10
0
    public void Damage()
    {
        if (isDead == true)
        {
            return;
        }

        Debug.Log("MossG Damage()");

        Health--;
        anim.SetTrigger("Hit");
        isHit = true;
        anim.SetBool("InCombat", true);

        Debug.Log("Health = " + Health);

        if (Health < 1)
        {
            isDead = true;
            anim.SetTrigger("Death");

            GameObject diaGO     = Instantiate(diamond, transform.position, Quaternion.identity);
            Diamond    diaScript = diaGO.GetComponent <Diamond>();
            if (diaScript != null)
            {
                diaScript.gems = base.gems;
            }
        }
    }
Пример #11
0
 public bool isInPrevList(Diamond data)
 {
     foreach (DiamondGroup d in prevList)
     {
         Diamond item = d.lstDimond.ElementAt(d.lstDimond.Count - 1);
         if ((data.pos.X == item.pos.X) && (data.pos.Y == item.pos.Y))
         {
             if (item.checkTime == 0)
             {
                 data.checkTime = System.Environment.TickCount;
                 return(true);
             }
             else
             {
                 if (System.Environment.TickCount - item.checkTime > 1000)
                 {
                     item.checkTime = System.Environment.TickCount;
                     data.checkTime = item.checkTime;
                     //txtDebug.AppendText("Time out" + item.pos + "\n");
                     return(false);
                 }
                 data.checkTime = item.checkTime;
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #12
0
        public void doPlay(int speed = 1)
        {
            adjustPoint();
            getBoard();
            evaluateBoard();
            List <DiamondGroup> m = createClickList();

            foreach (DiamondGroup d in m)
            {
                Diamond item = d.lstDimond.ElementAt(d.lstDimond.Count - 1);
                Point   pos  = boardToPos(item.pos.X, item.pos.Y);
                if (chkSmart.Checked)
                {
                    if (!isInPrevList(item))
                    {
                        Utils.MouseClick("LEFT", pos.X, pos.Y);
                    }
                    prevList = m;
                }
                else
                {
                    Utils.MouseClick("LEFT", pos.X, pos.Y);
                }
            }
            Thread.Sleep(100);
            imgDebug.Refresh();
        }
        public void Test01()
        {
            Shape s = new Circle();

            s.MethodVirtual();
            s.Method();

            Circle c = new Circle();

            c.MethodVirtual();
            c.Method();


            s = new Triangle();
            s.MethodVirtual();
            s.Method();

            Triangle t1 = new Triangle();

            t1.MethodVirtual();
            t1.Method();

            s = new Diamond();
            s.MethodVirtual();
            s.Method();

            Diamond d = new Diamond();

            d.MethodVirtual();
            d.Method();
        }
    void loadGoldView()
    {
        GameObject commonUIPrefab = Resources.Load("Prefabs/DiamondItem") as GameObject;

        diamondObjectList = new List <GameObject>();
        for (int i = 0; i < MainData.Instance().diamondList.Length; i++)
        {
            GameObject diamond = Instantiate(commonUIPrefab) as GameObject;
            float      width   = diamond.GetComponent <RectTransform>().sizeDelta.x;
            diamond.transform.parent        = GameObject.Find(gameObject.name + "/BackGround").transform;
            diamond.name                    = "" + i;
            diamond.transform.localPosition = new Vector3(-300 + i * width, -70, 0);
            diamond.transform.localScale    = new Vector3(1, 1, 0);

            Diamond goods      = MainData.Instance().diamondList[i];
            Text    DiamondNum = gameObject.Find <Text>(diamond.name + "/DiamondNum");
            Text    money      = gameObject.Find <Text>(diamond.name + "/BuyBtn/Money");
            DiamondNum.text = goods.number.ToString() + " 钻";
            money.text      = "¥ " + goods.price.ToString();

            Button buyBtn = gameObject.Find <Button>(diamond.name + "/BuyBtn");
            buyBtn.onClick.AddListener(() => {
                PurchaseToIOS.purchaseProductWithID(gameObject.name, goods.charge_goods_id);
            });

            diamondObjectList.Add(diamond);
        }
    }
Пример #15
0
        public void LoadContent(IsometricTile tile)
        {
            _sourceTile = tile;
            _hitbox     = new Diamond(new Rectangle((int)tile.Position.X, (int)tile.Position.Y, tile.SourceRect.Width, tile.SourceRect.Height));
            _type       = tile.Value1;
            _height     = tile.Height;
            _position   = tile.Position;

            //We can come up with many types, not just 3. (Double digit ints and negative ints can be read as well.)
            switch (Type)
            {
            case 1:
                _walkable = true;
                _damaging = false;
                break;

            case 2:
                _walkable = true;
                _damaging = false;
                break;

            case 3:
                _walkable = true;
                _damaging = false;
                break;

            default:
                _walkable = false;
                _damaging = false;
                break;
            }
        }
Пример #16
0
        /// <summary>
        /// Validate the data has no missing data
        /// </summary>
        /// <param name="diamond"></param>
        /// <returns></returns>
        internal bool validation(Diamond diamond)
        {
            if (diamond.ListPrice == 0)
            {
                return(false);
            }

            if (diamond.Price == 0)
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(diamond.Shape))
            {
                return(false);
            }

            if (diamond.Size == 0)
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(diamond.Clarity))
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(diamond.Color))
            {
                return(false);
            }

            return(true);
        }
Пример #17
0
        public void TestCanBePlaced_Player_Does_Not_Belong_To()
        {
            GameMap     map     = new GameMap(80, 20, 1, 1, new Point(40, 0), new Ball(40, 0));
            IGameObject diamond = new Diamond(GameBonus.Average, 1, 1);

            Assert.IsFalse(map.CanBePlaced(diamond, 0, 5));
        }
Пример #18
0
        public async Task <IActionResult> PutDiamond(decimal id, Diamond diamond)
        {
            if (id != diamond.Id)
            {
                return(BadRequest());
            }

            _context.Entry(diamond).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DiamondExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #19
0
 public void BasicTest1()
 {
     Assert.AreEqual(
         "      1      \n     121     \n    12321    \n   1234321   \n  123454321  \n 12345654321 \n1234567654321\n 12345654321 \n  123454321  \n   1234321   \n    12321    \n     121     \n      1      ",
         //   "123456_123456__12345___12345__1234_____1234__123_______123__12_________12__1__
         Diamond.Pattern(7));
 }
Пример #20
0
    public void All_rows_must_have_symmetric_contour(char letter)
    {
        var actual = Diamond.Make(letter);
        var rows   = Rows(actual);

        Assert.That(rows, Is.All.Matches <string>(row => LeadingSpaces(row) == TrailingSpaces(row)));
    }
Пример #21
0
        public double Result(out Diamond diamond, out Diamond sim)
        {
            (double similarity, Diamond diamond)max = (-1, new Diamond());
            foreach (var item in diamonds)
            {
                var _max = DiamondExtenssion.TotalWeight * (
                    DiamondExtenssion.XWeight * ((100 - (Math.Abs(this.diamond.X - item.X) / (DiamondExtenssion.XAbsolute))).ToPercent()) +
                    DiamondExtenssion.YWeight * ((100 - (Math.Abs(this.diamond.Y - item.Y) / (DiamondExtenssion.YAbsolute))).ToPercent()) +
                    DiamondExtenssion.ZWeight * ((100 - (Math.Abs(this.diamond.Z - item.Z) / (DiamondExtenssion.ZAbsolute))).ToPercent()) +
                    DiamondExtenssion.CutWeight * ((100 - (Math.Abs(this.diamond.CutValue - item.CutValue) / (DiamondExtenssion.CutAbsolute))).ToPercent()) +
                    DiamondExtenssion.ColorWeight * ((100 - (Math.Abs(this.diamond.ColorValue - item.ColorValue) / (DiamondExtenssion.ColorAbsolute))).ToPercent()) +
                    DiamondExtenssion.CaratWeight * ((100 - (Math.Abs(this.diamond.Carat - item.Carat) / (DiamondExtenssion.CaratAbsolute))).ToPercent()) +
                    DiamondExtenssion.ClarityWeight * ((100 - (Math.Abs(this.diamond.ClarityValue - item.ClarityValue) / (DiamondExtenssion.ClarityAbsolute))).ToPercent()) +
                    DiamondExtenssion.DepthWeight * ((100 - (Math.Abs(this.diamond.Depth - item.Depth) / (DiamondExtenssion.DepthAbsolute))).ToPercent()) +
                    DiamondExtenssion.TableWeight * ((100 - (Math.Abs(this.diamond.Table - item.Table) / (DiamondExtenssion.TableAbsolute))).ToPercent())
                    // DiamondExtenssion.PriceWeight * ((100 - Math.Abs((float)diamond.Price - (float)item.Price) / (DiamondExtenssion.PriceAbsolute)).ToPercent())
                    );

                max = max.GetMax(_max, item);
            }

            this.diamond.Price = max.diamond.Price;
            diamond            = this.diamond;
            sim = max.diamond;

            return(max.similarity);
        }
Пример #22
0
    public void Damage()
    {
        if (isDead)
        {
            return;
        }

        Health--;

        anim.SetTrigger("Hit");
        isHit = true;
        anim.SetBool("InCombat", true);

        if (Health < 1)
        {
            isDead = true;
            anim.SetTrigger("Death");

            // Spawn a Diamond
            GameObject gem     = Instantiate(gemPrefab, transform.position, Quaternion.identity) as GameObject;
            Diamond    diamond = gem.GetComponent <Diamond>();
            if (diamond)
            {
                diamond._diamondsToAdd = gems;
            }
        }
    }
Пример #23
0
        public void Non_Basic_ASCII_Error_Test()
        {
            var input    = 'é';
            var expected = ":(";

            Assert.AreEqual(expected, Diamond.Create(input));
        }
Пример #24
0
        public void Digit_Error_Test()
        {
            var input    = '2';
            var expected = ":(";

            Assert.AreEqual(expected, Diamond.Create(input));
        }
Пример #25
0
        public void B_Test()
        {
            var input    = 'B';
            var expected = " A\r\nB B\r\n A";

            Assert.AreEqual(expected, Diamond.Create(input));
        }
Пример #26
0
        public void Non_Letter_Error_Test()
        {
            var input    = '$';
            var expected = ":(";

            Assert.AreEqual(expected, Diamond.Create(input));
        }
Пример #27
0
        public void A_Test()
        {
            var input    = 'A';
            var expected = "A";

            Assert.AreEqual(expected, Diamond.Create(input));
        }
Пример #28
0
        public void Scandinave_O_Error_Test()
        {
            var input    = 'ø';
            var expected = ":(";

            Assert.AreEqual(expected, Diamond.Create(input));
        }
Пример #29
0
        public MenuWindow() : base(0, 0, 120, 30, "MENU")
        {
            diamond1 = new Diamond(10, 5);
            diamond2 = new Diamond(92, 5);
            candle1  = new Candle(5, 18);
            candle2  = new Candle(105, 18);

            title         = new TextLine(20, 3, 80, " !!! My super TODO APP !!! ", true, ConsoleColor.Cyan, ConsoleColor.DarkRed);
            copirightText = new TextLine(10, 27, 100, "All right Not reserved, go wild!, 2020", true, ConsoleColor.DarkGray);



            int menuY            = 16;
            int menuX            = 22;
            int menuGaps         = 28;
            int menuButtonWidth  = 20;
            int menuButtonHeight = 5;


            List <ButtonName> menuButtonNames = new List <ButtonName>()
            {
                ButtonName.Start, ButtonName.Credits, ButtonName.Quit
            };

            activeButtonName = menuButtonNames[0];
            for (int i = 0; i < menuButtonNames.Count; i++)
            {
                Button button = new Button(menuX + menuGaps * i, menuY, menuButtonWidth, menuButtonHeight, menuButtonNames[i].ToString());
                menuButtons.Add(menuButtonNames[i], button);
            }
            SetButtonActive(activeButtonName);
        }
Пример #30
0
    // Update is called once per frame
    void Update()
    {
        logo.Rotate(Vector3.forward * 20 * Time.deltaTime);

        rupeeAmount.text = Diamond.GetCurrentDiamondAmount().ToString();

        // For debug only
        if (Input.GetKeyDown(KeyCode.B))
        {
            PlayerPrefs.SetInt(Diamond.DiamondType, PlayerPrefs.GetInt(Diamond.DiamondType) + 500);
        }
        if (Input.GetKeyDown(KeyCode.U))
        {
            PlayerUpgrades.ResetPlayerUpgrades();
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            Diamond.ResetDiamondAmount();
        }

        UpdateUpgradeButtonStates(PlayerUpgrades.MaxHealth, playerData.maxHealth, maxHealthUpgradeButton);
        UpdateUpgradeButtonStates(PlayerUpgrades.HealthRegen, playerData.healthRegen, regenRateUpgradeButton);
        UpdateUpgradeButtonStates(PlayerUpgrades.RegenCooldown, playerData.regenCooldown, regenCooldownUpgradeButton);
        UpdateUpgradeButtonStates(PlayerUpgrades.Speed, playerData.speed, speedUpgradeButton);
        UpdateUpgradeButtonStates(PlayerUpgrades.AimDistance, playerData.aimDistance, aimDistanceUpgradeButton);
    }
Пример #31
0
        private IDictionary<Node, double> getNodeProb(int n)
        {
            DiamondInfo di = DiamondInfo.getDiamondInfo(n);
            IDictionary<Node, double> nodeProb;

            Diamond d = new Diamond();
            d.processProb(di, out nodeProb);

            return nodeProb;
        }
Пример #32
0
 void CalculateDiamondPhase()
 {
     diamondList.Clear();
     foreach (Square square in squareList)
     {
         Index top;
         Index bottom;
         Index left;
         Index right;
         Index center = new Index((square .top_left.x + square.top_right.x)/2,
             (square.top_left.y + square.bottom_left.y)/2);
         int sideLen = square.top_right.x - square.top_left.x;
         //set Square's center
         float val =
             (map[square.top_left.x,square.top_left.y]
             + map[square.top_right.x,square.top_right.y]
             + map[square.bottom_left.x,square.bottom_left.y]
             + map[square.bottom_right.x,square.bottom_right.y]) / 4
             + GetRandomValue();
         //val = val > maxLeve ? maxLeve : val;
         SetMaxHeightValue(val);
         SetMinHeightvalue(val);
         map[center.x,center.y] = Mathf.RoundToInt(val);
         Diamond diamond;
         //up
         top = new Index(center.x, center.y - sideLen);
         bottom = center;
         left = square.top_left;
         right = square.top_right;
         diamond = new Diamond(top, bottom, left, right);
         diamondList.Add(diamond);
         //down
         top = center;
         bottom = new Index(center.x, center.y + sideLen);
         left = square.bottom_left;
         right = square.bottom_right;
         diamond = new Diamond(top, bottom, left, right);
         diamondList.Add(diamond);
         //left
         top = square.top_left;
         bottom = square.bottom_left;
         left = new Index(center.x - sideLen, center.y);
         right = center;
         diamond = new Diamond(top, bottom, left, right);
         diamondList.Add(diamond);
         //right
         top = square.top_right;
         bottom = square.bottom_right;
         left = center;
         right = new Index(center.x + sideLen, center.y);
         diamond = new Diamond(top, bottom, left, right);
         diamondList.Add(diamond);
     }
 }
Пример #33
0
    public override void generate()
    {
        //Reset the array and apply any seed values before generation.
        initialiseArray ();

        int squareWidth = size - 1;
        float randomScale = 1.0f;
        float totalValue, randomValue, mean, finalValue;
        int halfSquareWidth;
        Square square;
        Diamond diamond;
        Point corner;

        while (squareWidth > 1) {
            halfSquareWidth = squareWidth / 2;

            //Iterate through squares in the array
            for (int x = 0; x < size - 1; x += squareWidth) {
                for (int y = 0; y < size - 1; y += squareWidth) {

                    //Get a square of points in the array
                    square = new Square (new Point (x, y), squareWidth);

                    //If the value for this square has already been set, move on.
                    if (m_values [square.center.y, square.center.x] != -1.0f) {
                        continue;
                    }

                    //Iterate through corners of the square, calculating their mean value.
                    totalValue = 0f;
                    for (int i = 0; i < 4; ++i) {
                        corner = square.corners [i];
                        totalValue += m_values [corner.y, corner.x];
                    }

                    //Set center of square to mean value plus random value
                    mean = (totalValue / 4.0f);
                    randomValue = Random.Range (-randomScale, randomScale);
                    finalValue = Mathf.Clamp (mean + randomValue, 0.0f, 1.0f);
                    m_values [square.center.y, square.center.x] = finalValue;
                }
            }

            //Iterate through diamonds in the array
            for (int x = 0; x < size - 1; x += halfSquareWidth) {
                for (int y = (x + halfSquareWidth) % squareWidth; y < size - 1; y += squareWidth) {

                    //If the value for this diamond has already been set, move on.
                    if (m_values [y, x] != -1.0f) {
                        continue;
                    }

                    //Get a diamond of points in the array
                    diamond = new Diamond (new Point (x, y), halfSquareWidth, size - 1);

                    //Iterate through corners of the diamond, calculating their mean value.
                    totalValue = 0f;
                    for (int i = 0; i < 4; ++i) {
                        corner = diamond.corners [i];
                        totalValue += m_values [corner.y, corner.x];
                    }

                    //Set center of diamond to mean value plus random value
                    mean = (totalValue / 4.0f);
                    randomValue = Random.Range (-randomScale, randomScale);
                    finalValue = Mathf.Clamp (mean + randomValue, 0.0f, 1.0f);
                    m_values [diamond.center.y, diamond.center.x] = finalValue;

                    //Wrap values on the edges
                    if (x == 0) {
                        m_values [y, size - 1] = finalValue;
                    }
                    if (y == 0) {
                        m_values [size - 1, x] = finalValue;
                    }
                }
            }

            //Reduce square width and random scale
            squareWidth /= 2;
            randomScale /= 2;
        }
    }
Пример #34
0
        public Stone CreateAnewStoneSkeleton(string filename)
        {
            Diamond diamond = new Diamond();
            diamond.Filename = filename;
            diamond.FullFilePath = Path.Combine(this.XmlFilePath, filename);
            if (Path.GetExtension(filename) == ".jpg")
            {
                diamond.MediaType = 1;
            }
            else
            {
                diamond.MediaType = 2;
            }

            return diamond;
        }
Пример #35
0
        /// <summary>
        /// Loads the stone using the filename in the current folder
        /// </summary>
        /// <param name="file">The name of the file in the folder without the path</param>
        /// <returns></returns>
        public Stone LoadStoneByFilenameInCurrentFolder(string file)
        {
            if (IsExtendedStoneInfoExists)
            {
                var q = from s in Xdoc.Root.Elements("stone")
                        where s.Attribute("filename").Value == file
                        select s;

                if (q.SingleOrDefault() != null)
                {
                    Diamond diamond = new Diamond();

                    var infoparts = from info in q.SingleOrDefault().Elements("info")
                                    select new StoneInfoPart
                                    {
                                        Title = info.Attribute("title").Value,
                                        Value = info.Value,
                                        TitleForReport=info.Attribute("titleforreport").Value
                                    };

                    foreach (var infopart in infoparts)
                    {
                        diamond.InfoList.Add(infopart);
                    }

                    diamond.Filename = file;
                    diamond.FullFilePath = Path.Combine(this.XmlFilePath, file);
                    diamond.MediaType =Convert.ToInt32(q.SingleOrDefault().Attribute("mediatype").Value);

                   var weight = infoparts.Where(m=> m.Title == "CaratWeight").SingleOrDefault<StoneInfoPart>().Value;
                   var type = infoparts.Where(m => m.Title == "StoneType").SingleOrDefault<StoneInfoPart>().Value;
                    var color = infoparts.Where(m=> m.Title == "StoneColor").SingleOrDefault<StoneInfoPart>().Value;
                    var clarity = infoparts.Where(m=> m.Title == "StoneClarity").SingleOrDefault<StoneInfoPart>().Value;

                    diamond.CompositeDescription = "A " + weight + " Ct. " + color + "/" + clarity + " " + type.ToLower() + " diamond.";

                    return diamond;

                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
Пример #36
0
 void Start()
 {
     mWinCount = 0;
     mScriptIndex = 0;
     objRabbit = Resources.Load<GameObject>("prefabRabbit");
     objDummy = Resources.Load<GameObject>("prefabDummy");
     objText = Resources.Load<GameObject>("prefabText");
     roomList = new List<GameObject>();
     //Cursor.SetCursor(Resources.Load<Texture2D>("cursor_grab1"), new Vector2(5, 5), CursorMode.Auto);
     mMoney = MONEY_START;
     mCurCam = Camera.main;
     mCurState = State.START;
     mDictIndex = 0;
     // make field area from experience
     fieldArea = new Diamond(new Vector2(0, -11), 215, 108);
     Rabbit.init();
     string targetText = "";
     for(int i = 0; i < scriptLevelSelect.levelList[scriptLevelSelect.level - 1].targetText.Length; ++i){
         targetText += scriptLevelSelect.levelList[scriptLevelSelect.level - 1].targetText[i] + "\n";
     }
     GameObject.Find("TargetText").GetComponent<TextMesh>().text = targetText;
     GameObject.Find("MessageBox").transform.Find("Text").GetComponent<TextMesh>().text = scriptLevelSelect.levelList[scriptLevelSelect.level - 1].script[mScriptIndex];
     foreach(string[][] element in scriptLevelSelect.levelList[scriptLevelSelect.level - 1].start){
         Rabbit.create(null, null);
         for(int i = 0; i < element[0].Length; ++i){
             for(int j = 0; j < element[i + 1].Length; j += 2){
                 Rabbit.rabbitList[Rabbit.rabbitList.Count - 1].GetComponent<Gene>().setField(element[0][i],
                                                                                              j / 2,
                                                                                              element[i + 1][j],
                                                                                              element[i + 1][j + 1]);
             }
         }
     }
     InvokeRepeating("decMoney", 10, 10);
     GameObject sisObj = (GameObject)Instantiate(Resources.Load("prefabSister" + scriptCloth.clothList[scriptCloth.clothIndex]), new Vector3(-110, -20, -1), Quaternion.identity);
     sisObj.transform.parent = GameObject.Find("Sister").transform;
     sisObj.name = "SisterBody";
     sisObj.GetComponent<Animator>().updateMode = AnimatorUpdateMode.UnscaledTime;
     Time.timeScale = 0;
 }
Пример #37
0
    void UnSpawnDiamond(Diamond d)
    {
        d.OnSpawnDone -= UnSpawnDiamond;

        d.gameObject.SetActive(false);

        _DiamondsActive.Remove(d);
        _Diamonds.Add(d);
    }