Files
butchers-games-test/Assets/Scripts/Game/Core/Section.cs
T
Boris Nikolaev 5f1e94b653 add project files
2026-08-14 01:58:31 +03:00

95 lines
1.7 KiB
C#

using System.Collections.Generic;
using UnityEngine;
public class Section : CoreBehaviour
{
public int difficulty;
public Transform endLevel;
public bool differentPath;
public bool V_1_1;
public bool V_1_6;
public int sectionCountNormalSection = 1;
public bool containIngameAds = true;
public void Setup(CoreDef def)
{
}
[ContextMenu("TEST")]
public void Test()
{
TestSection(this);
}
public static void TestSection(Section b)
{
AppController app = Object.FindObjectOfType<AppController>();
if (!(app == null))
{
CoreController core = app.coreGame;
var forced = new List<Section> { b };
if (core != null)
{
core.debugForcedLevel = forced;
}
}
}
private static float WrapAngle(float angle)
{
angle %= 360f;
if (angle > 180f)
{
angle -= 360f;
}
return angle;
}
public float GetYRotationTurnSection(Vector3 pos, float curYRot, MovePlayer moveP)
{
float t = 0f;
if (moveP.verti)
{
float from = base.transform.position.z;
float to = endLevel.transform.position.z;
if (from != to)
{
float r = (pos.z - from) / (to - from);
if (r >= 0f)
{
t = Mathf.Min(r, 1f);
}
}
}
else
{
float from = base.transform.position.x;
float to = endLevel.transform.position.x;
if (from != to)
{
float r = (pos.x - from) / (to - from);
if (r >= 0f)
{
t = Mathf.Min(r, 1f);
}
}
}
float targetY = WrapAngle(endLevel.transform.eulerAngles.y);
if (t >= 0.99f)
{
moveP.EndTurn();
return targetY;
}
return curYRot + Mathf.Max(t, 0f) * (targetY - curYRot);
}
public Vector3 GetPosTurnSection(Vector3 pos, float curYRot, Player p)
{
return Vector3.zero;
}
}