Пример #1
0
    private void Start()
    {
        bodySprites   = SpriteManager.instance.GetModifiedSprites(SpriteManager.ROBOT_SPRITES + Random.Range(0, SpriteManager.NUM_ROBOTS));
        legSprites    = SpriteManager.instance.GetModifiedSprites(SpriteManager.LEG_SPRITES);
        wireSprites   = SpriteManager.instance.GetModifiedSprites(SpriteManager.WIRE_SPRITES);
        partSprites   = SpriteManager.instance.GetModifiedSprites(SpriteManager.PART_SPRITES);
        shinySprites  = SpriteManager.instance.GetModifiedSprites(SpriteManager.SHINY_SPRITES);
        chargeSprites = SpriteManager.instance.GetModifiedSprites(SpriteManager.CHARGE_SPRITES);

        bodyRenderer   = transform.Find("RobotBody").GetComponent <SpriteRenderer>();
        legRenderer    = transform.Find("RobotLegs").GetComponent <SpriteRenderer>();
        wireRenderer   = transform.Find("RobotWires").GetComponent <SpriteRenderer>();
        shinyRenderer  = transform.Find("RobotShiny").GetComponent <SpriteRenderer>();
        chargeRenderer = transform.Find("ChargeFlare").GetComponent <SpriteRenderer>();
        crosshair      = transform.Find("Crosshair").GetComponent <LineRenderer>();


        SpriteManager.InitColorSwapTex(out mainColorSwapTex, out spriteColors, bodySprites[0].texture);
        SpriteManager.InitColorSwapTex(out justRobotSwapTex, out _, bodySprites[0].texture);
        bodyRenderer.material.SetTexture("_SwapTex", justRobotSwapTex);
        legRenderer.material.SetTexture("_SwapTex", justRobotSwapTex);
        wireRenderer.material.SetTexture("_SwapTex", justRobotSwapTex);
        shinyRenderer.material.SetTexture("_SwapTex", justRobotSwapTex);

        //DO SWAP
        SwapColor(SwapIndex.WireA, new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f)));
        SwapColor(SwapIndex.WireB, new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f)));

        float metalHue = Random.Range(0f, 1f);
        float glowHue  = Random.Range(0f, 1f);

        for (SwapIndex i = 0; i < (SwapIndex)256; i++)
        {
            Color refColor = spriteColors[(int)i];
            if (i == SwapIndex.Metal0 ||
                i == SwapIndex.Metal1 ||
                i == SwapIndex.Metal2 ||
                i == SwapIndex.Metal3 ||
                i == SwapIndex.Metal4 ||
                i == SwapIndex.Metal5)
            {
                Color.RGBToHSV(refColor, out float H, out float S, out float V);
                H = metalHue;
                Color newColor = Color.HSVToRGB(H, S, V);
                SwapColor(i, newColor);
            }
            if (i == SwapIndex.Glow0 ||
                i == SwapIndex.Glow1 ||
                i == SwapIndex.Glow2 ||
                i == SwapIndex.Glow3 ||
                i == SwapIndex.Glow4)
            {
                Color.RGBToHSV(refColor, out float H, out float S, out float V);
                H = glowHue;
                Color newColor = Color.HSVToRGB(H, S, V);
                SwapColor(i, newColor);

                if (i == SwapIndex.Glow4)
                {
                    crosshair.startColor          = newColor;
                    chargeRenderer.material.color = newColor;
                }
                if (i == SwapIndex.Glow0)
                {
                    crosshair.endColor = newColor;
                }
            }
        }
        mainColorSwapTex.Apply();
        SetRobotColor(Color.clear, true);

        legFrameTimer  = LegFrameInterval;
        wireFrameTimer = WireFrameInterval;

        myHPBar.UpdateHP(hitpoints);

        //myText.text = "Player " + playerID;

        myText.SetText(playerTag);
    }