Esempio n. 1
0
 public Filter(bool exclude, FieldIndex fieldIndex, TimeOfDay value, FilterTest test)
 {
     Exclude_ = exclude;
     FieldIndex_ = fieldIndex;
     Value_ = value.DayMinutes;
     Test_ = test;
 }
Esempio n. 2
0
 public Filter(bool exclude, FieldIndex fieldIndex, TimeLength value, FilterTest test)
 {
     Exclude_ = exclude;
     FieldIndex_ = fieldIndex;
     Value_ = value.TotalMinutes;
     Test_ = test;
 }
Esempio n. 3
0
 public Turn(FieldIndex ind)
 {
     orders = new List<Order>();
     valid = false;
     Order o = Order.Create(ind);
     Add(o);
 }
Esempio n. 4
0
        /// <summary>
        /// 添加字段
        /// </summary>
        /// <param name="field">字段信息</param>
        public void Push(FieldIndex field)
        {
            push(field.AnonymousName);
            bool       isCustom = false;
            MethodInfo method   = SerializeMethodCache.GetMemberMethodInfo(field.Member.FieldType, ref isCustom);

            if (isCustom)
            {
                if (isValueType)
                {
                    generator.Emit(OpCodes.Ldarga_S, 1);
                }
                else
                {
                    generator.Emit(OpCodes.Ldarg_1);
                }
                generator.Emit(OpCodes.Ldflda, field.Member);
                generator.Emit(OpCodes.Ldarg_0);
            }
            else
            {
                generator.Emit(OpCodes.Ldarg_0);
                if (isValueType)
                {
                    generator.Emit(OpCodes.Ldarga_S, 1);
                }
                else
                {
                    generator.Emit(OpCodes.Ldarg_1);
                }
                generator.Emit(OpCodes.Ldfld, field.Member);
            }
            generator.call(method);
        }
Esempio n. 5
0
        private static SetFuncFlag GetFlag(FieldIndex field)
        {
            SetFuncFlag setString = SetFuncFlag.SetInt32;
            int         num       = (int)field;

            if (num < 300)
            {
                return(SetFuncFlag.SetInt32);
            }
            if (num < 800)
            {
                return(SetFuncFlag.SetFloat);
            }
            if (num < 0x3e8)
            {
                return(SetFuncFlag.SetDouble);
            }
            if (num < 0x4b0)
            {
                return(SetFuncFlag.SetInt64);
            }
            if (num < 0x2328)
            {
                setString = SetFuncFlag.SetString;
            }
            return(setString);
        }
Esempio n. 6
0
 public Filter(bool exclude, FieldIndex fieldIndex, TimeOfDay value, FilterTest test)
 {
     Exclude_    = exclude;
     FieldIndex_ = fieldIndex;
     Value_      = value.DayMinutes;
     Test_       = test;
 }
Esempio n. 7
0
 public Filter(Filter other)
 {
     this.Exclude_ = other.Exclude_;
     this.FieldIndex_ = other.FieldIndex_;
     this.Value_ = other.Value_;
     this.Test_ = other.Test_;
 }
Esempio n. 8
0
 public Filter(bool exclude, FieldIndex fieldIndex, int value, FilterTest test)
 {
     Exclude_    = exclude;
     FieldIndex_ = fieldIndex;
     Value_      = value;
     Test_       = test;
 }
Esempio n. 9
0
        public async Task AddTermsWithMultipleCommits_AllShouldBeFound()
        {
            _fix = new FieldIndex(RootIndexDir, "text");

            await _fix.AddTerm("term of document 1", 1);

            await _fix.AddTerm("another term of document 1", 1);

            await _fix.Commit();

            await _fix.AddTerm("term of document 2", 2);

            await _fix.AddTerm("another term of document 2", 2);

            await _fix.Commit();

            _fix.Search("term of document 1")
            .Should().BeEquivalentTo(new[] { 1 });
            _fix.Search("another term of document 1")
            .Should().BeEquivalentTo(new[] { 1 });
            _fix.Search("term of document 2")
            .Should().BeEquivalentTo(new[] { 2 });
            _fix.Search("another term of document 2")
            .Should().BeEquivalentTo(new[] { 2 });
        }
Esempio n. 10
0
        /// <summary>
        /// 添加字段
        /// </summary>
        /// <param name="field">字段信息</param>
        public void Push(FieldIndex field)
        {
            isName();

            bool       isCustom = false;
            MethodInfo method   = ParseMethodCache.GetMemberMethodInfo(field.Member.FieldType, ref isCustom);

            if (isCustom)
            {
                generator.Emit(OpCodes.Ldarg_1);
                if (!isValueType)
                {
                    generator.Emit(OpCodes.Ldind_Ref);
                }
                generator.Emit(OpCodes.Ldflda, field.Member);
                generator.Emit(OpCodes.Ldarg_0);
            }
            else
            {
                generator.Emit(OpCodes.Ldarg_0);
                generator.Emit(OpCodes.Ldarg_1);
                if (!isValueType)
                {
                    generator.Emit(OpCodes.Ldind_Ref);
                }
                generator.Emit(OpCodes.Ldflda, field.Member);
            }
            generator.call(method);

            nextIndex();
            if (isMemberMap)
            {
                generator.memberMapSetMember(OpCodes.Ldarg_3, field.MemberIndex);
            }
        }
Esempio n. 11
0
        protected override void DoRun(Field field)
        {
            string value = field.Value;

            DataType dt = field.Definition.Type;

            if (dt.GetType() != typeof(DateDataType))
            {
                return;
            }

            DateDataType dataType = (DateDataType)dt;

            if (dataType.IsValid(value))
            {
                return;
            }

            // value is illegal date value
            FieldIndex fieldIndeks = field.Definition.GetIndex();

            if (!_nonDateValues.ContainsKey(fieldIndeks))
            {
                _nonDateValues.Add(fieldIndeks, new HashSet <string>());
            }

            _nonDateValues[fieldIndeks].Add(value);
        }
Esempio n. 12
0
        public void Insert(RegisterInfo registerInfo)
        {
            Storage   storage = DaoHelper.Instance.DbStorage;
            ClothRoot root    = (ClothRoot)storage.Root;

            FieldIndex registerInfoOidIndex = root.RegisterInfoOidIndex;

            if (registerInfo == null || registerInfoOidIndex.Contains(registerInfo))
            {
                return;
            }

            storage.BeginThreadTransaction(TransactionMode.Exclusive);
            try
            {
                // this method called for generate the Oid, or the key of RegisterInfoOidIndex will always be 0.
                storage.MakePersistent(registerInfo);
                registerInfoOidIndex.Set(registerInfo);
                root.RegisterInfoNameIndex.Set(registerInfo);
                storage.EndThreadTransaction();
            }
            catch (Exception)
            {
                // do some log
                storage.RollbackThreadTransaction();
            }
        }
Esempio n. 13
0
        protected override void DoRun(Field field)
        {
            string value = field.Value;

            FieldIndex fieldIndex = field.Definition.GetIndex();

            if (!_valuesPerField.ContainsKey(fieldIndex))
            {
                _valuesPerField.Add(fieldIndex, new HashSet <string>());
            }

            HashSet <string> fieldValues = _valuesPerField[fieldIndex];

            // If null, the testresult for this value has already been created
            if (fieldValues == null)
            {
                return;
            }

            // If field already contains the value, it is not unique
            if (fieldValues.Contains(value))
            {
                _testResults.Add(new TestResult(ResultType.Error, AddmlLocation.FromFieldIndex(fieldIndex),
                                                string.Format(Messages.ControlUniquenessMessage2)));

                // Set to null so we do not collect more values for this field
                _valuesPerField[fieldIndex] = null;
            }
            else
            {
                fieldValues.Add(value);
            }
        }
    public Index foreignIndex;                                 // index on MyPersistentClass which key is not part of this class
#endif

    // Persistent capable class should not use default constructor for initialization, since
    // this constructor is called by Perst each time the object is loaded from the database.
    // So persistent capable class should have not constructor at all (in this case
    // it will be automatically generated by compiler), either define constructor with non-empty
    // parameter list for object initialization (the most natural way is to pass Storage reference
    // to this constructor, since Storage in any case is neede to created instances of Perst
    // collections) and define empty default constructor (in case of using Sun JVM, definition of
    // empty constructor is not necessary since Perst is able to instantiate persistent object
    // without using default constructor using non-standard Sun's API).
    public MyRootClass(Storage db) : base(db)
    {
#if USE_GENERICS
        intKeyIndex = db.CreateFieldIndex <int, MyPersistentClass>(
            "intKey", // name of indexed field
            true);    // unique index
        strKeyIndex = db.CreateFieldIndex <string, MyPersistentClass>(
            "StrKey", // name of indexed property
            false);   // index allows duplicates (is not unique)
        foreignIndex = db.CreateIndex <int, MyPersistentClass>(
            false);   // index allows duplicates (is not unique)
#else
        intKeyIndex = db.CreateFieldIndex(
            typeof(MyPersistentClass), // class for which index is defined
            "intKey",                  // name of indexed field
            true);                     // unique index
        strKeyIndex = db.CreateFieldIndex(
            typeof(MyPersistentClass), // class for which index is defined
            "StrKey",                  // name of indexed property
            false);                    // index allows duplicates (is not unique)
        foreignIndex = db.CreateIndex(
            typeof(int),               // key type
            false);                    // index allows duplicates (is not unique)
#endif
    }
 public Filter(bool exclude, FieldIndex fieldIndex, TimeLength value, FilterTest test)
 {
     Exclude    = exclude;
     FieldIndex = fieldIndex;
     ValueAsInt = value.TotalMinutes;
     Test       = test;
 }
 public void Import(SearchExport searchExport)
 {
     _fieldIndex            = searchExport.FieldIndex;
     _documentNumberOfTerms = searchExport.DocumentNumberOfTerms;
     NumberOfDocuments      = searchExport.NumberOfDocuments;
     NumberOfTerms          = searchExport.NumberOfTerms;
 }
Esempio n. 17
0
        protected override void DoRun(Field field)
        {
            string value = field.Value;

            List <AddmlCode> codes = field.Definition.Codes;

            if (codes == null)
            {
                return;
            }

            foreach (AddmlCode addmlCode in codes)
            {
                if (addmlCode.GetCodeValue() == value)
                {
                    return;
                }
            }

            // value is not in code list
            FieldIndex fieldIndeks = field.Definition.GetIndex();

            if (!_valuesNotInCodeList.ContainsKey(fieldIndeks))
            {
                _valuesNotInCodeList.Add(fieldIndeks, new HashSet <string>());
            }

            _valuesNotInCodeList[fieldIndeks].Add(value);
        }
 public Filter(bool exclude, FieldIndex fieldIndex, TimeOfDay value, FilterTest test)
 {
     Exclude    = exclude;
     FieldIndex = fieldIndex;
     ValueAsInt = value.DayMinutes;
     Test       = test;
 }
 public Filter(bool exclude, FieldIndex fieldIndex, int value, FilterTest test)
 {
     Exclude    = exclude;
     FieldIndex = fieldIndex;
     ValueAsInt = value;
     Test       = test;
 }
Esempio n. 20
0
        public void UpdateNoneIndex(RegisterInfo registerInfo)
        {
            Storage   storage = DaoHelper.Instance.DbStorage;
            ClothRoot root    = (ClothRoot)storage.Root;

            FieldIndex registerInfoOidIndex = root.RegisterInfoOidIndex;

            if (null == registerInfo || !registerInfoOidIndex.Contains(registerInfo))
            {
                return;
            }

            storage.BeginThreadTransaction(TransactionMode.Exclusive);
            try
            {
                registerInfo.Modify();

                storage.EndThreadTransaction();
            }
            catch (Exception)
            {
                // do some log
                storage.RollbackThreadTransaction();
            }
        }
Esempio n. 21
0
        protected override void DoRun(Field field)
        {
            string value     = field.Value;
            int?   maxLength = field.Definition.MaxLength;

            if (!maxLength.HasValue)
            {
                return;
            }

            if (value.Length <= maxLength)
            {
                return;
            }

            // value is longer than max length
            FieldIndex fieldIndeks = field.Definition.GetIndex();

            if (!_valuesLongerThanMaxLength.ContainsKey(fieldIndeks))
            {
                _valuesLongerThanMaxLength.Add(fieldIndeks, new HashSet <string>());
            }

            _valuesLongerThanMaxLength[fieldIndeks].Add(value);
        }
Esempio n. 22
0
        protected override void DoEndOfFile()
        {
            foreach (KeyValuePair <FieldIndex, HashSet <string> > entry in _incorrectDataFormat)
            {
                FieldIndex       fieldIndex          = entry.Key;
                HashSet <string> incorrectDataFormat = entry.Value;

                string errorsToShow = string.Join(", ", incorrectDataFormat
                                                  .Take(NumberOfShownErrors)
                                                  .Select(s => "'" + s + "'")
                                                  .ToList()
                                                  );

                string message = string.Format(Messages.ControlDataFormatMessage, errorsToShow);

                if (incorrectDataFormat.Count > NumberOfShownErrors)
                {
                    int remainingErrors = incorrectDataFormat.Count - NumberOfShownErrors;
                    message += string.Format(Messages.ControlDataFormatMessageExtension, remainingErrors);
                }

                _testResults.Add(new TestResult(ResultType.Error, AddmlLocation.FromFieldIndex(fieldIndex), message));
            }

            _incorrectDataFormat.Clear();
        }
Esempio n. 23
0
 public Filter(bool exclude, FieldIndex fieldIndex, TimeLength value, FilterTest test)
 {
     Exclude_    = exclude;
     FieldIndex_ = fieldIndex;
     Value_      = value.TotalMinutes;
     Test_       = test;
 }
Esempio n. 24
0
 public Filter(Filter other)
 {
     this.Exclude_    = other.Exclude_;
     this.FieldIndex_ = other.FieldIndex_;
     this.Value_      = other.Value_;
     this.Test_       = other.Test_;
 }
Esempio n. 25
0
 public static Order Create(FieldIndex ind, SkillType skill, bool endTurn)
 {
     Order ret = new Order();
     ret.endTurn = endTurn;
     ret.skill = skill;
     ret.position = ind;
     return ret;
 }
Esempio n. 26
0
        public async Task CommitEmptyIndex_ShouldNotThrowError()
        {
            _fix = new FieldIndex(RootIndexDir, "text");

            await _fix.Commit();

            _fix.Search("any text").Should().BeEmpty();
        }
Esempio n. 27
0
 public Filter()
 {
     // defaults
     Exclude_    = true;
     FieldIndex_ = Solver.FieldIndex.Days;
     Test_       = FilterTest.GreaterThan;
     Value_      = 5;
 }
Esempio n. 28
0
    private Field<GridUnit> playFieldTransforms = new Field<GridUnit>(); //this is the actual playfield as it appears to the players.

    #endregion Fields

    #region Methods

    public static Vector3 BoardToWorldPoint(FieldIndex ind)
    {
        // returns the point in the middle of the route for the given index
        float x_new = 10f*(ind.x-4);
        float z_new = 10f*(ind.y-4);
        float y_new = 1;
        return new Vector3(x_new, y_new, z_new);
    }
 public void FlashBoard(FieldIndex ind)
 {
     if(graphicalEffects == null){
         Debug.LogError("no graphical effects factory found");
         return;
     }
     graphicalEffects.FlashBoard(ind);
 }
Esempio n. 30
0
 public Filter()
 {
     // defaults
     Exclude_ = true;
     FieldIndex_ = Solver.FieldIndex.Days;
     Test_ = FilterTest.GreaterThan;
     Value_ = 5;
 }
            /*public static string[] Names = new string[] {
             *  "Time at Uni", "Time in Classes", "Time in Breaks", "Days",
             *  "Shortest Day", "Longest Day", "Avg. Day Length",
             *  "Shortest Break", "Longest Break", "Average Break", "Number of Breaks",
             *  "Shortest Block", "Longest Block", "Average Block", "Number of Blocks",
             *  "Earliest Start", "Latest Start", "Average Start",
             *  "Earliest Finish", "Latest Finish", "Average Finish" };*/

            #region Constructors

            public Field(string name, FieldIndex index, FieldType type)
            {
                Name              = name;
                Index             = index;
                Type              = type;
                DefaultPreference = Preference.None;
                Progression       = FieldProgression.Unknown;
            }
Esempio n. 32
0
 public Field(string name, FieldIndex index, FieldType type)
 {
     Name_ = name;
     Index_ = index;
     Type_ = type;
     DefaultPreference_ = Preference.None;
     Progression_ = FieldProgression.Unknown;
 }
Esempio n. 33
0
 public Field(string name, FieldIndex index, FieldType type, Preference preference)
 {
     Name_              = name;
     Index_             = index;
     Type_              = type;
     DefaultPreference_ = preference;
     Progression_       = FieldProgression.Unknown;
 }
Esempio n. 34
0
 public Field(string name, FieldIndex index, FieldType type, FieldProgression progression)
 {
     Name_              = name;
     Index_             = index;
     Type_              = type;
     DefaultPreference_ = Preference.None;
     Progression_       = progression;
 }
 public Field(string name, FieldIndex index, FieldType type, Preference preference,
              FieldProgression progression)
 {
     Name              = name;
     Index             = index;
     Type              = type;
     DefaultPreference = preference;
     Progression       = progression;
 }
Esempio n. 36
0
        /// <summary>
        /// 添加字段
        /// </summary>
        /// <param name="field">字段信息</param>
        public void PushMemberMap(FieldIndex field)
        {
            Label isMember = generator.DefineLabel();

            generator.memberMapIsMember(OpCodes.Ldarg_2, field.MemberIndex);
            generator.Emit(OpCodes.Brfalse_S, isMember);
            Push(field);
            generator.MarkLabel(isMember);
        }
Esempio n. 37
0
    public static void FindEmpTower(int direction, FieldIndex ind, Field<bool> taken, ref List<Tower> buildList)
    {
        //Debug.Log("Finding 2nd piece forward on "+tmp.ToString());
        Tower newTower = new Tower();
        FieldIndex tmp = ind.Up(direction);
        newTower.Add(ind);
        newTower.Add(tmp);
        newTower.type = TowerType.silence;
        ind = tmp;
        FieldIndex right = ind.Right(direction);
        FieldIndex left = ind.Left(direction);
        bool left_tower = left.index != -1 && taken[left] == true;
        bool right_tower = right.index != -1 && taken[right] == true;
        if(left_tower && right_tower){
        //			Debug.Log("Finding 3rd piece forward on "+tmp.ToString());
            Tower rightTower = newTower.Copy();

            newTower.Add(left);
            //Debug.Log(newTower.ToString());
            rightTower.Add(right);
            //Debug.Log(rightTower.ToString());

            tmp = left.Up(direction);
            FieldIndex tmpRight = right.Up(direction);

            if(tmp.index != -1 && taken[tmp]==true){
                newTower.Add(tmp);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
            if(tmpRight.index != -1 && taken[tmpRight]==true){
                rightTower.Add(tmpRight);
        //				Debug.Log(newTower.ToString());
                buildList.Add(rightTower);
            }
        }
        else if(left_tower){
            newTower.Add(left);
            tmp = left.Up(direction);

            if(tmp.index != -1 && taken[tmp]==true){
                newTower.Add(tmp);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
        }
        else if(right_tower){
            newTower.Add(right);
            tmp = right.Up(direction);

            if(tmp.index != -1 && taken[tmp]==true){
                newTower.Add(tmp);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
        }
    }
        internal Project(Storage storage) : base(storage)
        {
            this.index = storage.CreateFullTextIndex();
#if USE_GENERICS
            this.sources = storage.CreateFieldIndex <string, SourceFile>("path", true);
#else
            this.sources = storage.CreateFieldIndex(typeof(SourceFile), "path", true);
#endif
        }
Esempio n. 39
0
 public void SetFlashLayer(FieldIndex index, bool active)
 {
     //changes the layer of the piece, so that that piece is hit by the flashing directional light (Tutorial-function)
     if(active){
         playFieldTransforms[index].gameObject.layer = 10;
     }else{
         playFieldTransforms[index].gameObject.layer = 0;
     }
 }
 public IXDescriptorProperty(string name, string value, byte[] binaryValue, FieldFlags flags, FieldStore store, FieldIndex index)
 {
     this.Name        = name;
     this.StringValue = (binaryValue == null) ? value : null;
     this.BinaryValue = (binaryValue == null) ? null : binaryValue;
     this.Flags       = flags;
     this.Store       = store;
     this.Index       = index;
 }
Esempio n. 41
0
 private static void AppendField(double value, FieldIndex fieldIndex, ref int lastIndex, StringBuilder s)
 {
     if (value != 0)
     {
         s.Append(',', (int)fieldIndex - lastIndex);
         lastIndex = (int)fieldIndex;
         s.Append(value.ToString(System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS));
     }
 }
Esempio n. 42
0
 //****STATIC FIND-TOWER-FUNCTIONS****
 public static Field<bool> FindAllClusterRecurse(FieldIndex ind, Field<bool> taken)
 {
     taken[ind] = true;
     foreach( FieldIndex i in ind.GetNeighbours() ){
         if( Control.cState.field[i] == Control.cState.field[ind] && taken[i] == false){
             taken = FindAllClusterRecurse(i, taken);
         }
     }
     return taken;
 }
Esempio n. 43
0
        protected void AddField(string name, string value, FieldStore store, FieldIndex index, float? boost = null) {
            if(string.IsNullOrEmpty(value)) {
                return;
            }

            Field.Store fieldStore = GetFromStoreEnum(store);
            Field.Index fieldIndex = GetFromIndexEnum(index);

            var field = new Field(name, value, fieldStore, fieldIndex);

            if (boost != null) {
                field.Boost = (float)boost;
            }

            _document.Add(field);
        }
 private IEnumerator DoFlashBoard(FieldIndex index)
 {
     grid.SetFlashLayer(index,true);
     yield return new WaitForSeconds(1f);
     grid.SetFlashLayer(index,false);
     yield return new WaitForSeconds(0.5f);
     grid.SetFlashLayer(index,true);
     yield return new WaitForSeconds(0.5f);
     grid.SetFlashLayer(index,false);
     yield return new WaitForSeconds(0.5f);
     grid.SetFlashLayer(index,true);
     yield return new WaitForSeconds(0.5f);
     grid.SetFlashLayer(index,false);
     yield return new WaitForSeconds(0.5f);
     grid.SetFlashLayer(index,true);
     yield return new WaitForSeconds(0.5f);
     grid.SetFlashLayer(index,false);
 }
Esempio n. 45
0
    private void PlaceTransform(Route type, FieldIndex pos)
    {
        Transform theTransform = null;
        switch (type){
            case Route.empty:
                theTransform = emptyPiece;
                break;
            case Route.red:
                theTransform = redPiece;
                break;
            case Route.blue:
                theTransform = bluePiece;
                break;
            case Route.redBuilt:
                theTransform = redTowerPiece;
                break;
            case Route.blueBuilt:
                theTransform = blueTowerPiece;
                break;
            case Route.destroyed:
                theTransform = destroyedPiece;
                break;
            case Route.outOfBounds:
                theTransform = outOfBoundsPiece;
                break;
        }
        Transform foo;
        foo= (Transform)Instantiate(theTransform,BoardToWorldPoint(pos),Quaternion.identity);

        GridUnit tmp = foo.GetComponent<GridUnit>();
        if( tmp != null){
            tmp.type = type;
            playFieldTransforms[pos] = tmp;
            tmp.index = pos;
        }else{
            Debug.LogError("Component GridUnit not found on Piece-transform");
        }
    }
Esempio n. 46
0
        private int GetInteger(string[] fields, FieldIndex fieldIndex)
        {
            string field = GetString(fields, fieldIndex);
            int value;
            if (!int.TryParse(field, out value))
            {
                value = 0;
                AddToolNotification(
                    "InvalidInteger",
                    NotificationLevel.Error,
                    ConverterResources.SemmleInvalidInteger,
                    field,
                    fieldIndex);
            }

            return value;
        }
Esempio n. 47
0
 public static void FindShootTower(int direction, FieldIndex ind, Field<bool> taken, ref List<Tower> buildList)
 {
     //Debug.Log("Finding 2nd piece forward on "+tmp.ToString());
     Tower newTower = new Tower();
     FieldIndex tmp = ind.Up(direction);
     newTower.Add(ind);
     newTower.Add(tmp);
     newTower.type = TowerType.shoot;
     ind = tmp;
     FieldIndex left = ind.Left(direction);
     FieldIndex right = ind.Right(direction);
     bool left_tower = left.index != -1 && taken[left] == true;
     bool right_tower = right.index != -1 && taken[right] == true;
     if(left_tower && right_tower){ //Shoot tower found.
         newTower.Add(left);
         newTower.Add(right);
     //			Debug.Log(newTower.ToString());
         buildList.Add(newTower);
     }
 }
Esempio n. 48
0
    public static void FindSquareTower(int direction, FieldIndex ind, Field<bool> taken, ref List<Tower> buildList)
    {
        Tower newTower = new Tower();
        newTower.type = TowerType.skillCap;
        //Debug.Log("Found 2nd piece forward on "+ind.ToString());
        newTower.Add(ind);
        FieldIndex tmp = ind.Up(direction);
        newTower.Add(tmp);
        ind = tmp.Right(direction);
        //Debug.Log("Looking for 3rd piece forward on "+tmp.ToString());

        if(ind.index != -1 && taken[ind]==true){
            newTower.Add(ind);
            ind = ind.Down(direction);
            //Debug.Log("Looking for 4th piece right on "+tmp.ToString());

            if(ind.index != -1 && taken[ind]==true){
                newTower.Add(ind);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
        }
    }
Esempio n. 49
0
        private Field.Index GetFromIndexEnum(FieldIndex index) {
            if(index==FieldIndex.Analyzed) {
                return Field.Index.ANALYZED;
            }
            if(index==FieldIndex.IndexOnly) {
                return Field.Index.NOT_ANALYZED;
            }

            return Field.Index.NO;
        }
Esempio n. 50
0
 public void Add(FieldIndex ind)
 {
     //Debug.Log("calling Tower.Add");
     if(list.Count == 0){
         list.Add(ind);
         //Debug.Log("Tower: Adding "+ind.ToString()+" on pos 0");
     }else{
         for( int i = 0; i < list.Count; i++){
             if( list[i].index > ind.index){
                 list.Insert(i,ind);
                 //Debug.Log("Tower: Adding "+ind.ToString()+" on pos "+i);
                 return;
             }
         }
         //if all the elements in the list is smaller than the new element
         list.Insert(list.Count,ind);
         //Debug.Log("Tower: Adding "+ind.ToString()+" on pos "+list.Count);
     }
 }
Esempio n. 51
0
    public static List<Tower> FindTower( Field<bool> taken)
    {
        List<Tower> buildList = new List<Tower>();
        for( int i = 0; i < Stats.fieldSize*Stats.fieldSize; i++){
            if( taken[i] == true ){

                //Debug.Log("starting from "+new FieldIndex(i).ToString());
                for( int j = 0; j<8; j++){	//all directions
                    FieldIndex ind = new FieldIndex(i);
                    FieldIndex tmp = ind.Up(j);

                    if(tmp.index != -1 && taken[tmp]==true){ //If true; there might be towers.
                        //checks with Stats if the towers has been disabled:
                        if((j%2==1 && Stats.skillEnabled.diagBuild ) || (j%2==0 && Stats.skillEnabled.build)){ // build
                            FindBuildTower(j, ind, taken, ref buildList);
                        }if((j%2==1 && Stats.skillEnabled.diagShoot) || ( j%2==0 && Stats.skillEnabled.shoot)){ // shoot
                            FindShootTower(j, ind, taken, ref buildList);
                        }if(j<4){
                            if((j%2==1 && Stats.skillEnabled.diagSilence) || ( j%2==0 && Stats.skillEnabled.silence)){ // silence
                                FindEmpTower(j, ind, taken, ref buildList);
                            }
                            if((j%2==1 && Stats.skillEnabled.diagFive) || ( j%2==0 && Stats.skillEnabled.five)){
                                FindFiveTower(j, ind, taken, ref buildList);
                            }
                        }
                        if(j>5 && ((j%2==1 && Stats.skillEnabled.diagSkillCap) || (j%2==0 && Stats.skillEnabled.skillCap))){ // square
                            FindSquareTower(j, ind, taken, ref buildList);
                        }

                    }

                }
            }
        }
        return buildList;
    }
Esempio n. 52
0
    //Move to Skill-class?
    private bool Shoot(FieldIndex index)
    {
        //select an enemy piece to destroy it

        if (cState.field[index] == Field<int>.GetPlayerColor( (cState.activePlayer+1)%2 ) || cState.field[index] == Field<int>.GetPlayerColor(cState.activePlayer) ){
            cState.field[index] = Route.destroyed;
            cState.player[cState.activePlayer].playerSkill.shoot--;
            Skill.skillsUsed.shoot++;
            Skill.skillInUse = 0;
            BroadcastMessage("UpdateField");
            sound.PlayEffect(SoundType.shoot);
            return true;
        }else{
            Console.PrintToConsole("Can only shoot active enemy pieces",Console.MessageType.ERROR);
            Debug.Log("invalid move");
            sound.PlayEffect(SoundType.error);
            return false;
            //write this out somehow
        }
    }
Esempio n. 53
0
    //Move to Skill-class?
    private bool PlacePiece(FieldIndex index)
    {
        //placing piece in a normal turn
        if (playerDone == false && cState.field[index] == Route.empty){
        //			Debug.Log("Index: " + index);

            if(cState.activePlayer == 0){
                cState.field[index] = Route.red;
            }else{
                cState.field[index] = Route.blue;
            }
            if(CheckCluster(index)){
                cState.IncPieceCount();
                playerDone = true;
                sound.PlayEffect (SoundType.onClick);
            }else{ //the move is illegal due to silence
                sound.PlayEffect (SoundType.error);
                cState.field[index] = Route.empty;
                Console.PrintToConsole("You are silenced; You can't build towers",Console.MessageType.ERROR);
                return false;
            }
            return true;
        }else{
            if(playerDone){
                Console.PrintToConsole("Can only place one piece each turn",Console.MessageType.ERROR);
            }else{
                Console.PrintToConsole("Cannot place there",Console.MessageType.ERROR);
            }
            sound.PlayEffect(SoundType.error);
            // **DEBUG** write this out somehow
            return false;
        }
    }
Esempio n. 54
0
 public static Order Create(FieldIndex ind)
 {
     return Create(ind,SkillType.place,true);
 }
Esempio n. 55
0
 public Criteria(FieldIndex fieldIndex)
 {
     FieldIndex_ = fieldIndex;
     Preference_ = Fields[(int)FieldIndex_].DefaultPreference;
 }
Esempio n. 56
0
    public static void FindFiveTower(int direction, FieldIndex ind, Field<bool> taken, ref List<Tower> buildList)
    {
        Tower newTower = new Tower();
        FieldIndex tmp = ind.Up(direction);
        newTower.Add(ind);
        newTower.Add(tmp);
        newTower.type = TowerType.five;
        ind = tmp;
        tmp = ind.Up(direction);

        if(tmp.index != -1 && taken[tmp] == true){
            newTower.Add(tmp);
            ind = tmp;
            tmp = ind.Up(direction);
            if(tmp.index != -1 && taken[tmp] == true){
                newTower.Add(tmp);
                ind = tmp;
                tmp = ind.Up(direction);
                if(tmp.index != -1 && taken[tmp] == true){
                    newTower.Add(tmp);
        //					Debug.Log(newTower.ToString());
                    buildList.Add(newTower);
                }
            }
        }
    }
Esempio n. 57
0
 public bool UserFieldSelect(FieldIndex index)
 {
     // Called when the user clicks on the field
     // Returns true if a the click resulted in the execution of a (valid) move
     bool validmove = false;
     if(Stats.playerController[cState.activePlayer] == Stats.PlayerController.localPlayer){
         Order o = new Order();
         o.endTurn = false;
         switch(Skill.skillInUse){
             case 0:
                 o.skill = SkillType.place;
                 o.position = index;
                 break;
             case 1:
                 o.skill = SkillType.shoot;
                 o.position = index;
                 break;
             case 2:
                 o.skill = SkillType.build;
                 o.position = index;
                 break;
             case 3:
                 o.skill = SkillType.silence;
                 break;
         }
         validmove = ExecuteOrder(o);
         if(cState.victory != VictoryType.noVictory)
             Victory();
     }
     return validmove;
 }
Esempio n. 58
0
 private static string GetString(string[] fields, FieldIndex fieldIndex)
 {
     return fields[(int)fieldIndex];
 }
Esempio n. 59
0
 public Root(Storage db)
     : base(db)
 {
     dates = db.CreateFieldIndex<DateTime, Record>("date", false);
     services = db.CreateFieldIndex<String, Record>("service", false);
     ids = db.CreateFieldIndex<String, Record>("id", false);
 }
Esempio n. 60
0
 public Criteria(FieldIndex fieldIndex, Preference preference)
 {
     FieldIndex_ = fieldIndex;
     Preference_ = preference;
 }