strange lags, object creation incapsiulation, gameobjectDeletionOnCLient fixed, soundmanager temp solution
TODO: ResourceMonitor, disply quantity of objects on scene
This commit is contained in:
parent
685011fd61
commit
1a37b10da4
2 changed files with 31 additions and 18 deletions
|
@ -208,22 +208,7 @@ namespace ZoFo.GameCore
|
|||
|
||||
else if (update is UpdateGameObjectCreated)
|
||||
{
|
||||
//TODO
|
||||
Entity created_gameObject;
|
||||
if ((update as UpdateGameObjectCreated).GameObjectType == "Player")
|
||||
{
|
||||
created_gameObject = new Player((update as UpdateGameObjectCreated).position.GetVector2());
|
||||
gameObjects.Add(created_gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
Type t = Type.GetType("ZoFo.GameCore.GameObjects." + (update as UpdateGameObjectCreated).GameObjectType);
|
||||
GameObject gameObject = Activator.CreateInstance(t, (update as UpdateGameObjectCreated).position.GetVector2()) as GameObject;
|
||||
if (gameObject is Entity)
|
||||
(gameObject as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
|
||||
gameObjects.Add(gameObject);
|
||||
}
|
||||
(gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
|
||||
Update_GameObjectCreated(update as UpdateGameObjectCreated);
|
||||
|
||||
}
|
||||
else if (update is UpdateGameObjectWithoutIdCreated)
|
||||
|
@ -284,6 +269,26 @@ namespace ZoFo.GameCore
|
|||
}
|
||||
|
||||
}
|
||||
#region UpdatesAnalysis
|
||||
public void Update_GameObjectCreated(UpdateGameObjectCreated update)
|
||||
{
|
||||
|
||||
if (update.GameObjectType == "Player")
|
||||
{
|
||||
Player player = new Player(update.position.GetVector2());
|
||||
player.SetIdByClient(update.IdEntity);
|
||||
gameObjects.Add(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
Type t = Type.GetType("ZoFo.GameCore.GameObjects." + update.GameObjectType);
|
||||
GameObject gameObject = Activator.CreateInstance(t, update.position.GetVector2()) as GameObject;
|
||||
if (gameObject is Entity)
|
||||
(gameObject as Entity).SetIdByClient(update.IdEntity);
|
||||
gameObjects.Add(gameObject);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
public void UpdatePlayerHealth(UpdatePlayerParametrs update)
|
||||
{
|
||||
|
||||
|
@ -346,6 +351,9 @@ namespace ZoFo.GameCore
|
|||
|
||||
public void DeleteObject(GameObject gameObject)
|
||||
{
|
||||
if (gameObjects.Contains(gameObject))
|
||||
gameObjects.Remove(gameObject);
|
||||
|
||||
if (gameObject is Entity)
|
||||
{
|
||||
DeleteEntity(gameObject as Entity);
|
||||
|
|
|
@ -66,8 +66,13 @@ namespace ZoFo.GameCore.GameManagers
|
|||
sound.SoundEffect.IsLooped = false;
|
||||
sound.SoundEffect.Volume = sound.baseVolume * AppManager.Instance.SettingsManager.SoundEffectsVolume * AppManager.Instance.SettingsManager.MainVolume;
|
||||
sound.SoundEffect.Pitch = pitch;
|
||||
sound.SoundEffect.Play();
|
||||
PlayingSounds.Add(sound);
|
||||
//TODO add sound importance, important will be allways played, non-important - not allways
|
||||
if (PlayingSounds.Count<50) //Exceptino when many sounds
|
||||
{
|
||||
sound.SoundEffect.Play();
|
||||
|
||||
PlayingSounds.Add(sound);
|
||||
}
|
||||
|
||||
/*/ if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue