public void ReplacePreferredComplexity(GameComplexityType newGameComplexity) { var index = GameInfoComponentsLookup.PreferredComplexity; var component = (PreferredComplexityComponent)CreateComponent(index, typeof(PreferredComplexityComponent)); component.GameComplexity = newGameComplexity; ReplaceComponent(index, component); }
public void ReplaceGameStart(bool newIsNew, GameComplexityType newGameComplexity) { var index = GameInfoComponentsLookup.GameStart; var component = (GameStartComponent)CreateComponent(index, typeof(GameStartComponent)); component.IsNew = newIsNew; component.GameComplexity = newGameComplexity; ReplaceComponent(index, component); }
public GameInfoEntity SetGameStart(bool newIsNew, GameComplexityType newGameComplexity) { if (hasGameStart) { throw new Entitas.EntitasException("Could not set GameStart!\n" + this + " already has an entity with GameStartComponent!", "You should check if the context already has a gameStartEntity before setting it or use context.ReplaceGameStart()."); } var entity = CreateEntity(); entity.AddGameStart(newIsNew, newGameComplexity); return(entity); }
public GameInfoEntity SetPreferredComplexity(GameComplexityType newGameComplexity) { if (hasPreferredComplexity) { throw new Entitas.EntitasException("Could not set PreferredComplexity!\n" + this + " already has an entity with PreferredComplexityComponent!", "You should check if the context already has a preferredComplexityEntity before setting it or use context.ReplacePreferredComplexity()."); } var entity = CreateEntity(); entity.AddPreferredComplexity(newGameComplexity); return(entity); }
public void ReplaceGameStart(bool newIsNew, GameComplexityType newGameComplexity) { var entity = gameStartEntity; if (entity == null) { entity = SetGameStart(newIsNew, newGameComplexity); } else { entity.ReplaceGameStart(newIsNew, newGameComplexity); } }
public void ReplacePreferredComplexity(GameComplexityType newGameComplexity) { var entity = preferredComplexityEntity; if (entity == null) { entity = SetPreferredComplexity(newGameComplexity); } else { entity.ReplacePreferredComplexity(newGameComplexity); } }
private float ConvertGameComplexityToBotStrength(GameComplexityType gameComplexity) { if (gameComplexity == GameComplexityType.Random) { return((float)_rand.NextDouble()); } var complexityTypeCount = Enum.GetNames(typeof(GameComplexityType)).Length - 1; var complexityScale = 1f / complexityTypeCount; var complexityIdx = (int)gameComplexity - 1; return((float)_rand.NextDouble() * complexityScale + complexityIdx * complexityScale); }