Exemplo n.º 1
0
        public override void Enter()
        {
            _targetSystem    = InputSystem.Game.GetSystem <TargetSystem>();
            _targetAttribute = InputSystem.ActiveCard.Card.GetAttribute <ManualTarget>();

            _targets = new List <CardView>();
            _targetAttribute.Selected = new List <Card>();

            var candidates = _targetSystem.GetTargetCandidates(InputSystem.ActiveCard.Card, _targetAttribute.Allowed);

            _candidateViews = InputSystem.GameView.FindCardViews(candidates);

            InputSystem.ActiveCard.Highlight(_targetAttribute.RequiredAmount == 0 ? Colors.HasTargets : Colors.NeedsTargets);
            _candidateViews.Highlight(Colors.IsTargetCandidate);

            if (_targetAttribute.Allowed.Zones.HasZone(Zones.Deck | Zones.Discard | Zones.Hand))
            {
                // NOTE: We only expect one of the above zones to be targetable at once, bad assumption?
                var player        = _candidateViews.Select(c => c.Card.Owner).Distinct().Single();
                var zoneToPreview = _candidateViews.Select(c => c.Card.Zone).Distinct().Single();

                if (player.Index != MatchData.LOCAL_PLAYER_INDEX || zoneToPreview != Zones.Hand)
                {
                    var zoneView = InputSystem.GameView.FindZoneView(player, zoneToPreview);
                    zoneView.GetPreviewSequence(sortOrder: PreviewSortOrder.ByType);
                    _zoneInPreview = zoneView;
                }
            }
        }
Exemplo n.º 2
0
    void Start()
    {
        playing        = false;
        index          = 0;
        frame          = 0;
        updatePerFrame = 10;
        try {
            system = new TargetSystem();
        } catch (System.Exception e) {
            Debug.Log(e.Message);
        }

        prefab_container = new GameObject("Prefabs");
        prefab_container.SetActive(false);
        // prefab_container.GetComponent<MeshRenderer>().enabled = false;
        prefabs     = new Dictionary <string, GameObject>();
        particles   = new Dictionary <ParticleID, GameObject>();
        not_updated = new List <ParticleID>();

        stepViewer.GetComponent <Text>().text = index.ToString();
        foreach (Particle particle in system[index])
        {
            Vector3 position = Real2Vector(particle.coordinate);
            particles.Add(particle.pid, CreateParticle(position, particle.radius, particle.species));
        }
    }
        public static void serialize(TargetSystem value, XSteam steam)
        {
            // null
            boolBuffer.serialize(value == null, steam);
            if (value == null)
            {
                return;
            }

            // systemType

            intBuffer.serialize(value.systemType, steam);



            // param1

            intBuffer.serialize(value.param1, steam);



            // param2

            intBuffer.serialize(value.param2, steam);



            // param3

            intBuffer.serialize(value.param3, steam);
        }
Exemplo n.º 4
0
        private string MapColumnType(TargetSystem targetSystem, Column column)
        {
            ColumnType columnType = column.ColumnType;
            Target target = null;
            string enumTypeName = null;

            while (target == null && columnType != null && enumTypeName == null)
            {
                enumTypeName = columnType.EnumTypeName;
                target = columnType.Targets[targetSystem.Name];
                if (target == null)
                {
                    columnType = columnType.BaseType;
                }
            }

            string typeString;
            if (enumTypeName != null)
            {
                typeString = enumTypeName;
            }
            else
            {
                if (target == null)
                {
                    throw new DataSchemaException("Target type not found for column " + column.Name);
                }
                typeString = target.DataType;
            }
            return MacroResolver.Resolve(column, typeString);
        }
Exemplo n.º 5
0
        public string GetColumnTypeString(TargetSystem targetSystem, Column column)
        {
            string result = MapColumnType(targetSystem, column);
            if (!column.CanBeNull)
            {
                result += " not null";
            }

            return result;
        }
Exemplo n.º 6
0
        public override void Exit()
        {
            _targets         = null;
            _candidateViews  = null;
            _targetAttribute = null;
            _targetSystem    = null;

            if (_zoneInPreview != null)
            {
                _zoneInPreview.GetZoneLayoutSequence();
                _zoneInPreview = null;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the effective target of this column given the specified targetSystem.
        /// </summary>
        /// <param name="targetSystem"></param>
        /// <returns></returns>
        public Target GetEffectiveTarget(TargetSystem targetSystem)
        {
            ColumnType columnType = this.ColumnType;
            Target target = null;

            while (target == null && columnType != null)
            {
                target = columnType.Targets[targetSystem.Name];
                if (target == null)
                {
                    columnType = columnType.BaseType;
                }
            }

            return target;
        }
        public static TargetSystem deserialize(byte[] buffer, ref uint offset)
        {
            // null
            bool _null = boolBuffer.deserialize(buffer, ref offset);

            if (_null)
            {
                return(null);
            }

            // systemType

            int _systemType = intBuffer.deserialize(buffer, ref offset);



            // param1

            int _param1 = intBuffer.deserialize(buffer, ref offset);



            // param2

            int _param2 = intBuffer.deserialize(buffer, ref offset);



            // param3

            int _param3 = intBuffer.deserialize(buffer, ref offset);

            TargetSystem _TargetSystem = new TargetSystem();

            _TargetSystem.systemType = _systemType;

            _TargetSystem.param1 = _param1;

            _TargetSystem.param2 = _param2;

            _TargetSystem.param3 = _param3;
            return(_TargetSystem);
        }
Exemplo n.º 9
0
        public void NoMap_NoTile()
        {
            var entity = SetMouseInput(float2.zero);

            if (TargetSystem.HasSingleton <MapSettings>() == false)
            {
                TargetSystem.SetSingleton(new MapSettings()
                {
                    MapEdgeSize = 5
                });
            }

            Update();

            var tileUnderMouse = _entityManager.GetComponentData <TileUnderMouse>(entity);

            AreEqual(new Entity(), tileUnderMouse.Tile);
            False(_entityManager.Exists(tileUnderMouse.Tile));
        }
Exemplo n.º 10
0
        private void SetMap(int edgeSize)
        {
            var mapSize = edgeSize * edgeSize;
            var tile    = _entityManager.CreateEntity(typeof(GroundType));

            _entityManager.SetComponentData(tile, new GroundType(BlobsMemory.Instance.ReferencesOf <GroundTypeBlob>()[0]));
            var tiles = new BlitableArray <Entity>(mapSize, Unity.Collections.Allocator.Temp);

            for (int i = 0; i < mapSize; i++)
            {
                tiles[i] = tile;
            }

            _entityManager.CreateEntity(typeof(MapSettings));
            TargetSystem.SetSingleton(new MapSettings()
            {
                Tiles = tiles, MapEdgeSize = edgeSize
            });
        }
Exemplo n.º 11
0
        public void EndTurn()
        {
            Console.WriteLine($"{GetType().Name} - ExecuteOption - End");
            TurnSystem.End();

            while (TurnSystem.Active is Enemy enemy && !enemy.IsDead && enemy.EnemyType != EnemyType.Enviroment)
            {
                enemyAISysytem.ExecuteEnemyTurn(this, TurnSystem.Active);
            }

            TargetSystem.Cleanup();
            if (Enemies.TrueForAll(enemy => enemy.IsDead))
            {
                BattleStateStore.State = BattleState.ENDED;
                Enemies.ForEach(enemy => enemy.OnKilled -= Enemy_OnKilled);
            }
            ActionMenu.Process();
            HealthCounter.Show();
        }
Exemplo n.º 12
0
        public TargetSystem Add(TargetSystem parent)
        {
            // ignore parent as at the moment there is no requirment for hierarchy here
            TargetSystem detail = new TargetSystem();
            detail.Default(Context.UserName);
            detail.Approve(Context.UserName);

            if (Context.TargetSystems.Local.Any())
            {
                detail.TargetSystemID = Context.TargetSystems.Local.Max(x => x.TargetSystemID) + 1;
            }
            else
            {
                detail.TargetSystemID = 1;
            }

            Context.TargetSystems.Add(detail);

            detail.Name = "Target System Name";

            return detail;
        }
Exemplo n.º 13
0
 public void Transform(DataSchema dataSchema, string name, TargetSystem targetSystem, System.Xml.Linq.XElement transformationElement, IScriptDocumentGeneratorFactory docGenFactory)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 14
0
 private void SetTargetSystemNode(TreeNode node, TargetSystem targetSystem)
 {
     node.Text = targetSystem.Name;
     node.ImageKey = ImageKeyTargetSystem;
     node.SelectedImageKey = node.ImageKey;
     node.Tag = targetSystem;
 }
Exemplo n.º 15
0
 public Arbitrate(GameObject agent)
     : base(agent, TaskType.Arbitrate)
 {
     stats = agent.GetComponent<Stats>();
     targetSystem = new TargetSystem(agent);
 }
Exemplo n.º 16
0
        private void ApplyParsedSchema(Parsing.DataSchema parsedSchema, IVerificationContext context)
        {
            const string PropertyMacroDefault = "(default)";

            // Column types
            foreach (Parsing.DataSchemaColumnType parsedColumnType in parsedSchema.ColumnTypes)
            {
                ColumnType columnType = new ColumnType();

                columnType.Name = parsedColumnType.name;
                columnType.Description = parsedColumnType.description;

                if (parsedColumnType.baseType != null)
                {
                    ColumnType baseType = this.ColumnTypes[parsedColumnType.baseType];
                    if (baseType == null)
                    {
                        context.Add(new VerificationMessage(Verification.Severity.Error,
                            string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.ColumnTypeBaseTypeUnkown, parsedColumnType.name, parsedColumnType.baseType)));
                        continue;
                    }
                    columnType.BaseType = baseType;
                    Debug.Assert(columnType.BaseType != null);
                }

                // Set default values when no base type
                if (columnType.BaseType == null)
                {
                    columnType.CanBeNull = false;
                    columnType.IsDbGenerated = false;
                }

                if (parsedColumnType.canBeNullSpecified)
                {
                    columnType.CanBeNull = parsedColumnType.canBeNull;
                }

                if (parsedColumnType.isDbGeneratedSpecified)
                {
                    columnType.IsDbGenerated = parsedColumnType.isDbGenerated;
                }

                if (parsedColumnType.maxLengthSpecified)
                {
                    columnType.MaxLength = parsedColumnType.maxLength;
                }

                if (parsedColumnType.enumType != null)
                {
                    columnType.EnumTypeName = parsedColumnType.enumType;
                }

                if (parsedColumnType.precisionSpecified)
                {
                    columnType.Precision = parsedColumnType.precision;
                }

                if (parsedColumnType.scaleSpecified)
                {
                    columnType.Scale = parsedColumnType.scale;
                }

                if (parsedColumnType.Target != null)
                {
                    foreach (var parsedTarget in parsedColumnType.Target)
                    {
                        TargetSystem targetSystem = this.TargetSystems[parsedTarget.name];
                        if (targetSystem == null)
                        {
                            targetSystem = new TargetSystem { Name = parsedTarget.name };
                            this.TargetSystems.Add(targetSystem);
                        }

                        Target target = new Target
                        {
                            TargetSystem = targetSystem,
                            DataType = parsedTarget.dataType,
                            DataTypeWhenReferenced = parsedTarget.dataTypeWhenReferenced,
                            DotNetType = parsedTarget.dotNetType,
                            DotNetTypeNullable = parsedTarget.dotNetTypeNullable
                        };
                        if (parsedTarget.ExtendedProperties != null && parsedTarget.ExtendedProperties.Length > 0)
                        {
                            target.ExtendedProperties.Clear();
                            foreach (var property in parsedTarget.ExtendedProperties)
                            {
                                target.ExtendedProperties.Add(property.name, property.Value);
                            }
                        }

                        try
                        {
                            columnType.Targets.Add(target);
                        }
                        catch (ArgumentException)
                        {
                            context.Add(new VerificationMessage(Severity.Error,
                                string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.ColumnTypeTargetDuplicates, target.TargetSystem.Name, columnType.Name)));
                        }
                    }
                }

                columnType.Verify(context);
                if (!this.ColumnTypes.Contains(columnType.Name))
                {
                    this.ColumnTypes.Add(columnType);
                }
                else
                {
                    context.Add(new VerificationMessage(Severity.Error,
                        string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.ColumnTypeDuplicates, columnType.Name)));
                }

            }

            if (parsedSchema.Tables != null)
            {
                // Tables: First pass - references are skipped until second pass.
                foreach (var parsedTable in parsedSchema.Tables)
                {
                    Table table = new Table();
                    table.Name = parsedTable.name;

                    try
                    {
                        this.Tables.Add(table);
                    }
                    catch (ArgumentException)
                    {
                        context.Add(new VerificationTableMessage(Severity.Error, table.Name, Properties.Resources.SchemaTableExists));
                    }

                    table.Description = parsedTable.description;

                    // Columns
                    foreach (var parsedColumn in parsedTable.Columns)
                    {
                        Column column = new Column();
                        column.Name = parsedColumn.name;
                        column.Description = parsedColumn.description;

                        if (parsedColumn.canBeNullSpecified)
                        {
                            column.CanBeNull = parsedColumn.canBeNull;
                        }

                        if (parsedColumn.inPrimaryKeySpecified)
                        {
                            column.InPrimaryKey = parsedColumn.inPrimaryKey;
                        }

                        if (!string.IsNullOrWhiteSpace(parsedColumn.columnType))
                        {
                            ColumnType columnType = this.ColumnTypes[parsedColumn.columnType];
                            if (columnType != null)
                            {
                                column.ColumnType = columnType;
                            }
                            else
                            {
                                context.Add(new VerificationTableMessage(Severity.Error, table.Name, column.Name,
                                    string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.ColumnTypeUnknown, parsedColumn.columnType)));
                            }
                        }

                        table.Columns.Add(column);
                    }

                    // Indices
                    if (parsedTable.Indices != null)
                    {
                        foreach (var parsedIndex in parsedTable.Indices)
                        {
                            Index index = new Index(table);
                            if (!string.IsNullOrWhiteSpace(parsedIndex.name))
                            {
                                index.Name = parsedIndex.name;
                            }
                            if (parsedIndex.uniqueSpecified)
                            {
                                index.IsUnique = parsedIndex.unique;
                            }

                            foreach (var parsedIndexColumn in parsedIndex.Column)
                            {
                                Column column = table.Columns[parsedIndexColumn.name];
                                if (column != null)
                                {
                                    index.Columns.Add(column);
                                }
                                else
                                {
                                    context.Add(new VerificationTableMessage(Severity.Error, table.Name,
                                        string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.IndexColumnUnknown, parsedIndexColumn.name)));
                                }
                            }
                            table.Indices.Add(index);
                        }
                    }
                }

                // Tables: Second pass - resolve references
                foreach (var parsedTable in parsedSchema.Tables)
                {
                    Table table = this.Tables[parsedTable.name];

                    foreach (var parsedColumn in parsedTable.Columns)
                    {
                        if (!string.IsNullOrWhiteSpace(parsedColumn.references))
                        {
                            Column column = table.Columns[parsedColumn.name];
                            string toTableName;
                            string toColumnName;
                            SplitReference(parsedColumn.references, out toTableName, out toColumnName);

                            Table toTable = this.Tables[toTableName];
                            if (toTable == null)
                            {
                                context.Add(new VerificationTableMessage(Severity.Error, table.Name, column.Name,
                                    string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.ReferencedTableNotExists,
                                        parsedColumn.references)));
                                continue;
                            }
                            Column toColumn = toTable.Columns[toColumnName];
                            if (toColumn == null)
                            {
                                context.Add(new VerificationTableMessage(Severity.Error, table.Name, column.Name,
                                    string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.ReferencedColumnNotExists, parsedColumn.references)));
                                continue;
                            }
                            ForeignKey foreignKey = new ForeignKey();
                            foreignKey.FromTable = table;
                            foreignKey.ToTable = toTable;
                            foreignKey.Columns.Add(new ForeignKey.ColumnPair { FromColumn = column, ToColumn = toColumn });
                            if (!string.IsNullOrEmpty(parsedColumn.referenceName))
                            {
                                foreignKey.Name = parsedColumn.referenceName;
                            }
                            table.ForeignKeys.Add(foreignKey);

                            column.ColumnType = this.GetReferenceToColumnType(toColumn.ColumnType);
                            column.CanBeNull = false;
                            if (parsedColumn.canBeNullSpecified)
                                column.CanBeNull = parsedColumn.canBeNull;

                            // Association properties
                            foreignKey.AssociationProperty = new AssociationProperty();
                            if (parsedColumn.AssociationCode != null)
                            {
                                if (parsedColumn.AssociationCode.Child != null)
                                {
                                    ParsedAssociationEndPointToNative(parsedColumn.AssociationCode.Child, foreignKey.AssociationProperty.Child);
                                }
                                else
                                {
                                    foreignKey.AssociationProperty.Child = null;
                                }
                                ParsedAssociationEndPointToNative(parsedColumn.AssociationCode.Parent, foreignKey.AssociationProperty.Parent);
                            }
                            else
                            {
                                // Check the quick-attributes for association properties
                                if (string.IsNullOrEmpty(parsedColumn.childProperty))
                                {
                                    foreignKey.AssociationProperty.Child = null;
                                }
                                else
                                {
                                    if (string.Compare(parsedColumn.childProperty, PropertyMacroDefault, StringComparison.Ordinal) != 0)
                                    {
                                        foreignKey.AssociationProperty.Child.Name = parsedColumn.childProperty;
                                    }
                                    else
                                    {
                                        // Using default
                                        foreignKey.AssociationProperty.Child.Name = null;
                                    }
                                }

                                if (string.IsNullOrEmpty(parsedColumn.parentProperty))
                                {
                                    foreignKey.AssociationProperty.Parent = null;
                                }
                                else
                                {
                                    if (string.Compare(parsedColumn.parentProperty, PropertyMacroDefault, StringComparison.Ordinal) != 0)
                                    {
                                        foreignKey.AssociationProperty.Parent.Name = parsedColumn.parentProperty;
                                    }
                                    else
                                    {
                                        // Using default
                                        foreignKey.AssociationProperty.Parent.Name = null;
                                    }
                                }
                            }
                        }
                    }   // end foreach (var parsedColumn in parsedTable.Columns)

                    // Foreign keys
                    if (parsedTable.ForeignKeys != null)
                    {
                        foreach (var parsedForeignKey in parsedTable.ForeignKeys)
                        {
                            ForeignKey foreignKey = new ForeignKey();
                            foreignKey.Name = parsedForeignKey.name;
                            foreignKey.FromTable = table;

                            Table toTable = this.Tables[parsedForeignKey.toTable];
                            if (toTable == null)
                            {
                                context.Add(new VerificationTableMessage(Severity.Error, table.Name,
                                    string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.ForeignKeyTableNotExists, parsedForeignKey.toTable)));
                                continue;
                            }

                            foreignKey.ToTable = toTable;

                            foreach (var columnPair in parsedForeignKey.ColumnPairs)
                            {
                                Column fromColumn = table.Columns[columnPair.from];
                                if (fromColumn == null)
                                {
                                    context.Add(new VerificationTableMessage(Severity.Error, table.Name,
                                        string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.ForeignKeyFromColumnNotExists, columnPair.from)));
                                    continue;
                                }

                                Column toColumn = toTable.Columns[columnPair.to];
                                if (toColumn == null)
                                {
                                    context.Add(new VerificationTableMessage(Severity.Error, table.Name,
                                        string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.ForeignKeyToColumnNotExists, columnPair.to)));
                                    continue;
                                }

                                foreignKey.Columns.Add(new ForeignKey.ColumnPair { FromColumn = fromColumn, ToColumn = toColumn });
                            }

                            table.ForeignKeys.Add(foreignKey);
                        }
                    }

                    // Table settings
                    if (parsedTable.Settings != null)
                    {
                        foreach (var parsedSetting in parsedTable.Settings)
                        {
                            if (!this.TargetSystems.Contains(parsedSetting.target))
                            {
                                context.Add(new VerificationTableMessage(Severity.Error, table.Name,
                                    string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.TableSettingsTargetNotExists, parsedSetting.target)));
                                continue;
                            }
                            table.Settings.Add(parsedSetting.target, parsedSetting.property, parsedSetting.value);
                        }
                    }

                }
            }
        }
 void Awake()
 {
     SI = this.GetComponent<statInformation>();
     TS = this.GetComponent<TargetSystem>();
 }
Exemplo n.º 18
0
 public string GetColumnTypeString(TargetSystem targetSystem, Column column)
 {
     return MapColumnType(targetSystem, column);
 }