summaryrefslogtreecommitdiff
path: root/GameCode/LevelScale.cs
blob: 39969cabe27a2787bf59c6d69997dc713a2688db (plain)
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
using System;
using UnityEngine;

public class LevelScale : MonoBehaviour
{
	public bool onLevelUp = true;

	public bool onStart;

	private AttackLevel level;

	private Vector3 startScale;

	private bool inited;

	private void Init()
	{
		if (!inited)
		{
			inited = true;
			startScale = base.transform.localScale;
		}
	}

	private void Start()
	{
		Init();
		level = GetComponent<AttackLevel>();
		if (onStart)
		{
			base.transform.localScale *= level.LevelScale();
		}
		if (onLevelUp)
		{
			AttackLevel attackLevel = level;
			attackLevel.LevelUpAction = (Action<int>)Delegate.Combine(attackLevel.LevelUpAction, new Action<int>(LevelUp));
		}
	}

	public void LevelUp(int lvl)
	{
		Init();
		base.transform.localScale = startScale * level.LevelScale();
	}
}