28 lines
641 B
C#
28 lines
641 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(Board))]
|
|
public class ChipsRotator : MonoBehaviour
|
|
{
|
|
[SerializeField] float angle = 15;
|
|
[SerializeField] float speed = 4;
|
|
|
|
private Board board;
|
|
|
|
private void Start() => board = GetComponent<Board>();
|
|
|
|
private void Update()
|
|
{
|
|
if (board == null) return;
|
|
if (board.Grid == null) return;
|
|
float y = angle * Unity.Mathematics.math.sin(speed * Time.time);
|
|
|
|
foreach (Chip chip in board.Grid)
|
|
{
|
|
if (chip == null) continue;
|
|
|
|
chip.transform.localRotation = Quaternion.Euler(0, y, 0);
|
|
}
|
|
}
|
|
}
|