Настройка нескольких призов на одного персонажа в процессе. И херанул пару десятков старых скриптов

This commit is contained in:
Сергей Бондарь 2026-08-24 15:28:57 +03:00
parent eb60c917a0
commit 23fc034e47
143 changed files with 4306 additions and 3635 deletions

View File

@ -0,0 +1,109 @@
using PrizeSystem;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class AvailablePrizesTable : MonoBehaviour
{
public PrizeButton _prizeButtonPrefab;
[SerializeField] RectTransform _buttonsRoot;
public void Refresh(PrizeSet set)
{
ClearButtons();
foreach (var type in GetMissingPrizeTypes(set.Prizes))
{
var button = Instantiate(_prizeButtonPrefab, _buttonsRoot);
button.Configure(type);
button.OnPrize += OnPrizeTypeSelected;
}
}
private void OnPrizeTypeSelected(PrizeType type)
{
//открыть окошко по типу, подписаться на него
}
private void ClearButtons()
{
for (int i = 0; i < _buttonsRoot.childCount; i++)
{
var go = _buttonsRoot.GetChild(i).gameObject;
Destroy(go);
}
}
public static List<PrizeType> GetMissingPrizeTypes(List<Prize> prizes)
{
// Все типы призов (кроме None и Empty)
var allTypes = new List<PrizeType>
{
PrizeType.Hopper,
PrizeType.Marbles,
PrizeType.Ticket,
PrizeType.Qr,
PrizeType.VitrinaBox
};
// Определяем, есть ли в списке хоть один CountablePrize
bool hasCountablePrize = prizes.Any(p => p is CountablePrize);
// Если есть CountablePrize, все счетные типы считаются добавленными
var countableTypes = new HashSet<PrizeType>
{
PrizeType.Hopper,
PrizeType.Marbles,
PrizeType.Ticket
};
// Собираем существующие типы
var existingTypes = new HashSet<PrizeType>();
foreach (var prize in prizes)
{
// Если это EmptyPrize - пропускаем (не влияет на существующие типы)
if (prize is EmptyPrize) continue;
// Если это CountablePrize и у нас уже есть флаг, что счетные есть
if (prize is CountablePrize)
{
// Добавляем все счетные типы, если их еще нет
if (hasCountablePrize)
{
foreach (var type in countableTypes)
{
existingTypes.Add(type);
}
}
else
{
// На случай, если hasCountablePrize false (но такого быть не может)
existingTypes.Add(prize.PrizeType);
}
}
else
{
// Для не-счетных призов добавляем их конкретный тип
existingTypes.Add(prize.PrizeType);
}
}
// Если есть CountablePrize, но не все типы добавлены, добавляем все счетные
if (hasCountablePrize)
{
foreach (var type in countableTypes)
{
existingTypes.Add(type);
}
}
// Возвращаем типы, которых нет в существующих
return allTypes
.Where(type => !existingTypes.Contains(type))
.ToList();
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 418dc3f246ef5e44cb059f5ca0c10b93

View File

@ -0,0 +1,23 @@
using PrizeSystem;
using System;
using UnityEngine;
public abstract class BasePrizeConfigurator : MonoBehaviour, IControlable
{
public event Action<Prize> OnPrizeConfigured;
public bool ControlsEnabled { get; set; } = true;
public abstract void Configure(PrizeType prizeType);
public virtual void Complete(Prize prize)
{
OnPrizeConfigured?.Invoke(prize);
Destroy(gameObject);
}
public virtual void UpdateControls()
{
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 587a63a8d0fa56d4691a6ac7910b9f73

View File

@ -0,0 +1,470 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2872055672348682947
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2166714241725172564}
- component: {fileID: 3610272716468530649}
- component: {fileID: 1049406941762121891}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2166714241725172564
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2872055672348682947}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7698163084671810053}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 116.2}
m_Pivot: {x: 0.5, y: 0}
--- !u!222 &3610272716468530649
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2872055672348682947}
m_CullTransparentMesh: 1
--- !u!114 &1049406941762121891
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2872055672348682947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: "\u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E
\u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: e15a0ab6490ab964998a0786c208c4b2, type: 2}
m_sharedMaterial: {fileID: 4262305343556741190, guid: e15a0ab6490ab964998a0786c208c4b2, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 32
m_fontSizeBase: 32
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 16
m_fontSizeMax: 64
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_characterHorizontalScale: 1
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &3548895642639160110
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2697007139903851628}
- component: {fileID: 2898386233667329125}
- component: {fileID: 6195150281388987687}
m_Layer: 5
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2697007139903851628
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3548895642639160110}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7698163084671810053}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 131}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2898386233667329125
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3548895642639160110}
m_CullTransparentMesh: 1
--- !u!114 &6195150281388987687
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3548895642639160110}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &4721586931901281940
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7698163084671810053}
- component: {fileID: 5497661148036193703}
- component: {fileID: 4217061767172003025}
- component: {fileID: 5680088572919083885}
m_Layer: 5
m_Name: CountableConfigurator
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7698163084671810053
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4721586931901281940}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2697007139903851628}
- {fileID: 1115757798774131713}
- {fileID: 2166714241725172564}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 500, y: 500}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5497661148036193703
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4721586931901281940}
m_CullTransparentMesh: 1
--- !u!114 &4217061767172003025
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4721586931901281940}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
m_Material: {fileID: 0}
m_Color: {r: 0.4415095, g: 0.4415095, b: 0.4415095, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &5680088572919083885
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4721586931901281940}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e17a04a6cb06a3c4d91aa58cadf7e6a7, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CountablePrizeConfigurator
icon: {fileID: 6195150281388987687}
numberInput: {fileID: 0}
--- !u!1001 &1512082769719754990
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 7698163084671810053}
m_Modifications:
- target: {fileID: 1834033349437326354, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1834033349437326354, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1834033349437326354, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1834033349437326354, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1834033349437326354, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMax.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMax.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMin.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMin.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_SizeDelta.y
value: 30
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6405499040113261454, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6405499040113261454, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6405499040113261454, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6405499040113261454, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6405499040113261454, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8055866410577572243, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8055866410577572243, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8055866410577572243, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8055866410577572243, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8055866410577572243, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8556998190284949453, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
propertyPath: m_Name
value: NumberStepper
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
--- !u!224 &1115757798774131713 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1981593229059902703, guid: ced775cf87d3b2c4b9c58d53e5af7f72, type: 3}
m_PrefabInstance: {fileID: 1512082769719754990}
m_PrefabAsset: {fileID: 0}

View File

@ -1,7 +1,6 @@
fileFormatVersion: 2
guid: ea951b5763668944a812d78215bf18a6
folderAsset: yes
DefaultImporter:
guid: 8b123b0e9e795b842948d07b6e135d84
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:

View File

@ -0,0 +1,36 @@
using PrizeSystem;
using UnityEngine.UI;
public class CountablePrizeConfigurator : BasePrizeConfigurator, IControlable
{
public Image icon;
public MNumberStepper numberInput;
public override void Configure(PrizeType prizeType)
{
icon.sprite = PrizeSystemManager.GetPrizeIcon(prizeType);
int maxValue = prizeType switch
{
PrizeType.Hopper => 10,
PrizeType.Ticket => 100,
PrizeType.Marbles => 10,
_ => 1
};
numberInput.Initialize(value: 1, min: 1, maxValue);
}
public override void UpdateControls()
{
numberInput.SetDirection(In.GetAxis(Axis.Horizontal, JoystickSide.Both, InteractMode.Continious));
if (In.GetButtonDownAnyPlayer(PlayerAction.action))
{
Prize prize = PrizeUtils.CreatePrize(CountablePrizeType.Hopper, numberInput.Value);
Complete(prize);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e17a04a6cb06a3c4d91aa58cadf7e6a7

View File

@ -22,13 +22,13 @@ public class MNumberStepper : MonoBehaviour
private bool _isHolding;
private float _lastChangeTime;
private int _value;
public int Value { get; private set; }
private int _min;
private int _max;
public void Initialize(int value, int min, int max)
{
_value = value;
Value = value;
_min = min;
_max = max;
ResetState();
@ -94,13 +94,13 @@ public class MNumberStepper : MonoBehaviour
private void ChangeValue(int direction, int step)
{
int newValue = _value + direction * step;
int newValue = Value + direction * step;
newValue = Mathf.Clamp(newValue, _min, _max);
if (newValue != _value)
if (newValue != Value)
{
_value = newValue;
OnValueChanged?.Invoke(_value);
Value = newValue;
OnValueChanged?.Invoke(Value);
UpdateView();
}
else
@ -112,9 +112,9 @@ public class MNumberStepper : MonoBehaviour
private void UpdateView()
{
_valueLabel.text = _value.ToString();
_leftArrow.alpha = _value == _min ? 0 : 1;
_rightArrow.alpha = _value == _max ? 0 : 1;
_valueLabel.text = Value.ToString();
_leftArrow.alpha = Value == _min ? 0 : 1;
_rightArrow.alpha = Value == _max ? 0 : 1;
}
public void ResetState()

View File

@ -1,7 +1,6 @@
using DG.Tweening;
using System;
using TMPro;
using TMPro.EditorUtilities;
using UnityEngine;
using UnityEngine.UI;
@ -9,15 +8,15 @@ public class MSignalButton : MonoBehaviour
{
public event Action OnClick;
[SerializeField] private Image _image;
[SerializeField] TextMeshProUGUI _textMeshPro;
[SerializeField] private Color _normalColor;
[SerializeField] private Color _selectedColor;
[SerializeField] private Color _pressedColor;
[SerializeField] private AudioClip _clip;
[SerializeField] protected Image _image;
[SerializeField] protected TextMeshProUGUI _textMeshPro;
[SerializeField] protected Color _normalColor;
[SerializeField] protected Color _selectedColor;
[SerializeField] protected Color _pressedColor;
[SerializeField] protected AudioClip _clip;
private bool _lastPressed = false;
private Sequence _animation;
protected bool _lastPressed = false;
protected Sequence _animation;
public void TakeInput(bool pressed)
{
@ -25,14 +24,13 @@ public class MSignalButton : MonoBehaviour
{
if (pressed)
{
ClickAnimation();
}
_lastPressed = pressed;
}
}
public void ClickAnimation()
public virtual void ClickAnimation()
{
StopAnimation();
@ -63,16 +61,11 @@ public class MSignalButton : MonoBehaviour
{
StopAnimation();
//_animation = DOTween.Sequence();
//_animation.Append(_image.DOColor(_normalColor, 0.1f));
//_animation.Join(_textMeshPro.DOColor(Color.white, 0.3f));
//_animation.PlayForward();
_image.color = _normalColor;
_textMeshPro.color = Color.white;
}
private void StopAnimation()
protected void StopAnimation()
{
if (_animation != null)
{

View File

@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 8604408698177003535}
- component: {fileID: 8039207184498597514}
- component: {fileID: 331023456886542288}
- component: {fileID: 6346851752755896837}
- component: {fileID: 1528631932536492394}
- component: {fileID: 58624349632693913}
m_Layer: 0
@ -49,9 +50,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.Character
characterName: "\u041A\u044C\u044E\u0431"
difficultyModule: {fileID: 0}
difficultyModule: {fileID: 11400000, guid: a3e2c9fd2fee87943af2947d5eb72597, type: 2}
visualModule: {fileID: 331023456886542288}
prizeModule: {fileID: 0}
prizeModule: {fileID: 6346851752755896837}
--- !u!114 &331023456886542288
MonoBehaviour:
m_ObjectHideFlags: 0
@ -64,13 +65,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84da6ca280c0ea746bd14d1c45b7272a, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.VisualModule
icon: {fileID: 0}
icon: {fileID: -8149160197350721816, guid: fbeb9853b48ea2844a0115637f7d3427, type: 3}
iconSmall: {fileID: 0}
chipImage: {fileID: 0}
_messageBox: {fileID: 0}
replicas: {fileID: 0}
_messageBox: {fileID: 1876940890959816278, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
replicas: {fileID: 11400000, guid: 1a042f31f2c98b64fb2511191b1d1001, type: 2}
_audioSource: {fileID: 0}
_animator: {fileID: 0}
_animator: {fileID: 1528631932536492394}
chipSpawningAnim: {fileID: 0}
chipThrowClip: {fileID: 0}
showDuration: 1
@ -79,6 +80,18 @@ MonoBehaviour:
hideEase: 1
HiddenPos: {x: 0, y: 0}
VisiblePos: {x: 0, y: 0}
--- !u!114 &6346851752755896837
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3388591762507178167}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 65613ca2ac760fd4781294edbf567a7f, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.PrizeModule
--- !u!95 &1528631932536492394
Animator:
serializedVersion: 7

View File

@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 8312733962015895203}
- component: {fileID: 8233466963536421093}
- component: {fileID: 743876072189889991}
- component: {fileID: 2927423071651238219}
- component: {fileID: 4924238884005179083}
- component: {fileID: 3477068820351240633}
m_Layer: 0
@ -49,9 +50,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.Character
characterName: "\u0422\u043E\u043C"
difficultyModule: {fileID: 0}
difficultyModule: {fileID: 11400000, guid: a3e2c9fd2fee87943af2947d5eb72597, type: 2}
visualModule: {fileID: 743876072189889991}
prizeModule: {fileID: 0}
prizeModule: {fileID: 2927423071651238219}
--- !u!114 &743876072189889991
MonoBehaviour:
m_ObjectHideFlags: 0
@ -64,13 +65,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84da6ca280c0ea746bd14d1c45b7272a, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.VisualModule
icon: {fileID: 0}
icon: {fileID: -529477370105943367, guid: 229dd13b366e5b04ab570cce8b4796e4, type: 3}
iconSmall: {fileID: 0}
chipImage: {fileID: 0}
_messageBox: {fileID: 0}
replicas: {fileID: 0}
_messageBox: {fileID: 1876940890959816278, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
replicas: {fileID: 11400000, guid: 1a042f31f2c98b64fb2511191b1d1001, type: 2}
_audioSource: {fileID: 0}
_animator: {fileID: 0}
_animator: {fileID: 4924238884005179083}
chipSpawningAnim: {fileID: 0}
chipThrowClip: {fileID: 0}
showDuration: 1
@ -79,6 +80,18 @@ MonoBehaviour:
hideEase: 1
HiddenPos: {x: 0, y: 0}
VisiblePos: {x: 0, y: 0}
--- !u!114 &2927423071651238219
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 216986101277937167}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 65613ca2ac760fd4781294edbf567a7f, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.PrizeModule
--- !u!95 &4924238884005179083
Animator:
serializedVersion: 7

View File

@ -102,6 +102,7 @@ GameObject:
- component: {fileID: 7360891851470844778}
- component: {fileID: 6676369703225837789}
- component: {fileID: 1922468027975826848}
- component: {fileID: 4781704477309761372}
- component: {fileID: 4476514036158972146}
- component: {fileID: 9076068693199869531}
m_Layer: 0
@ -139,10 +140,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: aa123dd73e3dcc84c9f46ca695aa1b17, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.Character
characterName: "\u0422\u043E\u043C"
difficultyModule: {fileID: 0}
characterName: "\u0420\u043E\u0431\u043E\u0432\u043E\u043B\u043A"
difficultyModule: {fileID: 11400000, guid: a3e2c9fd2fee87943af2947d5eb72597, type: 2}
visualModule: {fileID: 1922468027975826848}
prizeModule: {fileID: 0}
prizeModule: {fileID: 4781704477309761372}
--- !u!114 &1922468027975826848
MonoBehaviour:
m_ObjectHideFlags: 0
@ -155,13 +156,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84da6ca280c0ea746bd14d1c45b7272a, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.VisualModule
icon: {fileID: 0}
icon: {fileID: -1307639399570084333, guid: e35c65295e3ac234b9975dbe342f4090, type: 3}
iconSmall: {fileID: 0}
chipImage: {fileID: 0}
_messageBox: {fileID: 0}
replicas: {fileID: 0}
_messageBox: {fileID: 1876940890959816278, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
replicas: {fileID: 11400000, guid: 1a042f31f2c98b64fb2511191b1d1001, type: 2}
_audioSource: {fileID: 0}
_animator: {fileID: 0}
_animator: {fileID: 4476514036158972146}
chipSpawningAnim: {fileID: 0}
chipThrowClip: {fileID: 0}
showDuration: 1
@ -170,6 +171,18 @@ MonoBehaviour:
hideEase: 1
HiddenPos: {x: 0, y: 0}
VisiblePos: {x: 0, y: 0}
--- !u!114 &4781704477309761372
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4672236760054860725}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 65613ca2ac760fd4781294edbf567a7f, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.PrizeModule
--- !u!95 &4476514036158972146
Animator:
serializedVersion: 7

View File

@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 158448787793702589}
- component: {fileID: 7661847991293490837}
- component: {fileID: 135954504275540935}
- component: {fileID: 2680085133228831324}
m_Layer: 0
m_Name: 4. Sam
m_TagString: Untagged
@ -48,10 +49,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: aa123dd73e3dcc84c9f46ca695aa1b17, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.Character
characterName: "\u0422\u043E\u043C"
difficultyModule: {fileID: 0}
characterName: "\u0421\u0430\u043C\u0443\u0440\u0430\u0439"
difficultyModule: {fileID: 11400000, guid: a3e2c9fd2fee87943af2947d5eb72597, type: 2}
visualModule: {fileID: 158448787793702589}
prizeModule: {fileID: 0}
prizeModule: {fileID: 2680085133228831324}
--- !u!114 &158448787793702589
MonoBehaviour:
m_ObjectHideFlags: 0
@ -64,13 +65,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84da6ca280c0ea746bd14d1c45b7272a, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.VisualModule
icon: {fileID: 0}
icon: {fileID: 1809351836, guid: f52ee716872562446b5261ef80b4e8cd, type: 3}
iconSmall: {fileID: 0}
chipImage: {fileID: 0}
_messageBox: {fileID: 0}
replicas: {fileID: 0}
_messageBox: {fileID: 1876940890959816278, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
replicas: {fileID: 11400000, guid: 1a042f31f2c98b64fb2511191b1d1001, type: 2}
_audioSource: {fileID: 0}
_animator: {fileID: 0}
_animator: {fileID: 7661847991293490837}
chipSpawningAnim: {fileID: 0}
chipThrowClip: {fileID: 0}
showDuration: 1
@ -198,6 +199,18 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &2680085133228831324
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7238525776732110314}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 65613ca2ac760fd4781294edbf567a7f, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.PrizeModule
--- !u!1 &8166061890310921111
GameObject:
m_ObjectHideFlags: 0

View File

@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 3965767742986002211}
- component: {fileID: 4847740494483037661}
- component: {fileID: 791928390561251957}
- component: {fileID: 3332781226631085844}
m_Layer: 0
m_Name: 5. Feeshka
m_TagString: Untagged
@ -48,10 +49,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: aa123dd73e3dcc84c9f46ca695aa1b17, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.Character
characterName: "\u0422\u043E\u043C"
difficultyModule: {fileID: 0}
characterName: "\u0424\u0438\u0448\u043A\u0430"
difficultyModule: {fileID: 11400000, guid: a3e2c9fd2fee87943af2947d5eb72597, type: 2}
visualModule: {fileID: 3965767742986002211}
prizeModule: {fileID: 0}
prizeModule: {fileID: 3332781226631085844}
--- !u!114 &3965767742986002211
MonoBehaviour:
m_ObjectHideFlags: 0
@ -64,13 +65,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84da6ca280c0ea746bd14d1c45b7272a, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.VisualModule
icon: {fileID: 0}
icon: {fileID: -1325076913608113314, guid: b865778670f0b8c418a3450c41975937, type: 3}
iconSmall: {fileID: 0}
chipImage: {fileID: 0}
_messageBox: {fileID: 0}
replicas: {fileID: 0}
_messageBox: {fileID: 1876940890959816278, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
replicas: {fileID: 11400000, guid: 1a042f31f2c98b64fb2511191b1d1001, type: 2}
_audioSource: {fileID: 0}
_animator: {fileID: 0}
_animator: {fileID: 4847740494483037661}
chipSpawningAnim: {fileID: 0}
chipThrowClip: {fileID: 0}
showDuration: 1
@ -198,6 +199,18 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &3332781226631085844
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5358438370345097688}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 65613ca2ac760fd4781294edbf567a7f, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.PrizeModule
--- !u!1 &7413449725762096583
GameObject:
m_ObjectHideFlags: 0

View File

@ -140,7 +140,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.Character
characterName: "\u0422\u043E\u043C"
difficultyModule: {fileID: 0}
difficultyModule: {fileID: 11400000, guid: a3e2c9fd2fee87943af2947d5eb72597, type: 2}
visualModule: {fileID: 864774382241315247}
prizeModule: {fileID: 0}
--- !u!114 &864774382241315247

View File

@ -140,7 +140,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.Character
characterName: "\u0422\u043E\u043C"
difficultyModule: {fileID: 0}
difficultyModule: {fileID: 11400000, guid: a3e2c9fd2fee87943af2947d5eb72597, type: 2}
visualModule: {fileID: 5909990390208136556}
prizeModule: {fileID: 0}
--- !u!114 &5909990390208136556

View File

@ -0,0 +1,573 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3445425685777722834
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5038375750017055777}
- component: {fileID: 8299439785254263817}
- component: {fileID: 3522442556933999774}
m_Layer: 5
m_Name: Panel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5038375750017055777
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3445425685777722834}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4917617217911147516}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8299439785254263817
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3445425685777722834}
m_CullTransparentMesh: 1
--- !u!114 &3522442556933999774
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3445425685777722834}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: bf65b9affd8e1304d9074d6271c9ac04, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &6124346617087923689
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 519033178495556743}
- component: {fileID: 2477658180085709316}
- component: {fileID: 5385475176474712663}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &519033178495556743
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6124346617087923689}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4917617217911147516}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -0.043}
m_SizeDelta: {x: 0, y: -1.4016}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2477658180085709316
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6124346617087923689}
m_CullTransparentMesh: 1
--- !u!114 &5385475176474712663
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6124346617087923689}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: New Text
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 47e175ba6cb1126439b5583572a406fe, type: 2}
m_sharedMaterial: {fileID: 8312110174854069929, guid: 47e175ba6cb1126439b5583572a406fe, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 0.35
m_fontSizeBase: 0.5
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 0
m_fontSizeMax: 64
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_characterHorizontalScale: 1
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &6679944310692155710
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5739603173244235323}
- component: {fileID: 7454287611703797159}
- component: {fileID: 7725792043156676869}
m_Layer: 5
m_Name: Name
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5739603173244235323
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6679944310692155710}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4917617217911147516}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0.901}
m_SizeDelta: {x: 0, y: -1.4016}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7454287611703797159
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6679944310692155710}
m_CullTransparentMesh: 1
--- !u!114 &7725792043156676869
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6679944310692155710}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: "\u0422\u043E\u043C"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 47e175ba6cb1126439b5583572a406fe, type: 2}
m_sharedMaterial: {fileID: 8312110174854069929, guid: 47e175ba6cb1126439b5583572a406fe, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 0.35
m_fontSizeBase: 0.5
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 0
m_fontSizeMax: 64
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_characterHorizontalScale: 1
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &8620231027088551242
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4917617217911147516}
- component: {fileID: 7502150315990015490}
- component: {fileID: 8012185055219410538}
- component: {fileID: 8428301645144312930}
- component: {fileID: 1876940890959816278}
- component: {fileID: 8112158254562883423}
m_Layer: 5
m_Name: TestMessageBox
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4917617217911147516
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8620231027088551242}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5038375750017055777}
- {fileID: 5739603173244235323}
- {fileID: 519033178495556743}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 2, y: 2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!223 &7502150315990015490
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8620231027088551242}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 2
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_UseReflectionProbes: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!114 &8012185055219410538
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8620231027088551242}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.CanvasScaler
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 1
--- !u!114 &8428301645144312930
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8620231027088551242}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.GraphicRaycaster
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1876940890959816278
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8620231027088551242}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3a6ba6cd455be0e43985c4c7663c0596, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::CharacterSystem.MessageBox
_frame: {fileID: 4917617217911147516}
_localPos: {x: 0, y: 0}
nameLabel: {fileID: 7725792043156676869}
textField: {fileID: 5385475176474712663}
_audioSource: {fileID: 8112158254562883423}
typeClip: {fileID: 8300000, guid: 1c48900c9ab0aa8418920a8193050870, type: 3}
--- !u!82 &8112158254562883423
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8620231027088551242}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_Resource: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -1,7 +1,6 @@
fileFormatVersion: 2
guid: 347fc016c233c364cb86eb28d8823fcf
folderAsset: yes
DefaultImporter:
guid: 50b5075221b823240b287cd5e6c02d64
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:

46
Assets/PrizeButton.cs Normal file
View File

@ -0,0 +1,46 @@
using DG.Tweening;
using PrizeSystem;
using System;
using UnityEngine.UI;
public class PrizeButton : MSignalButton
{
public event Action<PrizeType> OnPrize;
private PrizeType _prizeType;
public override void ClickAnimation()
{
StopAnimation();
_animation = DOTween.Sequence();
_animation.Append(_image.DOColor(_pressedColor, 0.15f));
_animation.Append(_image.DOColor(_selectedColor, 0.15f));
_animation.AppendCallback(() =>
{
OnPrize?.Invoke(_prizeType);
SoundManager.instance.playClip(_clip);
});
_animation.PlayForward();
}
public void Configure(PrizeType prizeType)
{
_prizeType = prizeType;
_image.sprite = PrizeSystemManager.GetPrizeIcon(prizeType);
_textMeshPro.text = GetText(prizeType);
}
private string GetText(PrizeType prizeType)
=> prizeType switch
{
PrizeType.Hopper => "Добавить хоппер",
PrizeType.Marbles => "Добавить марблс",
PrizeType.Ticket => "Добавить тикет",
PrizeType.Qr => "Добавить QR",
PrizeType.VitrinaBox => "Добавить витрину",
_ => "ошибка"
};
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 29d71697c50744c4ba61a084f207c698

234
Assets/PrizeButton.prefab Normal file
View File

@ -0,0 +1,234 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1930693335002057802
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7244007432844469167}
- component: {fileID: 8928771092486777963}
- component: {fileID: 6574132780437697725}
- component: {fileID: 942699711437869465}
m_Layer: 5
m_Name: PrizeButton
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7244007432844469167
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1930693335002057802}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6796888954934601460}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8928771092486777963
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1930693335002057802}
m_CullTransparentMesh: 1
--- !u!114 &6574132780437697725
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1930693335002057802}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &942699711437869465
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1930693335002057802}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 29d71697c50744c4ba61a084f207c698, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PrizeButton
_image: {fileID: 6574132780437697725}
_textMeshPro: {fileID: 5975884200597755691}
_normalColor: {r: 0.554717, g: 0.554717, b: 0.554717, a: 1}
_selectedColor: {r: 1, g: 1, b: 1, a: 1}
_pressedColor: {r: 1, g: 1, b: 1, a: 1}
_clip: {fileID: 0}
--- !u!1 &3282660986900798294
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6796888954934601460}
- component: {fileID: 7466989399709544197}
- component: {fileID: 5975884200597755691}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6796888954934601460
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3282660986900798294}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7244007432844469167}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 20, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0, y: 0.5}
--- !u!222 &7466989399709544197
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3282660986900798294}
m_CullTransparentMesh: 1
--- !u!114 &5975884200597755691
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3282660986900798294}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: New Text
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 47e175ba6cb1126439b5583572a406fe, type: 2}
m_sharedMaterial: {fileID: 8312110174854069929, guid: 47e175ba6cb1126439b5583572a406fe, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 32
m_fontSizeBase: 32
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 16
m_fontSizeMax: 64
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_characterHorizontalScale: 1
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}

View File

@ -1,7 +1,6 @@
fileFormatVersion: 2
guid: b1f83e34f27996f458ea5a3a5cddc55c
folderAsset: yes
DefaultImporter:
guid: f4d8e373cd4ebc948abb9692f14709e6
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:

File diff suppressed because it is too large Load Diff

50
Assets/PrizesSelector.cs Normal file
View File

@ -0,0 +1,50 @@
using CharacterSystem;
using PrizeSystem;
using UnityEngine;
public class PrizesSelector : MonoBehaviour
{
[SerializeField] RectTransform _addedPrizesTable;
[SerializeField] PrizeView _prizeViewPrefab;
[SerializeField] AvailablePrizesTable _availablePrizesTable;
private PrizeSet set;
public void Open(Character character)
{
print($"открыто с персонажем {character.CharacterIndex}");
gameObject.SetActive(true);
set = PrizeSystemManager.PrizeContainer.Sets[character.CharacterIndex];
UpdateView();
}
private void UpdateView()
{
ClearTable();
DisplayPrizeSet(set);
_availablePrizesTable.Refresh(set);
}
private void ClearTable()
{
for (int i = _addedPrizesTable.childCount - 1; i >= 0; i--)
{
var go = _addedPrizesTable.GetChild(i).gameObject;
Destroy(go);
}
}
private void DisplayPrizeSet(PrizeSet prizeSet)
{
foreach (var item in prizeSet.Prizes)
{
var view = Instantiate(_prizeViewPrefab, _addedPrizesTable);
view.SetPrize(item);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f48e5505c7183ea42bc61e529a276725

View File

@ -1151,6 +1151,74 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 64783859}
m_CullTransparentMesh: 1
--- !u!1 &65425788
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 65425791}
- component: {fileID: 65425790}
- component: {fileID: 65425789}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &65425789
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 65425788}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.EventSystems.StandaloneInputModule
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &65425790
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 65425788}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.EventSystems.EventSystem
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &65425791
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 65425788}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &71076714
GameObject:
m_ObjectHideFlags: 0
@ -2781,7 +2849,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
prizeErrorSound: {fileID: 8300000, guid: 5fb832a50dc689845898a59217fd0535, type: 3}
SoundNotification: 1
PrizeNotificationSounds:
- {fileID: 8300000, guid: 1347f6385fc35fe4882304613a9fbfe9, type: 3}
- {fileID: 8300000, guid: 2e6426be1392aea48936249e22b54e1f, type: 3}
@ -2794,7 +2861,20 @@ MonoBehaviour:
ImagePosition: {x: -172.5, y: 9.9}
ImageSize: 445
audioClip: {fileID: 8300000, guid: 7fb340d179cafc04cb2e4baa2ddde96f, type: 3}
vitrinaPanel: {fileID: 61619038}
iconsMap:
- prizeType: 0
sprite: {fileID: 0}
- prizeType: 1
sprite: {fileID: 1846153687249437008, guid: d082c4b9803e5a644984a930192356cb, type: 3}
- prizeType: 2
sprite: {fileID: -314096454217921429, guid: d082c4b9803e5a644984a930192356cb, type: 3}
- prizeType: 3
sprite: {fileID: 4024560508046998061, guid: d082c4b9803e5a644984a930192356cb, type: 3}
- prizeType: 4
sprite: {fileID: -882981077604546528, guid: d082c4b9803e5a644984a930192356cb, type: 3}
- prizeType: 5
sprite: {fileID: 1421601187438738523, guid: d082c4b9803e5a644984a930192356cb, type: 3}
defaultIcon: {fileID: 1846153687249437008, guid: d082c4b9803e5a644984a930192356cb, type: 3}
--- !u!114 &259182291
MonoBehaviour:
m_ObjectHideFlags: 0
@ -14088,11 +14168,11 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
characterPrefabs:
- {fileID: 8873348988979391587, guid: 8813a05b560fe74499373105c065d482, type: 3}
- {fileID: 8873348988979391587, guid: dbde6acf97979cd4caaca68f83b75d64, type: 3}
- {fileID: 8873348988979391587, guid: 280922cd1d9e3ef44bdbfe757f8cfdef, type: 3}
- {fileID: 8873348988979391587, guid: b1bd71cccf32b4c4a94b2ff65361e9fe, type: 3}
- {fileID: 8873348988979391587, guid: 4b7845a03cf955e4488f4e3286f11b60, type: 3}
- {fileID: 8039207184498597514, guid: 7702b7919503a1e479151e8fecd78924, type: 3}
- {fileID: 8233466963536421093, guid: 53736a6cd29210e4eb0f110ef04d344c, type: 3}
- {fileID: 6676369703225837789, guid: eb3cf1ffcc790864db631f50a02da123, type: 3}
- {fileID: 3215344534852605381, guid: d2448bca251e50a4ebaae923084264a0, type: 3}
- {fileID: 5982990141465619124, guid: f1fc145bd1885e146bc33b2669940862, type: 3}
--- !u!4 &1542626845
Transform:
m_ObjectHideFlags: 0
@ -18834,7 +18914,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1967587903
RectTransform:
m_ObjectHideFlags: 0
@ -22500,10 +22580,6 @@ PrefabInstance:
propertyPath: m_Name
value: PrizesConfigurator
objectReference: {fileID: 0}
- target: {fileID: 5423109734219761443, guid: dcef42dd0beb95f4e9b230192966f091, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
@ -24229,6 +24305,107 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f99466ff04084264e9e9fc17b47090bf, type: 3}
--- !u!1001 &8712459775951269144
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_SizeDelta.x
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_SizeDelta.y
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_AnchoredPosition.x
value: 16.9
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0.77
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4917617217911147516, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7725792043156676869, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_fontSize
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 8620231027088551242, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
propertyPath: m_Name
value: TestMessageBox
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
--- !u!1 &8752651682790280933
GameObject:
m_ObjectHideFlags: 0
@ -24296,3 +24473,5 @@ SceneRoots:
- {fileID: 46193421}
- {fileID: 1606109336}
- {fileID: 1329752847}
- {fileID: 8712459775951269144}
- {fileID: 65425791}

View File

@ -19,7 +19,6 @@ namespace CharacterSystem
public void Initialize()
{
return;
I = this;
SetupCharacters();
}
@ -68,10 +67,11 @@ namespace CharacterSystem
public void RefreshPrizes()
{
List<Prize> prizes = PrizeSerializer.LoadPrizes();
for (int i = 0; i < characters.Length; i++)
characters[i].prizeModule.SetPrize(prizes[i]);
{
PrizeSet prizesSet = PrizeSystemManager.PrizeContainer.Sets[i];
characters[i].prizeModule.SetPrizes(prizesSet);
}
}
public void ShowCharacter(int newIndex)

View File

@ -1,16 +1,17 @@
using PrizeSystem;
using System.Collections.Generic;
using UnityEngine;
namespace CharacterSystem
{
public class PrizeModule : MonoBehaviour
{
private Prize _prize;
private List<Prize> _prizes;
public bool HasPrize { get; private set; }
public void SetPrize(Prize prize)
public void SetPrizes(PrizeSet prizesSet)
{
_prize = prize;
_prizes = prizesSet.Prizes;
}
public void ResetModule()
@ -18,19 +19,19 @@ namespace CharacterSystem
HasPrize = true;
}
public Prize CheckPrize()
=> _prize;
public List<Prize> CheckPrizes()
=> _prizes;
public bool TryFetchPrize(out Prize prize)
public bool TryFetchPrize(out List<Prize> prizes)
{
if (HasPrize)
{
prize = _prize;
prizes = _prizes;
HasPrize = false;
return true;
}
prize = null;
prizes = null;
return false;
}
@ -41,7 +42,7 @@ namespace CharacterSystem
if (HasPrize == false)
return false;
if (_prize is T casted)
if (_prizes is T casted)
{
castedPrize = casted;
HasPrize = false;

View File

@ -1,169 +0,0 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using UnityEngine;
public static class CryptoUtil
{
// Формат пакета (Base64):
// [1 байт Version][16 байт Salt][16 байт IV][N байт Cipher][32 байта HMAC]
private const byte Version = 1;
private const int SaltSize = 16;
private const int IvSize = 16;
private const int HmacSize = 32;
private const int Pbkdf2Iterations = 1000; // можно поднять до 200-300k, если ок по производительности
public static string EncryptJson(string json, string password)
{
if (json == null) throw new ArgumentNullException(nameof(json));
if (string.IsNullOrEmpty(password)) throw new ArgumentException("Password is empty.", nameof(password));
byte[] salt = RandomBytes(SaltSize);
byte[] iv = RandomBytes(IvSize);
// Получаем 64 байта: 32 на AES ключ + 32 на HMAC ключ
DeriveKeys(password, salt, out var encKey, out var macKey);
byte[] plainBytes = Encoding.UTF8.GetBytes(json);
byte[] cipherBytes = AesCbcEncrypt(plainBytes, encKey, iv);
// Собираем заголовок+данные (без HMAC)
byte[] headerAndCipher = new byte[1 + SaltSize + IvSize + cipherBytes.Length];
int offset = 0;
headerAndCipher[offset++] = Version;
Buffer.BlockCopy(salt, 0, headerAndCipher, offset, salt.Length); offset += salt.Length;
Buffer.BlockCopy(iv, 0, headerAndCipher, offset, iv.Length); offset += iv.Length;
Buffer.BlockCopy(cipherBytes, 0, headerAndCipher, offset, cipherBytes.Length);
// HMAC по всему, что выше (version+salt+iv+cipher)
byte[] hmac = ComputeHmac(macKey, headerAndCipher);
// Финальный пакет
byte[] package = new byte[headerAndCipher.Length + hmac.Length];
Buffer.BlockCopy(headerAndCipher, 0, package, 0, headerAndCipher.Length);
Buffer.BlockCopy(hmac, 0, package, headerAndCipher.Length, hmac.Length);
return Convert.ToBase64String(package);
}
public static string DecryptJson(string encryptedBase64, string password)
{
if (encryptedBase64 == null) throw new ArgumentNullException(nameof(encryptedBase64));
if (string.IsNullOrEmpty(password)) throw new ArgumentException("Password is empty.", nameof(password));
byte[] package;
try
{
package = Convert.FromBase64String(encryptedBase64);
}
catch (FormatException)
{
throw new CryptographicException("Input is not valid Base64.");
}
if (package.Length < 1 + SaltSize + IvSize + 1 + HmacSize)
throw new CryptographicException("Encrypted data is too short.");
int minHeader = 1 + SaltSize + IvSize;
int cipherLen = package.Length - minHeader - HmacSize;
if (cipherLen <= 0) throw new CryptographicException("Encrypted data has no ciphertext.");
byte version = package[0];
if (version != Version) throw new CryptographicException($"Unsupported version: {version}");
byte[] salt = new byte[SaltSize];
byte[] iv = new byte[IvSize];
byte[] cipher = new byte[cipherLen];
byte[] hmac = new byte[HmacSize];
Buffer.BlockCopy(package, 1, salt, 0, SaltSize);
Buffer.BlockCopy(package, 1 + SaltSize, iv, 0, IvSize);
Buffer.BlockCopy(package, minHeader, cipher, 0, cipherLen);
Buffer.BlockCopy(package, minHeader + cipherLen, hmac, 0, HmacSize);
DeriveKeys(password, salt, out var encKey, out var macKey);
// Проверка HMAC (важно: до расшифровки)
byte[] headerAndCipher = new byte[minHeader + cipherLen];
Buffer.BlockCopy(package, 0, headerAndCipher, 0, headerAndCipher.Length);
byte[] expectedHmac = ComputeHmac(macKey, headerAndCipher);
if (!FixedTimeEquals(hmac, expectedHmac))
throw new CryptographicException("Invalid password or data was tampered (HMAC mismatch).");
byte[] plainBytes = AesCbcDecrypt(cipher, encKey, iv);
return Encoding.UTF8.GetString(plainBytes);
}
// ===== helpers =====
private static void DeriveKeys(string password, byte[] salt, out byte[] encKey, out byte[] macKey)
{
using var kdf = new Rfc2898DeriveBytes(password, salt, Pbkdf2Iterations, HashAlgorithmName.SHA256);
byte[] keyMaterial = kdf.GetBytes(64);
encKey = new byte[32];
macKey = new byte[32];
Buffer.BlockCopy(keyMaterial, 0, encKey, 0, 32);
Buffer.BlockCopy(keyMaterial, 32, macKey, 0, 32);
// чуть безопаснее: затереть временный буфер
Array.Clear(keyMaterial, 0, keyMaterial.Length);
}
private static byte[] AesCbcEncrypt(byte[] plain, byte[] key, byte[] iv)
{
using var aes = Aes.Create();
aes.KeySize = 256;
aes.Mode = CipherMode.CBC;
aes.Padding = PaddingMode.PKCS7;
aes.Key = key;
aes.IV = iv;
using var ms = new MemoryStream();
using (var cs = new CryptoStream(ms, aes.CreateEncryptor(), CryptoStreamMode.Write))
{
cs.Write(plain, 0, plain.Length);
cs.FlushFinalBlock();
}
return ms.ToArray();
}
private static byte[] AesCbcDecrypt(byte[] cipher, byte[] key, byte[] iv)
{
using var aes = Aes.Create();
aes.KeySize = 256;
aes.Mode = CipherMode.CBC;
aes.Padding = PaddingMode.PKCS7;
aes.Key = key;
aes.IV = iv;
using var ms = new MemoryStream();
using (var cs = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Write))
{
cs.Write(cipher, 0, cipher.Length);
cs.FlushFinalBlock();
}
return ms.ToArray();
}
private static byte[] ComputeHmac(byte[] macKey, byte[] data)
{
using var h = new HMACSHA256(macKey);
return h.ComputeHash(data);
}
private static byte[] RandomBytes(int size)
{
var b = new byte[size];
RandomNumberGenerator.Fill(b);
return b;
}
private static bool FixedTimeEquals(byte[] a, byte[] b)
{
if (a == null || b == null || a.Length != b.Length) return false;
return CryptographicOperations.FixedTimeEquals(a, b);
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 63eee6b84ab7d65488940534d6ded2dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,52 +0,0 @@
using UnityEngine;
public class CheckLeadersFromMenuState : IState
{
Leaderboard lb;
float timeToExit = 60f;
float timeElapsed = 0;
public void enter()
{
ComWrapper.InputRecieved +=ResetTimer;
lb = GameManager.Instance.leaderboard;
//вкл
lb.gameObject.SetActive(true);
lb.Initialize();
SoundManager.instance.playSwitch();
timeElapsed = 0;
}
void ResetTimer(string s) => timeElapsed = 0;
public void exit()
{
ComWrapper.InputRecieved-=ResetTimer;
lb.ClearRowsText();
lb.gameObject.SetActive(false);
SoundManager.instance.playSwitch();
}
public void update()
{
//проверка
bool exitCombo = In.GetButtonDownAnyPlayer(PlayerAction.left) && In.GetButtonDownAnyPlayer(PlayerAction.right);
if (exitCombo)
{
GameManager.Instance.GotoMenu();
}
bool keepDownButton = In.GetButtonAnyPlayer(PlayerAction.down);
float accelerationSign = keepDownButton ? 1 : -1f;
lb.accelerationY = Mathf.Abs(lb.accelerationY) * accelerationSign;
timeElapsed += Time.deltaTime;
if (timeElapsed > timeToExit)
{
GameManager.Instance.GotoMenu();
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: da31cb838704c31478eef984dc9a9d30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,99 +0,0 @@
using System.Collections.Generic;
using UnityEngine;
public class CheckSettingsPasswordState : IState
{
//EnterPasswordPanel panel;
public void enter()
{
//panel = GameManager.instance.enterPasswordPanel;
Debug.Log("[Проход в настройки]");
//Пароль не установлен.
//bool Pwd = SettingsManager.GetBool(SettingKey.PASSWORD_ON_SETTINGS, false);
//if (!Pwd)
//{
// Debug.Log("[Пароля нет, заходим братья]");
// GameManager.instance.stateMachine.ChangeState(new SettingsState());
// return;
//}
//Пароль есть.
//Получить пароль.
string password = ExternalFilesGetter.GetSettingsPassword();
//Если он не валидный, то сбросить настройку и пропустить.
if (password == null)
{
Debug.Log("[Файла пароля нет. Сброс пароля. Заход в настройки]");
disableCheck();
GameManager.Instance.stateMachine.ChangeState(new SettingsState());
return;
}
if (PasswordValid(password))
{
// если валидный, то запускаем ввод пароля
//panel.gameObject.SetActive(true);
//panel.Initialize(password);
}
else
{
Debug.Log("[пароль невалидный. Сброс пароля. Заход в настройки]");
disableCheck();
ExternalFilesGetter.SetPassword("");
GameManager.Instance.stateMachine.ChangeState(new SettingsState());
}
}
private static void disableCheck()
{
//Setting setting = SettingsManager.Container.TryGetSetting(SettingKey.PASSWORD_ON_SETTINGS);
//setting.ChangeValue(-1);//ставим false
//SettingsManager.OnSettingsChanged?.Invoke();
}
public void exit()
{
//panel.gameObject.SetActive(false);
}
public void update()
{
//panel._Update();
//if (panel.truePassword)
//{
// GameManager.instance.stateMachine.ChangeState(new SettingsState());
//}
GameManager.Instance.stateMachine.ChangeState(new SettingsState());
}
private bool PasswordValid(string password)
{
if(password.Length!=12) return false;
List<string> combinations = SplitPasswordIntoPairs(password);
List<string> validCombinations = new List<string> { "L1", "L2", "R1", "R2", "A1", "A2", "P1", "P2" };
foreach (string combination in combinations)
{
if (!validCombinations.Contains(combination)) return false;
}
return true;
}
List<string> SplitPasswordIntoPairs(string password)
{
List<string> result = new List<string>();
for (int i = 0; i < password.Length; i += 2)
{
result.Add(password.Substring(i, 2));
}
return result;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: a53795db75745c44e913b9ceb5564076
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,47 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnterPricePVERevengeState : IState
{
NumberInput numberInput;
GameManager gm;
IState prevState;
public EnterPricePVERevengeState(IState prevState)
{
this.prevState = prevState;
}
public void enter()
{
gm = GameManager.Instance;
numberInput = gm.pricePveRevengeInput;
numberInput.gameObject.SetActive(true);
numberInput.Initialize();
}
public void exit() => numberInput.gameObject.SetActive(false);
public void update()
{
int continiousDir = 0;
if (In.GetButtonAnyPlayer(PlayerAction.left)) continiousDir -= 1;
if (In.GetButtonAnyPlayer(PlayerAction.right)) continiousDir += 1;
numberInput.SwitchValue(continiousDir);
if (In.GetButtonDownAnyPlayer(PlayerAction.down))
{
numberInput.AcceptAndClose();
//обратный переход
gm.stateMachine.ChangeState(new SettingsState());
gm.stateMachine.ChangeState(prevState);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 490905846487abe4e82e8c3963832923
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,43 +0,0 @@
public class EnterPricePVEState : IState
{
NumberInput numberInput;
GameManager gm;
IState prevState;
public EnterPricePVEState(IState prevState)
{
this.prevState = prevState;
}
public void enter()
{
gm = GameManager.Instance;
numberInput = gm.pricePveInput;
numberInput.gameObject.SetActive(true);
numberInput.Initialize();
}
public void exit() => numberInput.gameObject.SetActive(false);
public void update()
{
int continiousDir = 0;
if (In.GetButtonAnyPlayer(PlayerAction.left)) continiousDir -= 1;
if (In.GetButtonAnyPlayer(PlayerAction.right)) continiousDir += 1;
numberInput.SwitchValue(continiousDir);
if (In.GetButtonDownAnyPlayer(PlayerAction.down))
{
numberInput.AcceptAndClose();
//обратный переход
//gm.stateMachine.ChangeState(new SettingsState());
gm.stateMachine.ChangeState(prevState);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c0411a6c1362bf24b918381632d84723
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,47 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnterPricePVPState : IState
{
NumberInput numberInput;
GameManager gm;
IState prevState;
public EnterPricePVPState(IState prevState)
{
this.prevState = prevState;
}
public void enter()
{
gm = GameManager.Instance;
numberInput = gm.pricePvpInput;
numberInput.gameObject.SetActive(true);
numberInput.Initialize();
}
public void exit() => numberInput.gameObject.SetActive(false);
public void update()
{
int continiousDir = 0;
if (In.GetButtonAnyPlayer(PlayerAction.left)) continiousDir -= 1;
if (In.GetButtonAnyPlayer(PlayerAction.right)) continiousDir += 1;
numberInput.SwitchValue(continiousDir);
if (In.GetButtonDownAnyPlayer(PlayerAction.down))
{
numberInput.AcceptAndClose();
//обратный переход
//gm.stateMachine.ChangeState(new SettingsState());
gm.stateMachine.ChangeState(prevState);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8ae20d54bb0db594984b29182ae45c47
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,47 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnterPrizesAvailableState : IState
{
NumberInput numberInput;
GameManager gm;
IState prevState;
public EnterPrizesAvailableState(IState prevState)
{
this.prevState = prevState;
}
public void enter()
{
gm = GameManager.Instance;
numberInput = gm.prizesAvailableInput;
numberInput.gameObject.SetActive(true);
numberInput.Initialize();
}
public void exit() => numberInput.gameObject.SetActive(false);
public void update()
{
int continiousDir = 0;
if (In.GetButtonAnyPlayer(PlayerAction.left)) continiousDir -= 1;
if (In.GetButtonAnyPlayer(PlayerAction.right)) continiousDir += 1;
numberInput.SwitchValue(continiousDir);
if (In.GetButtonDownAnyPlayer(PlayerAction.down))
{
numberInput.AcceptAndClose();
//обратный переход
//gm.stateMachine.ChangeState(new SettingsState());
gm.stateMachine.ChangeState(prevState);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1a343c2bce2420a4fa58579c6927e08f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,31 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PrizeSystem;
public class EnterPrizesForCharactersState : IState
{
GameObject rootPanel;
List<Prize> prizes;
IState prevState;
public EnterPrizesForCharactersState(IState prevState)
{
this.prevState = prevState;
}
public void enter()
{
rootPanel = GameManager.Instance.CharactersConfigurator;
rootPanel.SetActive(true);
}
public void exit()
{
rootPanel.SetActive(false);
}
public void update()
{
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c387a59b81cdaa4458e46591efe8ab6a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,46 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnterPulsesToResetDifficulty : IState
{
NumberInput numberInput;
GameManager gm;
IState prevState;
public EnterPulsesToResetDifficulty(IState prevState)
{
this.prevState = prevState;
}
public void enter()
{
gm = GameManager.Instance;
numberInput = gm.pulsesToResetDifficultyInput;
numberInput.gameObject.SetActive(true);
numberInput.Initialize();
}
public void exit() => numberInput.gameObject.SetActive(false);
public void update()
{
int continiousDir = 0;
if (In.GetButtonAnyPlayer(PlayerAction.left)) continiousDir -= 1;
if (In.GetButtonAnyPlayer(PlayerAction.right)) continiousDir += 1;
numberInput.SwitchValue(continiousDir);
if (In.GetButtonDownAnyPlayer(PlayerAction.down))
{
numberInput.AcceptAndClose();
//обратный переход
//gm.stateMachine.ChangeState(new SettingsState());
gm.stateMachine.ChangeState(prevState);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: fa5ad459c5c33cf4884c71ac83a031c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,46 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnterValutaPerImpulse : IState
{
NumberInput numberInput;
GameManager gm;
IState prevState;
public EnterValutaPerImpulse(IState prevState)
{
this.prevState = prevState;
}
public void enter()
{
gm = GameManager.Instance;
numberInput = gm.valutaPerPulseInput;
numberInput.gameObject.SetActive(true);
numberInput.Initialize();
}
public void exit() => numberInput.gameObject.SetActive(false);
public void update()
{
int continiousDir = 0;
if (In.GetButtonAnyPlayer(PlayerAction.left)) continiousDir -= 1;
if (In.GetButtonAnyPlayer(PlayerAction.right)) continiousDir += 1;
numberInput.SwitchValue(continiousDir);
if (In.GetButtonDownAnyPlayer(PlayerAction.down))
{
numberInput.AcceptAndClose();
//обратный переход
//gm.stateMachine.ChangeState(new SettingsState());
gm.stateMachine.ChangeState(prevState);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: dc7bce07ffba4b54992def810c526f32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,14 +0,0 @@
using UnityEngine;
public class GameStateMachine : MonoBehaviour
{
public IState currentState;
public void ChangeState(IState nextState)
{
currentState?.exit();
currentState = nextState;
currentState.enter();
}
private void Update() => currentState?.update();
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 644deb7c42b828041920ca8c69f133ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +0,0 @@
public interface IState
{
void enter();
void update();
void exit();
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 624afa00bb6a20f4db8f23e120b71fc7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,18 +0,0 @@
using UnityEngine;
public class IoTestState : IState
{
GameObject io;
IState prevState;
public IoTestState(GameObject ioPanel, IState prevState)
{
io = ioPanel;
this.prevState = prevState;
}
public void enter() => io.SetActive(true);
public void exit() => io.SetActive(false);
public void update()
{
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 88ee8c8343146aa478df440a7912b71d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,41 +0,0 @@
using UnityEngine;
//показ таблицы лидеров после победы.
public class LeaderboardState : IState
{
PlayerStatsRecord record;
Leaderboard leaderboard;
public LeaderboardState(PlayerStatsRecord record)
{
this.record = record;
}
public void enter()
{
leaderboard = GameManager.Instance.leaderboard;
leaderboard.gameObject.SetActive(true);
leaderboard.Initialize();
PlayerStatsRecord lastRecord = GameManager.Instance.StatsService.GetLatestRecord();
leaderboard.DisplayCurrentPlayer(record);
}
public void exit()
{
leaderboard.ClearRowsText();
leaderboard.gameObject.SetActive(false);
}
public void update()
{
bool keepDownButton = In.GetButtonAnyPlayer(PlayerAction.down);
float accelerationSign = keepDownButton ? 1 : -1f;
leaderboard.accelerationY = Mathf.Abs(leaderboard.accelerationY) * accelerationSign;
if (In.GetButtonDownAnyPlayer(PlayerAction.left) && In.GetButtonDownAnyPlayer(PlayerAction.right))
{
Board.Instance.MakeClearField();
GameManager.Instance.GotoMenu();
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 003dcc5df85966d47ab408def0e372df
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,75 +0,0 @@
using PrizeSystem;
using UnityEngine;
public class PrizeState : IState
{
private GameManager gm;
private IState nextState;
private VitrinaPanel vitrina;
private QrPanel qr;
public PrizeState(IState nextState)
{
this.nextState = nextState;
}
public void enter()
{
Debug.Log("Зашел в приз");
gm = GameManager.Instance;
gm.timerManager.StopAllTimers();
if(PrizeSystemManager.HasVitrinaPrizeToGive)
{
if(gm.vitrinaPanel.TryGetComponent(out vitrina))
{
vitrina.OnComplete += OnComplete;
gm.vitrinaPanel.gameObject.SetActive(true);
VitrinaPrize prize = PrizeSystemManager.DequeueVitrinaPrize();
gm.vitrinaPanel.Initialize(prize.Boxes);
}
}
else if (PrizeSystemManager.HasQrPrizeToGive)
{
if (gm.qrPanel.TryGetComponent(out qr))
{
qr.OnComplete += OnComplete;
gm.qrPanel.gameObject.SetActive(true);
QrPrize prize = PrizeSystemManager.DequeueQrPrize();
gm.qrPanel.Initialize(prize);
}
}
//добавить qr панель-выдатчик.
else
{
gm.stateMachine.ChangeState(nextState);
}
}
private void OnComplete()
{
gm.stateMachine.ChangeState(nextState);
}
public void exit()
{
if (vitrina != null)
{
vitrina.OnComplete -= OnComplete;
vitrina = null;
}
}
public void update()
{
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1aa945d28720e3c42838820bfc351306
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,44 +0,0 @@
using UnityEngine;
public class RulesState : IState
{
private RulesController rules;
private float timeout = 60f;
private float restTime;
public void enter()
{
rules = GameManager.Instance.rulesController;
SoundManager.instance.playSwitch();
rules.Open();
restTime = timeout;
}
public void exit()
{
SoundManager.instance.playSwitch();
rules.Close();
}
public void update()
{
int direction = 0;
if (In.GetButtonDownAnyPlayer(PlayerAction.left)) direction -= 1;
if (In.GetButtonDownAnyPlayer(PlayerAction.right)) direction += 1;
if (direction != 0)
{
rules.SwitchPage(direction);
restTime = timeout;
SoundManager.instance.playSwitch();
}
if (In.GetButtonDownAnyPlayer(PlayerAction.down) || restTime <= 0)
{
rules.Close();
GameManager.Instance.GotoMenu();
}
restTime -= Time.deltaTime;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 48ff82c7f11da4c4a9f10eaf8e87d6a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,48 +0,0 @@
using UnityEngine;
public class SettingsState : IState
{
float elapsedTime = 0;
float timeToExit = 3f;
public void enter()
{
//SettingsManager.OnSettingsChanged?.Invoke();
GameManager.Instance.AdminPanel.SetActive(true);
elapsedTime = 0;
}
public void exit()
{
GameManager.Instance.AdminPanel.SetActive(false);
}
public void update()
{
if (ShouldExit())
{
SoundManager.instance.playChoose();
GameManager.Instance.GotoMenu();
}
}
private bool ShouldExit()
{
//опрашиваем кнопки
bool startButtonsPressed = In.GetButton(InSignal.startOnePlayer) && In.GetButton(InSignal.startTwoPlayers);
bool serviceButtonPressed = In.GetButton(InSignal.secret) || Input.GetKey(KeyCode.F5);
bool exitPressed = startButtonsPressed || serviceButtonPressed;
//считаем таймеры
if (exitPressed)
elapsedTime += Time.deltaTime;
else
elapsedTime -= Time.deltaTime;
//подгоняем прошедшее время к интервалу
elapsedTime = Mathf.Clamp(elapsedTime, 0f, timeToExit);
//Если жали столько, сколько надо для выхода - надо выходить
return elapsedTime == timeToExit;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f988c08fecbcb304699bc5620223c6ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,16 +0,0 @@
public class SetupPasswordState : IState
{
public void enter()
{
GameManager.Instance.setPasswordPanel.SetActive(true);
}
public void exit()
{
GameManager.Instance.setPasswordPanel.SetActive(false);
}
public void update()
{
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3bf865fa23954834abc37df19d5a20e8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,337 +0,0 @@
using CharacterSystem;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ShowWinnerState : IState
{
Color empty = new Color(0, 0, 0, 0);
CoinCounter coinCounter;
private GameManager gm = GameManager.Instance;
public enum ShowWinnerSubstates { PanelFalling, HandlingInputs, PanelRising, ExitByTime }
public ShowWinnerSubstates subState;
enum EndOption { Restart, Menu }
EndOption option;
RectTransform panel;
Image left, right;
float speedY = 0;
float acceleration = 500;
Vector3 targetDownPosition = new Vector3(0, 447.560f, 0);
Vector3 targetUpPosition = new Vector3(0, 1200, 0);
CheckResult result;
List<SpriteRenderer> winningChips;
Color orange = new Color(1, 0.537794f, 0, 1f);
float TimeRest = 60;
bool NeedToPay => !result.Draw;
public float timeToExit = 0;
public ShowWinnerState()
{
this.result = gm.lastResult;
subState = ShowWinnerSubstates.PanelFalling;
}
public ShowWinnerState(float timeToExit)
{
this.timeToExit = timeToExit;
subState = ShowWinnerSubstates.ExitByTime;
}
public void enter()
{
coinCounter = GameObject.FindAnyObjectByType<CoinCounter>();
gm.timerManager.StopAllTimers();
InitPanel();
if (gm.gameMode == GameMode.pvp)
{
if (!result.Draw)
{
LightUtility.Win();
winningChips = new List<SpriteRenderer>();
CollectChipsList(result);
if (gm.player1score == 5)//полная победа 1 игрока
{
//обнулить очки и выдать приз
gm.player1score = 0;
gm.player2score = 0;
//переход в приз
}
else if (gm.player2score == 5)//полная победа 2 игрока
{
//обнулить очки и выдать приз
gm.player1score = 0;
gm.player2score = 0;
//переход в приз
}
}
}
else if (gm.gameMode == GameMode.pve)
{
if (!result.Draw)
{
winningChips = new List<SpriteRenderer>();
CollectChipsList(result);
if (gm.currentPlayer == Team.Player1)//Последный держал фишку игрок
{
if (gm.vsBotScore == 5)//5 побед над ботом
{
gm.vsBotScore = 0;
}
}
}
}
}
public void exit()
{
if (result.Draw)
{
return;
}
//вернуть альфу фишкам
foreach (SpriteRenderer chip in winningChips)
{
Color c = chip.color;
c.a = 1;
chip.color = c;
//MonoBehaviour.Destroy(chip.GetComponent<SinRotator>());
chip.transform.rotation = Quaternion.identity;
}
}
public void update()
{
switch (subState)
{
case ShowWinnerSubstates.PanelFalling:
DropPanel();
break;
case ShowWinnerSubstates.HandlingInputs:
PollingInputs();
TimerProcessing();
break;
case ShowWinnerSubstates.PanelRising:
RaisePanel();
break;
case ShowWinnerSubstates.ExitByTime:
ExitByTime(); break;
}
if (!result.Draw)
BlinkChips();
}
private void ExitByTime()
{
timeToExit -= Time.deltaTime;
if (timeToExit < 0)
{
timeToExit = 0;
//чистимся и топаем дальше в след раунд
Board.Instance.MakeClearField();
//Фишка ходит первой если ее не побеждали сегодня еще
//текущий бот - последний
bool goingToLastBot = CharactersController.CurrentCharacter.CharacterIndex == GameManager.Instance.botsAmount - 1;
if (goingToLastBot)
{
//Вопрос к логике тут.
//bool bossUpgraded = GameManager.instance.BossUpgraded;
bool bossFirst = SettingsManager.GetString(SettingKey.DIFFICULTY_MODE) != "Прохождение";
Team firstRoundPlayer = bossFirst ? Team.Player2 : Team.Player1;
gm.PrepareRound(firstRoundPlayer);
return;
}
else
{
Team nextPlayer = GameManager.Instance.currentPlayer == Team.Player1 ? Team.Player2 : Team.Player2;
gm.PrepareRound(nextPlayer);
}
}
}
private void TimerProcessing()
{
TimeRest -= Time.deltaTime;
if (TimeRest < 0)
{
option = EndOption.Menu;
subState = ShowWinnerSubstates.PanelRising;
}
}
private void RaisePanel()
{
panel.localPosition = Vector3.MoveTowards(panel.localPosition, targetUpPosition, speedY * Time.deltaTime);
speedY += acceleration * Time.deltaTime;
if (panel.localPosition == targetUpPosition)//панель дошла до верха
{
if (gm.lastResult != null && !gm.lastResult.Draw)
{
foreach (SpriteRenderer chip in winningChips)
{
chip.transform.localScale = Vector3.one;
}
}
switch (option)
{
case EndOption.Restart://чистим поле и перезапуск. Меняем игрока
AvatarEventBus.Instance.OnNewRoundStarted?.Invoke(gm.currentPlayer);
Board.Instance.MakeClearField();
Team nextPlayer = gm.currentPlayer == Team.Player1 ? Team.Player2 : Team.Player1;
gm.PrepareRound(nextPlayer);
break;
case EndOption.Menu://чистим поле и переходим в меню с параметром чтобы панельки съехались обратно
CharactersController.I.HideCharacter();
DualAvatarController.Instance.HideCharacters();
Board.Instance.MakeClearField();
//GameManager.instance.stateMachine.ChangeState(new MenuState(fromGameplay: true));
GameManager.Instance.GotoMenu();
break;
}
}
}
private void PollingInputs()
{
if (In.GetButtonDownAnyPlayer(PlayerAction.right))
{
SoundManager.instance.playSwitch();
option = EndOption.Menu;
right.transform.GetChild(0).GetComponent<Image>().color = orange;
left.transform.GetChild(0).GetComponent<Image>().color = empty;
}
if (In.GetButtonDownAnyPlayer(PlayerAction.left))
{
SoundManager.instance.playSwitch();
option = EndOption.Restart;
right.transform.GetChild(0).GetComponent<Image>().color = empty;
left.transform.GetChild(0).GetComponent<Image>().color = orange;
}
if (In.GetButtonDown(InSignal.startOnePlayer))
{
option = EndOption.Restart;
SoundManager.instance.playChoose();
if (NeedToPay)
paymentAndRestart();
else
restart();
}
if (In.GetButtonDown(InSignal.startTwoPlayers))
{
option = EndOption.Menu;
SoundManager.instance.playChoose();
subState = ShowWinnerSubstates.PanelRising;
}
if (In.GetButtonDownAnyPlayer(PlayerAction.down))
{
SoundManager.instance.playChoose();
if (option == EndOption.Restart)
{
if (NeedToPay)
paymentAndRestart();
else
restart();
}
else
{
subState = ShowWinnerSubstates.PanelRising;
}
}
void paymentAndRestart()
{
int price = PaymentSystem.GetRevengePrice(gm.gameMode);
if (PaymentSystem.TryPay(price))
{
subState = ShowWinnerSubstates.PanelRising;
}
}
void restart()
{
subState = ShowWinnerSubstates.PanelRising;
}
}
void InitPanel()
{
option = EndOption.Restart;
left.transform.GetChild(0).GetComponent<Image>().color = orange;
right.transform.GetChild(0).GetComponent<Image>().color = empty;
}
private void DropPanel()
{
panel.transform.localPosition = Vector3.MoveTowards(panel.transform.localPosition, targetDownPosition, speedY * Time.deltaTime);
speedY += acceleration * Time.deltaTime;
if (panel.localPosition == targetDownPosition)
{
speedY = 0;
subState = ShowWinnerSubstates.HandlingInputs;
}
}
void CollectChipsList(CheckResult result)
{
if (result.WinningIndexes == null) return; //кто то победил по таймеру
foreach (var index in result.WinningIndexes)
{
//todo: разобраться че это я тут закомментил чтобы избавиться от ошибки
//gm.chipTransforms[index.row, index.col].rotation = Quaternion.identity;
//var renderer = gm.chipTransforms[index.row, index.col].GetChild(0).GetComponent<SpriteRenderer>();
//winningChips.Add(renderer);
//renderer.gameObject.AddComponent<SinRotator>().speed = 8;
}
}
void BlinkChips()
{
foreach (SpriteRenderer chip in winningChips)
{
Color c = chip.color;
c.a = 0.2f + Mathf.PingPong(Time.time * 2, 0.8f);
chip.color = c;
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 196aa31466e86b64880e9422ebed726a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,169 +0,0 @@
using CharacterSystem;
using PrizeSystem;
using UnityEngine;
public static class StateRouter
{
private static GameManager gm => GameManager.Instance;
public static void RouteAfterTurn()
{
//var checkResult = FieldChecker.Check(GameManager.instance.currentPlayer);
CheckResult checkResult = null;
gm.lastResult = checkResult;//это неправильно. Нужно при проверке записывать в поле.
TurnEndingResult turnResult = EndOfTurnHandler.Evaluate(checkResult, gm.gameMode, gm.currentPlayer);
if(turnResult == TurnEndingResult.GameContinues)
{
gm.DetermineNextTurn();
return;
}
IState nextState = turnResult switch
{
TurnEndingResult.BotWin => BotWinHandler(),
TurnEndingResult.PlayerWinPve => PlayerWinPveHandler(),
TurnEndingResult.PlayerWinPvp => PlayerWinPvpHandler(gm.currentPlayer),
TurnEndingResult.Draw => DrawHandler(),
_ => ToMenu()
};
gm.stateMachine.ChangeState(nextState);
}
private static IState BotWinHandler()
{
LightUtility.Lose();
CharactersController.CurrentCharacter.GetComponent<Animator>().SetTrigger("Win");
CharactersController.CurrentCharacter.difficultyModule.DecreaseDifficulty();
if (gm.vsBotScore != 0)
gm.vsBotScore -= 1;
EventBus.TriggerEvent(GameEvent.BotWin);
//gm.botScale.SetMedalsCount(gm.vsBotScore);
return new ShowWinnerState();
}
private static IState PlayerWinPveHandler() //тут нужна обертка в приз + обертка в приз/супер приз
{
bool prizing = SettingsManager.GetBool(SettingKey.PRIZING);
if (!prizing) return NextBot();
bool takeOrRisk = SettingsManager.GetBool(SettingKey.TAKE_OR_RISK);
if (!takeOrRisk)
{
TryGivePrize();
return NextBot();
}
//todo: Разобраться в этой дичи
//var character = CharactersController.CurrentCharacter;
//var currentPrize = character.prizeModule;
//bool currentBotHasNonEmptyPrize = character.prizeModule.HasPrize && currentPrize is not EmptyPrize;
//if(character.prizeModule.TryFetchIfTypeMatch(out VitrinaPrize vitrinaPrize))
//{
// int[] readyBoxes = PrizeStandController.GetReadyBoxes();
// if (VitrinaPanel.FindIntersection(readyBoxes, vitrinaPrize.Boxes).Length == 0)
// {
// currentBotHasNonEmptyPrize = false;
// }
//}
//if (!currentBotHasNonEmptyPrize) return NextBot();
return NextBot();
//var nextPrize = PrizeSystemManager.GetFirstNonEmptyPrizeAfter(currentPrize);
//if (nextPrize != null)
//{
// gm.takeOrRiskPanel.SetPrizes(currentPrize, nextPrize);
// gm.timerManager.StopAllTimers();
// return new TakeOrRiskState(NextBot(), gm.takeOrRiskPanel);
//}
//else
//{
// return NextBot();
//}
void TryGivePrize()
{
if (CharactersController.CurrentCharacter.prizeModule.TryFetchPrize(out Prize prize))
{
PrizeSystemManager.GivePrize(prize);
}
}
}
public static IState NextBot()
{
CharactersController.CurrentCharacter.difficultyModule.IncreaseDifficulty();
gm.vsBotScore += 1;
EventBus.TriggerEvent(GameEvent.PlayerWin);
LightUtility.Win();
//gm.botScale.SetMedalsCount(gm.vsBotScore);
//если фишку победили, то повышаем.
if (gm.vsBotScore == gm.botsAmount)
GameManager.Instance.upgradeFeeshkaDifficulty();
if (TotalWin())
{
//ClearAllScales();
return new VictoryState();
}
else
{
return new PrizeState(CreateAutoTransitionState(2f));
}
}
private static IState PlayerWinPvpHandler(Team winner)
{
gm.IncreaseScore(winner);
if (TotalWin())
AvatarEventBus.Instance.OnEndGame?.Invoke(gm.currentPlayer);
else
AvatarEventBus.Instance.OnEndRound?.Invoke(gm.currentPlayer);
if (TotalWin())
{
//ClearAllScales();
return new VictoryState();
}
else
{
return new ShowWinnerState();
}
}
private static IState DrawHandler()
{
EventBus.TriggerEvent(GameEvent.Draw);
return new ShowWinnerState();
}
public static IState ToMenu()
{
Board.Instance.MakeClearField();
GameManager.Instance.GotoMenu();
return null;//
}
// Helpers
private static ShowWinnerState CreateAutoTransitionState(float time)
{
var state = new ShowWinnerState();
state.subState = ShowWinnerState.ShowWinnerSubstates.ExitByTime;
state.timeToExit = time;
return state;
}
private static bool TotalWin() =>
gm.player1score == 5 || gm.player2score == 5 || gm.vsBotScore == gm.botsAmount;
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 15cf6845e43cf2b41bfb574314ebbfa0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,66 +0,0 @@
using CharacterSystem;
using PrizeSystem;
using UnityEngine;
public class TakeOrRiskState : IState
{
private IState nextState;
private TakeOrRiskPanel takeOrRiskPanel;
public float timeElapsed = 0;
public float timeToOpen = 4;
public bool opened = false;
public TakeOrRiskState(IState nextState, TakeOrRiskPanel takeOrRiskPanel)
{
this.nextState = nextState;
this.takeOrRiskPanel = takeOrRiskPanel;
}
public void enter()
{
}
private void TakeOrRiskPanel_OnComplete(TakeOrRiskOption selectedOption)
{
if (selectedOption == TakeOrRiskOption.Take)
{
var character = CharactersController.CurrentCharacter;
if (character.prizeModule.TryFetchPrize(out Prize prize))
PrizeSystemManager.GivePrize(prize);
GameManager.Instance.stateMachine.ChangeState(new PrizeState(StateRouter.ToMenu()));
}
else
{
//Следующий бот
GameManager.Instance.stateMachine.ChangeState(nextState);
}
}
public void exit()
{
takeOrRiskPanel.OnComplete -= TakeOrRiskPanel_OnComplete;
}
public void update()
{
if (!opened)
{
if (timeElapsed < timeToOpen)
timeElapsed += Time.deltaTime;
else
{
takeOrRiskPanel.gameObject.SetActive(true);
takeOrRiskPanel.OnComplete += TakeOrRiskPanel_OnComplete;
opened = true;
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 968f890c735d5bf4b93d90ee008ec65f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
public enum TurnEndingResult
{
GameContinues,
BotWin,
PlayerWinPve,
PlayerWinPvp,
Draw
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 9a9025e10e9f56343b3bfad833b2f424
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,98 +0,0 @@
using TMPro;
using UnityEngine;
public class VictoryState : IState
{
GameManager gameManager;
TextMeshProUGUI ToMenuLabel;
TextMeshProUGUI TimerLabel;
float TimeRest = 15;
IState nextState;
public void enter()
{
LightUtility.Prize();
gameManager = GameManager.Instance;
gameManager.timerManager.StopAllTimers();
ToMenuLabel.gameObject.SetActive(true);
//определяем с какой шкалой мы имеем дело
if (gameManager.gameMode == GameMode.pvp)
{
nextState = new ShowWinnerState();
//if (gameManager.currentPlayer == CellState.Player1)
//{
// scale = gameManager.Player1Scale;
//}
//else
//{
// scale = gameManager.Player2Scale;
//}
}
else
{
//победили ботов
//scale = gameManager.botScale;
//nextState = new VictoryVideoState(new EnterNameState());
}
////вкл анимацию приза
//scale.SetWinState();
//scale.winParticles.Play();
}
public void exit()
{
//выкл анимацию приза
//scale.SetIdleState();
//scale.winParticles.Stop();
ToMenuLabel.gameObject.SetActive(false);
}
public void update()
{
//полинг инпутов
if (In.GetButtonDownAnyPlayer(PlayerAction.down))
{
gameManager.stateMachine.ChangeState(nextState);
}
TimerProcessing();
}
void GivePrizeAndGoMenu()
{
gameManager.stateMachine.ChangeState(nextState);
}
private void TimerProcessing()
{
TimeRest -= Time.deltaTime;
if (TimeRest < 0)
{
GivePrizeAndGoMenu();
}
TimerLabel.text = getTimeText();
}
private string getTimeText()//todo: в утилити бы это вынести
{
string minutes = ((int)(TimeRest / 60)).ToString();
string seconds = ((int)(TimeRest % 60)).ToString();
if (minutes.Length < 2) minutes = "0" + minutes;
if (seconds.Length < 2) seconds = "0" + seconds;
string result = minutes + ":" + seconds;
return result;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 399efd7369e44764fb25c73b5453d995
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,46 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VictoryVideoState : IState
{
IState nextState;
float startTime;
float videoLength;
public VictoryVideoState(IState nextState)
{
this.nextState = nextState;
}
public void enter()
{
VideoUtility.PlayEnding(); VideoUtility.PlayEnding();
SoundManager.instance.music.mute = true;
SoundManager.instance.SetMusicVolumeToVideo();
startTime = Time.time;
videoLength = VideoUtility.victoryLength;
}
public void exit()
{
VideoUtility.PlayFon();
SoundManager.instance.music.mute = false;
}
public void update()
{
bool anyInput = In.GetButtonDownAnyPlayer(PlayerAction.left) ||
In.GetButtonDownAnyPlayer(PlayerAction.right) ||
In.GetButtonDownAnyPlayer(PlayerAction.down) ||
In.GetButtonDown(InSignal.startOnePlayer) ||
In.GetButtonDown(InSignal.startTwoPlayers);
bool kinoVse = (Time.time - startTime) > videoLength;
if (anyInput || kinoVse)
{
GameManager.Instance.stateMachine.ChangeState(nextState);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1ddce44ea09ab9e4b9cb0047fbed9050
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,16 +0,0 @@
//Выбор номера ячейки витрины
public class VitrinaChoseState : IState
{
VitrinaPanel vitrinaPanel;
public void enter()
{
vitrinaPanel = GameManager.Instance.vitrinaPanel;
vitrinaPanel.gameObject.SetActive(true);
}
public void update() { }
public void exit()
{
vitrinaPanel.gameObject.SetActive(false);
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 961834e0e84be814e888c8e9905a74ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -15,8 +15,6 @@ public class GameManager : MonoBehaviour
public int botsAmount = 5;
[Header("General")]
public GameStateMachine stateMachine;
public static GameManager Instance;
public GameObject AdminPanel, NumberPanel;
public TimerManager timerManager;
@ -49,14 +47,6 @@ public class GameManager : MonoBehaviour
[Header("Панели ввода")]
public TextInput nameInput;
public TextInput ValutaNameInput;
public TextInput NumberTech;
public NumberInput pricePveInput;
public NumberInput pricePvpInput;
public NumberInput pricePveRevengeInput;
public NumberInput prizesAvailableInput;
public NumberInput pulsesToResetDifficultyInput;
public NumberInput valutaPerPulseInput;
public Leaderboard leaderboard;
public GameObject CharactersConfigurator;
@ -220,7 +210,7 @@ public class GameManager : MonoBehaviour
if (gameMode == GameMode.pvp)//переключаем таймеры только в pvp
{
timerManager.SetActiveTimer(currentPlayer);
LightUtility.Player(currentPlayer);
LightSystem.Player(currentPlayer);
}
}
@ -271,7 +261,7 @@ public class GameManager : MonoBehaviour
yield return new WaitForSeconds(3600f); // ✅ Проверка каждый час
double lastRecordTime = PlayerPrefs.GetFloat("LastBotRecord", 0);
double currentTime = Utils.GetUnixTimestamp();
double currentTime = (DateTime.UtcNow - new System.DateTime(1970, 1, 1)).TotalSeconds;
if (currentTime - lastRecordTime >= 172800f)
{

View File

@ -1,24 +0,0 @@
using TMPro;
using UnityEngine;
public class HSV_TMPRO : MonoBehaviour
{
public TextMeshProUGUI label;
public float speed = 1f;
private float hue = 0f;
private void OnEnable()
{
label = GetComponent<TextMeshProUGUI>();
}
private void Update()
{
// Изменяем оттенок (hue) от 0 до 1
hue += Time.deltaTime * speed;
hue %= 1f; // Ограничиваем от 0 до 1
// Преобразуем HSV в RGB
Color color = Color.HSVToRGB(hue, 1f, 1f);
label.color = color;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d5ba96e91114b0544ba59501932dd77c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,101 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class NumberInput : MonoBehaviour
{
[Header("Ключ prefs")]
[SerializeField] private string key;
[SerializeField] private bool loadData;
[SerializeField] private bool saveDataOnClose = true;
[Header("Звуки")]
[SerializeField] private AudioClip switchSlotSound;
[SerializeField] private AudioClip switchLetterSound;
[SerializeField] private AudioClip acceptSound;
[SerializeField] private AudioClip openSound;
[Header("Скорость переключения")]
[SerializeField] private float MaxSpeedLetterPerSecond = 8;
[SerializeField] private float MinSpeedLetterPerSecond = 3;
[SerializeField] private float MaxSpeedTime = 3;
[SerializeField] private float MinSpeedTime = 0.5f;
private float switchButtonPressedTime = 0;
private float letterSwitchSpeed = 0;
private float switchDelayRest = 1;
//[SerializeField] private int defaultValue = 1;
[SerializeField] private int minValue = 1;
[SerializeField] private int maxValue = 999;
[SerializeField] private int currentValue;
[SerializeField] TextMeshProUGUI valueLabel;
public void Initialize()
{
LoadSavedData();
SoundManager.instance.playClip(openSound);
}
public int AcceptAndClose()
{
if (!string.IsNullOrEmpty(key) && saveDataOnClose)
{
PlayerPrefs.SetInt(key, currentValue);
}
SoundManager.instance.playClip(acceptSound);
return currentValue;
}
private void LoadSavedData()
{
currentValue = 1;
if (loadData)
currentValue = PlayerPrefs.GetInt(key, 1);
// Заполняем сохраненными данными
valueLabel.text = currentValue.ToString();
}
public void SwitchValue(int continiousDirection)
{
continiousDirection = Mathf.Clamp(continiousDirection, -1, 1);
if (continiousDirection == 0)//сброс переключения
{
switchDelayRest = 0;
switchButtonPressedTime = 0;
return;
}
if (switchDelayRest < 0)
{
//переключение
currentValue = Math.Clamp(currentValue + continiousDirection, minValue, maxValue);
valueLabel.text = currentValue.ToString();
recalculateRest();
}
switchDelayRest -= Time.deltaTime;
switchButtonPressedTime += Time.deltaTime;
void recalculateRest()
{
float k = (MaxSpeedLetterPerSecond - MinSpeedLetterPerSecond)
/ (MaxSpeedTime - MinSpeedTime);
float b = MinSpeedLetterPerSecond - k * MinSpeedTime;
letterSwitchSpeed = k * switchButtonPressedTime + b;
letterSwitchSpeed = Mathf.Clamp(letterSwitchSpeed,
MinSpeedLetterPerSecond,
MaxSpeedLetterPerSecond);
switchDelayRest = 1 / letterSwitchSpeed;
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8a0b385f42d212146ae051d31ee01b71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,7 +2,7 @@
using UnityEngine;
//Зависит от ComWrapper
public static class LightUtility
public static class LightSystem
{
private const string LIGHT_COMMAND_PREFIX = "80";
public static void Idle()

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5faca1e92316db048865cef609bb0cbc

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 28352dc78d0472f45b9a32204e37f456
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class PaymentEmulator : MonoBehaviour
{
@ -10,5 +8,4 @@ public class PaymentEmulator : MonoBehaviour
{
if (Input.GetKeyDown(key)) PaymentSystem.AddCredit();
}
}
}

View File

@ -1,67 +0,0 @@
using System.Collections;
using TMPro;
using UnityEngine;
enum PrefsType { str, intNumber, floatNumber }
[RequireComponent(typeof(TextMeshProUGUI))]
public class PrefsApplicator : MonoBehaviour
{
[SerializeField] PrefsType prefsType = PrefsType.str;
[SerializeField] string prefix;
[SerializeField] string suffix;
[SerializeField] string prefsKey;
[SerializeField] string defaultText;
Coroutine coroutine;
TextMeshProUGUI label;
private void OnEnable() => StartPolling();
private void OnDisable() => StopPolling();
void Refresh()
{
string data;
if (PlayerPrefs.HasKey(prefsKey))
{
data = prefsType switch
{
PrefsType.str => PlayerPrefs.GetString(prefsKey),
PrefsType.intNumber => PlayerPrefs.GetInt(prefsKey).ToString(),
PrefsType.floatNumber => PlayerPrefs.GetFloat(prefsKey).ToString(),
_ => PlayerPrefs.GetString(prefsKey)
};
}
else
{
data = defaultText;
}
string message = $"{prefix} {data} {suffix}";
label.text = message;
}
void StartPolling()
{
label = GetComponent<TextMeshProUGUI>();
coroutine = StartCoroutine(poll());
}
void StopPolling()
{
if (coroutine != null)
StopCoroutine(coroutine);
}
IEnumerator poll()
{
while (true)
{
Refresh();
yield return new WaitForSeconds(5);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3a3ea547a8c834648ae7cd81280d5cb6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -21,4 +21,5 @@
public const string SERIAL = "Serial";
public const string PRIZE_GIVEN_BUFFER = "PrizeGivenBuffer";
}

View File

@ -0,0 +1,22 @@
using CharacterSystem;
using UnityEngine;
public class CharacterPrizeConfigurator : MonoBehaviour
{
[SerializeField] private CharacterSelectionPanel _characterSelection;
[SerializeField] private PrizesSelector _prizesSelector;
private void OnEnable()
{
_characterSelection.gameObject.SetActive(true);
_prizesSelector.gameObject.SetActive(false);
_characterSelection.OnCharacterSelected += OnCharacterSelected;
}
private void OnCharacterSelected(Character character)
{
_characterSelection.gameObject.SetActive(false);
_prizesSelector.Open(character);
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1bf3043857e54fd41b0d39086cd9c3be

View File

@ -1,179 +0,0 @@
using CharacterSystem;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace PrizeSystem
{
public class CharacterPrizeConfigurator : MonoBehaviour
{
[SerializeField] TypeSelectionPanel typePanel;
[SerializeField] PrizeSettingPanel prizePanel;
[SerializeField] CharacterSelectionPanel characterPanel;
[SerializeField] List<GameObject> controlPanels;
[SerializeField] private Color AccentColor;
[SerializeField] private AudioClip ClickClip;
int controlIndex = 0;
bool readyToWork = false;
float exitTimer = 0;
private GameObject SelectedPanel => controlPanels[controlIndex];
IControl SelectedControl => SelectedPanel.GetComponent<IControl>();
private List<Prize> prizesCache;
private Coroutine BlinkCoroutine;
private void OnEnable()
{
readyToWork = false;
controlIndex = 0;
SetupPanels();
prizesCache = PrizeSerializer.LoadPrizes();
Debug.Log($"Загружены призы: \n{PrizeSerializer.SerializePrizes(prizesCache)}");
prizePanel.SetPanelByPrize(prizesCache[characterPanel.CharacterIndex]);
typePanel.SetType(prizesCache[0].PrizeType);
typePanel.OnTypeChanged += TypePanel_OnTypeChanged;
characterPanel.BeforeCharacterChange += CharacterPanel_BeforeCharacterChange;
characterPanel.OnCharacterChanged += CharacterPanel_OnCharacterChanged;
}
private void OnDisable()
{
typePanel.OnTypeChanged -= TypePanel_OnTypeChanged;
characterPanel.OnCharacterChanged -= CharacterPanel_OnCharacterChanged;
LightOnPanel(false);
}
private void TypePanel_OnTypeChanged(PrizeType newType)
{
prizePanel.SetPanelByType(newType);
}
private void CharacterPanel_BeforeCharacterChange(Character oldCharacter)
{
prizesCache[characterPanel.CharacterIndex] = prizePanel.GetPrize();
}
private void CharacterPanel_OnCharacterChanged(Character character)
{
Prize prize = prizesCache[characterPanel.CharacterIndex];
typePanel.SetType(prize.PrizeType);
prizePanel.SetPanelByPrize(prize);
}
#region ОБРАБОТКА ВВОДА
private void Update()
{
if (readyToWork)
{
var input = GetInputs();
if (input.Direction != 0) SelectedControl.Swipe(input.Direction);
if (input.Switch) SelectedControl.Switch();
if (input.NextPanel) NextPanel();
SaveProcessing(input.HoldSave);
}
else
{
if(!In.AnyButton()) readyToWork = true;
}
}
private (int Direction, bool Switch, bool NextPanel, bool HoldSave) GetInputs()
{
int Direction = 0;
if (In.GetButtonAnyPlayer(PlayerAction.right)) Direction += 1;
if (In.GetButtonAnyPlayer(PlayerAction.left)) Direction -= 1;
bool Switch = In.GetButtonDown(InSignal.down1);
bool NextPanel = In.GetButtonDown(InSignal.down2);
bool HoldExit = In.GetButton(InSignal.startOnePlayer) && In.GetButton(InSignal.startTwoPlayers);
return (Direction, Switch, NextPanel, HoldExit);
}
#endregion
private void NextPanel()
{
LightOnPanel(false);
controlIndex = (controlIndex + 1 + controlPanels.Count) % controlPanels.Count;
LightOnPanel(true);
if(ClickClip!= null) {SoundManager.instance.playClip(ClickClip); }
}
private void LightOnPanel(bool on)
{
if (on && SelectedPanel.TryGetComponent<Graphic>(out var graphic))
{
BlinkCoroutine = StartCoroutine(BlinkAnimation(graphic));
}
else
{
StopCoroutine(BlinkCoroutine);
BlinkCoroutine = null;
SelectedPanel.GetComponent<Graphic>().color = Color.black;
}
}
//вероятно это будет единственный метод для обновления.
private void SetupPanels()
{
LightOnPanel(true);
}
private void SaveProcessing(bool HoldSave)
{
if (HoldSave) exitTimer += Time.deltaTime;
else exitTimer -= Time.deltaTime;
exitTimer = Mathf.Clamp(exitTimer, 0f, 2f);
if (exitTimer >= 2)
{
exitTimer = 0;
Save();
Exit();
}
}
private void Save()
{
//Кэшнуть текущего персонажа
prizesCache[characterPanel.CharacterIndex] = prizePanel.GetPrize();
PrizeSerializer.SavePrizes(prizesCache);
CharactersController.I.RefreshPrizes();
}
private void Exit()
{
GameManager.Instance.stateMachine.ChangeState(new SettingsState());
}
IEnumerator BlinkAnimation(Graphic graphic)
{
while (true)
{
graphic.color = Vector4.Lerp(AccentColor, Color.black, Mathf.PingPong(Time.time, 1));
yield return null;
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 402c502466ff4494499138f429fe8f04
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,58 +1,126 @@
using CharacterSystem;
using PrizeSystem;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class CharacterSelectionPanel : MonoBehaviour, IControl
public class CharacterSelectionPanel : MonoBehaviour, IControlable
{
public event Action<Character> BeforeCharacterChange;
public event Action<Character> OnCharacterChanged;
public event Action<Character> OnCharacterSelected;
public event Action OnExitRequested;
[SerializeField] TextMeshProUGUI CharacterNameLabel;
[SerializeField] Image CharacterIcon;
[SerializeField] float ChangeCharacterInterval = 0.15f;
[SerializeField] AudioClip ClickSound;
private float LastSwipeTime = 0;
private Character[] characters;
public int CharacterIndex { get; private set; }
[SerializeField] RectTransform _prizeTable;
[SerializeField] PrizeView _prizeViewPrefab;
private Character[] characters;
private int characterIndex = 0;
[SerializeField] private List<MSignalButton> buttons;
[SerializeField] private MSignalButton _selectButton;
[SerializeField] private MSignalButton _exitButton;
private int buttonIndex = 0;
public int CharactersCount => characters.Length;
public Character SelectedCharacter => characters[CharacterIndex];
private bool CanSwipe => Time.time - LastSwipeTime > ChangeCharacterInterval;
public Character SelectedCharacter => characters[characterIndex];
private void OnEnable()
public bool ControlsEnabled { get; set; }
private MSignalButton SelectedButton => buttons[buttonIndex];
private void Update()
{
UpdateControls();
}
private void Start()
{
_selectButton.OnClick += _selectButton_OnClick;
_exitButton.OnClick += _exitButton_OnClick;
characters = CharactersController.GetCharactersArray();
CharacterIndex = 0;
characterIndex = 0;
DisplaySelectedCharacter();
buttonIndex = 0;
SelectedButton.SelectAnimation();
DisplaySelectedCharacter();
}
public void Swipe(int direction)
private void _selectButton_OnClick()
{
if (CanSwipe)
{
if (ClickSound != null) { SoundManager.instance.playClip(ClickSound); }
BeforeCharacterChange?.Invoke(SelectedCharacter);
CharacterIndex = (CharacterIndex + direction + CharactersCount) % CharactersCount;
DisplaySelectedCharacter();
OnCharacterChanged?.Invoke(SelectedCharacter);
LastSwipeTime = Time.time;
}
OnCharacterSelected?.Invoke(SelectedCharacter);
}
public void Switch() { }
private void _exitButton_OnClick()
{
OnExitRequested?.Invoke();
}
public void SwitchCharacter(int direction)
{
if (direction == 0) return;
characterIndex = (characterIndex + direction + characters.Length) % characters.Length;
DisplaySelectedCharacter();
}
public void SwitchButton(int direction)
{
if (direction == 0) return;
int newIndex = Mathf.Clamp(buttonIndex + direction, 0, buttons.Count - 1);
if (newIndex == buttonIndex) return;
SelectedButton.DeselectAnimation();
buttonIndex = newIndex;
SelectedButton.SelectAnimation();
}
private void DisplaySelectedCharacter()
{
CharacterNameLabel.text = SelectedCharacter.characterName;
CharacterIcon.sprite = SelectedCharacter.visualModule.icon;
ClearTable();
var set = PrizeSystemManager.PrizeContainer.Sets[SelectedCharacter.CharacterIndex];
DisplayPrizeSet(set);
}
}
public void UpdateControls()
{
int dir_h = In.GetAxis(Axis.Horizontal, JoystickSide.Both);
SwitchCharacter(dir_h);
int dir_v = -In.GetAxis(Axis.Vertical, JoystickSide.Both);
SwitchButton(dir_v);
SelectedButton.TakeInput(In.GetButtonAnyPlayer(PlayerAction.action));
}
private void ClearTable()
{
for (int i = _prizeTable.childCount - 1; i >= 0; i--)
{
var go = _prizeTable.GetChild(i).gameObject;
Destroy(go);
}
}
private void DisplayPrizeSet(PrizeSet prizeSet)
{
foreach (var item in prizeSet.Prizes)
{
var view = Instantiate(_prizeViewPrefab, _prizeTable);
view.SetPrize(item);
}
}
}

View File

@ -1,14 +0,0 @@
public interface IControl
{
/// <summary>
/// Для передачи сигнала "Листать". Выбор следующего пункта.
/// </summary>
public void Switch();
/// <summary>
/// Контракт для передачи в элемент управления направления взаимодействия
/// </summary>
/// <param name="direction">Направление взаимодействия. Предполагается -1, 0 или 1</param>
public void Swipe(int direction);
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b76d8a33e9c614948aeeea94d198e6e7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,11 +1,11 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace PrizeSystem
{
public class PrizeSettingPanel : MonoBehaviour, IControl
public class PrizeSettingPanel : MonoBehaviour
{
[SerializeField] AbstractPrizeConfigurator CurrentConfigurator;
@ -26,7 +26,7 @@ namespace PrizeSystem
}
catch
{
Debug.LogError("Не нашел панель по типу. Вероятно мапинг не заполнен", this);
Debug.LogError("Не нашел панель по типу. Вероятно мапинг не заполнен", this);
return null;
}
@ -56,7 +56,7 @@ namespace PrizeSystem
//Конфигурировать панель
//Конфигурировать панель

View File

@ -1,9 +1,9 @@
using System;
using System;
using TMPro;
using UnityEngine;
namespace PrizeSystem{
public class TypeSelectionPanel : MonoBehaviour, IControl
public class TypeSelectionPanel : MonoBehaviour
{
public event Action<PrizeType> OnTypeChanged;

Some files were not shown because too many files have changed in this diff Show More