예제 #1
0
 public Element(ElementKind kind, Dictionary<string, object> startTagTokens)
 {
     Kind = kind;
     StartTagTokens = startTagTokens;
     EndTagTokens = new Dictionary<string, object>();
     Children = new List<Element>();
 }
예제 #2
0
        internal static String CreateElementKindString(ElementKind elementKind, GeneralArrayInfo arrayInfo)
        {
            var builder = new StringBuilder();

            CreateElementKindString(elementKind, arrayInfo, builder);
            return(builder.ToString());
        }
예제 #3
0
 public Element(ElementKind kind, Dictionary <string, object> startTagTokens)
 {
     Kind           = kind;
     StartTagTokens = startTagTokens;
     EndTagTokens   = new Dictionary <string, object>();
     Children       = new List <Element>();
 }
예제 #4
0
 public Element(ElementKind kind, Dictionary <string, object> startTagTokens, Dictionary <string, object> endTagTokens, List <Element> children)
 {
     Kind           = kind;
     StartTagTokens = startTagTokens;
     EndTagTokens   = endTagTokens;
     Children       = children;
 }
예제 #5
0
 public Element(ElementKind kind, Token startTag)
 {
     Kind = kind;
     StartTagTokens = new Dictionary<string, object> { { "", startTag } };
     EndTagTokens = new Dictionary<string, object>();
     Children = new List<Element>();
 }
예제 #6
0
 public Element(ElementKind kind, Dictionary<string, object> startTagTokens, Dictionary<string, object> endTagTokens, List<Element> children)
 {
     Kind = kind;
     StartTagTokens = startTagTokens;
     EndTagTokens = endTagTokens;
     Children = children;
 }
예제 #7
0
        //攻撃力と他のステータスを受け取り、防御力を適用しダメージ算出
        public void Damage(int attackPower,ElementKind element, float magnification)
        {
            var calcDamage = CalcDamage(attackPower, element, magnification);
            characterParameter.HP -= calcDamage;
            CreateDamageText(calcDamage);

            animator.SetDamage();
            //character.StateUI.UpdateUI();
        }
예제 #8
0
 public Element(ElementKind kind, Token startTag)
 {
     Kind           = kind;
     StartTagTokens = new Dictionary <string, object> {
         { "", startTag }
     };
     EndTagTokens = new Dictionary <string, object>();
     Children     = new List <Element>();
 }
예제 #9
0
        //攻撃力と他のステータスを受け取り、防御力を適用しダメージ算出
        public void Damage(int attackPower, ElementKind element, float magnification)
        {
            var calcDamage = CalcDamage(attackPower, element, magnification);

            characterParameter.HP -= calcDamage;
            CreateDamageText(calcDamage);

            animator.SetDamage();
            //character.StateUI.UpdateUI();
        }
예제 #10
0
        private static void CreateElementKindString(ElementKind elementKind, GeneralArrayInfo arrayInfo, StringBuilder builder)
        {
            switch (elementKind)
            {
            case ElementKind.Array:
                builder.Append('[');
                if (arrayInfo != null)
                {
                    if (arrayInfo.Rank == 1 && arrayInfo.Sizes.Count == 0 && arrayInfo.LowerBounds.Count == 0)
                    {
                        // Special case
                        builder.Append('*');
                    }
                    else
                    {
                        for (var i = 0; i < arrayInfo.Rank; ++i)
                        {
                            var appendLoBound = i < arrayInfo.LowerBounds.Count;
                            if (appendLoBound)
                            {
                                var loBound = arrayInfo.LowerBounds[i];
                                appendLoBound = loBound != 0;
                                if (appendLoBound)
                                {
                                    builder.Append(loBound).Append("..");
                                }
                            }
                            if (i < arrayInfo.Sizes.Count)
                            {
                                builder.Append(arrayInfo.Sizes[i]);
                            }
                            else if (appendLoBound)
                            {
                                builder.Append('.');
                            }

                            if (i < arrayInfo.Rank - 1)
                            {
                                builder.Append(',');
                            }
                        }
                    }
                }
                builder.Append(']');
                break;

            case ElementKind.Pointer:
                builder.Append('*');
                break;

            case ElementKind.Reference:
                builder.Append('&');
                break;
            }
        }
예제 #11
0
        public ItemSpawner(HexData.Addition data)
        {
            count = data.count;
            kind = data.kind;
            itemType = data.type;
            minRespTime = data.minRespawnTime;
            maxRespTime = data.maxRespawnTime;
            firstSpawn = data.respawnOnStart;

            roundCounter = 0;
            requiredRound = URandom.Range(minRespTime, maxRespTime + 1);
        }
예제 #12
0
        private Operation CreateOperationFromAttribute(
            XElement element,
            ElementKind kind,
            XAttribute attribute,
            bool throwOnId = false)
        {
            string attributeName = attribute.LocalName();

            if (throwOnId &&
                DefaultComparer.NameEquals(attributeName, AttributeNames.Id))
            {
                Throw(ErrorMessages.CannotUseOperationOnProperty(element, attributeName));
            }

            PropertyDefinition property;

            string name = attribute.LocalName();

            if (name == PropertyDefinition.TagsName)
            {
                property = PropertyDefinition.Tags;
            }
            else
            {
                property = GetProperty(attribute);
            }

            switch (kind)
            {
            case ElementKind.With:
            {
                return(new Operation(property, GetValue(attribute), _depth, OperationKind.With));
            }

            case ElementKind.Without:
            {
                if (!property.IsCollection)
                {
                    Throw(ErrorMessages.CannotUseOperationOnNonCollectionProperty(element, property.Name));
                }

                return(new Operation(property, GetValue(attribute), _depth, OperationKind.Without));
            }

            default:
            {
                Debug.Assert(kind == ElementKind.New, kind.ToString());

                return(new Operation(property, GetValue(attribute), _depth, OperationKind.With));
            }
            }
        }
예제 #13
0
        public static Type GetMatchingType(this ElementKind kind)
        {
            switch (kind)
            {
            case ElementKind.Boolean:
                return(typeof(bool));

            case ElementKind.Float32:
                return(typeof(float));

            case ElementKind.Int32:
                return(typeof(int));
            }

            throw new NotSupportedException();
        }
예제 #14
0
파일: Shape.cs 프로젝트: allisterb/Adrien
 public Shape(ElementKind kind, IReadOnlyList <int> dimensions)
 {
     Kind       = kind;
     Dimensions = dimensions;
 }
예제 #15
0
 public virtual void InitElement(ElementKind kind, string name)
 {
     FKind = kind;
     FName = name;
 }
예제 #16
0
        private IEnumerable <IPropertyOperation> CreateOperationsFromElement(XElement element, bool throwOnMultiCommand = false)
        {
            Debug.Assert(element.HasAttributes, element.ToString());

            ElementKind kind = element.Kind();

            switch (kind)
            {
            case ElementKind.Set:
            {
                foreach (XAttribute attribute in element.Attributes())
                {
                    yield return(CreateOperationFromAttribute(element, kind, attribute, throwOnId: true, throwOnCollection: true));
                }

                break;
            }

            case ElementKind.Postfix:
            {
                foreach (XAttribute attribute in element.Attributes())
                {
                    yield return(new PostfixOperation(GetProperty(attribute), GetValue(attribute), Depth));
                }

                break;
            }

            case ElementKind.PostfixMany:
            {
                if (throwOnMultiCommand)
                {
                    ThrowInvalidOperation(ErrorMessages.CommandCannotBeUsedAsChildCommandOfNewCommand(element));
                }

                foreach (XAttribute attribute in element.Attributes())
                {
                    yield return(new PostfixManyOperation(GetProperty(attribute), GetValue(attribute), Depth));
                }

                break;
            }

            case ElementKind.Prefix:
            {
                foreach (XAttribute attribute in element.Attributes())
                {
                    yield return(new PrefixOperation(GetProperty(attribute), GetValue(attribute), Depth));
                }

                break;
            }

            case ElementKind.PrefixMany:
            {
                if (throwOnMultiCommand)
                {
                    ThrowInvalidOperation(ErrorMessages.CommandCannotBeUsedAsChildCommandOfNewCommand(element));
                }

                foreach (XAttribute attribute in element.Attributes())
                {
                    yield return(new PrefixManyOperation(GetProperty(attribute), GetValue(attribute), Depth));
                }

                break;
            }

            case ElementKind.Add:
            case ElementKind.Remove:
            {
                foreach (XAttribute attribute in element.Attributes())
                {
                    yield return(CreateOperationFromAttribute(element, kind, attribute, throwOnId: true));
                }

                break;
            }

            case ElementKind.AddRange:
            case ElementKind.RemoveRange:
            {
                char separator = ',';

                foreach (XAttribute attribute in element.Attributes())
                {
                    switch (attribute.LocalName())
                    {
                    case AttributeNames.Separator:
                    {
                        string separatorText = attribute.Value;

                        if (separatorText.Length != 1)
                        {
                            Throw("Separator must be a single character", attribute);
                        }

                        separator = separatorText[0];
                        break;
                    }

                    default:
                    {
                        yield return(CreateOperationFromAttribute(element, kind, attribute, separator: separator, throwOnId: true));

                        break;
                    }
                    }
                }

                break;
            }

            default:
            {
                Throw(ErrorMessages.OperationIsNotDefined(element.LocalName()));
                break;
            }
            }
        }
예제 #17
0
        //ここを変えるとダメージが変わる
        //計算式(ATK-1/2DEF)*magnification
        int CalcDamage(int power, ElementKind element, float magnification)
        {
            var deffence = element == ElementKind.なし ? character.characterParameter.deffence : character.characterParameter.elementDeffence;

            return(Mathf.Max(0, (int)((power - (1 / 2 * deffence)) * magnification)));
        }
예제 #18
0
 public static Type GetTensorType(this ElementKind kind)
 {
     return(typeof(Tensor <>).MakeGenericType(kind.GetMatchingType()));
 }
예제 #19
0
        private IEnumerable <Operation> CreateOperationsFromElement(XElement element)
        {
            Debug.Assert(element.HasAttributes, element.ToString());

            ElementKind kind = element.Kind();

            switch (kind)
            {
            case ElementKind.With:
            case ElementKind.Without:
            {
                foreach (XAttribute attribute in element.Attributes())
                {
                    yield return(CreateOperationFromAttribute(element, kind, attribute, throwOnId: true));
                }

                //TODO: Separator
                //char separator = ',';

                //foreach (XAttribute attribute in element.Attributes())
                //{
                //    switch (attribute.LocalName())
                //    {
                //        case AttributeNames.Separator:
                //            {
                //                string separatorText = attribute.Value;

                //                if (separatorText.Length != 1)
                //                    Throw("Separator must be a single character", attribute);

                //                separator = separatorText[0];
                //                break;
                //            }
                //        default:
                //            {
                //                yield return CreateOperationFromAttribute(element, kind, attribute, separator: separator, throwOnId: true);
                //                break;
                //            }
                //    }
                //}

                break;
            }

            case ElementKind.Postfix:
            {
                foreach (XAttribute attribute in element.Attributes())
                {
                    yield return(new Operation(GetProperty(attribute), GetValue(attribute), _depth, OperationKind.Postfix));
                }

                break;
            }

            case ElementKind.Prefix:
            {
                foreach (XAttribute attribute in element.Attributes())
                {
                    yield return(new Operation(GetProperty(attribute), GetValue(attribute), _depth, OperationKind.Prefix));
                }

                break;
            }

            default:
            {
                Throw(ErrorMessages.OperationIsNotDefined(element.LocalName()));
                break;
            }
            }
        }
예제 #20
0
 //ここを変えるとダメージが変わる
 //計算式(ATK-1/2DEF)*magnification
 int CalcDamage(int power,ElementKind element, float magnification)
 {
     var deffence = element == ElementKind.なし ? character.characterParameter.deffence : character.characterParameter.elementDeffence;
     return Mathf.Max(0, (int)((power - (1 / 2 * deffence)) * magnification));
 }
예제 #21
0
 public static bool IsKind(this XElement element, ElementKind kind)
 {
     return(element.Kind() == kind);
 }
예제 #22
0
        private int volume;         // cm^3

        /**
         * @param kind
         * @param volume in cm^3
         */
        public GameElement(ElementKind kind, int volume)
        {
            super(kind.getName(), kind.getSymbol());
            this.kind   = kind;
            this.volume = volume;
        }
예제 #23
0
        private IPropertyOperation CreateOperationFromAttribute(
            XElement element,
            ElementKind kind,
            XAttribute attribute,
            char separator         = ',',
            bool throwOnId         = false,
            bool throwOnCollection = false)
        {
            string attributeName = attribute.LocalName();

            if (throwOnId &&
                DefaultComparer.NameEquals(attributeName, AttributeNames.Id))
            {
                Throw(ErrorMessages.CannotUseOperationOnProperty(element, attributeName));
            }

            PropertyDefinition property;

            string name = attribute.LocalName();

            if (name == PropertyDefinition.TagsName)
            {
                property = PropertyDefinition.Tags;
            }
            else
            {
                property = GetProperty(attribute);
            }

            if (throwOnCollection &&
                property.IsCollection)
            {
                Throw(ErrorMessages.CannotUseOperationOnCollectionProperty(element, property.Name));
            }

            switch (kind)
            {
            case ElementKind.Add:
                return(new AddOperation(property, GetValue(attribute), Depth));

            case ElementKind.AddRange:
                return(new AddRangeOperation(property, GetValue(attribute), separator, Depth));

            case ElementKind.Remove:
                return(new RemoveOperation(property, GetValue(attribute), Depth));

            case ElementKind.RemoveRange:
                return(new RemoveRangeOperation(property, GetValue(attribute), separator, Depth));

            default:
            {
                Debug.Assert(kind == ElementKind.Set || kind == ElementKind.New, kind.ToString());

                if (property.IsCollection)
                {
                    return(new AddOperation(property, GetValue(attribute), Depth));
                }
                else
                {
                    return(new SetOperation(property, GetValue(attribute), Depth));
                }
            }
            }
        }
예제 #24
0
 public Shape(ElementKind kind, IReadOnlyList <int> dimensions)
 {
     Kind       = kind;
     Dimensions = dimensions ?? throw new ArgumentNullException(nameof(dimensions));
 }