Exemplo n.º 1
0
        public void ReCreate(VisifireElement element, ElementTypes elementType, VcProperties property, object oldValue, object newValue)
        {   
            //Type elementType = element.GetType();
            
            // Create a plot groups list
            // this.PlotGroups = new List<PlotGroup>();

            CalculateInternalXValue4NumericAxis(Chart);

            // Set default chart orientation
            if((elementType == ElementTypes.Chart && property == VcProperties.Series)
                ||(elementType == ElementTypes.DataSeries && property == VcProperties.RenderAs)
            )
                this.ChartOrientation = ChartOrientationType.Undefined;

            // Validate XValue type of the DataPoint and DataSeries
            if ((elementType == ElementTypes.Chart && property == VcProperties.Series)
                || (elementType == ElementTypes.DataSeries && property == VcProperties.RenderAs)
                || (elementType == ElementTypes.DataPoint && property == VcProperties.XValue)
                || (elementType == ElementTypes.Chart && property == VcProperties.None)
             )  
                SetDataPointsNameAndValidateDataPointXValueType();

            // Calculate all the required details
            this.Calculate(element, elementType, property, oldValue, newValue);
        }
Exemplo n.º 2
0
        public InstructionSet BuildPath(Point Start, ElementTypes Type, Direction CurrentDirection)
        {
            AlreadySearched = new List<Node>();

            Shortest = null;
            distance = int.MaxValue;
            AlreadyTraveled = new List<Point>();

            if (!GeneratedYet)
                GenerateMatrix();

            Path N = FindClosestPath(Start, CurrentDirection);

            if (N != null)
                AlreadyTraveled.Add(N.Start.Location);

            InstructionSet Mine = new InstructionSet();

            List<Path> Begin = new List<Path>();
            Begin.Add(N);
            if (N != null)
            {
                    BuildPath(new InstructionSet(Begin), Type, N.End);
            }

            //N.End.BuildPath(new InstructionSet(Begin), Type);

            return Shortest;
        }
Exemplo n.º 3
0
	public Town(Vector2 position, ControlledBy controlledBy, ElementTypes type, bool playerPresent) {
		_position = position;
		_controlledBy = controlledBy;
		_elementType = type;
		_playerPresent = playerPresent;
		_adjacentTownIndexes = new List<int>();
		_underAttack = false;
		_turnsUntilTaken = 0;
	}
Exemplo n.º 4
0
	public void setTownType(ElementTypes type) {
		_townElement = type;
		if (_isNeutral) {
			_enemyElementCount = Manager.TownManager.GetElementCountForCharacter (ControlledBy.Enemy);
		} 
		else {
			_enemyElementCount = 1;
		}
	}
Exemplo n.º 5
0
 /// <summary>
 /// Initialises a new instance of the ConstraintSignitureToken from the <paramref name="signiture"/>
 /// at the specified <paramref name="offset"/>.
 /// </summary>
 /// <param name="signiture">The signiture to load from.</param>
 /// <param name="offset">The offset in the signiture.</param>
 public ConstraintSignatureToken(byte[] signiture, Offset offset)
     : base(SignatureTokens.Constraint)
 {
     _constraint = (ElementTypes)GetCompressedValue(signiture, offset);
 }
Exemplo n.º 6
0
 public Element(int line, ElementTypes elementtype, Attribute list)
 {
     Line = line;
     ElementType = elementtype;
     AttributeList = list;
 }
Exemplo n.º 7
0
 internal abstract void PassClosingTag(ElementTypes ElementType);
Exemplo n.º 8
0
 public ElementAttribute(byte a, byte b, byte c, byte d, ElementTypes type, string description = null) : this(type, description)
 {
     ClassIdentifier = new ClassIdentifier(a, b, c, d);
 }
Exemplo n.º 9
0
 internal Element(int line, ElementTypes elementtype, Attribute list)
 {
     Line = line;
     ElementType = elementtype;
     AttributeList = list;
     AttributeCheck();
 }
Exemplo n.º 10
0
		internal override void PassClosingTag(ElementTypes ElementType)
		{
			this.xmlReader.Read();
#if DEBUG
			if (this.xmlReader.NodeType != XmlNodeType.EndElement
					|| this.xmlReader.Name != XmlSerializationFormatter.XmlElementNames[(int)ElementType])
				throw new Exception(
					string.Format("Unattended xml element {0} while waiting a closing tag {1}", xmlReader.Name, ElementType.ToString()));
#endif
		}
        internal override bool GetNextElementAs(
            ref Element e,
            bool AcceptChannelSection, string Name, L3TypeManager SupposedType, bool NeedsThisElement, bool WantClosingElement)
        {
            bool SupposedTypeNumberIsKnown = SupposedType != null;

            // There is no tag for value primitive types:
            if (SupposedTypeNumberIsKnown &&
                SupposedType.TypeIndex < (int)TypeCode.String &&
                SupposedType.TypeIndex >= (int)TypeCode.Boolean)
            {
                e.ContainsAValue   = true;
                e.ElementType      = ElementTypes.PrimitiveValue;
                e.IsAClosingTag    = true;
                e.typeIndex        = SupposedType.TypeIndex;
                e.typeIndexIsKnown = true;
                return(true);
            }

            // There is no tag for structures:
            if (SupposedTypeNumberIsKnown &&
                SupposedType.TypeIndex != (int)TypeCode.Object &&
                SupposedType.l2TypeManager.L1TypeManager.IsStructure &&
                (SupposedType.l2TypeManager.Container == null) &&
                !SupposedType.l2TypeManager.L1TypeManager.IsNullable)
            {
                e.ContainsAValue   = false;
                e.ElementType      = ElementTypes.SubBranch;
                e.IsAClosingTag    = true;
                e.typeIndex        = SupposedType.TypeIndex;
                e.typeIndexIsKnown = true;
                return(true);
            }



            // 1) Element code : byte
            //int b = this.binaryReader.BaseStream.ReadByte(); // Unlike this.binaryReader.ReadByte(), this function does not cause an exception (exceptions can prevent method inlining).
            int b = this.binaryReader.ReadByteNoException();             // Unlike this.binaryReader.ReadByte(), this function does not cause an exception (exceptions can prevent method inlining).

            if (b < 0)
#if DEBUG
            { throw new EndOfStreamException(); }
#else
            { return(false);                  // end of file.
            }
#endif
            byte elementCode = unchecked ((byte)b);
            if (elementCode == BinarySerializationFormatter.DataEndMarkCode)
            {
                return(false);                // end of file.
            }
            ElementTypes et = (ElementTypes)(elementCode & (byte)BinaryElementCode.BitMask);

#if DEBUG
            if (!AcceptChannelSection &&
                !(et == ElementTypes.InstancesChannelSection || et == ElementTypes.TypesChannelSection))
            {
                throw new Exception();
            }
#endif

            // 2) typeNumber : 7 bit-compressed int
            bool HasTypeNumber = (elementCode & (byte)BinaryAttributeCode.HasATypeNumber) != 0;

#if DEBUG
            if (!SupposedTypeNumberIsKnown && !HasTypeNumber &&
                (elementCode == (byte)BinaryElementCode.PrimitiveValue || elementCode == (byte)BinaryElementCode.SubBranch))
            {
                throw new Exception();
            }
#endif

            int typeNumber =
                HasTypeNumber ?
                this.binaryReader.Read7BitEncodedInt()
                                : (SupposedTypeNumberIsKnown ? SupposedType.TypeIndex : 0);

            // 3) Reference InstanceIndex : 7 bit-compressed int
            int?InstanceNumber =
                et == ElementTypes.Reference ?
                this.binaryReader.Read7BitEncodedInt()
                                : (int?)null;

            // 4) NumberOfElements : 7 bit-compressed long
            bool HasANumberOfElements = (elementCode & (byte)BinaryAttributeCode.HasANumberOfElements) != 0;
            long?numberOfElements     =
                HasANumberOfElements ?
                this.binaryReader.Read7BitEncodedLong()
                                : (long?)null;
#if DEBUG
            if (HasANumberOfElements && et != ElementTypes.SubBranch)
            {
                Debugger.Break();
            }
#endif

            e.ElementType = et;
#if DEBUG
            e.Name = Name;
#endif
            e.typeIndexIsKnown = SupposedTypeNumberIsKnown | HasTypeNumber;
            e.typeIndex        = typeNumber;
            e.InstanceIndex    = InstanceNumber;
            e.IsAClosingTag    = true;
            e.NumberOfElements = numberOfElements;
            e.ContainsAValue   = et == ElementTypes.PrimitiveValue;
            return(true);
        }
Exemplo n.º 12
0
 public ElementAttribute(ClassIdentifier identifier, ElementTypes type, string description = null) : this(type, description)
 {
     ClassIdentifier = identifier;
 }
Exemplo n.º 13
0
 private ElementAttribute(ElementTypes type, string description = null)
 {
     Type        = type;
     Description = description;
 }
Exemplo n.º 14
0
 public Score(int score, string name, ElementTypes character)
 {
     NumericScore = score;
     Name = name;
     CharacterType = character;
 }
Exemplo n.º 15
0
 public ElementAttribute(byte a, byte b, byte c, byte d, ElementTypes type, string description = null) : this(type, description)
 {
     ClassIdentifier = new ClassIdentifier(a, b, c, d);
 }
Exemplo n.º 16
0
	public int getElementCountForPlayer(ElementTypes elementType) {
		int count = 0;
		foreach (Town town in _towns){
			if (town._controlledBy == ControlledBy.Player && town._elementType == elementType) {
				count++;
			}
		}
		return count;
	}
		// useless in this formatter.
		internal override void PassClosingTag(ElementTypes ElementType)
		{
		}
			// --------------------------------------------

			internal override void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType)
			{
			}
        /// <summary>
        /// Checks if the token a the <paramref name="offset"/> in the <paramref name="signiture"/>
        /// is one of the <paramref name="allowed"/> element types.
        /// </summary>
        /// <param name="signiture">The signiture blob.</param>
        /// <param name="offset">The offset in the signiture.</param>
        /// <param name="allowed">The allowed element type flags.</param>
        /// <returns>True of false</returns>
        public static bool IsToken(byte[] signiture, int offset, ElementTypes allowed)
        {
            ElementTypes value = (ElementTypes)GetCompressedValue(signiture, offset);

            return(value == allowed);
        }
Exemplo n.º 20
0
 public ElementDescriptor() {
     this.isDisabledField = false;
     this.isRequiredField = false;
     this.elementTypeField = ElementTypes.String;
     this.lengthLimitField = 0;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Update the axis
        /// </summary>
        /// <param name="isSizeChanged"></param>
        internal void PrePartialUpdateConfiguration(VisifireElement sender, ElementTypes elementType, VcProperties property, object oldValue, object newValue, Boolean updateLists, Boolean calculatePlotDetails, Boolean updateAxis, AxisRepresentations renderAxisType, Boolean isPartialUpdate)
        {
            if (updateLists)
                PopulateInternalSeriesList(false);

            if (calculatePlotDetails)
            {
                PlotDetails.ReCreate(sender, elementType, property, oldValue, newValue);
            }

            if (updateLists)
            {
                SetDataPointColorFromColorSet(Chart.Series);
            }

            if (updateAxis)
            {
                PopulateInternalAxesXList();
                PopulateInternalAxesYList();

                ClearAxesPanel();

                CreateTrendLinesLabel();

                /*
                Size remainingSizeAfterDrawingAxes = RenderAxes(_plotAreaSize);
                */

                //----------

                Size remainingSizeAfterDrawingAxes = RenderAxes(_plotAreaSize);

                remainingSizeAfterDrawingAxes = RecalculateAxisAndRerenderBasedOnChartTypes(_plotAreaSize, remainingSizeAfterDrawingAxes);

                //-----------

                ResizePanels(remainingSizeAfterDrawingAxes, renderAxisType, isPartialUpdate);

                // Draw the chart grids
                if (PlotDetails.ChartOrientation != ChartOrientationType.NoAxis)
                {
                    RenderGrids();
                    RenderTrendLines();
                }
            }

            AddOrRemovePanels(Chart);
        }
Exemplo n.º 22
0
 public void PointerFollowedByNoCustomModsThenVoid_IsCorrect()
 {
     ElementTypes pointer = ElementTypes.Ptr;
 }
Exemplo n.º 23
0
		// ------------------------------

		internal override void PassClosingTag(ElementTypes ElementType)
		{
			this.GetNextJSONPart();
			if (this._JSONReader.Name == JSONSerializationFormatter.DataEndMarkTag)
			{
				this.WeAlreadyObtainedJSONPart = true;
				return;
			}
#if DEBUG
			if (this._JSONReader.NodeType != XmlNodeType.EndElement
					|| this._JSONReader.Name != JSONSerializationFormatter.JSONElementNames[(int)ElementType])
				throw new Exception(
					string.Format("Unattended JSON element {0} while waiting a closing tag {1}", _JSONReader.Name, ElementType.ToString()));
#endif
		}
Exemplo n.º 24
0
 public VirtualPlayer(Players playerType, ElementTypes element) : base(playerType, element)
 {
 }
Exemplo n.º 25
0
 private ElementAttribute(ElementTypes type, string description = null)
 {
     Type = type;
     Description = description;
 }
			internal ElementInfos(
				ElementTypes ElementType,
				AttributeUsage[] AttributeUsages)
			{
				this.AttributeUsages = AttributeUsages;
				this.ElementType = ElementType;
			}
Exemplo n.º 27
0
 public bool IsType(ElementTypes Type, Point P)
 {
     foreach (Element E in FindAt(P))
     {
         if (E.et == Type)
         {
             return true;
         }
     }
     return false;
 }
        // Resolve all the custom attributes found in the assemblies registered
        // in 'resolver', using all the type information found in 'resolver' and
        // 'resolvers'.
        internal void resolveReferences(MetaDataResolver resolver,
                                        MetaDataResolver[] resolvers)
        {
            if (this.buffer[0] != 0x01 || this.buffer[1] != 0x00)
            {
                throw new MetaDataLoader.IllegalMetaDataFormatException("Custom Attribute doesn't start with 0x0001!");
            }
            SignatureMethod signature;

            if (this.type is MetaDataMethod)
            {
                MetaDataMethod method = (MetaDataMethod)this.type;
                signature = (SignatureMethod)method.Signature;
                if (!method.Name.Equals(".ctor"))
                {
                    throw new MetaDataLoader.IllegalMetaDataFormatException("Custom attribute with unexpected method name: " + method.Name);
                }
                this.typeDefOrRef = method.Parent;
                this.name         = method.Parent.FullName;
            }
            else if (this.type is MetaDataMemberRef)
            {
                MetaDataMemberRef memberRef = (MetaDataMemberRef)this.type;
                signature = (SignatureMethod)memberRef.Signature;
                if (!memberRef.Name.Equals(".ctor"))
                {
                    throw new MetaDataLoader.IllegalMetaDataFormatException("Custom attribute with unexpected memberRef name: " + memberRef.Name);
                }
                MetaDataObject methodParent = memberRef.Class;
                this.typeDefOrRef = methodParent;
                if (methodParent is MetaDataTypeDefinition)
                {
                    this.name = ((MetaDataTypeDefinition)methodParent).FullName;
                }
                else if (methodParent is MetaDataTypeReference)
                {
                    this.name = ((MetaDataTypeReference)methodParent).FullName;
                }
                else
                {
                    throw new MetaDataLoader.IllegalMetaDataFormatException("Custom attribute with unexpected class type: " + methodParent);
                }
            }
            else
            {
                throw new MetaDataLoader.IllegalMetaDataFormatException("Custom attribute with unexpected type: " + this.type);
            }
            Signature.Param[] parameters = signature.Parameters;
            int fixedCount = parameters.Length;

            this.fixedArgs = new Object[fixedCount];
            MemoryStream stream =
                new MemoryStream(this.buffer, 2, this.buffer.Length - 2, false);
            BinaryReader reader = new BinaryReader(stream);

            for (int i = 0; i < fixedCount; i++)
            {
                Signature.Param parameter = parameters[i];
                Signature.Type  paramType = parameter.Type;
                Object          value     =
                    ExtractParameter(paramType, reader, resolver, resolvers);
                fixedArgs[i] = value;
            }
            short namedCount = ((reader.PeekChar() == -1) ?
                                (short)0 :
                                reader.ReadInt16());

            if (namedCount > this.buffer.Length &&
                this.Name.Equals("System.Runtime.CompilerServices.RequiredAttributeAttribute"))
            {
                // Some CLR libraries have been compiled against a version of
                // mscorlib that had a fixed parameter to RequiredAttribute.
                // Simply ignore whatever the parameter was!
                namedCount = 0;
            }
            this.namedArgs = new NamedArg[namedCount];
            for (int i = 0; i < namedCount; i++)
            {
                SerializationTypes propOrField = (SerializationTypes)
                                                 reader.ReadByte();
                ElementTypes fieldType = (ElementTypes)reader.ReadByte();
                ElementTypes arrayType = ElementTypes.END;
                switch (fieldType)
                {
                case ElementTypes.SZARRAY: {
                    arrayType = (ElementTypes)reader.ReadByte();
                    if (arrayType == (ElementTypes)SerializationTypes.ENUM)
                    {
                        throw new Exception("Not implemented: Array of ENUM " +
                                            "for named field/property");
                    }
                    break;
                }

                case (ElementTypes)SerializationTypes.ENUM: {
                    String enumName = ExtractString(reader);
                    if (enumName.Length == 0)
                    {
                        throw new Exception("Empty enum name");
                    }
                    // Hope it is a 4-byte enum
                    fieldType = (ElementTypes)SerializationTypes.U4;
                    break;
                }

                case (ElementTypes)SerializationTypes.TAGGED_OBJECT: {
                    throw new Exception("Not implemented: " + fieldType +
                                        " for named field/property");
                }

                default: {
                    break;
                }
                }
                String name = ExtractString(reader);
                Object value;
                if (fieldType == ElementTypes.SZARRAY)
                {
                    value = ExtractArrayValue(arrayType, reader);
                }
                else
                {
                    value = ExtractValue(fieldType, reader);
                }
                if (propOrField == SerializationTypes.FIELD ||
                    propOrField == SerializationTypes.PROPERTY)
                {
                    this.namedArgs[i] =
                        new NamedArg(propOrField == SerializationTypes.FIELD,
                                     -1, name, value);
                }
                else
                {
                    throw new MetaDataLoader.IllegalMetaDataFormatException("Unknown prop-or-field type: " + propOrField);
                }
            }
        }
Exemplo n.º 29
0
	public void setPlayerElement(ElementTypes type) {
		_chosenPlayerElement = type;
		_chosenPlayerElementCount = Manager.TownManager.GetElementCountForCharacter(ControlledBy.Player);
	}
        private static Object ExtractArrayValue(ElementTypes elementType,
                                                int arraySize,
                                                BinaryReader reader)
        {
            switch (elementType)
            {
            case ElementTypes.BOOLEAN: {
                bool[] array = new bool[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadBoolean();
                }
                return(array);
            }

            case ElementTypes.CHAR: {
                char[] array = new char[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = (char)reader.ReadUInt16();
                }
                return(array);
            }

            case ElementTypes.I1: {
                sbyte[] array = new sbyte[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadSByte();
                }
                return(array);
            }

            case ElementTypes.U1: {
                byte[] array = new byte[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadByte();
                }
                return(array);
            }

            case ElementTypes.I2: {
                short[] array = new short[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadInt16();
                }
                return(array);
            }

            case ElementTypes.U2: {
                ushort[] array = new ushort[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadUInt16();
                }
                return(array);
            }

            case ElementTypes.I4: {
                int[] array = new int[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadInt32();
                }
                return(array);
            }

            case ElementTypes.U4: {
                uint[] array = new uint[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadUInt32();
                }
                return(array);
            }

            case ElementTypes.I8: {
                long[] array = new long[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadInt64();
                }
                return(array);
            }

            case ElementTypes.U8: {
                ulong[] array = new ulong[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadUInt64();
                }
                return(array);
            }

            case ElementTypes.R4: {
                float[] array = new float[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadSingle();
                }
                return(array);
            }

            case ElementTypes.R8: {
                double[] array = new double[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = reader.ReadDouble();
                }
                return(array);
            }

            case ElementTypes.STRING: {
                String[] array = new String[arraySize];
                for (int i = 0; i < arraySize; i++)
                {
                    array[i] = ExtractString(reader);
                }
                return(array);
            }

            default:
                throw new Exception("Not implemented: custom attribute " +
                                    "array of type " + elementType);
            }
        }
Exemplo n.º 31
0
 public DOMElement(ElementTypes type, int startPosition)
 {
     Type          = type;
     StartPosition = startPosition;
 }
Exemplo n.º 32
0
        public ActionResult DeleteElementType(Guid id)
        {
            bool result = ElementTypes.DeleteElementTypeByElementTypeId(id);

            return(RedirectToLocal(""));
        }
Exemplo n.º 33
0
        /// <summary>
        /// Get animations for current spellcast.
        /// This happens the first time a spell is cast and stored for re-casting.
        /// It's likely player will use a wide variety of spell types in normal play.
        /// </summary>
        void SetCurrentAnims(ElementTypes elementType, int border = 0, bool dilate = false)
        {
            // Attempt to get current anims
            if (castAnims.ContainsKey(elementType))
            {
                currentAnimType = elementType;
                currentAnims    = castAnims[elementType];
                return;
            }

            // Load spellcast file
            string     filename = WeaponBasics.GetMagicAnimFilename(elementType);
            string     path     = Path.Combine(DaggerfallUnity.Instance.Arena2Path, filename);
            CifRciFile cifFile  = new CifRciFile();

            if (!cifFile.Load(path, FileUsage.UseMemory, true))
            {
                throw new Exception(string.Format("Could not load spell anims file {0}", path));
            }

            // Load CIF palette
            cifFile.Palette.Load(Path.Combine(DaggerfallUnity.Instance.Arena2Path, cifFile.PaletteName));

            // Load textures - spells have a single frame per record unlike weapons
            AnimationRecord[] animationRecords = new AnimationRecord[cifFile.RecordCount];
            for (int record = 0; record < cifFile.RecordCount; record++)
            {
                Texture2D texture;
                if (!TextureReplacement.TryImportCifRci(filename, record, 0, false, out texture))
                {
                    // Get Color32 array
                    DFSize    sz;
                    Color32[] colors = cifFile.GetColor32(record, 0, 0, border, out sz);

                    // Dilate edges
                    if (border > 0 && dilate)
                    {
                        ImageProcessing.DilateColors(ref colors, sz);
                    }

                    // Create Texture2D
                    texture = new Texture2D(sz.Width, sz.Height, TextureFormat.ARGB32, false);
                    texture.SetPixels32(colors);
                    texture.Apply(true);
                }

                // Set filter mode and store in frames array
                if (texture)
                {
                    texture.filterMode = (FilterMode)DaggerfallUnity.Settings.MainFilterMode;
                    animationRecords[record].Texture = texture;
                    animationRecords[record].Size    = cifFile.GetSize(record);
                }
            }

            // Add frames array to dictionary
            castAnims.Add(elementType, animationRecords);

            // Use as current anims
            currentAnimType = elementType;
            currentAnims    = animationRecords;
        }
Exemplo n.º 34
0
        private void Start()
        {
            // Setup light and shadows
            myLight                   = GetComponent <Light>();
            myLight.enabled           = EnableLight;
            forceDisableSpellLighting = !DaggerfallUnity.Settings.EnableSpellLighting;
            if (forceDisableSpellLighting)
            {
                myLight.enabled = false;
            }
            if (!DaggerfallUnity.Settings.EnableSpellShadows)
            {
                myLight.shadows = LightShadows.None;
            }
            initialRange     = myLight.range;
            initialIntensity = myLight.intensity;

            // Setup collider
            myCollider        = GetComponent <SphereCollider>();
            myCollider.radius = ColliderRadius;

            // Setup rigidbody
            myRigidbody            = GetComponent <Rigidbody>();
            myRigidbody.useGravity = false;

            // Use payload when available
            if (payload != null)
            {
                // Set payload missile properties
                caster      = payload.CasterEntityBehaviour;
                targetType  = payload.Settings.TargetType;
                elementType = payload.Settings.ElementType;

                // Set spell billboard anims automatically from payload for mobile missiles
                if (targetType == TargetTypes.SingleTargetAtRange ||
                    targetType == TargetTypes.AreaAtRange)
                {
                    UseSpellBillboardAnims();
                }
            }

            // Setup senses
            if (caster && caster != GameManager.Instance.PlayerEntityBehaviour)
            {
                enemySenses = caster.GetComponent <EnemySenses>();
            }

            // Setup arrow
            if (isArrow)
            {
                // Create and orient 3d arrow
                goModel = GameObjectHelper.CreateDaggerfallMeshGameObject(99800, transform);
                MeshCollider arrowCollider = goModel.GetComponent <MeshCollider>();
                arrowCollider.sharedMesh = goModel.GetComponent <MeshFilter>().sharedMesh;
                arrowCollider.convex     = true;
                arrowCollider.isTrigger  = true;

                // Offset up so it comes from same place LOS check is done from
                Vector3 adjust;
                if (caster != GameManager.Instance.PlayerEntityBehaviour)
                {
                    CharacterController controller = caster.transform.GetComponent <CharacterController>();
                    adjust    = caster.transform.forward * 0.6f;
                    adjust.y += controller.height / 3;
                }
                else
                {
                    // Offset forward to avoid collision with player
                    adjust = GameManager.Instance.MainCamera.transform.forward * 0.6f;
                    // Adjust slightly downward to match bow animation
                    adjust.y -= 0.11f;
                    // Adjust to the right or left to match bow animation
                    if (!GameManager.Instance.WeaponManager.ScreenWeapon.FlipHorizontal)
                    {
                        adjust += GameManager.Instance.MainCamera.transform.right * 0.15f;
                    }
                    else
                    {
                        adjust -= GameManager.Instance.MainCamera.transform.right * 0.15f;
                    }
                }

                goModel.transform.localPosition = adjust;
                goModel.transform.rotation      = Quaternion.LookRotation(GetAimDirection());
                goModel.layer = gameObject.layer;
            }

            // Ignore missile collision with caster (this is a different check to AOE targets)
            if (caster)
            {
                Physics.IgnoreCollision(caster.GetComponent <Collider>(), this.GetComponent <Collider>());
            }
        }
Exemplo n.º 35
0
        /// <summary>
        /// Checks if the entry at <paramref name="offset"/> in the <paramref name="signiture"/>
        /// heap is a token.
        /// </summary>
        /// <param name="signiture">The signiture to check.</param>
        /// <param name="offset">The offset in the signiture.</param>
        /// <returns>True if it is a token else false.</returns>
        public static bool IsToken(byte[] signiture, int offset)
        {
            ElementTypes type = (ElementTypes)GetCompressedValue(signiture, offset);

            return((type & ElementTypes.Pinned) != 0);
        }
    public override void OnInspectorGUI()
    {
        // emptyTexture = (Texture)EditorGUIUtility.Load("Assets/EditorDefaultResources/empty.png");

        base.OnInspectorGUI();
        GUILayout.Label("Current Selected : " + currentSelected.ToString());

        LevelCreator levelCreator = (LevelCreator)target;
        int          rows         = (int)Mathf.Sqrt(levelCreator.level.Count);

        //int currentI = levelCreator.level.Count-1;
        GUILayout.BeginVertical();
        for (int r = rows - 1; r >= 0; r--)
        {
            GUILayout.BeginHorizontal();
            for (int c = 0; c < rows; c++)
            {
                if (GUILayout.Button(textureHolder[levelCreator.level[c + ((rows) * r)]], GUILayout.Width(50), GUILayout.Height(50)))
                {
                    levelCreator.level[c + ((rows) * r)] = currentSelected;
                }
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndVertical();

        GUILayout.Space(20);
        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal();
        int count = 0;

        foreach (KeyValuePair <ElementTypes, Texture> e in textureHolder)
        {
            count++;
            if (GUILayout.Button(e.Value, GUILayout.Width(50), GUILayout.Height(50)))
            {
                currentSelected = e.Key;
            }
            if (count % 4 == 0)
            {
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
            }
        }

        GUILayout.EndVertical();

        /* if (GUILayout.Button(textureHolder[ElementTypes.Empty],GUILayout.Width(50),GUILayout.Height(50))){
         *   currentSelected = ElementTypes.Empty;
         * }
         * else if (GUILayout.Button(textureHolder[ElementTypes.Baba], GUILayout.Width(50), GUILayout.Height(50)))
         * {
         *   currentSelected = ElementTypes.Baba;
         * }
         * else if (GUILayout.Button(textureHolder[ElementTypes.Wall], GUILayout.Width(50), GUILayout.Height(50)))
         * {
         *   currentSelected = ElementTypes.Wall;
         * }
         * else if (GUILayout.Button("Rock"))
         * {
         *   currentSelected = ElementTypes.Rock;
         * }
         * else if (GUILayout.Button("Flag"))
         * {
         *   currentSelected = ElementTypes.Flag;
         * }
         * else if (GUILayout.Button("Goop"))
         * {
         *   currentSelected = ElementTypes.Goop;
         * }
         * else if (GUILayout.Button("Is"))
         * {
         *   currentSelected = ElementTypes.IsWord;
         * }
         * else if (GUILayout.Button("BabaWord"))
         * {
         *   currentSelected = ElementTypes.BabaWord;
         * }
         * else if (GUILayout.Button("WallWord"))
         * {
         *   currentSelected = ElementTypes.WallWord;
         * }
         * else if (GUILayout.Button("FlagWord"))
         * {
         *   currentSelected = ElementTypes.FlagWord;
         * }
         * else if (GUILayout.Button("RockWord"))
         * {
         *   currentSelected = ElementTypes.RockWord;
         * }
         * else if (GUILayout.Button("YouWord"))
         * {
         *   currentSelected = ElementTypes.YouWord;
         * }
         * else if (GUILayout.Button("PushWord"))
         * {
         *   currentSelected = ElementTypes.PushWord;
         * }
         * else if (GUILayout.Button("WinWord"))
         * {
         *   currentSelected = ElementTypes.WinWord;
         * }
         * else if (GUILayout.Button("StopWord"))
         * {
         *   currentSelected = ElementTypes.StopWord;
         * }*/
    }
Exemplo n.º 37
0
        public override State PushChar(char c, IParseContext context, ref string rollback)
        {
            if (context.CurrentStateLength == 1 && context.PreviousState is HtmlScriptBodyState)
            {
                return(Parent);
            }

            //NOTE: This is (mostly) duplicated in HtmlClosingTagState
            //handle "paragraph" tags implicitly closed by block-level elements
            if (context.CurrentStateLength == 1 && context.PreviousState is XmlNameState)
            {
                XElement element = (XElement)context.Nodes.Peek();

                if (!element.Name.HasPrefix && element.Name.IsValid)
                {
                    //Note: the node stack will always be at least 1 deep due to the XDocument
                    var parent = context.Nodes.Peek(1) as XElement;

                    while (parent != null && parent.ValidAndNoPrefix() && parent.IsImplicitlyClosedBy(element))
                    {
                        context.Nodes.Pop();
                        context.Nodes.Pop();
                        if (warnAutoClose)
                        {
                            context.LogWarning(string.Format("Tag '{0}' implicitly closed by tag '{1}'.",
                                                             parent.Name.Name, element.Name.Name), parent.Region);
                        }
                        //parent.Region.End = element.Region.Start;
                        //parent.Region.EndColumn = Math.Max (parent.Region.EndColumn - 1, 1);
                        parent.Close(parent);
                        context.Nodes.Push(element);

                        parent = context.Nodes.Peek(1) as XElement;
                    }
                }
            }

            State ret = base.PushChar(c, context, ref rollback);

            if (ret == Parent && c == '>')
            {
                var element = context.Nodes.Peek() as XElement;
                if (element != null && !element.Name.HasPrefix && element.Name.IsValid)
                {
                    if (element.Name.Name.Equals("script", StringComparison.OrdinalIgnoreCase))
                    {
                        return(ScriptState);
                    }
                    else if (ElementTypes.IsEmpty(element.Name.Name))
                    {
                        element.Close(element);
                        context.Nodes.Pop();

                        if (warnAutoClose)
                        {
                            context.LogWarning(string.Format("Implicitly closed empty tag '{0}'", element.Name.Name),
                                               element.Region);
                        }
                    }
                }
            }

            return(ret);
        }
		internal abstract void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType);
Exemplo n.º 39
0
 public static String StringFromElementType(ElementTypes elementType)
 {
     return elementType.ToString();
 }
Exemplo n.º 40
0
        internal override bool GetNextElementAs(
            ref Element e,
            bool AcceptChannelSection, string Name, L3TypeManager SupposedType, bool NeedsThisElement, bool WantClosingElement)
        {
            int?SupposedTypeNumber = SupposedType != null ? SupposedType.TypeIndex : (int?)null;

            if (!this.GetNextXmlPart())
            {
                if (NeedsThisElement)
                {
                    throw new Exception();
                }
                else
                {
                    return(false);                    // end of document.
                }
            }
            if (this.xmlReader.Name == XmlSerializationFormatter.DataEndMarkTag)
            {
                return(false);                // end of document.
            }
            ElementTypes?et2 = this.GetElementType();
            if (et2 == null)
            {
#if DEBUG
                if (this.xmlReader.NodeType != XmlNodeType.EndElement && this.xmlReader.Name != "data")
                {
                    Debugger.Break();
                }
#endif
                return(false);
            }
            ElementTypes et = et2.Value;

            if (WantClosingElement && this.xmlReader.NodeType == XmlNodeType.Element)
            {
                if (NeedsThisElement)
                {
                    throw new Exception();
                }
                else
                {
                    return(false);
                }
            }

#if DEBUG
            if (!AcceptChannelSection &&
                !(et == ElementTypes.InstancesChannelSection || et == ElementTypes.TypesChannelSection))
            {
                throw new Exception();
            }


            // Checks name correspondance:
            string name = this.xmlReader.GetAttribute(XmlAttributeName.Name);
            if (Name != null && name != null && name != Name)
            {
                throw new Exception();
            }
#endif

            string typeNumber = this.xmlReader.GetAttribute(XmlAttributeName.TypeNumber);
#if DEBUG
            // Checks type correspondance:
            if (typeNumber != null && typeNumber != string.Empty && SupposedTypeNumber != null)
            {
                int foundTypeNumber = int.Parse(typeNumber);
                if (foundTypeNumber != SupposedTypeNumber.Value)
                {
                    var found    = this.typeManagerCollection.GetTypeManager(foundTypeNumber);
                    var foundGtd = found.l2TypeManager.L1TypeManager;
                    if (!foundGtd.type.Is(typeof(ITypeContainer)))
                    {
                        var supposed    = this.typeManagerCollection.GetTypeManager(SupposedTypeNumber.Value);
                        var supposedGtd = supposed.l2TypeManager.L1TypeManager;
                        if (!foundGtd.type.Is(supposedGtd.type))
                        {
                            if (!supposedGtd.IsNullable || supposedGtd.type.GetGenericArguments().Length == 0 || !foundGtd.type.Is(supposedGtd.type.GetGenericArguments()[0]))
                            {
                                throw new Exception();
                            }
                        }
                    }
                }
            }
#endif
            int?tn =
                typeNumber != null ? (
                    int.Parse(typeNumber))
                                : SupposedTypeNumber;

            string inum        = this.xmlReader.GetAttribute(XmlAttributeName.InstanceIndex);
            int?InstanceNumber =
                inum != null?
                int.Parse(inum)
                    : (int?)null;

            string noe            = this.xmlReader.GetAttribute(XmlAttributeName.NumberOfElements);
            long?numberOfElements =
                noe != null?
                long.Parse(noe)
                    : (long?)null;

            e.ContainsAValue = !this.xmlReader.IsEmptyElement;
            e.ElementType    = et;
            e.InstanceIndex  = InstanceNumber;
            e.IsAClosingTag  = this.xmlReader.NodeType == XmlNodeType.EndElement;
#if DEBUG
            e.Name = name != null ? name : Name;
#endif
            e.NeedsAnEndElement = !this.xmlReader.IsEmptyElement;
            e.NumberOfElements  = numberOfElements;
            if (tn != null)
            {
                e.typeIndex        = tn.Value;
                e.typeIndexIsKnown = true;
            }

            return(true);
        }
Exemplo n.º 41
0
 Texture2D GetSpellElementIcon(ElementTypes elementType)
 {
     return(DaggerfallUI.Instance.SpellIconCollection.GetSpellElementIcon(elementType));
 }
Exemplo n.º 42
0
 public void AddElementType(PlyElementType elementType)
 {
     ElementTypes.Add(elementType.Name, elementType);
 }
Exemplo n.º 43
0
		// --------------------------------------------

		internal override void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType)
		{
			this.ChannelWriteStringToStream(
				ref channelInfos,
				"</"
			 + XmlSerializationFormatter.XmlElementNames[(int)elementType]
			 + ">\n");
		}
Exemplo n.º 44
0
 public bool Contains(ElementTypes element)
 {
     return(_elementTypes.ContainsKey(element));
 }
Exemplo n.º 45
0
			// --------------------------------------------

			internal override void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType)
			{
				this.ChannelWriteStringToStream(ref channelInfos, "\n}");
			}
Exemplo n.º 46
0
 public void Add(ElementTypes elementType, XElement element)
 {
     _elementTypes.Add(elementType, element);
 }
        // --------------------------------------------

        internal override void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType)
        {
        }
Exemplo n.º 48
0
 public XElement Get(ElementTypes element)
 {
     return(_elementTypes[element]);
 }
 // useless in this formatter.
 internal override void PassClosingTag(ElementTypes ElementType)
 {
 }
        private ACConfiguration BuildConfiguration(DoorControllerDescriptor[] doorControllers, DoorDescriptor[] doors, EventDescriptor[] eventDescriptors)
        {
            var elements = new List <ACElement>();

            // Add element types
            elements.Add(ElementTypes.ServerType);
            elements.Add(ElementTypes.DoorControllerType);

            // Add event types
            elements.AddRange(EventTypes.ServerEventTypes);

            foreach (var eventDescriptor in eventDescriptors)
            {
                var acEventType = TypeConverter.ToACEventType(eventDescriptor, !_disabledEventTypes.Contains(eventDescriptor.EventId));
                elements.Add(acEventType);
            }

            // Add state types
            elements.AddRange(StateTypes.ServerStateTypes);
            elements.AddRange(StateTypes.DoorStateTypes);

            // Add command types
            elements.AddRange(CommandTypes.DoorCommands);

            // Look up the all events, which can be fired on a door
            // OBS: In the Demo Access Control application, events with source "DoorController" are actually fired on the door.
            var doorEventTypeIds = eventDescriptors.Where(e => e.SourceType == "Door" || e.SourceType == "DoorController").Select(ed => ed.EventId.ToString());

            elements.Add(ElementTypes.CreateDoorType(doorEventTypeIds));

            // Look up the all events, which can be fired on an access point
            var apEventTypeIds = eventDescriptors.Where(ed => ed.SourceType == "AccessPoint").Select(ed => ed.EventId.ToString());

            elements.Add(ElementTypes.CreateAccessPointType(apEventTypeIds));

            // Add server element
            elements.Add(TypeConverter.CreateACServer(_client.ServerId, _systemProperties.Address));

            // Add door controllers
            foreach (var doorController in doorControllers)
            {
                elements.Add(TypeConverter.ToACUnit(doorController));
            }

            // Add doors and access points
            foreach (var door in doors)
            {
                door.Enabled = !_disabledDoors.Contains(door.DoorId);
                elements.AddRange(TypeConverter.ToACUnits(door));
            }

            try
            {
                return(ACConfiguration.CreateACConfiguration(DateTime.UtcNow, elements));
            }
            catch (ACConfigurationException ex)
            {
                ACUtil.Log(true, "DemoACPlugin.ConfigurationManager", "Error building configuration: " + ex.Message);
                return(null);
            }
        }
Exemplo n.º 51
0
 public ElementAttribute(int identifier, ElementTypes type, string description = null) : this(type, description)
 {
     ClassIdentifier = new ClassIdentifier(identifier);
 }
		internal abstract void PassClosingTag(ElementTypes ElementType);
Exemplo n.º 53
0
 public ElementAttribute(ClassIdentifier identifier, ElementTypes type, string description = null) : this(type, description)
 {
     ClassIdentifier = identifier;
 }
Exemplo n.º 54
0
 public Node(ElementTypes type, long id) : base(type, id)
 {
 }
Exemplo n.º 55
0
 internal bool IsTypeAndAlive(ElementTypes Type, Point P)
 {
     if (Type == ElementTypes.PacPlayer || Type == ElementTypes.Ghost)
     {
         foreach (Element E in Players)
         {
             if (E.et == Type && E.IsAlive && E.Location.Equals(P))
             {
                 return true;
             }
         }
     }
     else
     {
         Element E = null;
         FastBoard.TryGetValue(P, out E);
         return E != null && E.et == Type && E.IsAlive == true;
     }
     //foreach (Element E in FindAt(P))
     //{
     //    if (E.et == Type && E.IsAlive)
     //    {
     //        return true;
     //    }
     //}
     return false;
 }
Exemplo n.º 56
0
        private void DetermineElementType()
        {
            if (Items.Count == 0)
            {
                ElementType = ElementTypes.None;
                return;
            }

            // If at list one item is builtin, the whole category considers as builtin.
            if (Items.Any(item => item.ElementType.HasFlag(ElementTypes.BuiltIn)))
                ElementType = ElementTypes.BuiltIn;
            else
            {
                // If some items come from package, the whole category considers as package.
                if (Items.Any(item => item.ElementType.HasFlag(ElementTypes.Packaged)))
                    ElementType = ElementTypes.Packaged;
                else
                {
                    if (Items.Any(item => item.ElementType.HasFlag(ElementTypes.ZeroTouch)))
                        ElementType = ElementTypes.ZeroTouch;
                    else
                        if (Items.Any(item => item.ElementType.HasFlag(ElementTypes.CustomNode)))
                            ElementType = ElementTypes.CustomNode;
                }
            }
        }
Exemplo n.º 57
0
 internal Element(int line, ElementTypes types, string value)
 {
     Line = line;
     ElementType = types;
     ElementCheck(value);
 }
Exemplo n.º 58
0
        //----------------------------------------------------------------------------------------------------
        public void Parse(st line)
        {
            this.MarkdownLine = line;
            this.TreeLevel    = this.CountHyphens(line);
            line = line.TruncateLeft(this.TreeLevel).Trim();

            if (line.StartsWith("'", false))
            {
                this.ElementName = "";
                this.ElementType = ElementTypes.HtmlLiteral;
                line             = line.TruncateLeft(1);
                if (line.EndsWith("'", false))
                {
                    line = line.TruncateRight(1);
                }
                this.InnerHtml = line.TheString;
            }
            else
            {
                this.ElementType = ElementTypes.ElementsHolder;
                if (line.Contains("html=", false))
                {
                    string tmpLine           = "";
                    bool   insideSingleQuote = false;
                    for (int i = 0; i < line.Length(); i++)
                    {
                        string c = line.Substring(i, 1);
                        if (c == "'")
                        {
                            insideSingleQuote = !insideSingleQuote;
                        }
                        if (c == " " && insideSingleQuote)
                        {
                            tmpLine += "(---[[[SPACE].].]---)";
                        }
                        else
                        {
                            tmpLine += c;
                        }
                    }
                    line.TheString = tmpLine;
                }
                var tokens = line.Split(" ", false);
                if (tokens[0].StartsWith("i", true))
                {
                    this.ElementType = ElementTypes.EmptyElementTag;
                    this.ElementName = "input";
                    this.InputType   = "text";
                    var inArr = tokens[0].Split(":", false);
                    if (inArr.Length > 1)
                    {
                        switch (inArr[1].TheString)
                        {
                        case "": this.InputType = "text"; break;

                        case "t": this.InputType = "text"; break;

                        case "b": this.InputType = "button"; break;

                        case "s": this.InputType = "submit"; break;

                        case "c": this.InputType = "checkbox"; break;

                        case "r": this.InputType = "radio"; break;

                        case "f": this.InputType = "file"; break;

                        case "h": this.InputType = "hidden"; break;

                        default: this.InputType = inArr[1].TheString; break;
                        }
                    }
                }
                else
                {
                    switch (tokens[0].TheString)
                    {
                    case "d": this.ElementName = "div";
                        break;

                    case "s": this.ElementName = "span";
                        break;

                    case "br":
                        this.ElementName = "br";
                        this.ElementType = ElementTypes.EmptyElementTag;
                        break;

                    case "t": this.ElementName = "table";
                        break;

                    case "tr": this.ElementName = "tr";
                        break;

                    case "td": this.ElementName = "td";
                        break;

                    default: this.ElementName = tokens[0].TheString;
                        break;
                    }
                }

                this.ClassesString = "";
                for (int i = 1; i < tokens.Length; i++)
                {
                    var token = tokens[i].Trim();
                    token = token.Replace("(---[[[SPACE].].]---)", " ");
                    if (token.Length() > 0)
                    {
                        if (token.StartsWith("#", false))
                        {
                            this.IdClass = token.TruncateLeft(1).Trim().TheString;
                        }
                        else if (token.StartsWith(".", true))
                        {
                            this.ClassesString += " " + token.TruncateLeft(1).Replace(".", " ").TheString;
                        }
                        else if (token.StartsWith("evt.", true))
                        {
                            if (this.EventNames == null)
                            {
                                this.EventNames = new string[0];
                            }
                            this.EventNames[this.EventNames.Length] = token.TruncateLeft(4).Trim().TheString;
                        }
                        else if (token.StartsWith("m=", true))
                        {
                            var modelKey = token.TruncateLeft(2).Trim();
                            if (modelKey.StartsWith("'", false))
                            {
                                modelKey = modelKey.TruncateLeft(1);
                            }
                            if (modelKey.EndsWith("'", false))
                            {
                                modelKey = modelKey.TruncateRight(1);
                            }
                            this.ModelKey = modelKey.TheString;
                        }
                        else if (token.StartsWith("html=", true))
                        {
                            var html = token.TruncateLeft(5).Trim();
                            if (html.StartsWith("'", false))
                            {
                                html = html.TruncateLeft(1);
                            }
                            if (html.EndsWith("'", false))
                            {
                                html = html.TruncateRight(1);
                            }
                            this.InnerHtml = html.TheString;
                        }
                        else if (token.StartsWith("v=", true))
                        {
                            var value = token.TruncateLeft(2).Trim();
                            if (value.StartsWith("'", false))
                            {
                                value = value.TruncateLeft(1);
                            }
                            if (value.EndsWith("'", false))
                            {
                                value = value.TruncateRight(1);
                            }
                            this.Value = value.TheString;
                        }
                        else if (token.Contains("=", false))
                        {
                            this.AttributesStr += " " + token.TheString + " ";
                        }
                    }
                }
                if (this.IdClass.Length > 0)
                {
                    this.ClassesString += " " + this.IdClass;
                }
                this.ClassesString = st.New(this.ClassesString).Trim().TheString;

                if (this.EventNames != null && this.IdClass.Length > 0)
                {
                    for (int i = 0; i < this.EventNames.Length; i++)
                    {
                        this.AttributesStr += st.New(" On_{0}='{1}_{0}'").Format2(this.EventNames[0], this.IdClass).TheString;
                    }
                }
            }
        }
Exemplo n.º 59
0
        //----------------------------------------------------------------------------------------------------
        public string ToHtmlString()
        {
            string rtn = "";

            if (this.ElementType == ElementTypes.ElementsHolder && (this.Children == null || this.Children.Length < 0))
            {
                this.ElementType = ElementTypes.HtmlHolder;
            }

            string prefix = "";

            for (int i = 1; i < this.TreeLevel; i++)
            {
                prefix += "&nbsp;&nbsp;&nbsp;&nbsp;";
            }
            string suffix = "\n";

            if (1 != 0)
            {
                prefix = ""; suffix = "";
            }


            st attributesStr = st.New("");

            if (this.InputType.Length > 0)
            {
                attributesStr.AppendST(st.New(" type='{0}'").Format1(this.InputType));
            }
            if (this.ModelKey.Length > 0)
            {
                attributesStr.AppendST(st.New(" ModelKey='{0}'").Format1(this.ModelKey));
            }
            if (this.IdClass.Length > 0)
            {
                attributesStr.AppendST(st.New(" IdClass='{0}'").Format1(this.IdClass));
            }
            if (this.ClassesString.Length > 0)
            {
                attributesStr.AppendST(st.New(" class='{0}'").Format1(this.ClassesString));
            }
            if (this.Value.Length > 0)
            {
                attributesStr.AppendST(st.New(" value='{0}'").Format1(this.Value));
            }

            attributesStr = attributesStr.Trim();
            if (this.AttributesStr != "")
            {
                attributesStr.Append(" " + this.AttributesStr);
            }
            if (attributesStr.Length() > 0)
            {
                attributesStr.TheString = " " + attributesStr.TheString;
            }


            if (this.ElementType == ElementTypes.ElementsHolder)
            {
                rtn += st.New("{0}<{1}{2}>{3}").Format4(prefix, this.ElementName, attributesStr.TheString, suffix).TheString;
                for (int i = 0; i < this.Children.Length; i++)
                {
                    rtn += this.Children[i].ToHtmlString();
                }
                rtn += st.New("{0}</{1}>{2}").Format3(prefix, this.ElementName, suffix).TheString;
            }
            else if (this.ElementType == ElementTypes.HtmlHolder)
            {
                rtn += st.New("{0}<{1}{2}>{3}</{1}>{4}").Format5(prefix, this.ElementName, attributesStr.TheString, this.InnerHtml, suffix).TheString;
            }
            else if (this.ElementType == ElementTypes.EmptyElementTag)
            {
                rtn += st.New("{0}<{1}{2} />{3}").Format4(prefix, this.ElementName, attributesStr.TheString, suffix).TheString;
            }
            else if (this.ElementType == ElementTypes.HtmlLiteral)
            {
                rtn += st.New("{0}{1}{2}").Format3(prefix, this.InnerHtml, suffix).TheString;
            }

            return(rtn);
        }
Exemplo n.º 60
0
        private void BuildPath(InstructionSet IS, ElementTypes Type, Node Start)
        {
            //AlreadySearched.Add(this);

            //Random rnd = new Random();
            //for (int i = IS.Last.Paths.Count; i > 1; i--)
            //{
            //    int pos = rnd.Next(i);
            //    var x = IS.Last.Paths[i - 1];
            //    IS.Last.Paths[i - 1] = IS.Last.Paths[pos];
            //    IS.Last.Paths[pos] = x;
            //}

            //for (int i = 0; i < IS.Last.Paths.Count; i++ )
            //{
            //    Path Path = IS.Last.Paths[i];
            //    if (Path.ContainsType(Type, Board) && (Shortest == null || Shortest.distance > IS.distance))
            //    {
            //        Shortest = IS.AddPath(Path);
            //        continue;
            //    }
            //    if (AlreadySearched.Contains(Path.End))
            //    {
            //        continue;
            //    }
            //    Path.End.BuildPath(IS.AddPath(Path), Type);
            //}
            //AlreadySearched.Remove(this);

            Queue<Node> State = new Queue<Node>();
            List<Node> Traveled = new List<Node>();
            Queue<InstructionSet> Instructions = new Queue<InstructionSet>();

            Traveled.Add(Start);
            State.Enqueue(Start);
            Instructions.Enqueue(IS);

            while (State.Count > 0)
            {
                Node T = State.Dequeue();
                InstructionSet How = Instructions.Dequeue();
                foreach (Path P in T.Paths)
                {
                    if (P.ContainsType(Type, Board))
                    {
                        InstructionSet Found = How.AddPath(P);
                        if (Shortest == null || Found.distance < Shortest.distance)
                        {
                            Shortest = Found;
                        }
                        continue;
                    }
                    Node N = P.End;
                    if (!Traveled.Contains(N))
                    {
                        Traveled.Add(N);
                        State.Enqueue(N);
                        Instructions.Enqueue(How.AddPath(P));
                    }
                }
            }
        }