Skip to content

Instantly share code, notes, and snippets.

View zonaryFUND's full-sized avatar

zonaryfund zonaryFUND

View GitHub Profile
// ドラッグして移動されるオブジェクトAを受け取るオブジェクトBにアタッチされるべきコンポーネント
public class ReceiverComponentB: MonoBehaviour, IDropReceiver {
public void OnOverlappingCorrespondingSenderChange(GameObject senderObject) {
// このオブジェクトがDraggedComponentAを持つ別のオブジェクトと重なった/重ならなくなったときに呼ばれる
// 色替えなどをする
}
public void OnDrop(GameObject senderObject) {
// このオブジェクトがDraggedComponentAを持つ別のオブジェクトと重なったままドロップされたときに呼ばれる
// 各種処理をする
}
// ドラッグして移動されるオブジェクトAに、DragDropSenderと一緒にアタッチされるべきコンポーネント
public class DraggedComponentA: MonoBehaviour, ISenderComponent {
public void OnBeginDrag() {
// ドラッグしはじめでこのメソッドがDragDropSenderから呼ばれる
// 色変えなどをする
}
public bool IsCorrespondingObject(GameObject obj) {
// このオブジェクトがIDropReceiverを持つ別のオブジェクトと重なったときに呼ばれる
// 対応するコンポーネントBであればtrueを返す
public interface IDropSender {
void OnBeginDrag();
bool IsCorrespondingObject(GameObject obj);
void OnOverlappingCorrespondingReceiverChange(GameObject receiverObject);
void OnDrop(GameObject receiverObject);
}
public interface IDropReceiver {
void OnOverlappingCorrespondingSenderChange(GameObject senderObject);
void OnDrop(GameObject senderObject);
// 受け手オブジェクトB/Dにアタッチされる何かが継承すべきinterface
public interface IDropReceptor {
bool ReceiveDrop(GameObject obj);
}
// ドロップされるオブジェクトA/Cのコンポーネントのドロップ処理
public class ComponentA: MonoBehaviour {
// 中略
public void OnEndDrag(PointerEventData eventData)
public class CommandWindowManager: MonoBehaviour {
public class CreateWindow(Array<(string, Action)>) {
// コマンドボタンの作成
}
}
public class BattleMain: MonoBehabiour {
void CreateCommandWindow() {
commandWindowManager.CreateWindow(new Array<(string, Action)> {
(
Color color = colorType switch {
UNIT_COLOR.DEFAULT => new Color(1.0f, 1.0f, 1.0f, 1.0f),
UNIT_COLOR.ACTIVE => new Color(1.0f, 1.0f, 1.0f, 1.0f),
UNIT_COLOR.CANNOT_SELECT => new Color(1.0f, 1.0f, 1.0f, 1.0f),
UNIT_COLOR.EFFECTIVE => new Color(1.0f, 1.0f, 1.0f, 1.0f),
_ => throw new InvalidOperationException()
};
_objUnitColorTop = Enumerable.Range(0, 3).Select(y => Enumerable.Range(0, 6).Select(x => {
var obj = Instantiate("PrefabName");
// obj.transform.parent = などの処理
return obj;
}).ToArray()).ToArray();
@zonaryFUND
zonaryFUND / a.cs
Last active February 2, 2022 15:50
public class BattleMain: MonoBehaviour {
public event EventHandler<List<UnitInfo>> UnitInfoUpdateHandler;
public SomeBattleProcess() {
// ~~~~何らかの戦闘処理でUnitInfoのリストが更新
UnitInfoUpdateHandler(this, this.unitInfoList);
}
}
////////////////////////////////
using System.Linq;
using Monad;
using Monad.Extensions;
namespace BuildCiv.Model.CardDifinition
{
public readonly struct Barter : IPlayable
{
public int CivilCost => 1;
using System;
namespace Monad.Extensions
{
public interface ContState<TState, TValue> : Cont<Unit, State<TState, TValue>> { }
internal readonly struct PureContState<TState, TValue> : ContState<TState, TValue>
{
readonly Func<Func<State<TState, TValue>, Unit>, Unit> function;
internal PureContState(Func<Func<State<TState, TValue>, Unit>, Unit> function) => this.function = function;