private void Awake() { JSONNodeReader jsonReader = new JSONNodeReader(fileItems); JSONNamedEventReader itemReader = new JSONNamedEventReader("identifier"); itemReader.AddCallbackInt("health bonus", player.AddMaxHealth, "+{0} health"); itemReader.AddCallbackInt("tongue damage bonus", player.AddTongueDamage, "+{0} tongue damage"); itemReader.AddCallbackInt("headbutt damage bonus", player.AddHeadbuttDamage, "+{0} headbutt damage"); itemReader.AddCallbackInt("laser damage bonus", player.AddLaserDamage, "+{0} laser damage"); itemReader.AddCallbackInt("contact damage per second bonus", player.AddContactDamagePerSecond, "+{0} contact damage"); itemReader.AddCallbackInt("damaged explosion damage bonus", player.AddEggExplosionDamage, "+{0} egg damage...?"); itemReader.AddCallbackInt("headbutt explosion damage bonus", player.AddHeadbuttExplosionDamage, "+{0} headbutt explosion damage"); itemReader.AddCallbackFloat("jump velocity bonus", player.AddJumpVelocity, "+{0} jump height"); itemReader.AddCallbackFloat("horizontal acceleration bonus", player.AddHorizontalAcceleration, "+{0} acceleration"); itemReader.AddCallbackFloat("max horizontal speed bonus", player.AddMaxHorizontalSpeed, "+{0} max speed"); itemReader.AddCallbackBool("press down for shield", player.SetHasSoap, "Press down for shield"); JSONArrayReader itemsReader = jsonReader.Get <JSONArrayReader>("items"); JSONNodeReader itemNodeReader; while (itemsReader.GetNextNode(out itemNodeReader)) { bool blacklist = itemNodeReader.Get("BLACKLIST", false); if (!blacklist) { NamedEvent item = itemReader.Read(itemNodeReader); item.AddCallback(() => Claim(item)); pool.AddUnclaimed(item); } } }
private void Tune() { JSONNodeReader jsonP = new JSONNodeReader(filePlayer); playerTongue.SetData(new PlayerTongue.Data( jsonP.Get("seconds of tongue", 0.2f), jsonP.Get("seconds of tongue cooldown", 1.0f))); AddTongueDamage(jsonP.Get("tongue damage", 10)); AddHeadbuttDamage(jsonP.Get("headbutt damage", 20)); gbao.SetAcceleration(jsonP.Get("horizontal acceleration", 40.0f)); gban.SetGroundDeceleration(jsonP.Get("ground deceleration", 32.0f)); gban.SetMaxHorizontalSpeed(jsonP.Get("max horizontal speed", 16.0f)); gbj.SetJumpVelocity(jsonP.Get("jump velocity", 20.0f)); gravity.SetAcceleration(jsonP.Get("gravity", 39.2f)); InitializeHealth(jsonP.Get("health", 100)); }
private void Awake() { JSONNodeReader jsonReader = new JSONNodeReader(fileItems); float timerItemSeconds = jsonReader.Get("seconds to display item text", 3.0f); timerItemText = new Timer(timerItemSeconds, Disappear, false, true); }
private void Tune() { JSONNodeReader jsonP = new JSONNodeReader(playerFile); JSONNodeReader jsonI = new JSONNodeReader(itemFile); PlayerPunch.Data punchData = new PlayerPunch.Data( jsonP.Get("seconds of punching", 1.0f), jsonP.Get("seconds of punch cooldown", 1.0f), jsonI.Get("seconds of more arms punch cooldown", 0.1f), jsonP.Get("base punch hitbox size", 1.4f), jsonI.Get("battle axe hitbox size", 2.0f)); PlayerPowerup.Data powerupData = new PlayerPowerup.Data( jsonI.Get("seconds of battle axe", 8.0f), jsonI.Get("seconds of more arms", 8.0f)); PlayerInput.Data inputData = new PlayerInput.Data( jsonP.Get("base movement speed", 10.0f)); PlayerHealth.Data healthData = new PlayerHealth.Data( jsonP.Get("seconds of invincibility when damaged", 1.0f), jsonP.Get("chance of saying f**k", 0.01f), jsonP.Get("max health", 100)); PlayerDeathTracker.Data deathData = new PlayerDeathTracker.Data( jsonP.Get("seconds to wait after dying", 5.0f)); SetData(new Data(punchData, powerupData, inputData, healthData, deathData)); }
// Reads from the given node and returns the resulting NamedEvent. public NamedEvent Read(JSONNodeReader nodeReader) { this.nodeReader = nodeReader; string identifier = nodeReader.Get(nameKey, "ERROR"); currentEvent = new NamedEvent(identifier); // Read all callback JSON node data. foreach (KeyValuePair <string, EventCallback <int> > pair in nameToCallbackInt) { TryAddCallback(pair.Key, pair.Value); } return(currentEvent); }
// Read data for a floor spike. private FloorSpike.Data ReadFloorSpike(JSONNodeReader attackNodeReader, string appearance) { GameObject spikeWarning; spikeWarnings.TryGetValue(appearance, out spikeWarning); FloorSpike.Data d = new FloorSpike.Data( attackNodeReader.Get("damage", 20), spikeWarning, attackNodeReader.Get("seconds of warning", 1.0f), attackNodeReader.Get("seconds of rising", 0.2f), attackNodeReader.Get("seconds to idle", 3.0f), attackNodeReader.Get("seconds to lower", 0.5f), attackNodeReader.Get("height to rise", 1.0f), attackNodeReader.Get("height to rise variance", 0.0f)); int damageBonusPerArena = attackNodeReader.Get("damage bonus per arena", 0); DifficultyIncreased += () => d.damage += damageBonusPerArena; return(d); }
private void Awake() { JSONNodeReader jsonReader = new JSONNodeReader(fileItems); JSONNamedEventReader itemReader = new JSONNamedEventReader("identifier"); itemReader.AddCallbackInt("health bonus", player.AddMaxHealth); itemReader.AddCallbackInt("tongue damage bonus", player.AddTongueDamage); itemReader.AddCallbackInt("headbutt damage bonus", player.AddHeadbuttDamage); JSONArrayReader itemsReader = jsonReader.Get <JSONArrayReader>("items"); JSONNodeReader itemNodeReader; while (itemsReader.GetNextNode(out itemNodeReader)) { NamedEvent item = itemReader.Read(itemNodeReader); item.AddCallback(() => Claim(item)); pool.AddUnclaimed(item); } }
private void Tune() { JSONNodeReader reader = new JSONNodeReader(scoreFile); pointsPerSecondPlaying = reader.Get("points per second playing", 10); }
private void Awake() { JSONNodeReader jsonReader = new JSONNodeReader(fileBosses); JSONArrayReader bossesReader = jsonReader.Get <JSONArrayReader>("bosses"); JSONNodeReader bossNodeReader; while (bossesReader.GetNextNode(out bossNodeReader)) { List <Boss.AttackGroup> attackGroups = new List <Boss.AttackGroup>(); JSONArrayReader attackGroupsReader = bossNodeReader.Get <JSONArrayReader>("attack groups"); JSONNodeReader attackGroupNodeReader; while (attackGroupsReader.GetNextNode(out attackGroupNodeReader)) { Boss.AttackGroup attackGroup = new Boss.AttackGroup( attackGroupNodeReader.Get("seconds of cooldown", 2.0f), attackGroupNodeReader.Get("seconds of cooldown variance", 0.5f)); float secondsOfCooldownBonusPerArena = attackGroupNodeReader.Get("seconds of cooldown bonus per arena", 0.0f); float secondsOfCooldownMin = attackGroupNodeReader.Get("seconds of cooldown min", 0.1f); DifficultyIncreased += () => attackGroup.SetSecondsOfCooldown( UtilApproach.Float(attackGroup.GetSecondsOfCooldown(), secondsOfCooldownMin, -secondsOfCooldownBonusPerArena) ); JSONArrayReader attacksReader = attackGroupNodeReader.Get <JSONArrayReader>("attacks"); JSONNodeReader attackNodeReader; while (attacksReader.GetNextNode(out attackNodeReader)) { string identifier = attackNodeReader.Get("identifier", "ERROR"); string appearance = attackNodeReader.Get("appearance", "ERROR"); if (identifier == "FloorSpikes") { float count = attackNodeReader.Get("count", 3); RuntimeAnimatorController rac; spikeAnimators.TryGetValue(appearance, out rac); FloorSpike.Data d = ReadFloorSpike(attackNodeReader, appearance); attackGroup.AddAttack(x => Boss.FloorSpikes(x, attackGroup, d, rac, count)); float countBonusPerArena = attackNodeReader.Get("count bonus per arena", 0.0f); float countMax = attackNodeReader.Get("count max", 6); DifficultyIncreased += () => count = UtilApproach.Float(count, countMax, countBonusPerArena); } else if (identifier == "FloorSpikeTargetPlayer") { RuntimeAnimatorController rac; spikeAnimators.TryGetValue(appearance, out rac); FloorSpike.Data d = ReadFloorSpike(attackNodeReader, appearance); attackGroup.AddAttack(x => Boss.FloorSpikeTargetPlayer(x, attackGroup, d, rac)); } else if (identifier == "Orb") { RuntimeAnimatorController rac; orbAnimators.TryGetValue(appearance, out rac); BossOrb.Data d = new BossOrb.Data( attackNodeReader.Get("damage", 20), attackNodeReader.Get("seconds to idle", 3.0f), attackNodeReader.Get("seconds to idle variance", 2.0f), attackNodeReader.Get("seconds to move to center", 0.2f), attackNodeReader.Get("seconds to move to bottom", 0.8f), attackNodeReader.Get("horizontal speed", 8.0f)); string positionName = attackNodeReader.Get("position", "ERROR"); attackGroup.AddAttack(x => Boss.SpawnOrb(x, attackGroup, d, positionName, rac)); int damageBonusPerArena = attackNodeReader.Get("damage bonus per arena", 0); int damageMax = attackNodeReader.Get("damage max", 10000); DifficultyIncreased += () => d.damage = UtilApproach.Int(d.damage, damageMax, damageBonusPerArena); } /* * else if (identifier == "HorizontalProjectile") * { * int damage = attackNodeReader.Get("damage", 20); * float speed = attackNodeReader.Get("speed", 8.0f); * float spawnHeight = attackNodeReader.Get("spawn height", 1.0f); * float seconds = attackNodeReader.Get("seconds to wait after attack", * 1.0f); * Velocity2D.Data d = new Velocity2D.Data(new Vector2(-speed, 0.0f)); * attacks.Add(x => Boss.FireProjectile(x, d, damage, spawnHeight, * seconds)); * } */ } attackGroups.Add(attackGroup); } Boss.Data boss = new Boss.Data( bossNodeReader.Get("identifier", "ERROR"), bossNodeReader.Get("base health", 1), attackGroups); int healthBonusPerArena = bossNodeReader.Get("health bonus per arena", 0); DifficultyIncreased += () => boss.baseHealth += healthBonusPerArena; pool.Add(boss); } }
private void Tune() { JSONNodeReader jsonP = new JSONNodeReader(filePlayer); playerTongue.SetData(new NTFPlayerTongue.Data( jsonP.Get("seconds of tongue", 0.2f), jsonP.Get("seconds of tongue cooldown", 1.0f))); AddTongueDamage(jsonP.Get("tongue damage", 10)); AddHeadbuttDamage(jsonP.Get("headbutt damage", 20)); playerHeadbutt.SetRequiredHorizontalSpeed( jsonP.Get("headbutt required horizontal speed", 8.0f)); gbar.SetAcceleration(jsonP.Get("horizontal acceleration", 40.0f)); gban.SetGroundDeceleration(jsonP.Get("ground deceleration", 32.0f)); gban.SetMaxHorizontalSpeed(jsonP.Get("max horizontal speed", 16.0f)); gbj.SetJumpVelocity(jsonP.Get("jump velocity", 20.0f)); gravity.SetAcceleration(jsonP.Get("gravity", 39.2f)); InitializeHealth(jsonP.Get("health", 100)); invincibilityFrames.SetSecondsTarget(jsonP.Get( "seconds of invincibility when damaged", 1.0f)); damagePerSecondOfContact.SetSeconds(1.0f); }
// Read data from the files. private void Tune() { JSONNodeReader reader = new JSONNodeReader(enemySpawnersFile); challengeMax = reader.Get("initial challenge", 1.0f); challengeIncreasePerSpawnGroup = reader.Get("challenge increase per spawn group", 1.0f); spawnGroupsPerDeadTime = reader.Get("spawn groups per dead time", 3); secondsBetweenSpawns = reader.Get("seconds between spawns", 1.0f); secondsBetweenSpawnGroups = reader.Get("seconds between spawn groups", 2.0f); secondsPerDeadTime = reader.Get("seconds per dead time", 3.0f); enemyBaseLeftMovementSpeed = reader.Get("enemy base left movement speed", 0.05f); timerSpawn = new Timer(secondsBetweenSpawns); timerSpawnGroup = new Timer(secondsBetweenSpawnGroups); timerDeadTime = new Timer(secondsPerDeadTime); ChooseRandomSpawnPosition(); // How much health a single health kit should give. int healthPerHealthKit; int pointsPerEnemyKilled; int pointsPerProjectilePunched; int pointsPerFullHealthHealthKit; reader.SetFile(scoreFile); pointsPerEnemyKilled = reader.Get("points per enemy killed", 100); pointsPerProjectilePunched = reader.Get("points per projectile punched", 10); pointsPerFullHealthHealthKit = reader.Get("points per full health health kit", 100); // Drop rates for items. Probability <ItemType> probItem = new Probability <ItemType>(ItemType.None); float dropRateHealthKit; float dropRateBattleAxe; float dropRateMoreArms; reader.SetFile(itemsFile); dropRateHealthKit = reader.Get("health kit drop rate", 0.07f); dropRateBattleAxe = reader.Get("battle axe drop rate", 0.05f); dropRateMoreArms = reader.Get("more arms drop rate", 0.05f); healthPerHealthKit = reader.Get("health per health kit", 50); probItem.SetChance(ItemType.HealthKit, dropRateHealthKit); probItem.SetChance(ItemType.BattleAxe, dropRateBattleAxe); probItem.SetChance(ItemType.MoreArms, dropRateMoreArms); reader.SetFile(enemiesFile); JSONArrayReader enemyArray = reader.Get <JSONArrayReader>("enemies"); //for (int i = 0; i < enemyArray.GetCount(); ++i) JSONNodeReader enemyNode; while (enemyArray.GetNextNode(out enemyNode)) { //JSONNodeReader enemyNode = enemyArray.GetNode(i); string enemyName = enemyNode.Get("name", "UNNAMED"); // Read volley data. JSONNodeReader volleyNode = enemyNode.Get <JSONNodeReader>("volley"); string colString = volleyNode.Get("color", "#ffffff"); Color projColor; if (!ColorUtility.TryParseHtmlString(colString, out projColor)) { Debug.Log(enemyName + ": Could not parse HTML color for volley!"); } EnemyProjectile.Data projectile = new EnemyProjectile.Data( new EnemyProjectile.Data.Refs(ts, score), volleyNode.Get("projectile punchable", true), volleyNode.Get("projectile damage", 20), pointsPerProjectilePunched, projColor, volleyNode.Get("direction", 180.0f), volleyNode.Get("speed", 4.0f)); VolleyData volley = new VolleyData(projectile, volleyNode.Get("projectile count", 1), volleyNode.Get("spread angle", 0.0f), volleyNode.Get("aims at player", false)); OscillatePosition2D.Data oscData = new OscillatePosition2D.Data( new OscillatePosition2D.Data.Refs(ts), 0.0f, 0.0f, enemyNode.Get("y oscillation magnitude", 0.0f), enemyNode.Get("y oscillation speed", 0.0f)); EnemyAttack.Data attack = new EnemyAttack.Data( new EnemyAttack.Data.Refs(ts, playerPowerup.gameObject), volley, enemyNode.Get("seconds between volleys", 1.0f), enemyNode.Get("volley direction delta per shot", 0.0f), enemyBaseLeftMovementSpeed); EnemySprite.Data enemySprite = new EnemySprite.Data( enemyNode.Get("sprite name", "basic")); Velocity2D.Data leftMovement = new Velocity2D.Data( new Velocity2D.Data.Refs(ts), new Vector2( -enemyNode.Get("left movement speed increase", 0.0f) - enemyBaseLeftMovementSpeed, 0.0f)); ItemHealthKit.Data healthKitData = new ItemHealthKit.Data( new ItemHealthKit.Data.Refs(score), healthPerHealthKit, pointsPerFullHealthHealthKit); EnemyHealth.Data enemyHealthData = new EnemyHealth.Data( new EnemyHealth.Data.Refs(ts, score, playerPowerup), healthKitData, pointsPerEnemyKilled, probItem); Enemy.Data enemy = new Enemy.Data(enemyNode.Get("challenge", 1.0f), oscData, attack, enemySprite, leftMovement, enemyHealthData); // Add the enemy to the possible enemies pool. possibleEnemies.Add(enemy); } }