Ejemplo n.º 1
0
        private void CheckInterfacePeoperty(ITypeInfo type, DefaultResolvedProperty property)
        {
            if (!type.InstanceProperties.ContainsKey(property.Name))
            {
                foreach (IType baseClass in type.Type.GetAllBaseTypes())
                {
                    if (baseClass.Kind == TypeKind.Class)
                    {
                        BridgeType baseBridgeType = BridgeTypes.Get(baseClass);
                        ITypeInfo  baseTypeInfo   = baseBridgeType.TypeInfo;
                        if (baseTypeInfo != null)
                        {
                            if (baseTypeInfo.InstanceProperties.ContainsKey(property.Name))
                            {
                                var instanceConfig = baseTypeInfo.InstanceConfig;
                                int fieldIndex     = instanceConfig.Fields.FindIndex(i => i.Name == property.Name);
                                if (fieldIndex != -1)
                                {
                                    if (!instanceConfig.Properties.Exists(i => i.Name == property.Name))
                                    {
                                        TypeConfigItem item = instanceConfig.Fields[fieldIndex];
                                        instanceConfig.Properties.Add(item);
                                        instanceConfig.Fields.RemoveAt(fieldIndex);

                                        TypeDefinition     typeDefinition     = baseBridgeType.TypeDefinition;
                                        PropertyDefinition propertyDefinition = typeDefinition.Properties.First(i => i.Name == property.Name);
                                        Helpers.SetCacheOfAutoPropertyOfDefinition(propertyDefinition);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private bool SkipFromReflection(ITypeDefinition typeDef, BridgeType bridgeType)
        {
            var isObjectLiteral = this.Emitter.Validator.IsObjectLiteral(typeDef);
            var isPlainMode     = isObjectLiteral && this.Emitter.Validator.GetObjectCreateMode(bridgeType.TypeDefinition) == 0;

            if (isPlainMode)
            {
                return(true);
            }

            var skip = typeDef.Attributes.Any(a =>
                                              a.AttributeType.FullName == "Bridge.GlobalMethodsAttribute" ||
                                              a.AttributeType.FullName == "Bridge.NonScriptableAttribute" ||
                                              a.AttributeType.FullName == "Bridge.MixinAttribute");

            if (!skip && typeDef.FullName != "System.Object")
            {
                var name = BridgeTypes.ToJsName(typeDef, this.Emitter);

                if (name == "Object" || name == "System.Object" || name == "Function")
                {
                    return(true);
                }
            }

            return(skip);
        }
Ejemplo n.º 3
0
        public InlineArgumentsBlock(IEmitter emitter, ArgumentsInfo argsInfo, string inline, IMethod method = null, ResolveResult targetResolveResult = null)
            : base(emitter, argsInfo.Expression)
        {
            this.Emitter       = emitter;
            this.ArgumentsInfo = argsInfo;
            this.InlineCode    = inline;

            argsInfo.AddExtensionParam();
            this.Method = method;
            this.TargetResolveResult = targetResolveResult;

            if (argsInfo.Expression != null)
            {
                var rr = emitter.Resolver.ResolveNode(argsInfo.Expression, emitter) as MemberResolveResult;

                if (rr != null)
                {
                    BridgeType bridgeType = emitter.BridgeTypes.Get(rr.Member.DeclaringType, true);

                    if (bridgeType != null)
                    {
                        bool isCustomName;
                        BridgeTypes.AddModule(null, bridgeType, out isCustomName);
                    }
                }
            }
        }
Ejemplo n.º 4
0
    void GenBridge(HexCell cell, Direction dir, Vector3 v1, Vector3 v2, Vector3 ie1, Vector3 ie2)
    {
        if (cell.GetNeigbors(dir) == null)
        {
            return;
        }

        Vector3    bridge     = HexMetrics.GetBridge(cell, dir);
        BridgeType bridgeType = GetBridgeType(cell, dir);

        //生成两个六边形间的连接
        //只有slope类型的连接会生成梯度上升
        if (bridgeType == BridgeType.Slope)
        {
            GenSlopBridge(bridge, v1, v2);
        }
        else
        {
            GenFlatBridge(bridge, v1, v2);
        }
        //生成三个六边形的间的三角形
        if (dir != Direction.SE && cell.GetNeigbors(dir.Next()) != null)
        {
            Vector3 begin = v2;
            Vector3 left  = begin + HexMetrics.GetBridge(cell, dir);
            Vector3 right = begin + HexMetrics.GetBridge(cell, dir.Next());

            HexCell leftCell  = cell.GetNeigbors(dir);
            HexCell rightCell = cell.GetNeigbors(dir.Next());

            int beginLevel = cell.Elevation;
            int leftLevel  = leftCell.Elevation;
            int rightLevel = rightCell.Elevation;

            //这里需要将三个点按高度排序,传参又要符合特定顺序
            if (beginLevel < leftLevel)
            {
                if (beginLevel < rightLevel)
                {
                    GenCornerTriangle(begin, cell, left, leftCell, right, rightCell);
                }
                else
                {
                    GenCornerTriangle(right, rightCell, begin, cell, left, leftCell);
                }
            }
            else
            {
                if (leftLevel < rightLevel)
                {
                    GenCornerTriangle(left, leftCell, right, rightCell, begin, cell);
                }
                else
                {
                    GenCornerTriangle(right, rightCell, begin, cell, left, leftCell);
                }
            }
        }
    }
Ejemplo n.º 5
0
        protected virtual void AddNestedTypes(IEnumerable <TypeDefinition> types)
        {
            bool skip_key;

            foreach (TypeDefinition type in types)
            {
                if (type.FullName.Contains("<"))
                {
                    continue;
                }

                this.Validator.CheckType(type, this);

                string key = BridgeTypes.GetTypeDefinitionKey(type);

                BridgeType duplicateBridgeType = null;

                skip_key = false;
                if (this.BridgeTypes.TryGetValue(key, out duplicateBridgeType))
                {
                    var duplicate = duplicateBridgeType.TypeDefinition;

                    var message = string.Format(
                        Constants.Messages.Exceptions.DUPLICATE_BRIDGE_TYPE,
                        type.Module.Assembly.FullName,
                        type.FullName,
                        duplicate.Module.Assembly.FullName,
                        duplicate.FullName);

                    if (!this.AssemblyInfo.IgnoreDuplicateTypes)
                    {
                        this.Log.Error(message);
                        throw new System.InvalidOperationException(message);
                    }
                    else
                    {
                        this.Log.Warn(message);
                    }
                    skip_key = true;
                }

                if (!skip_key)
                {
                    this.TypeDefinitions.Add(key, type);

                    this.BridgeTypes.Add(key, new BridgeType(key)
                    {
                        TypeDefinition = type
                    });

                    if (type.HasNestedTypes)
                    {
                        Translator.InheritAttributes(type);
                        this.AddNestedTypes(type.NestedTypes);
                    }
                }
            }
        }
    public void PlaceBridgeEdge(BridgeType bridgeType, Direction edgeSide)
    {
        BridgeEdge bridgeEdge = (BridgeEdge)InstantiateTileAttributeGO <BridgeEdge>();

        bridgeEdge.WithBridgeEdgeSide(edgeSide);
        bridgeEdge.WithBridgeType(bridgeType);
        bridgeEdge.SetSprite();
        bridgeEdge.SetTile(Tile);

        Tile.AddBridgeEdge(bridgeEdge);
    }
Ejemplo n.º 7
0
        public override void OnAttach(ActorInstantiationDetails details)
        {
            base.OnAttach(details);

            bridgeWidth = details.Params[0];
            bridgeType  = (BridgeType)details.Params[1];
            if (bridgeType > BridgeType.Lab)
            {
                bridgeType = BridgeType.Rope;
            }

            int toughness = details.Params[2];

            heightFactor = MathF.Sqrt((16 - toughness) * bridgeWidth) * 4f;

            // Request metadata here to allow async loading
            RequestMetadata("Bridge/" + bridgeType.ToString("G"));

            Vector3 pos = Transform.Pos;

            originalY = pos.Y - 6;

            bridgePieces = new List <Piece>();

            int[] widthList = PieceWidths[(int)bridgeType];

            int widthCovered = widthList[0] / 2;

            for (int i = 0; (widthCovered <= bridgeWidth * 16 + 6) || (i * 16 < bridgeWidth); i++)
            {
                Piece piece = new Piece();
                piece.OnAttach(new ActorInstantiationDetails {
                    Api    = api,
                    Pos    = new Vector3(pos.X + widthCovered - 16, pos.Y - 20, LevelHandler.MainPlaneZ + 10),
                    Params = new[] { (ushort)bridgeType, (ushort)i }
                });
                api.AddActor(piece);

                bridgePieces.Add(piece);

                widthCovered += (widthList[i % widthList.Length] + widthList[(i + 1) % widthList.Length]) / 2;
            }

            collisionFlags = CollisionFlags.CollideWithOtherActors /*| CollisionFlags.IsSolidObject*/;

            OnUpdateHitbox();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="id">序号</param>
        /// <param name="nm">桥名</param>
        /// <param name="brt">结构类型</param>
        /// <param name="col">排</param>
        /// <param name="lay">层</param>
        /// <param name="pc">块</param>
        /// <param name="isE">是否加强</param>
        /// <param name="isT">是否第三弦杆</param>
        /// <param name="ss">纵坡</param>
        public Bridge(int id, string nm, BridgeType brt, int col, int lay, int pc, bool isE, bool isT, double ss, double bgs, double eds)
        {
            ID        = id;
            Name      = nm;
            Type      = brt;
            Columns   = col;
            Layers    = lay;
            Pieces    = pc;
            IsEnhence = isE;
            IsTriple  = isT;
            Slop      = ss;
            MatTab    = GetMatTab();
            NumTab    = GetTab("NumberTable.csv");

            BeginStation = bgs;
            EndStation   = eds;
        }
Ejemplo n.º 9
0
    void InstantiateBridge(BridgeType type, Vector3 tallestWallPosition, float speed)
    {
        Debug.Log("Creating bridge type: " + type + "| on position: " + tallestWallPosition);

        switch (type)
        {
        case BridgeType.MOVING:
            GameObject mBridge = Instantiate(movingBridgePrefab, new Vector3(movingBridgePrefab.transform.position.x, tallestWallPosition.y, movingBridgePrefab.transform.position.z)
                                             + new Vector3(0.0f, bridgeGap, 0.0f), transform.rotation) as GameObject;
            mBridge.GetComponent <MovingBridge>().speedClosing = speed;
            break;

        case BridgeType.ROTATING:
            GameObject rBridge = Instantiate(rotatingBridgePrefab, new Vector3(rotatingBridgePrefab.transform.position.x, tallestWallPosition.y, rotatingBridgePrefab.transform.position.z)
                                             + new Vector3(0.0f, bridgeGap, 0.0f), transform.rotation) as GameObject;
            rBridge.GetComponent <RotatingBridge>().speedClosing = speed;
            break;
        }
    }
Ejemplo n.º 10
0
        protected override async Task OnActivatedAsync(ActorActivationDetails details)
        {
            bridgeWidth = details.Params[0];
            bridgeType  = (BridgeType)details.Params[1];
            if (bridgeType > BridgeType.Lab)
            {
                bridgeType = BridgeType.Rope;
            }

            int toughness = details.Params[2];

            heightFactor = MathF.Sqrt((16 - toughness) * bridgeWidth) * 4f;

            // Request metadata here to allow async loading
            await RequestMetadataAsync("Bridge/" + bridgeType.ToString("G"));

            Vector3 pos = Transform.Pos;

            originalY = pos.Y - 6;

            bridgePieces = new List <Piece>();

            int[] widthList = PieceWidths[(int)bridgeType];

            int widthCovered = widthList[0] / 2;

            for (int i = 0; (widthCovered <= bridgeWidth * 16 + 6) || (i * 16 < bridgeWidth); i++)
            {
                Piece piece = new Piece();
                piece.OnActivated(new ActorActivationDetails {
                    Api    = api,
                    Pos    = new Vector3(pos.X + widthCovered - 16, pos.Y - 20, LevelHandler.MainPlaneZ + 10),
                    Params = new[] { (ushort)bridgeType, (ushort)i }
                });
                api.AddActor(piece);

                bridgePieces.Add(piece);

                widthCovered += (widthList[i % widthList.Length] + widthList[(i + 1) % widthList.Length]) / 2;
            }

            collisionFlags = CollisionFlags.CollideWithOtherActors | CollisionFlags.SkipPerPixelCollisions;
        }
    public void PlaceBridgePiece(BridgeType bridgeType, BridgePieceDirection bridgePieceDirection)
    {
        BridgePiece bridgePiece = (BridgePiece)InstantiateTileAttributeGO <BridgePiece>();

        bridgePiece.WithBridgeType(bridgeType);
        bridgePiece.WithBridgePieceDirection(bridgePieceDirection);
        bridgePiece.SetSprite();

        Tile.SetWalkable(true);
        Tile.TryMakeMarkable(false);
        Tile.AddAttribute(bridgePiece);

        TileWater tileWater = Tile.TryGetTileWater();

        if (tileWater)
        {
            tileWater.SetWalkabilityForBridge(bridgePieceDirection);
        }
    }
Ejemplo n.º 12
0
        public async Task <IBridge> CreateBridge(BridgeType bridgeType)
        {
            switch (bridgeType)
            {
            case BridgeType.NoMedia:
                return(await _ariClient.CreateBridgeAsync((new MixingBridgeType()).Type, new BridgeNameGenerator().GetRandomBridgeName()));

            case BridgeType.Holding:
                return(await _ariClient.CreateBridgeAsync((new HoldingBridgeType()).Type, new BridgeNameGenerator().GetRandomBridgeName()));

            case BridgeType.NoDTMF:
                return(await _ariClient.CreateBridgeAsync((new ProxyMediaBridgeType()).Type, new BridgeNameGenerator().GetRandomBridgeName()));

            case BridgeType.WithDTMF:
                return(await _ariClient.CreateBridgeAsync($"{(new DtmfBridgeType()).Type},{(new MixingBridgeType()).Type}", new BridgeNameGenerator().GetRandomBridgeName()));

            default:
                return(await _ariClient.CreateBridgeAsync((new DtmfBridgeType()).Type, new BridgeNameGenerator().GetRandomBridgeName()));
            }
        }
Ejemplo n.º 13
0
    protected AudioWall CreateAudioWall(BridgeType type, int x, int y)
    {
        GameObject obj = null;

        switch(type)
        {
        case BridgeType.BLUE:
            obj = gameManager.blueWall;
            break;

        case BridgeType.RED:
            obj = gameManager.redWall;
            break;

        case BridgeType.ORANGE:
            obj = gameManager.orangeWall;
            break;

        case BridgeType.PURPLE:
            obj = gameManager.purpleWall;
            break;

        case BridgeType.GREEN:
            obj = gameManager.greenWall;
            break;

        case BridgeType.YELLOW:
            obj = gameManager.yellowWall;
            break;
        }

        int posX = (int)gameObject.transform.position.x + (x * scale);
        int posY = (int)gameObject.transform.position.y + (y * scale);

        GameObject wallObj = (GameObject)Instantiate(obj, new Vector3(posX, posY, gameObject.transform.position.z), Quaternion.identity);
        wallObj.transform.parent = gameObject.transform;
        wallObj.transform.Rotate(new Vector3(0, 180, 0));
        wallObj.transform.localScale = new Vector3(scale, scale, scale);

        return wallObj.GetComponent<AudioWall>();
    }
Ejemplo n.º 14
0
            protected override async Task OnActivatedAsync(ActorActivationDetails details)
            {
                BridgeType type = (BridgeType)details.Params[0];

                canBeFrozen = false;

                await RequestMetadataAsync("Bridge/" + type.ToString("G"));

                SetAnimation("Piece");

                int variations = currentAnimation.FrameCount;

                if (variations > 0)
                {
                    ushort idx = details.Params[1];
                    renderer.AnimFirstFrame = idx % variations;
                }

                collisionFlags = CollisionFlags.CollideWithOtherActors | CollisionFlags.IsSolidObject | CollisionFlags.SkipPerPixelCollisions;

                IsOneWay = true;
            }
Ejemplo n.º 15
0
            public override void OnAttach(ActorInstantiationDetails details)
            {
                base.OnAttach(details);

                BridgeType type = (BridgeType)details.Params[0];

                canBeFrozen = false;

                RequestMetadata("Bridge/" + type.ToString("G"));
                SetAnimation("Piece");

                int variations = currentAnimation.FrameCount;

                if (variations > 0)
                {
                    ushort idx = details.Params[1];
                    renderer.AnimFirstFrame = idx % variations;
                }

                collisionFlags = CollisionFlags.CollideWithOtherActors | CollisionFlags.IsSolidObject | CollisionFlags.SkipPerPixelCollisions;

                IsOneWay = true;
            }
Ejemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        //If bridge is on, leave the collider on
        //If it's off, turn the collider off,
        //If it's malfuctioning, then repeatedly turn it on and off for the user defined ammount of time.
        privateBridgeType = bridgeType;

        if (bridgeType == BridgeType.On)
        {
            BridgeOn();
        }
        else if (bridgeType == BridgeType.Off)
        {
            BridgeOff();
        }
        else if (bridgeType == BridgeType.Malfunctioning)
        {
            BridgeMalfuctioning();
        }
        else
        {
            Debug.Log("Unexpected Error: Bridge Type doesn't seem to have been set properly");
        }
    }
Ejemplo n.º 17
0
    // Use this for initialization
    void Start()
    {
        //If bridge is on, leave the collider on
        //If it's off, turn the collider off,
        //If it's malfuctioning, then repeatedly turn it on and off for the user defined ammount of time.
        privateBridgeType = bridgeType;

        if (bridgeType == BridgeType.On)
        {
            BridgeOn();
        }
        else if (bridgeType == BridgeType.Off)
        {
            BridgeOff();
        }
        else if (bridgeType == BridgeType.Malfunctioning)
        {
            BridgeMalfuctioning();
        }
        else
        {
            Debug.Log("Unexpected Error: Bridge Type doesn't seem to have been set properly");
        }
    }
Ejemplo n.º 18
0
    //rightCell最高 Low left Right呈现顺时针方向
    void GenCornerTriangle_SCCR(Vector3 low, HexCell lowCell, Vector3 left, HexCell leftCell, Vector3 right, HexCell rightCell)
    {
        BridgeType oppsite = HexMetrics.GetBridgeType(rightCell.Elevation, leftCell.Elevation);

        Vector3 disturb_low   = HexMetrics.DisturbXZ(low);
        Vector3 disturb_left  = HexMetrics.DisturbXZ(left);
        Vector3 disturb_right = HexMetrics.DisturbXZ(right);

        float   t        = (disturb_left - disturb_low).y / (disturb_right - disturb_low).y;
        Vector3 junction = Vector3.Lerp(disturb_low, disturb_right, t);

        if (oppsite == BridgeType.Slope)
        {
            AddTriangleUndisturbed(disturb_low, disturb_left, junction);

            Vector3 v1 = left;
            for (int i = 1; i <= HexMetrics.StepAmount; i++)
            {
                Vector3 v2 = HexMetrics.StepLerp(left, right, i);
                AddTriangleUndisturbed(v1.DisturbXZ(), v2.DisturbXZ(), junction);
                v1 = v2;
            }
        }
        else
        {
            AddTriangleUndisturbed(disturb_left, disturb_right, junction);

            Vector3 v1 = low;
            for (int i = 1; i <= HexMetrics.StepAmount; i++)
            {
                Vector3 v2 = HexMetrics.StepLerp(low, left, i);
                AddTriangleUndisturbed(v1.DisturbXZ(), v2.DisturbXZ(), junction);
                v1 = v2;
            }
        }
    }
Ejemplo n.º 19
0
    void GenCornerTriangle(Vector3 low, HexCell lowCell, Vector3 left, HexCell leftCell, Vector3 right, HexCell rightCell)
    {
        BridgeType ToLeft   = HexMetrics.GetBridgeType(lowCell.Elevation, leftCell.Elevation);
        BridgeType ToRight  = HexMetrics.GetBridgeType(lowCell.Elevation, rightCell.Elevation);
        BridgeType Opposite = HexMetrics.GetBridgeType(leftCell.Elevation, rightCell.Elevation);

        //0-Flate,1-Slope,2-Cliff
        int[] type = new int[3];
        type[(int)ToLeft]++;
        type[(int)ToRight]++;
        type[(int)Opposite]++;

        if (type[1] == 2 && type[0] == 1)
        {
            GenCornerTriangle_SFS(low, lowCell, left, leftCell, right, rightCell);
        }
        else if (type[1] == 2 && type[2] == 1)
        {
            GenCornerTriangle_SSC(low, lowCell, left, leftCell, right, rightCell);
        }
        else if (type[2] == 2 && type[1] == 1)
        {
            if (leftCell.Elevation > rightCell.Elevation)
            {
                GenCornerTriangle_SCCL(low, lowCell, left, leftCell, right, rightCell);
            }
            else
            {
                GenCornerTriangle_SCCR(low, lowCell, left, leftCell, right, rightCell);
            }
        }
        else
        {
            GenCornerTriangle_Flat(low, lowCell, left, leftCell, right, rightCell);
        }
    }
Ejemplo n.º 20
0
 public UBSBridgeAttribute(BridgeType moduleType)
 {
     this.m_bridgeType = moduleType;
 }
Ejemplo n.º 21
0
    protected EmptyBridge CreateBridge(BridgeType type, int x, int y, int tileX, int tileY)
    {
        GameObject obj = null;

        switch(type)
        {
        case BridgeType.BLUE:
            obj = gameManager.blueBridge;
            break;

        case BridgeType.RED:
            obj = gameManager.redBridge;
            break;

        case BridgeType.ORANGE:
            obj = gameManager.orangeBridge;
            break;

        case BridgeType.PURPLE:
            obj = gameManager.purpleBridge;
            break;

        case BridgeType.GREEN:
            obj = gameManager.greenBridge;
            break;

        case BridgeType.YELLOW:
            obj = gameManager.yellowBridge;
            break;
        }

        GameObject bridgeObj = (GameObject)Instantiate(gameManager.bridgeBuilder, new Vector3(transform.position.x + (x * scale), transform.position.y + (y * scale), -2), Quaternion.identity);
        bridgeObj.transform.parent = gameObject.transform;
        bridgeObj.transform.Rotate(new Vector3(270, 0, 0));

        bridgeObj.GetComponent<EmptyBridge>().scale = scale;
        bridgeObj.GetComponent<EmptyBridge>().nbBlocX = tileX;
        bridgeObj.GetComponent<EmptyBridge>().nbBlocY = tileY;
        bridgeObj.GetComponent<EmptyBridge>().bridgePart = obj;

        return bridgeObj.GetComponent<EmptyBridge>();
    }