68 lines
1.5 KiB
C#
68 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PlayCtrl : SingletonMonoBehaviour<PlayCtrl>
|
|
{
|
|
public GameObject camera;
|
|
public float speed;
|
|
float move = 0;
|
|
|
|
public Slider slider;
|
|
float summons;
|
|
int stage;
|
|
|
|
public Animator anim;
|
|
|
|
public GameObject unit;
|
|
|
|
public SummonsUnit player;
|
|
public SummonsUnit enemy;
|
|
|
|
protected override void OnAwake()
|
|
{
|
|
summons = 0.1f;
|
|
slider.value = 0;
|
|
stage = 0;
|
|
}
|
|
|
|
public void MoveCamera(float move)
|
|
{
|
|
this.move = move;
|
|
}
|
|
|
|
public void CtrlButton()
|
|
{
|
|
anim.SetTrigger("MoveUI");
|
|
}
|
|
private void Update()
|
|
{
|
|
float deltaTime = Time.deltaTime;
|
|
camera.transform.position += Vector3.left * speed * deltaTime * move;
|
|
if (camera.transform.position.x < -40)
|
|
{
|
|
camera.transform.position = new Vector3(-40, 0, -10);
|
|
}
|
|
if (camera.transform.position.x > 40)
|
|
{
|
|
camera.transform.position = new Vector3(40, 0, -10);
|
|
}
|
|
slider.value += Time.deltaTime / 30;
|
|
if (slider.value >= 1)
|
|
{
|
|
slider.value -= 1;
|
|
summons = 0.1f;
|
|
stage++;
|
|
}
|
|
if (summons < slider.value)
|
|
{
|
|
int count = (int)(summons / 0.2);
|
|
player.Summons(count);
|
|
enemy.Summons(count);
|
|
summons += 0.2f;
|
|
}
|
|
|
|
}
|
|
}
|