Archival Commit
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public struct ObjectItaretion
|
||||
{
|
||||
public GameObject obj;
|
||||
public bool completed;
|
||||
}
|
||||
|
||||
|
||||
public class Minigame : MonoBehaviour
|
||||
{
|
||||
public ObjectItaretion[] objectsToInterat;
|
||||
public Task taskToComplete;
|
||||
|
||||
private TaskManager TM;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
TM = GameObject.FindGameObjectWithTag("TM").GetComponent<TaskManager>();
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
foreach (ObjectItaretion objectIt in objectsToInterat)
|
||||
{
|
||||
|
||||
if (!objectIt.completed)
|
||||
{
|
||||
objectIt.obj.GetComponent<ObjectAnim>().interatuable = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void ObjectInteraction(GameObject interactedObj)
|
||||
{
|
||||
for(int i = 0; i < objectsToInterat.Length; i++)
|
||||
{
|
||||
if(objectsToInterat[i].obj == interactedObj && !objectsToInterat[i].completed)
|
||||
{
|
||||
|
||||
objectsToInterat[i].completed = true;
|
||||
interactedObj.GetComponent<ObjectAnim>().interatuable = false;
|
||||
interactedObj.GetComponent<ObjectAnim>().ResetScale();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = objectsToInterat.Length - 1; i >= 0; i--)
|
||||
{
|
||||
if (!objectsToInterat[i].completed)
|
||||
{
|
||||
break;
|
||||
}
|
||||
FinishMinigame();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void FinishMinigame()
|
||||
{
|
||||
gameObject.GetComponentInParent<WindowAnimation>().CloseWindow();
|
||||
TM.CompleteTask(taskToComplete);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ad9f9346bd456b459b88444b25db631
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(BoxCollider2D))]
|
||||
public class MinigameStarter : MonoBehaviour
|
||||
{
|
||||
|
||||
public GameObject miniGamePrefab;
|
||||
|
||||
public bool interatuable = false;
|
||||
|
||||
public Vector3 scaleAmount;
|
||||
|
||||
private Collider2D col;
|
||||
private Vector3 startScale;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
col = GetComponent<Collider2D>();
|
||||
startScale = transform.localScale;
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (interatuable)
|
||||
{
|
||||
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);
|
||||
|
||||
RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
|
||||
|
||||
if (hit.collider == col)
|
||||
{
|
||||
transform.localScale = startScale + scaleAmount;
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
OnInteract();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localScale = startScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnInteract()
|
||||
{
|
||||
Instantiate(miniGamePrefab);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
|
||||
public void ResetScale()
|
||||
{
|
||||
transform.localScale = startScale;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c447ee4c824be949b33557be484e088
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[RequireComponent(typeof(BoxCollider2D))]
|
||||
public class ObjectAnim : MonoBehaviour
|
||||
{
|
||||
|
||||
//public objectAnimType objType;
|
||||
|
||||
public bool interatuable = false;
|
||||
|
||||
public Vector3 scaleAmount;
|
||||
|
||||
private Collider2D col;
|
||||
private Vector3 startScale;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
col = GetComponent<Collider2D>();
|
||||
startScale = transform.localScale;
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (interatuable)
|
||||
{
|
||||
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);
|
||||
|
||||
RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
|
||||
|
||||
if(hit.collider == col)
|
||||
{
|
||||
transform.localScale = startScale + scaleAmount;
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
gameObject.GetComponentInParent<Minigame>().ObjectInteraction(this.gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localScale = startScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ResetScale()
|
||||
{
|
||||
transform.localScale = startScale;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public enum objectAnimType
|
||||
{
|
||||
minigame = 0, scene = 1
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64d33ee7ca4e8e145bc63c7096606e38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,104 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Timers;
|
||||
using UnityEngine;
|
||||
|
||||
public class WindowAnimation : MonoBehaviour
|
||||
{
|
||||
|
||||
WindowAnimation(Vector2 givenStartPos, Vector2 givenTarget)
|
||||
{
|
||||
startPos = givenStartPos;
|
||||
targetPos = givenTarget;
|
||||
}
|
||||
|
||||
public Vector2 startPos;
|
||||
public Vector2 targetPos;
|
||||
public Vector3 maxScale = new Vector3(1.3f, 1.3f, 1.3f);
|
||||
public float animSpeed = 25f;
|
||||
public float scaleTime = 5f;
|
||||
|
||||
private bool closing = false;
|
||||
private bool opening = true;
|
||||
|
||||
|
||||
private float interpolationValue;
|
||||
|
||||
private float startTime;
|
||||
private float closeTime;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
startTime = Time.time;
|
||||
|
||||
transform.position = startPos;
|
||||
transform.localScale = new Vector3(0, 0, 0);
|
||||
|
||||
opening = true;
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector2 pos = new Vector2(transform.position.x, transform.position.y);
|
||||
|
||||
//interpolationValue = (Time.time - closeTime) / animSpeed;
|
||||
|
||||
|
||||
if (opening)
|
||||
{
|
||||
animatePos();
|
||||
animateScale();
|
||||
|
||||
if(transform.localScale == maxScale)
|
||||
{
|
||||
opening = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (closing)
|
||||
{
|
||||
interpolationValue = (closeTime) / scaleTime;
|
||||
CloseAnim();
|
||||
|
||||
if (pos == startPos)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void CloseWindow()
|
||||
{
|
||||
opening = false;
|
||||
closing = true;
|
||||
closeTime = Time.time;
|
||||
}
|
||||
|
||||
|
||||
private void CloseAnim()
|
||||
{
|
||||
transform.position = Vector2.MoveTowards(transform.position, startPos, animSpeed * Time.deltaTime);
|
||||
|
||||
Vector3 trans = Vector3.Lerp(maxScale, Vector3.zero, interpolationValue);
|
||||
transform.localScale = trans;
|
||||
}
|
||||
|
||||
|
||||
private void animatePos()
|
||||
{
|
||||
transform.position = Vector2.MoveTowards(transform.position, targetPos, animSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
private void animateScale()
|
||||
{
|
||||
transform.localScale = Vector3.Lerp(Vector3.zero, maxScale, 1.38f * (Time.time - startTime));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f14612ff94b813941b9155b1cda63c34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user