您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
41 行
1.2 KiB
41 行
1.2 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.Collections;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
using Unity.NetCode;
|
|
|
|
// TODO (petera) Rename this to GameModeState or something even better
|
|
|
|
// This is data is replicated to the clients about the 'global' state of
|
|
// the game mode, scores etc.
|
|
|
|
public class GameMode : MonoBehaviour, IConvertGameObjectToEntity
|
|
{
|
|
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
|
|
{
|
|
// no reason to pass over any variables as this is only
|
|
// used from code. but we make a prefab and conversion
|
|
// code to have it picked up by netcode
|
|
dstManager.AddComponentData(entity, new GameModeData());
|
|
}
|
|
}
|
|
|
|
|
|
[Serializable]
|
|
public struct GameModeData : IComponentData
|
|
{
|
|
[GhostDefaultField]
|
|
public int gameTimerSeconds;
|
|
[GhostDefaultField]
|
|
public NativeString64 gameTimerMessage;
|
|
[GhostDefaultField]
|
|
public NativeString64 teamName0;
|
|
[GhostDefaultField]
|
|
public NativeString64 teamName1;
|
|
[GhostDefaultField]
|
|
public int teamScore0;
|
|
[GhostDefaultField]
|
|
public int teamScore1;
|
|
}
|