Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .idea/.idea.Conjuction/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions Assets/DefaultHandMaterial.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: DefaultHandMaterial
m_Shader: {fileID: 4800000, guid: cfa50fc6e259b524ea01ec7dde0f108d, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _FresnelPower: 0.215
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HandAlpha: 1
- _Metallic: 0
- _MinVisibleAlpha: 0.164
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _RimFactor: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _ColorBottom: {r: 1, g: 0.49705708, b: 0, a: 0.38431373}
- _ColorPrimary: {r: 0.75735295, g: 0.75735295, b: 0.75735295, a: 1}
- _ColorTop: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
8 changes: 8 additions & 0 deletions Assets/DefaultHandMaterial.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/DefaultVolumeProfile.asset
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ MonoBehaviour:
highQualityFiltering:
m_OverrideState: 1
m_Value: 0
filter:
m_OverrideState: 1
m_Value: 0
downscale:
m_OverrideState: 1
m_Value: 0
Expand Down
97 changes: 67 additions & 30 deletions Assets/Global/Cauldron/Cauldron.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[Serializable]
public class Potion {
public Vector3 potionColor;
public float glowingIntensity;
public bool isSteaming;
public PotionEffect potionEffect;
}

public class Cauldron : MonoBehaviour
{
[SerializeField] private List<RecipePart> recipe = new();
[SerializeField] private BoxCollider cauldronWater;
[SerializeField] private UnityEvent onIngredientAdded;
[SerializeField] private UnityEvent<Potion> onIngredientAdded;
[SerializeField] private UnityEvent onRecipeComplete;
[SerializeField] private UnityEvent onWrongIngredientAdded;
[SerializeField] private UnityEvent onGoodIngredientAdded;
[SerializeField] private Fireplace fireplace;
[SerializeField] private ParticleSystem potionEffects;
[SerializeField] private Potion potion;
private List<RecipePart> startRecipe = new();
private bool boiled = false;
[SerializeField] private AudioClip[] waterClips;
Expand All @@ -38,29 +48,36 @@ private void Start()

private void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent(out Flask flask)) {
flask.CollectPotion(potion);
return;
}

if (!other.TryGetComponent<Ingredient>(out Ingredient ing))
return;
if (fireplace && !fireplace.isFireplaceIgnited())
return;

Destroy(other.gameObject);
onIngredientAdded.Invoke();
//onIngredientAdded.Invoke();
audioSource.pitch = UnityEngine.Random.Range(0.9f, 1.1f);
audioSource.PlayOneShot(waterClips[UnityEngine.Random.Range(0, waterClips.Length)]);

if (recipe[0].ingredientName != ing.ingredientName) {
onWrongIngredientAdded?.Invoke();
StartCoroutine(RestartRecipe());

if (badIngredientAddedClips.Length == 0)
return;

int randomClipIndex = UnityEngine.Random.Range(0, badIngredientAddedClips.Length);
audioSource.PlayOneShot(badIngredientAddedClips[randomClipIndex]);
return;
}

recipe[0].amount--;
Debug.Log("Ingredient added!");
UpdatePotionStats(ing);
// if (recipe[0].ingredientName != ing.ingredientName) {
// onWrongIngredientAdded?.Invoke();
// StartCoroutine(RestartRecipe());
//
// if (badIngredientAddedClips.Length == 0)
// return;
//
// int randomClipIndex = UnityEngine.Random.Range(0, badIngredientAddedClips.Length);
// audioSource.PlayOneShot(badIngredientAddedClips[randomClipIndex]);
// return;
// }
//
// recipe[0].amount--;

onGoodIngredientAdded?.Invoke();
if (!boiled && IsComplete()) {
Expand All @@ -69,29 +86,49 @@ private void OnTriggerEnter(Collider other)
Debug.Log("Recipe complete!");
}

UpdateRecipe();
// UpdateRecipe();
}

private void UpdatePotionStats(Ingredient ing) {
Potion potionTemp = ing.GetPotionProperties();

potion.glowingIntensity = potionTemp.glowingIntensity;
potion.isSteaming = potionTemp.isSteaming;
ClampColor(potionTemp.potionColor);
potion.potionEffect = potionTemp.potionEffect;
onIngredientAdded.Invoke(potion);
}
private void UpdateRecipe()
{
SetIngredientAmountText(0);

if (recipe[0].amount == 0)
recipe.RemoveAt(0);
private void ClampColor(Vector3 potionColor) {
potion.potionColor += potionColor;
potion.potionColor.x %= 360;
potion.potionColor.y %= 100;
potion.potionColor.z %= 100;
potion.potionColor.y = Mathf.Clamp(potion.potionColor.y, 30f, 100f);
potion.potionColor.z = Mathf.Clamp(potion.potionColor.z, 30f, 100f);
}

// private void UpdateRecipe()
// {
// SetIngredientAmountText(0);
//
// if (recipe[0].amount == 0)
// recipe.RemoveAt(0);
// }

private void SetIngredientAmountText(int i) {
if (recipe[i].text)
recipe[i].text.SetText($"{recipe[i].amount}");
}

private IEnumerator RestartRecipe() {
cauldronWater.enabled = true;

yield return new WaitForSeconds(3);

recipe = startRecipe;
cauldronWater.enabled = false;
}
// private IEnumerator RestartRecipe() {
// cauldronWater.enabled = true;
//
// yield return new WaitForSeconds(3);
//
// recipe = startRecipe;
// cauldronWater.enabled = false;
// }

private bool IsComplete()
{
Expand Down
Loading