52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ButtonDOne: MonoBehaviour
|
|
{
|
|
public SpriteRenderer spriteRenderer;
|
|
public Sprite originalSprite;
|
|
public Sprite activatedSprite;
|
|
public GameObject movingPoint;
|
|
public Vector3 activatedPointPosition;
|
|
private Vector3 originalPointPosition;
|
|
public bool einsAn = false;
|
|
public GameObject _LevelManager1;
|
|
private keyWhenPressed script1;
|
|
bool isActivated;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
originalPointPosition = movingPoint.transform.position;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
script1 = _LevelManager1.GetComponent<keyWhenPressed>();
|
|
isActivated = script1.isActivated;
|
|
if (isActivated){
|
|
spriteRenderer.sprite = activatedSprite;
|
|
}
|
|
|
|
}
|
|
|
|
void OnTriggerEnter2D(Collider2D other) {
|
|
if (other.CompareTag("PressurePlatable") || other.CompareTag("PlayerIsOnIt")){
|
|
spriteRenderer.sprite = activatedSprite;
|
|
movingPoint.transform.position = activatedPointPosition;
|
|
einsAn = true;
|
|
}
|
|
}
|
|
|
|
void OnTriggerExit2D(Collider2D other) {
|
|
if (other.CompareTag("PressurePlatable")|| other.CompareTag("PlayerIsOnIt")) {
|
|
spriteRenderer.sprite = originalSprite;
|
|
movingPoint.transform.position = originalPointPosition;
|
|
einsAn = false;
|
|
|
|
}
|
|
}
|
|
}
|