Exemplo n.º 1
0
        private bool checkChecksum()
        {
            ExpandedPair  firstPair      = pairs[0];
            DataCharacter checkCharacter = firstPair.LeftChar;
            DataCharacter firstCharacter = firstPair.RightChar;

            if (firstCharacter == null)
            {
                return(false);
            }

            int checksum = firstCharacter.ChecksumPortion;
            int s        = 2;

            for (int i = 1; i < pairs.Count; ++i)
            {
                ExpandedPair currentPair = pairs[i];
                checksum += currentPair.LeftChar.ChecksumPortion;
                s++;
                DataCharacter currentRightChar = currentPair.RightChar;
                if (currentRightChar != null)
                {
                    checksum += currentRightChar.ChecksumPortion;
                    s++;
                }
            }

            checksum %= 211;

            int checkCharacterValue = 211 * (s - 4) + checksum;

            return(checkCharacterValue == checkCharacter.Value);
        }
        public void testDecodeDataCharacter()
        {
            RSSExpandedReader rssExpandedReader = new RSSExpandedReader();

            String path = "test/data/blackbox/rssexpanded-1/3.png";

            if (!File.Exists(path))
            {
                // Support running from project root too
                path = Path.Combine("..\\..\\..\\Source", path);
            }

#if !SILVERLIGHT
            var image = new Bitmap(Image.FromFile(path));
#else
            var image = new WriteableBitmap(0, 0);
            image.SetSource(File.OpenRead(path));
#endif
            BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BitmapLuminanceSource(image)));
            BitArray     row       = binaryMap.getBlackRow(binaryMap.Height / 2, null);

            int[] startEnd = { 145, 243 }; //image pixels where the A1 pattern starts (at 124) and ends (at 214)
            int   value    = 0;            // A
#if !SILVERLIGHT
            FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.Height / 2);
#else
            FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.PixelHeight / 2);
#endif
            //{1, 8, 4, 1, 1};
            DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, false);

            Assert.AreEqual(19, dataCharacter.Value);
            Assert.AreEqual(1007, dataCharacter.ChecksumPortion);
        }
 internal ExpandedPair(DataCharacter leftChar,
                       DataCharacter rightChar,
                       FinderPattern finderPattern)
 {
     LeftChar      = leftChar;
     RightChar     = rightChar;
     FinderPattern = finderPattern;
 }
Exemplo n.º 4
0
 internal ExpandedPair(DataCharacter leftChar,
                       DataCharacter rightChar,
                       FinderPattern finderPattern,
                       bool mayBeLast)
 {
     LeftChar      = leftChar;
     RightChar     = rightChar;
     FinderPattern = finderPattern;
     MayBeLast     = mayBeLast;
 }
Exemplo n.º 5
0
 internal ExpandedPair(DataCharacter leftChar,
              DataCharacter rightChar,
              FinderPattern finderPattern,
              bool mayBeLast)
 {
    LeftChar = leftChar;
    RightChar = rightChar;
    FinderPattern = finderPattern;
    MayBeLast = mayBeLast;
 }
Exemplo n.º 6
0
        // not private for testing
        internal ExpandedPair retrieveNextPair(BitArray row, List <ExpandedPair> previousPairs, int rowNumber)
        {
            bool isOddPattern = previousPairs.Count % 2 == 0;

            if (startFromEven)
            {
                isOddPattern = !isOddPattern;
            }

            FinderPattern pattern;

            bool keepFinding  = true;
            int  forcedOffset = -1;

            do
            {
                if (!findNextPair(row, previousPairs, forcedOffset))
                {
                    return(null);
                }
                pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern);
                if (pattern == null)
                {
                    forcedOffset = getNextSecondBar(row, startEnd[0]);
                }
                else
                {
                    keepFinding = false;
                }
            } while (keepFinding);

            // When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not.
            // bool mayBeLast;
            // if (!checkPairSequence(previousPairs, pattern, out mayBeLast))
            //   return null;

            DataCharacter leftChar = decodeDataCharacter(row, pattern, isOddPattern, true);

            if (leftChar == null)
            {
                return(null);
            }

            if (previousPairs.Count != 0 &&
                previousPairs[previousPairs.Count - 1].MustBeLast)
            {
                return(null);
            }

            DataCharacter rightChar = decodeDataCharacter(row, pattern, isOddPattern, false);

            return(new ExpandedPair(leftChar, rightChar, pattern, true));
        }
Exemplo n.º 7
0
    public void ReadInfoCharacter(DataCharacter dataChar)
    {
        isMove = true;

        nameTxt.text = dataChar.name;
        HpTxt.text   = "HP: " + dataChar.HP.ToString();
        AtkTxt.text  = "ATK: " + dataChar.ATK.ToString();
        DefTxt.text  = "DEF: " + dataChar.DEF.ToString();


        frameInfo.SetActive(true);
    }
Exemplo n.º 8
0
        public bool CreateCharacter(BasicSheet sheet)
        {
            NewCharacter newCharacter = new NewCharacter();

            Character = newCharacter.Get(sheet);
            DataCharacter dataCharacter = new DataCharacter();

            dataCharacter.Save(Character);


            return(true);
        }
Exemplo n.º 9
0
    public void GatchaCharacter()
    {
        int           indexChar = Random.Range(0, dataCharacter.Length);
        DataCharacter data      = dataCharacter [indexChar];

        ShowCharacterX1(true);

        hatCharImg.transform.parent.parent.GetComponent <CointainData> ().dataChar = data;
        if (isCharacterUI)
        {
            nameOfCharacter.text = data.name;
            hatCharImg.sprite    = data.equipmentOfChar;
        }
    }
Exemplo n.º 10
0
        // not private for testing
        internal ExpandedPair retrieveNextPair(BitArray row, List <ExpandedPair> previousPairs, int rowNumber)
        {
            bool isOddPattern = previousPairs.Count % 2 == 0;

            FinderPattern pattern;

            bool keepFinding  = true;
            int  forcedOffset = -1;

            do
            {
                if (!findNextPair(row, previousPairs, forcedOffset))
                {
                    return(null);
                }
                pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern);
                if (pattern == null)
                {
                    forcedOffset = getNextSecondBar(row, startEnd[0]);
                }
                else
                {
                    keepFinding = false;
                }
            } while (keepFinding);

            bool mayBeLast;

            if (!checkPairSequence(previousPairs, pattern, out mayBeLast))
            {
                return(null);
            }

            DataCharacter leftChar = decodeDataCharacter(row, pattern, isOddPattern, true);

            if (leftChar == null)
            {
                return(null);
            }
            DataCharacter rightChar = decodeDataCharacter(row, pattern, isOddPattern, false);

            if (rightChar == null && !mayBeLast)
            {
                return(null);
            }

            return(new ExpandedPair(leftChar, rightChar, pattern, mayBeLast));
        }
    void GameStart()
    {
        //코딩
        Room RO = PhotonNetwork.room;

        RO.IsOpen = false;                  // false 방에 못들어옴
        //
        for (int i = 0; i < iMaxCount; i++) // 팀을 나눔

        {
            if (i == 0 || i == 2)
            {
                players[i].tag = "RED";

                int           generalnumber = (int)TOY.YUBI;
                DataCharacter tmpPlayer     = CCM.Instance.CharacterSetting(id, players[i], generalnumber, 2, 0, 2, (int)COUNTRYTYPE.CHOK, -1);
            }
            else
            {
                players[i].tag = "BLUE";

                int           generalnumber = (int)TOY.JOJO;
                DataCharacter tmpPlayer     = CCM.Instance.CharacterSetting(id, players[i], generalnumber, 18, 0, 18, (int)COUNTRYTYPE.WI, -1);
            }

            muzzleFlame[i] = players[i].transform.Find("itm_gun").transform.Find("muzzleflame").gameObject;               // 총구화염

            if (player.playerChar.transform.GetComponent <PhotonView> ().viewID == players [i].GetComponent <PhotonView> ().viewID)
            {
                iPlayerId = i;
            }

            player.playerChar.transform.Find("Camera").gameObject.SetActive(true);               // 유저 카메라 켜기
        }

        ResetDisplayHp();                // HP 초기값 넣어주기

        bControll = true;                // 조이스틱 컨트롤 시작
    }
Exemplo n.º 12
0
        private static BitArray buildBitArray(int[][] pairValues)
        {
            List <ExpandedPair> pairs = new List <ExpandedPair>();

            for (int i = 0; i < pairValues.Length; ++i)
            {
                int[] pair = pairValues[i];

                DataCharacter leftChar;
                if (i == 0)
                {
                    leftChar = null;
                }
                else
                {
                    leftChar = new DataCharacter(pair[0], 0);
                }

                DataCharacter rightChar;
                if (i == 0)
                {
                    rightChar = new DataCharacter(pair[0], 0);
                }
                else if (pair.Length == 2)
                {
                    rightChar = new DataCharacter(pair[1], 0);
                }
                else
                {
                    rightChar = null;
                }

                ExpandedPair expandedPair = new ExpandedPair(leftChar, rightChar, null);
                pairs.Add(expandedPair);
            }

            return(BitArrayBuilder.buildBitArray(pairs));
        }
Exemplo n.º 13
0
      private static BitArray buildBitArray(int[][] pairValues)
      {
         List<ExpandedPair> pairs = new List<ExpandedPair>();
         for (int i = 0; i < pairValues.Length; ++i)
         {
            int[] pair = pairValues[i];

            DataCharacter leftChar;
            if (i == 0)
            {
               leftChar = null;
            }
            else
            {
               leftChar = new DataCharacter(pair[0], 0);
            }

            DataCharacter rightChar;
            if (i == 0)
            {
               rightChar = new DataCharacter(pair[0], 0);
            }
            else if (pair.Length == 2)
            {
               rightChar = new DataCharacter(pair[1], 0);
            }
            else
            {
               rightChar = null;
            }

            ExpandedPair expandedPair = new ExpandedPair(leftChar, rightChar, null, true);
            pairs.Add(expandedPair);
         }

         return BitArrayBuilder.buildBitArray(pairs);
      }
Exemplo n.º 14
0
 IDataCharacter IInfoProvider2.createDataCharacter()
 {
     DataCharacter collection = new DataCharacter(character);
     return collection;
 }
Exemplo n.º 15
0
    public DataCharacter CharacterSetting(int id, GameObject basebody, int num_general, float charX, float charY, float charZ, int countrycolor, int armytype)
    {
        DataCharacter a = new DataCharacter();

        int iarmyType = 0;
        int icountry  = countrycolor;
        int iHelmet   = 0;
        int iEye      = 0;
        int iBeard    = -1;
        int iTbody    = 0;
        int iskin     = 0;
        int iweapon   = 0;
        int grade     = 0;

        if (num_general == (int)TOY.SMASHER)               // smasher
        {
            a.playerChar = Instantiate(Resources.Load("Data/Char/" + "smasher", typeof(GameObject))) as GameObject;

            a.playerChar.transform.Find("yubi/Bone01/Bone02/Object01").gameObject.GetComponent <Renderer> ().material.mainTexture = DataManager.Instance.smasherTexture [countrycolor];
            a.playerChar.transform.Find("yubi/Bone01/Bone04/Object04").gameObject.GetComponent <Renderer> ().material.mainTexture = DataManager.Instance.smasherTexture [countrycolor];
            a.playerChar.transform.Find("yubi/Bone01/Bone06/Object03").gameObject.GetComponent <Renderer> ().material.mainTexture = DataManager.Instance.smasherTexture [countrycolor];

            iarmyType = (int)ARMYTYPE.SMASHER;
        }
        else                                                 // character
        //a.playerChar = Instantiate (Resources.Load ("basebody", typeof(GameObject))) as GameObject;
        {
            a.playerChar = basebody;

            if (num_general == (int)TOY.SOLDIER)
            {
                iHelmet = (int)TOY.SOLDIER;
                iEye    = (int)TOY.SOLDIER;
                iTbody  = (int)TOY.SOLDIER;
                iBeard  = 0;                 // no beard
                iskin   = DataManager.Instance.dataGeneral[(int)TOY.SOLDIER].iSkin;
            }
            else
            {
                iHelmet = num_general;
                iEye    = num_general;
                iTbody  = num_general;
                iskin   = DataManager.Instance.dataGeneral[num_general].iSkin;
                a.playerChar.GetComponent <PlayerFSM> ().generalNumber = num_general;
            }

            if (armytype == -1)                // Default armytype
            {
                iarmyType = DataManager.Instance.dataGeneral[num_general].armyType;
            }
            else                              // Change character armytype
            {
                iarmyType = armytype;
            }

            for (int i = 0; i < DataManager.Instance.iDataBeardCount; i++)
            {
                if (num_general == DataManager.Instance.dataBeard[i].i_generalnumber)
                {
                    iBeard = i;                       // beard index
                }
            }
            //-----------------------------------Eye----------------------------------------------------------------------------------
            a.eye = Instantiate(DataManager.Instance.dataGeneral[iEye].eye) as GameObject;
            //-----------------------------------Head--------------------------------------------------------------------------------------
            if (num_general == (int)TOY.JOJO)
            {
                a.head = Instantiate(Resources.Load("Data/Char/" + "m_head_jojo", typeof(GameObject)))  as GameObject;                    //jojo head
            }
            else
            {
                a.head = Instantiate(Resources.Load("Data/Char/" + "m_head_base", typeof(GameObject)))  as GameObject;                    //base head
            }
            a.head.gameObject.GetComponent <Renderer> ().material.mainTexture = DataManager.Instance.HeadTexture [iskin];
            //----------------------------------Helmet-----------------------------------------------------------------------------------------
            a.helmet = Instantiate(DataManager.Instance.dataHelmet[iHelmet].helmet) as GameObject; //
            if (DataManager.Instance.dataGeneral[iHelmet].basecap == 1)                            // basecap texture
            {
                a.helmet.gameObject.GetComponent <Renderer> ().material.mainTexture = DataManager.Instance.dataGeneral[iHelmet].tHelmet;
            }
            //---------------------------------Body Arm Foot--------------------------------------------------------------------------------------------
            a.playerChar.transform.Find("yubi/Bip01/Bip01 Pelvis/Bip01 Spine/body").gameObject.GetComponent <Renderer> ().material.mainTexture
                = DataManager.Instance.dataGeneral[iTbody].Tbody;                                                                                                                                        // body texture
            a.playerChar.transform.Find("yubi/armfoot").gameObject.GetComponent <Renderer> ().material.mainTexture
                = DataManager.Instance.Tarmfoot [icountry];                                                                                                                                              // arm foot texture
            //---------------------------------Soldier Body Arm Foot-----------------------------------------------------------------------------------
            if (num_general == (int)TOY.SOLDIER)                                                                                                                                                         // helmet, body texture
            {
                a.helmet.gameObject.GetComponent <Renderer> ().material.mainTexture = DataManager.Instance.soldierHelmetTexture [icountry];                                                              // change helmet texture countrycolor
                a.playerChar.transform.Find("yubi/Bip01/Bip01 Pelvis/Bip01 Spine/body").gameObject.GetComponent <Renderer> ().material.mainTexture = DataManager.Instance.soldierBodyTexture [icountry]; // change body texture countrycolor
            }
            //----------------------------------------------------------------------------------------------------------------------------------------------
            a.point_head   = a.playerChar.transform.Find("yubi/Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Neck/Bip01 Head").GetComponent <Transform> ();
            a.point_weapon = a.playerChar.transform.Find("yubi/Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Neck/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/point_weapon").GetComponent <Transform> ();

            a.head.transform.position   = a.playerChar.transform.position;
            a.eye.transform.position    = a.playerChar.transform.position;
            a.helmet.transform.position = a.playerChar.transform.position;

            a.head.transform.SetParent(a.point_head.transform);
            a.eye.transform.SetParent(a.point_head.transform);
            a.helmet.transform.SetParent(a.point_head.transform);

            int iweaponindex = 0;
            for (int i = 0; i < DataManager.Instance.dataWeapon.Count; i++)
            {
                if (iweapon == DataManager.Instance.dataWeapon[i].num_weapon)
                {
                    iweaponindex = i;
                }
            }
//			a.weapon = Instantiate (DataManager.Instance.dataWeapon[iweaponindex].m_weapon)as GameObject;
//			a.weapon.transform.position = a.point_weapon.transform.position;
//			a.weapon.transform.rotation = a.point_weapon.transform.rotation;
//			a.weapon.transform.SetParent (a.point_weapon.transform);

            if (iBeard >= 0)
            {
                a.beard = Instantiate(DataManager.Instance.dataBeard[iBeard].m_beard) as GameObject; //
                a.beard.transform.position = a.playerChar.transform.position;                        //
                a.beard.transform.SetParent(a.point_head.transform);                                 //
            }
        }

        a.playerChar.transform.position = new Vector3(charX, charY, charZ);
        a.playerChar.GetComponent <PlayerFSM> ().armytype      = iarmyType;
        a.playerChar.GetComponent <PlayerFSM> ().grade         = grade;
        a.playerChar.GetComponent <PlayerFSM> ().CharId        = id;
        a.playerChar.GetComponent <PlayerFSM> ().country       = icountry;
        a.playerChar.GetComponent <PlayerFSM> ().generalNumber = num_general;

        return(a);
    }