private void SetSprite()
    {
        string spritePath = DirectionStart + (DirectionEnd != 0 ? "_" + DirectionEnd : "");

        Sprite[]       Color = SpriteManager.WireSprites[this.Color.ToString()];
        SpriteRenderer SR    = gameObject.GetComponentInChildren <SpriteRenderer>();
        //the red sprite is spliced differently than the rest for some reason :^(
        int spriteIndex = WireDirections.GetSpriteIndex(spritePath);

        if (this.Color == WiringColor.red)
        {
            spriteIndex *= 2;
            if (TRay)
            {
                spriteIndex++;
            }
        }
        else if (TRay)
        {
            spriteIndex += 36;
        }
        SR.sprite = Color[spriteIndex];
        if (SR.sprite == null)
        {
            this.Color = WiringColor.red;
            SetDirection(1);
        }
    }
    public static ElectricalCableTile RetrieveElectricalTile(Connection WireEndA, Connection WireEndB, PowerTypeCategory powerTypeCategory)
    {
        ElectricalCableTile Tile = null;
        int spriteIndex          = WireDirections.GetSpriteIndex(WireEndA, WireEndB);

        switch (powerTypeCategory)
        {
        case PowerTypeCategory.StandardCable:
        {
            Tile = ElectricalManager.Instance.MediumVoltageCables.Tiles[spriteIndex];
            break;
        }

        case PowerTypeCategory.LowVoltageCable:
        {
            Tile = ElectricalManager.Instance.LowVoltageCables.Tiles[spriteIndex];
            break;
        }

        case PowerTypeCategory.HighVoltageCable:
        {
            Tile = ElectricalManager.Instance.HighVoltageCables.Tiles[spriteIndex];
            break;
        }
        }

        return(Tile);
    }
Esempio n. 3
0
    private void SetSprite()
    {
        SpriteRenderer SR = gameObject.GetComponentInChildren <SpriteRenderer>();
        //the red sprite is spliced differently than the rest for some reason :^(
        string Compound;

        if (WireEndA < WireEndB)
        {
            Compound = WireEndA + "_" + WireEndB;
        }
        else
        {
            Compound = WireEndB + "_" + WireEndA;
        }
        int spriteIndex = WireDirections.GetSpriteIndex(Compound);

        if (TRay)
        {
            spriteIndex += 36;
        }

        SR.sprite = CableSprites.Sprites[spriteIndex];
        if (SR.sprite == null)
        {
            Logger.LogError("SetSprite: Couldn't find wire sprite, sprite value didn't return anything!", Category.Electrical);
        }
    }
    public static ElectricalCableTile RetrieveElectricalTile(Connection WireEndA, Connection WireEndB, PowerTypeCategory powerTypeCategory)
    {
        ElectricalCableTile Tile = null;
        string Compound;

        if (WireEndA < WireEndB)
        {
            Compound = WireEndA + "_" + WireEndB;
        }
        else
        {
            Compound = WireEndB + "_" + WireEndA;
        }
        int spriteIndex = WireDirections.GetSpriteIndex(Compound);

        switch (powerTypeCategory)
        {
        case PowerTypeCategory.StandardCable:
            Tile = ElectricalManager.Instance.MediumVoltageCables.Tiles[spriteIndex];
            break;

        case PowerTypeCategory.LowVoltageCable:
            Tile = ElectricalManager.Instance.LowVoltageCables.Tiles[spriteIndex];
            break;

        case PowerTypeCategory.HighVoltageCable:
            Tile = ElectricalManager.Instance.HighVoltageCables.Tiles[spriteIndex];
            break;
        }

        return(Tile);
    }
Esempio n. 5
0
        private void SetSprite()
        {
            SpriteRenderer SR          = gameObject.GetComponentInChildren <SpriteRenderer>();
            int            spriteIndex = WireDirections.GetSpriteIndex(WireEndA, WireEndB, TRay);

            SR.sprite = CableSprites.Sprites[spriteIndex];
            if (SR.sprite == null)
            {
                Logger.LogError("SetSprite: Couldn't find wire sprite, sprite value didn't return anything!", Category.Electrical);
            }
        }
Esempio n. 6
0
    public void AddElectricalNode(Vector3Int position, WireConnect wireConnect)
    {
        var metaData = metaDataLayer.Get(position, true);
        var newdata  = new ElectricalMetaData();

        newdata.Initialise(wireConnect, metaData, position, this);
        metaData.ElectricalData.Add(newdata);

        ElectricalCableTile Tile = null;
        string Compound;

        if (newdata.InData.WireEndA < newdata.InData.WireEndB)
        {
            Compound = newdata.InData.WireEndA + "_" + newdata.InData.WireEndB;
        }
        else
        {
            Compound = newdata.InData.WireEndB + "_" + newdata.InData.WireEndA;
        }
        int spriteIndex = WireDirections.GetSpriteIndex(Compound);

        switch (newdata.InData.Categorytype)
        {
        case PowerTypeCategory.StandardCable:
            Tile = ElectricalManager.Instance.MediumVoltageCables.Tiles[spriteIndex];
            break;

        case PowerTypeCategory.LowVoltageCable:
            Tile = ElectricalManager.Instance.LowVoltageCables.Tiles[spriteIndex];
            break;

        case PowerTypeCategory.HighVoltageCable:
            Tile = ElectricalManager.Instance.HighVoltageCables.Tiles[spriteIndex];
            break;
        }
        newdata.RelatedTile = Tile;
        if (Tile != null)
        {
            if (metaTileMap != null)
            {
                metaTileMap.SetTile(position, Tile);
            }
        }
    }
Esempio n. 7
0
    public void EditorAddElectricalNode(Vector3Int position, WireConnect wireConnect)
    {
        var ElectricalManager    = FindObjectOfType <ElectricalManager>();
        ElectricalCableTile Tile = null;
        string Compound;

        if (wireConnect.InData.WireEndA < wireConnect.InData.WireEndB)
        {
            Compound = wireConnect.InData.WireEndA + "_" + wireConnect.InData.WireEndB;
        }
        else
        {
            Compound = wireConnect.InData.WireEndB + "_" + wireConnect.InData.WireEndA;
        }
        int spriteIndex = WireDirections.GetSpriteIndex(Compound);

        switch (wireConnect.InData.Categorytype)
        {
        case PowerTypeCategory.StandardCable:
            Tile = ElectricalManager.MediumVoltageCables.Tiles[spriteIndex];
            break;

        case PowerTypeCategory.LowVoltageCable:
            Tile = ElectricalManager.LowVoltageCables.Tiles[spriteIndex];
            break;

        case PowerTypeCategory.HighVoltageCable:
            Tile = ElectricalManager.HighVoltageCables.Tiles[spriteIndex];
            break;
        }
        if (Tile != null)
        {
            if (metaTileMap != null)
            {
                metaTileMap.SetTile(position, Tile);
            }
        }
    }
Esempio n. 8
0
    private void SetSprite()
    {
        //WireEndA;
        //WireEndB;

        Sprite[] Color = SpriteManager.WireSprites[CableType.ToString()];
        if (Color == null)
        {
            SpriteManager.Instance.InitWireSprites();
            Color = SpriteManager.WireSprites[CableType.ToString()];
        }
        SpriteRenderer SR = gameObject.GetComponentInChildren <SpriteRenderer>();
        //the red sprite is spliced differently than the rest for some reason :^(
        string Compound;

        if (WireEndA < WireEndB)
        {
            Compound = WireEndA + "_" + WireEndB;
        }
        else
        {
            Compound = WireEndB + "_" + WireEndA;
        }
        //Logger.Log(Compound + "?");
        int spriteIndex = WireDirections.GetSpriteIndex(Compound);

        if (TRay)
        {
            spriteIndex += 36;
        }

        SR.sprite = Color[spriteIndex];
        if (SR.sprite == null)
        {
            Logger.LogError("SetSprite: Couldn't find wire sprite, sprite value didn't return anything!", Category.Electrical);
        }
    }