public static BirdPersonality readPersonality(this IPersistableReader r) { var ply = new BirdPersonality(); ply.A = r.ReadFloat(); ply.S = r.ReadFloat(); return(ply); }
public WingData(Wing wing) { uid = wing.uid; name = wing.name; wingClass = wing.wingClass; energy = wing.core.energy; ply = wing.mind.soul.ply; armed = wing.HasComponent <Shooter>(); }
/// <summary> /// create an NPC (autonomous/ai-controlled) wing /// </summary> /// <param name="name"></param> /// <param name="pos"></param> /// <param name="ply"></param> /// <returns></returns> public Wing createNpcWing(string name, Vector2 pos, BirdPersonality ply) { var mind = new DuckMind(new AvianSoul { ply = ply }, true); var wing = createWing(name, pos, mind); wing.AddComponent <LogicInputController>(); return(wing); }
/// <summary> /// instantiate the player wing and add components /// </summary> /// <param name="pos"></param> /// <returns></returns> public Wing createPlayer(Vector2 pos) { var playerSoul = new AvianSoul(); playerSoul.ply = BirdPersonality.makeNeutral(); var mind = new DuckMind(playerSoul, false); var player = createWing(Constants.Game.PLAYER_NAME, pos, mind); player.AddComponent(new PlayerInputController(0)); state.player = player; // save player return(player); }
public static void Spawn(string name, float a = 0f, float s = 0f) { var wingPly = new BirdPersonality { A = a, S = s }; // wingPly.generateRandom(); var spawnOffset = Vector2Ext.Rotate(new Vector2(0, -120f), Random.NextFloat() * Mathf.PI * 2f); var wing = play.setup.createNpcWing(name, play.state.player.Entity.Position + spawnOffset, wingPly); play.AddEntity(wing.Entity); debugLog($"spawned 1 entity named {wing.Entity.Name}"); }
/// <summary> /// create and set up the ecosystem (living members) of the scene /// </summary> private void createEcosystem() { var spawn = new Vector2(200, 200); if (NGame.config.generateMap) { var mapBounds = state.map.tmxMap.TileToWorldPosition(new Vector2(state.map.tmxMap.Width, state.map.tmxMap.Height)); spawn = new Vector2(Random.NextFloat() * mapBounds.X, Random.NextFloat() * mapBounds.Y); } state.player = createPlayer(spawn); state.player.Entity.AddComponent(new Shooter()); // arm the player // a friendly bird var frend = createNpcWing("frend", spawn + new Vector2(-140, 20), new BirdPersonality { A = -0.8f, S = 0.7f }); frend.AddComponent(new Shooter()); // friend is armed // // unfriendly bird // var enmy = createWing("enmy", new Vector2(120, 80), // new BirdPersonality {A = 0.8f, S = -0.7f}); // enmy.AddComponent(new Shooter()); // enmy is armed // if spawning is enabled, create additional birds if (NGame.context.config.spawnBirds) { var unoPly = new BirdPersonality(); unoPly = BirdPersonality.makeNeutral(); var uno = createNpcWing("uno", spawn + new Vector2(-140, 920), unoPly); uno.changeClass(Wing.WingClass.Predator); // a second friendly bird var fren2 = createNpcWing("yii", spawn + new Vector2(400, -80), new BirdPersonality { A = -0.5f, S = 0.4f }); // a somewhat anxious bird var anxious1 = createNpcWing("ada", spawn + new Vector2(640, 920), new BirdPersonality { A = 0.6f, S = -0.2f }); // generate random birds spread across the map var gen = new BirdGenerator(this); gen.spawnBirds(); } }
public override void Initialize() { base.Initialize(); ClearColor = gameContext.assets.bgColor; // show cursor Core.Instance.IsMouseVisible = true; // add fixed renderer var fixedRenderer = AddRenderer(new ScreenSpaceRenderer(1023, renderlayer_ui_overlay)); fixedRenderer.ShouldDebugRender = false; playerNt = CreateEntity(Constants.Game.PLAYER_NAME, new Vector2(400, 400)).SetTag(Constants.Tags.WING); var playerSoul = new AvianSoul(); playerSoul.ply = BirdPersonality.makeNeutral(); var playerWing = playerNt.AddComponent(new Wing(new DuckMind(playerSoul, false))); playerNt.AddComponent(new PlayerInputController(0)); // add our physicist physicistDuck = CreateEntity("physical", new Vector2(300f, 200f)).SetTag(Constants.Tags.WING); var physicistSoul = new AvianSoul { ply = new BirdPersonality { A = 0.8f, S = -0.4f } }; var duckWing = physicistDuck.AddComponent(new Wing(new DuckMind(physicistSoul, true))); physicistDuck.AddComponent <LogicInputController>(); physicistDuck.AddComponent(new MindDisplay(playerWing, true)); duckWing.core.energy = 1000f; duckWing.mind.state.addOpinion(playerWing, Constants.DuckMind.OPINION_FRIEND); // set the player as the target duckWing.mind.state.plan.Enqueue(new EntityTarget(duckWing.mind, playerWing.Entity, Approach.Within, TargetSource.RANGE_MED)); var wingInteractions = AddEntityProcessor(new WingUpdateSystem()); // add component to make Camera follow the player var followCamera = Camera.Entity.AddComponent(new LockedCamera(playerNt, Camera, LockedCamera.LockMode.Position)); followCamera.AddComponent <CameraShake>(); }
public static void writePersonality(this IPersistableWriter w, BirdPersonality ply) { w.Write(ply.A); w.Write(ply.S); }