上车前所有逻辑

This commit is contained in:
oldpeper 2024-10-22 11:31:23 +08:00
parent 2af88c3147
commit e7d6487487
21 changed files with 10513 additions and 103 deletions

8
d2/Assets/Demigiant.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0601edf0b587e8b4eae85ba535c269cb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,14 +0,0 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>DOTweenUpgradeManager</name>
</assembly>
<members>
<member name="T:DG.DOTweenUpgradeManager.Autorun">
<summary>
This class and its whole library are deleted the first time DOTween's setup is run after an upgrade (or after a new install).
NOTE: DidReloadScripts doesn't work on first install so it's useless, InitializeOnLoad is the only way
</summary>
</member>
</members>
</doc>

View File

@ -1,21 +0,0 @@
fileFormatVersion: 2
guid: 2bf936a5d80799e4e88ec9270fea75a4
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

8
d2/Assets/Resources.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8d971d6ebe9a5954ba04f03eb63d7f79
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,48 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 16995157, guid: a811bde74b26b53498b4f6d872b09b6d, type: 3}
m_Name: DOTweenSettings
m_EditorClassIdentifier:
useSafeMode: 1
safeModeOptions:
nestedTweenFailureBehaviour: 0
timeScale: 1
useSmoothDeltaTime: 0
maxSmoothUnscaledTime: 0.15
rewindCallbackMode: 0
showUnityEditorReport: 0
logBehaviour: 0
drawGizmos: 1
defaultRecyclable: 0
defaultAutoPlay: 3
defaultUpdateType: 0
defaultTimeScaleIndependent: 0
defaultEaseType: 6
defaultEaseOvershootOrAmplitude: 1.70158
defaultEasePeriod: 0
defaultAutoKill: 1
defaultLoopType: 0
debugMode: 0
debugStoreTargetId: 0
showPreviewPanel: 1
storeSettingsLocation: 0
modules:
showPanel: 0
audioEnabled: 1
physicsEnabled: 1
physics2DEnabled: 1
spriteEnabled: 1
uiEnabled: 1
textMeshProEnabled: 0
tk2DEnabled: 0
showPlayingTweens: 0
showPausedTweens: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 50e8b0c9a089c7f41a780927e3de4b28
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,35 @@
using System;
using Script.Map;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Script
{
public class GameManager : MonoBehaviour
{
public static GameManager ins;
[SerializeField] private PassengerObject _passengerObject;
[SerializeField] private Transform passengerParent;
private void Awake()
{
ins = this;
}
// Start is called before the first frame update
void Start()
{
MapManager.ins.InitPlayData();
foreach (var grid in MapManager.ins.MapGrid)
{
if (!grid.Open) continue;
var colorIndex =Random.Range(0, 3);
var passenger = Instantiate(_passengerObject.gameObject, passengerParent).GetComponent<PassengerObject>();
passenger.transform.position=grid.transform.position;
passenger.passColor = (ColorEnum)colorIndex;
grid.passenger = passenger;
grid.buttonAction = grid.PlaySystemEvent;
}
}
// Update is called once per frame
@ -15,5 +37,23 @@ namespace Script
{
}
public void MoveWaitEvent(Grid grid)
{
if (MapManager.ins.WaitSlot.MoveOpen(out var moveGrid))
{
if (grid.NorthOpen())
{
moveGrid.passenger = grid.passenger;
grid.passenger = null;
moveGrid.PassengerAni();
}
}
}
public void MoveCarEvent()
{
}
}
}

View File

@ -6,6 +6,7 @@ using UnityEngine.Serialization;
namespace Script.Map
{
//地图总控制脚本
public class MapManager : MonoBehaviour
{
public static MapManager ins;
@ -13,29 +14,60 @@ namespace Script.Map
[SerializeField] private List<CarObject> carObjects;
[SerializeField] private GameObject templateGrid;
public WaitSlot WaitSlot => _waitSlot;
[SerializeField] private WaitSlot _waitSlot;
public Grid[,] MapGrid ;
[SerializeField] private List<Grid> MapGrids;
[SerializeField] private Transform gridParent;
public int x { get; private set; }
public int y { get; private set; }
public int x => mX;
[SerializeField] private int mX;
public int y => mY;
[SerializeField] private int mY;
public bool InitReady { get; private set; } = false;
private void Awake()
{
ins = this;
}
/// <summary>
/// 初始化游戏数据
/// </summary>
public void InitPlayData()
{
MapGrid = new Grid[x, y];
foreach (var grid in MapGrids)
{
MapGrid[grid.X, grid.Y] = grid;
}
}
[InspectorButton("初始化地图")]
public void InitMap()
{
if (ins==null)
{
ins = this;
}
Init(10, 10);
}
/// <summary>
/// 地图生成调用
/// </summary>
/// <param name="最大纵向列数x"></param>
/// <param name="最大横向行数y"></param>
public void Init(int _x,int _y)
{
InitReady = false;
x = _x;
y = _y;
mX = _x;
mY = _y;
MapGrid = new Grid[x, y];
StartCoroutine(InitGrid());
InitGrid();
}
private IEnumerator InitGrid(Action action=null)
private void InitGrid(Action action=null)
{
for (var i = 0; i < x; i++)
{
@ -45,7 +77,7 @@ namespace Script.Map
MapGrid[i,j].SetData(i,j);
MapGrid[i,j].SetBool(true);
MapGrid[i, j].SetRestPostion();
yield return null;
MapGrids.Add(MapGrid[i,j]);
}
}

View File

@ -1,76 +1,136 @@
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using Script;
using Script.Map;
using UnityEngine;
using UnityEngine.UI;
//格子脚本,用于获取相邻信息
public class Grid : MonoBehaviour
{
public int x { get; private set; }
public int y { get; private set; }
public bool Open { get; private set; }
public Grid East { get; private set; }
public Grid South { get; private set; }
public Grid West { get; private set; }
public Grid North { get; private set; }
public int X => gx;
[SerializeField] private int gx;
public int Y => gy;
[SerializeField] private int gy;
public bool Open => gOpen;
[SerializeField] private bool gOpen=true;
public Grid East => gEast;
[SerializeField] private Grid gEast;
public Grid South => gSouth;
[SerializeField] private Grid gSouth;
public Grid West => gWest;
[SerializeField] private Grid gWest;
public Grid North => gNorth;
[SerializeField] private Grid gNorth;
public bool aniPlay => gAniPlay;
[SerializeField] private bool gAniPlay=false;
public PassengerObject passenger;
public Action action = null;
public Action buttonAction=null;
private void Awake()
{
GetComponent<Button>().onClick.AddListener(ButtonEvent);
}
public void SetData(int _x,int _y)
{
x = _x;
y = _y;
gx = _x;
gy = _y;
}
public void SetBool(bool bo)
{
Open = bo;
gOpen= bo;
}
public void SetRestPostion()
{
transform.localPosition = new Vector3(x*100, y * -100,0);
transform.localPosition = new Vector3(X*100, Y * -100,0);
}
public void SetAdjacentGrid()
{
if (x - 1>=0)
if (X - 1>=0)
{
MapManager.ins.MapGrid[x - 1,y].SetEast(this);
MapManager.ins.MapGrid[X - 1,Y].SetEast(this);
}
if (y - 1>=0)
if (Y - 1>=0)
{
MapManager.ins.MapGrid[x,y - 1].SetSouth(this);
MapManager.ins.MapGrid[X,Y - 1].SetSouth(this);
}
if (y + 1<MapManager.ins.y)
if (Y + 1<MapManager.ins.y)
{
MapManager.ins.MapGrid[x,y + 1].SetNorth(this);
MapManager.ins.MapGrid[X,Y + 1].SetNorth(this);
}
if (x + 1<MapManager.ins.x)
if (X + 1<MapManager.ins.x)
{
MapManager.ins.MapGrid[x + 1,y].SetWest(this);
MapManager.ins.MapGrid[X + 1,Y].SetWest(this);
}
}
public void SetEast(Grid grid)
{
East = grid;
gEast = grid;
}
public void SetSouth(Grid grid)
{
South = grid;
gSouth = grid;
}
public void SetWest(Grid grid)
{
West = grid;
gWest = grid;
}
public void SetNorth(Grid grid)
{
North = grid;
gNorth = grid;
}
public bool NorthOpen()
{
if (gAniPlay)
{
return false;
}
if (gNorth==null)
{
return true;
}
return gNorth.passenger==null;
}
/// <summary>
/// 播放当前点动画
/// </summary>
public void PassengerAni()
{
gAniPlay = true;
passenger.transform.DOMove(transform.position, 0.2f).OnComplete(() =>
{
gAniPlay = false;
action?.Invoke();
});
}
public void ResetPosition()
{
}
private void ButtonEvent()
{
buttonAction?.Invoke();
}
public void PlaySystemEvent()
{
GameManager.ins.MoveWaitEvent(this);
}
// Start is called before the first frame update
void Start()
{

View File

@ -1,10 +1,43 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//人物脚本
public class PassengerObject : MonoBehaviour
{
public ColorEnum passColor=ColorEnum.white;
public ColorEnum passColor
{
get { return objColor; }
set
{
objColor = value;
if (_image==null)
{
_image = GetComponent<Image>();
}
switch (objColor)
{
case ColorEnum.white:
_image.color = Color.white;
break;
case ColorEnum.red:
_image.color = Color.red;
break;
case ColorEnum.yellow:
_image.color = Color.yellow;
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
[SerializeField]
private ColorEnum objColor=ColorEnum.white;
[SerializeField] private Image _image;
// Start is called before the first frame update
void Start()
{

View File

@ -0,0 +1,36 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class WaitSlot : MonoBehaviour
{
[SerializeField]
private List<Grid> waitGrids;
private void Awake()
{
foreach (var grid in waitGrids)
{
grid.action = AniEndEvent;
}
}
public bool MoveOpen(out Grid mGrid)
{
mGrid = null;
foreach (var grid in waitGrids.Where(grid => grid.passenger==null))
{
mGrid = grid;
return true;
}
return false;
}
public void AniEndEvent()
{
}
}

View File

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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ccb270f13b66d574b889e6200c8c954c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
d2/Assets/prefab.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f3e39cc37c60b5b4baccef6d065b9a34
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,144 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5354859336855344782
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2200061265831995976}
- component: {fileID: 5934320313861736961}
- component: {fileID: 885723422504026729}
- component: {fileID: 738782307581096147}
- component: {fileID: 4069025118584030439}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2200061265831995976
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354859336855344782}
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}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -2188, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5934320313861736961
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354859336855344782}
m_CullTransparentMesh: 1
--- !u!114 &885723422504026729
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354859336855344782}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
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 &738782307581096147
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354859336855344782}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eb5e86ba02993fd42afb26dde82ca88c, type: 3}
m_Name:
m_EditorClassIdentifier:
gx: 0
gy: 0
gOpen: 1
gEast: {fileID: 0}
gSouth: {fileID: 0}
gWest: {fileID: 0}
gNorth: {fileID: 0}
gAniPlay: 0
passenger: {fileID: 0}
--- !u!114 &4069025118584030439
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354859336855344782}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 885723422504026729}
m_OnClick:
m_PersistentCalls:
m_Calls: []

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 3df9fdaadcb4c394e826a4d8d20bb952
TextScriptImporter:
guid: 347afb8e82ae236408817cc553201f8d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:

View File

@ -0,0 +1,92 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3177501339843202458
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6642763178059109073}
- component: {fileID: 663669390409551146}
- component: {fileID: 8433908050974999130}
- component: {fileID: 2422974875141270476}
m_Layer: 5
m_Name: passenger
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6642763178059109073
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3177501339843202458}
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}
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: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &663669390409551146
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3177501339843202458}
m_CullTransparentMesh: 1
--- !u!114 &8433908050974999130
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3177501339843202458}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0.10849059, b: 0.10849059, a: 1}
m_RaycastTarget: 0
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 &2422974875141270476
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3177501339843202458}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6f58acfc3b7dd6d4781eecbf343cf983, type: 3}
m_Name:
m_EditorClassIdentifier:
objColor: 0
_image: {fileID: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 50b0450c3204b6a4597a37c30269108b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -8,6 +8,15 @@ EditorUserSettings:
RecentlyUsedSceneGuid-0:
value: 515250075c0c595e5f5a5e71122159444e4e4a2f7a7d7f602f284d66b4b76661
flags: 0
RecentlyUsedSceneGuid-1:
value: 02020157070050580c5b582340215c44464f4b297f7d7e64792d1c62b1e16269
flags: 0
RecentlyUsedSceneGuid-2:
value: 5550060701065c085e5c5924162609444f4f4b297e70226674284564b1b8326d
flags: 0
RecentlyUsedSceneGuid-3:
value: 0204525104005f5f5e5d5526117b0b44424e4073752d2536747c1b31e7b3673c
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
flags: 0