-
Notifications
You must be signed in to change notification settings - Fork 0
/
flytomiddel.cs
66 lines (58 loc) · 2.48 KB
/
flytomiddel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class flytomiddel : MonoBehaviour
{
public GameObject page;
public Transform target;
public Transform targetfire;
SpriteRenderer spriteRenderer;
public Sprite sprite2;
public GameObject puzzle;
public bool isfinish = false;
// Start is called before the first frame update
void Start()
{
spriteRenderer = gameObject.GetComponent<SpriteRenderer>();
}
// Update is called once per frame
void Update()
{
if (page.activeSelf)
{
gameObject.GetComponent<SpriteRenderer>().color = new Color32(255, 255, 225, 255);
spriteRenderer.maskInteraction = SpriteMaskInteraction.None;
spriteRenderer.sortingOrder = 10;
// gameObject.transform.localScale = target.localScale;
// iTween.MoveTo(gameObject, iTween.Hash("position", target.position, "speed", 50, "easetype", "linear"));
gameObject.transform.position = Vector3.MoveTowards(gameObject.transform.position, target.position, 1);
transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, 10);
transform.parent = target.parent;
if (gameObject.transform.position == target.transform.position)
{
iTween.ScaleTo(gameObject, iTween.Hash("scale", target.localScale, "time", 1));
if(gameObject.transform.localScale== target.localScale)
{
puzzle.SetActive(true);
}
}
if (isfinish)
{
spriteRenderer.sprite = sprite2;
gameObject.transform.position = Vector3.MoveTowards(gameObject.transform.position, targetfire.position, 1);
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetfire.rotation, 1);
if (gameObject.transform.position == targetfire.transform.position)
{
// sldie.SetActive(true);
transform.parent = targetfire.parent;
iTween.ScaleTo(gameObject, iTween.Hash("scale", targetfire.localScale, "time", 1));
}
}
}
else
{
gameObject.GetComponent<SpriteRenderer>().color = new Color32(255, 255, 225, 0);
puzzle.SetActive(false);
}
}
}