示例#1
0
    private void setSprite()
    {
        switch (reaction.ToString())
        {
        case "Gravity":
            reacts = "g";
            break;

        case "Positive":
            reacts = "p";
            break;

        case "Negative":
            reacts = "n";
            break;

        case "Flux":
            reacts = "f";
            break;

        default:
            Debug.Log("Invalid ReactType in Properties.cs");
            break;
        }

        switch (production.ToString())
        {
        case "Graviton":
            produces = "g";
            break;

        case "Electron":
            produces = "e";
            break;

        case "Fluxion":
            produces = "f";
            break;

        default:
            Debug.Log("Invalid ProductionType in Properties.cs");
            break;
        }

        for (int i = 0; i < spriteSearcher.Length; i++)
        {
            if (produces + reacts == spriteSearcher[i].Substring(0, 2).ToLower())
            {
                if (isEditor)
                {
                    this.GetComponent <Image> ().sprite = sprites [i];
                }
                else
                {
                    this.GetComponent <SpriteRenderer> ().sprite = sprites [i];
                }
            }
        }
    }