Exemplo n.º 1
0
    private void SetTrailColor(GameController.materialType material)
    {
        // Return if mapping not found in game controller
        if (!gameController.colorMapping.ContainsKey(material))
        {
            Debug.LogWarning("Trail color mapping not found for material " + material);
            return;
        }
        GameController.materialTrail trail = gameController.colorMapping[material];

        // Get gradient values from trail
        Color startColor = trail.startColor;
        Color endColor   = trail.endColor;

        float startAlpha = trail.startAlpha;
        float endAlpha   = trail.endAlpha;

        // Create gradient
        Gradient gradient = new Gradient();

        gradient.SetKeys(
            new GradientColorKey[] { new GradientColorKey(startColor, 0.0f), new GradientColorKey(endColor, 1.0f) },
            new GradientAlphaKey[] { new GradientAlphaKey(startAlpha, 0.0f), new GradientAlphaKey(endAlpha, 1.0f) }
            );

        // Get reference to color over time module (requires stepping through each component)
        ParticleSystem.MainModule main = pSystem.main;
        ParticleSystem.ColorOverLifetimeModule colorModule = pSystem.colorOverLifetime;

        // Assign gradient to module
        colorModule.color = gradient;
    }
Exemplo n.º 2
0
    /// <summary>
    /// Eqiups material and changes color of player trail to match
    /// </summary>
    /// <param name="material">Material to equip</param>
    private void EquipMaterial(GameController.materialType material)
    {
        Debug.Log("Equpping material " + material);

        // Set equipped material
        materials.equippedMaterial = material;

        // Set trail color
        SetTrailColor(material);
    }
Exemplo n.º 3
0
 /// <summary>
 /// Returns material of given type
 /// </summary>
 /// <param name="type">Type of material</param>
 /// <param name="preview">Returns transparent material overlay preview if true</param>
 public Material GetMaterial(GameController.materialType type, bool preview = false)
 {
     if (!preview)
     {
         return(materialMapping[type]);
     }
     else
     {
         return(previewMaterialMapping[type]);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Set tiling parameters on material to work with associated material texture
 /// </summary>
 /// <param name="materialType">Material type</param>
 /// <param name="material">Material</param>
 void SetMaterialTiling(GameController.materialType materialType, Material material)
 {
     // Slip material has regular tiling
     if (materialType.Equals(GameController.materialType.SLIP))
     {
         material.mainTextureScale = transform.localScale;
     }
     // All other materials are in weird grid form (material texture image should be changed so we don't have to do this)
     else
     {
         material.mainTextureScale = transform.localScale / 3;
     }
 }
Exemplo n.º 5
0
    /// <summary>
    /// Changes appearance and behavior of surface to match given material type
    /// </summary>
    /// <param name="materialType">Material type</param>
    void ChangeSurface(GameController.materialType materialType)
    {
        // Set material type
        type = materialType;

        // Set material on renderer
        ChangeMaterial(gameController.GetMaterial(materialType));

        // Set tiling to fit to surface dimensions
        SetMaterialTiling(materialType, GetComponent <Renderer>().material);

        // Set move speeds
        InitializeSurfaceSpeeds(materialType);
    }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes surface with associated move speeds from surfaceSpeeds (called from derived class)
 /// </summary>
 protected void InitializeSurfaceSpeeds(GameController.materialType materialType)
 {
     // Initialize surface speeds
     surfaceSpeeds = GameObject.FindWithTag("GameController").GetComponent <GameController>().speedMapping[materialType];
 }