54 lines
1.5 KiB
C#
Executable File
54 lines
1.5 KiB
C#
Executable File
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace BF
|
|
{
|
|
public class BattleControlBg : MonoBehaviour
|
|
{
|
|
public float speed = 0.0f;
|
|
public float endX = 0.0f;
|
|
public float resetX = 0.0f;
|
|
public int type = 0;
|
|
public bool canMove = true;
|
|
|
|
public void SetPositionByTime(float time)
|
|
{
|
|
var transformRect = GetComponent<RectTransform>();
|
|
transformRect.anchoredPosition = new Vector2(transformRect.anchoredPosition.x + speed * time, transformRect.anchoredPosition.y);
|
|
}
|
|
|
|
void FixedUpdate()
|
|
{
|
|
if (!canMove) return;
|
|
var transformRect = GetComponent<RectTransform>();
|
|
if (transformRect.anchoredPosition.x <= endX)
|
|
{
|
|
transformRect.anchoredPosition = new Vector2(resetX, transformRect.anchoredPosition.y);
|
|
}
|
|
// if (type == 1)
|
|
// {
|
|
// speed = BF.BFMain.Instance.BattleMgr.SceneSpeedC;
|
|
// }
|
|
// else if (type == 2)
|
|
// {
|
|
// speed = BF.BFMain.Instance.BattleMgr.SceneSpeedM;
|
|
// }
|
|
// else if (type == 3)
|
|
// {
|
|
// speed = BF.BFMain.Instance.BattleMgr.SceneSpeedF;
|
|
// }
|
|
// else if (type == 4)
|
|
// {
|
|
// speed = BF.BFMain.Instance.BattleMgr.SceneSpeedCould;
|
|
// }
|
|
// else if (type == 5)
|
|
// {
|
|
// speed = BF.BFMain.Instance.BattleMgr.SceneSpeedBg;
|
|
// }
|
|
// transform.Translate(speed * Time.fixedDeltaTime, 0.0f, 0.0f);
|
|
transformRect.anchoredPosition = new Vector2(transformRect.anchoredPosition.x + speed * Time.fixedDeltaTime, transformRect.anchoredPosition.y);
|
|
}
|
|
}
|
|
}
|