internal override void HandleActorCreation(INetworkMessageIn msg) { var quantity = msg.ReadInt(); for (int i = 0; i < quantity; i++) { var id = msg.ReadInt(); var x = msg.ReadInt(); var y = msg.ReadInt(); var hashedClassName = msg.ReadInt(); if (Actors.Exists(a => a.Id == id)) { return; } var newActor = CreateRemoteActorByName(hashedClassName, id, x, y); if (newActor == null) { return; } Actors.Add(newActor); if (newActor.ReplicateProperties) { newActor.Deserialize(msg); } } }
public GameStateViewModel([NotNull] States.GameState state, Genes.ActorChromosome brain) { _state = state ?? throw new ArgumentNullException(nameof(state)); foreach (var actor in _state.World.Actors.Where(a => a.IsActive)) { Actors.Add(new ActorViewModel(actor)); } var values = new Dictionary <WorldPos.WorldPos, double>(); for (int y = 1; y <= state.World.MaxY; y++) { for (int x = 1; x <= state.World.MaxX; x++) { var pos = new WorldPos.WorldPos(x, y); values[pos] = Genes.evaluateTile(brain, state.World, pos); } } var min = values.Values.Min(); var max = values.Values.Max(); foreach (var(pos, value) in values) { HeatMap.Add(new HeatMapViewModel(pos, value, min, max)); } }
/// <summary> /// Initializes a new instance of the <see cref="LevelOne"/> class. /// </summary> public LevelOne() { // Sounds this.MusicAsset = @"Assets\overworldtheme.mp3"; // Controls Players.Add(new PlayerOne()); // Backgrounds Actors.Add(new Cloud()); // Actors Actors.Add(new OrangeLand { Position = new Vector2D_Dbl(0, 400), Width = 1500, Height = 10 }); Actors.Add(new QuestionBox { Position = new Vector2D_Dbl(300, 300) }); Actors.Add(new Goomba { Position = new Vector2D_Dbl(400, 100), WalkingVelocity = new Vector2D_Dbl(1, 0) }); Actors.Add(new GreenStaticPipe { Position = new Vector2D_Dbl(380, 340) }); Actors.Add(new GreenStaticPipe { Position = new Vector2D_Dbl(520, 340) }); // Players Actors.Add(new Mario(Players[0])); this.Width = 1500; }
public override void LoadLevel() { Actors.Add(new PlayerActor(new Vector2(250, 200), 0)); Actors.Add(new ExitActor(new Vector2(500, 500))); Waypoint root = new Waypoint(new Vector2(230, 560), new Waypoint(new Vector2(388, 560), new Waypoint(new Vector2(292, 620)))); var enemy = new Enemy1(new Vector2(0, 0), root); Actors.Add(enemy); levelTex = ResourceManager.Resources["ComplexLevelLayoutMap"]; levelFieldTex = ResourceManager.Resources["ComplexLevelCollisionMap"]; base.LoadLevel(); }
/// <summary> /// Gets an existing actor with this alias, or creates a new one with alias and name. /// </summary> public ActorViewModel GetOrCreateActor(string alias, string name) { if (string.IsNullOrEmpty(alias)) { throw new ArgumentNullException(nameof(alias)); } // Trim whitespace and quotes from alias and name alias = alias.Trim().Trim('\"'); if (name != null) { name = name.Trim().Trim('\"'); } foreach (ActorViewModel i in Actors) { if (string.Equals(i.Alias, alias, StringComparison.OrdinalIgnoreCase)) { return(i); } } ActorViewModel actor = new ActorViewModel(alias, name ?? alias, Actors.Count); Actors.Add(actor); return(actor); }
public void Update(double dt) { foreach (IActor actor in NewActors) { Actors.Add(actor); } NewActors.Clear(); foreach (IActor actor in Actors) { actor.OnUpdate(dt); if (actor.MustBeDestroyed) { ActorsToRemove.Add(actor); } } foreach (IActor actor in ActorsToRemove) { actor.OnDestroy(); Game.PM.DeleteBoxComponent(actor.BC); Actors.Remove(actor); } ActorsToRemove.Clear(); }
//=========================================================================== /*---------------------------------------- * * Helper function to set up player1 * * ------------------------------------*/ internal void SetupPlayer1() { int X = level.StartingLocation.X; int Y = level.StartingLocation.Y; player1 = new Character("Erina", X, Y); player1.SpriteSource = "Characters.Erina.Leather"; //-- motion characteristics player1.MaxJumps = 2; // 2 enables doublejump player1.Max_X_Speed = 12; Sprite player1Sprite = new Sprite(player1); //-- set up player1 in the physics handler Actor PL1 = new Actor(player1, player1Sprite); Actors.Add(PL1); deviceScreen_.AddCharacter(PL1); //-- set up control ControlProfileLoaded = LoadInputProfile("ErinaProfile.xml"); PlayerInputChanged = new InputChangedHandler(OnInputChanged); }
public override void LoadLevel() { Actors.Add(new PlayerActor(new Vector2(205, 400), 0)); Actors.Add(new ExitActor(new Vector2(1070, 400))); //Waypoint root = // new Waypoint(new Vector2(230, 560), // new Waypoint(new Vector2(388, 560), // new Waypoint(new Vector2(292, 620)))); //var enemy = new Enemy1(new Vector2(0, 0), root); //Actors.Add(enemy); levelTex = ResourceManager.Resources["simpleLevelLayoutMap"]; levelFieldTex = ResourceManager.Resources["SimpleLevelCollisionMap"]; base.LoadLevel(); }
private void CreateAndReloadMovieActors() { foreach (var person in ActorsEditList) { if (person.IsActorChecked) { var actor = Actors.FirstOrDefault(x => x.Id == person.Id); if (actor == null) { var movieActor = new PersonActorDetailModel() { Id = Guid.NewGuid(), MovieId = EditDetailModel.Id, ActorId = person.Id }; _movieActorRepository.Create(movieActor); Actors.Add(person); } } else { var actor = Actors.FirstOrDefault(x => x.Id == person.Id); if (actor != null) { _movieActorRepository.TryDeleteActorMovieRelation(EditDetailModel.Id, person.Id); DeleteActorInActorListById(person.Id); } } } }
public void AddActor(Actor actor) { if (!Actors.Contains(actor)) { Actors.Add(actor); } }
public Level(ILevelContext levelControl, List <Platform> platforms) { _levelControl = levelControl; _platforms = platforms; Door = platforms.Count == 0 ? null : new Door(platforms.Last().Box.TopRight - Vector2.X_UNIT / 2); Actors.Add(new Actor(this, platforms.Count == 0 ? new Point2(0, 0) : platforms[0].Box.TopLeft + Vector2.X_UNIT / 2)); }
public TActor Create <TActor>(IComponent[]?components = null) where TActor : Actor { var actor = _actorFactory.Create <TActor>(components); Actors.Add(actor); return(actor); }
public void Initialize(IEnumerable <IActorViewModel> actors) { Actors.Clear(); foreach (IActorViewModel actor in actors) { Actors.Add(actor); } }
public Actor Create(IComponent[]?components = null) { var actor = _actorFactory.Create(components); Actors.Add(actor); return(actor); }
public virtual void Register(Actor actor) { if (Actors.Count >= MaxActors) { throw new InvalidOperationException($"Actor count has reached the maximum for {Name}"); } Actors.Add(actor); }
/// <summary>Adiciona entidades a cena.</summary> /// <param name="actors">Lista de entidades a serem adicionada.</param> public void AddActor(params Actor[] actors) { foreach (var e in actors) { e.Screen = this; Actors.Add(e); } }
/// <summary> /// Adds children of the specified actor to the <see cref="Actors"/>. /// </summary> /// <param name="actor">The actor to get chidren from.</param> private void InitializeActorsAddChildren(Actor actor) { foreach (Actor child in actor.Children) { Actors.Add(child.ActorId, child); InitializeActorsAddChildren(child); } }
/// <summary> /// Initializes a new instance of the <see cref="LevelOne"/> class. /// </summary> public LevelOne() { // Sounds this.MusicAsset = @"Assets\overworldtheme.mp3"; // Controls Players.Add(new PlayerOne()); // Backgrounds Actors.Add(new Cloud()); // Players Mario mario = new Mario(Players[0]); Actors.Add(mario); // Actors Actors.Add(new OrangeLand { Position = new Vector2D_Dbl(0, 400), Width = 1500, Height = 50 }); Actors.Add(new QuestionBox { Position = new Vector2D_Dbl(300, 300) }); Actors.Add(new Goomba(mario) { Position = new Vector2D_Dbl(420, 100) }); Actors.Add(new Coin { Position = new Vector2D_Dbl(450, 250) }); Actors.Add(new GreenStaticPipe { Position = new Vector2D_Dbl(200, 340) }); Actors.Add(new Coin { Position = new Vector2D_Dbl(380, 300) }); Actors.Add(new GreenStaticPipe { Position = new Vector2D_Dbl(520, 340) }); Actors.Add(new Coin { Position = new Vector2D_Dbl(520, 300) }); Actors.Add(new GreenStaticPipe { Position = new Vector2D_Dbl(660, 340) }); Actors.Add(new Lava { Position = new Vector2D_Dbl(560, 380), Width = 100, Height = 20 }); Actors.Add(new Coin { Position = new Vector2D_Dbl(660, 300) }); Actors.Add(new Teleport(this) { Position = new Vector2D_Dbl(1060, 340) }); this.Width = 1500; }
public VoiceActor.VoiceActor AddNewActor() { var actor = new VoiceActor.VoiceActor { Id = m_currentId++ }; Actors.Add(actor); return(actor); }
public Actor(Vector2 position, float rotation) { this.Position = position; this.Rotation = rotation; Renderer = new ActorRenderer(this); Shield = new Shield(this); Actors.Add(this); }
internal override void HandleActorRequestPlayerActor(INetworkMessageIn msg) { var id = msg.ReadInt(); var x = msg.ReadInt(); var y = msg.ReadInt(); var player = CreateLocalPlayer(id, x, y); Actors.Add(player); }
/// <summary> /// Initializes a new instance of the <see cref="LevelOne" /> class. /// </summary> public LevelOne() { // Backgrounds FileName = @"Assets\LevelOne.png"; // Enemies for (int i = 0; i < 7; i++) { var ship = new Ship(this); int positionY = ship.Height + 10; int positionX = 150 + i * (ship.Width + 50); ship.Position = new Point(positionX, positionY); Actors.Add(ship); } // Enemies2 for (int i = 0; i < 5; i++) { var ship2 = new Ship2(this); int positionY1 = ship2.Height + 30; int positionX1 = 180 + i * (ship2.Width + 50); ship2.Position = new Point(positionX1, positionY1); Actors.Add(ship2); } for (int i = 0; i < 4; i++) { var ship3 = new Ship3(this); int positionY = ship3.Height + 70; int positionX = 180 + i * (ship3.Width + 50); ship3.Position = new Point(positionX, positionY); //присваиваем значение Ship куда он должен лететь true false ship3.Movement = i < 2; Actors.Add(ship3); } // Player Player = new PlayerShip(this); int playerPositionX = Size.Width / 2 - Player.Width / 2; int playerPositionY = Size.Height - Player.Height - 50; Player.Position = new Point(playerPositionX, playerPositionY); Actors.Add(Player); var superm = new Superman(this); int positionYS = superm.Height + 10; int positionXS = superm.Width + 10; superm.Position = new Point(positionXS, positionYS); Actors.Add(superm); }
void PopulateActorListView(List <ActorModel> actors) { var position = Actors.Count(); actors.ForEach(actor => { position = position + 1; actor.Position = position; Actors.Add(actor); }); }
private void GenerateBullet() { MyShip[] arrayShip = Actors.Where(actor => actor is MyShip).Cast <MyShip>().ToArray(); if (arrayShip.Count() > 0) { Random rnd = new Random(); int num = rnd.Next(0, arrayShip.Count()); Actors.Add(arrayShip[num].CreatEnemyBullet()); } }
public override void OnStartClient() { if (!Actors.Contains(this)) { Actors.Add(this); } if (hasAuthority) { Local = this; } }
public Actor CreateActor(Player owner, Guid?externalId, string nativeName, RoleModelNative roleModel, Tile target, string visualization, string enemyVisualization, float?z) { if (target.TempObject != null) { return(null); } Actor actor = new Actor(this, owner, externalId, target, visualization, enemyVisualization, z, NativeManager.GetActorNative(nativeName), roleModel); Actors.Add(actor); target.ChangeTempObject(actor, true); return(actor); }
/// <summary> /// Adds actor to the network. /// </summary> /// <param name="actorName">Name of the actor.</param> /// <returns>Newly added actor.</returns> public Actor AddActor(string actorName) { Actor newActor = GetActor(actorName); if (newActor == null) { var actorId = maxActorId++; newActor = new Actor(actorId, actorName); Actors.Add(newActor); ActorByName.Add(newActor.Name, newActor); } return(newActor); }
public override void LoadLevel() { Actors.Add(new PlayerActor(new Vector2(205, 400), 0)); Actors.Add(new ExitActor(new Vector2(500, 400))); levelTex = ResourceManager.Resources["titleLogoLayoutMask"]; levelFieldTex = ResourceManager.Resources["titleLogoCollisionMask"]; base.LoadLevel(); }
/// <summary> /// Initializes a new instance of the <see cref="LevelOne" /> class. /// </summary> public LevelOne() { // Backgrounds FileName = @"Assets\LevelOne.png"; //// Enemies for (int i = 0; i < 5; i++) { var ship = new Ship(this); int positionY = ship.Height + 10; int positionX = 150 + i * (ship.Width + 50); ship.Position = new Point(positionX, positionY); Actors.Add(ship); } for (int i = 0; i < 1; i++) { var Thunderbolt = new Thunderbolt(this); int positionY = Thunderbolt.Height + 200; int positionX = 170 + i * (Thunderbolt.Width + 100); Thunderbolt.Position = new Point(positionX, positionY); Actors.Add(Thunderbolt); } for (int i = 0; i < 4; i++) { var ship2 = new Ship2(this); int positionY = ship2.Height + 50; int positionX = 170 + i * (ship2.Width + 100); ship2.Position = new Point(positionX, positionY); Actors.Add(ship2); } for (int i = 0; i < 3; i++) { var starOfDeathShip = new StarOfDeathShip(this); int positionY = starOfDeathShip.Height + 90; int positionX = 160 + i * (starOfDeathShip.Width + 120); starOfDeathShip.Position = new Point(positionX, positionY); Actors.Add(starOfDeathShip); } // Player Player = new PlayerShip(this); int playerPositionX = Size.Width / 2 - Player.Width / 2; int playerPositionY = Size.Height - Player.Height - 50; Player.Position = new Point(playerPositionX, playerPositionY); Actors.Add(Player); }
public void Populate( int width, int length, int zombies) { // Verify geometry if (width <= 8 || length <= 8) { throw new ArgumentException("Bad scene geometry"); } // Pick random number generator var rand = new Random(); // Clear the scenery Scenery.Clear(); // Generate scene var sceneItems = (width * length + 9) / 10; for (var i = 0; i < sceneItems; ++i) { var x = rand.Next(-width, width); var y = rand.Next(-length, length); var o = (float)(rand.NextDouble() * Math.PI * 2); var type = rand.Next(2); Scenery.Add(new Scenery { Id = Guid.NewGuid(), Position = new Vec(x, y), Orientation = o, Model = type == 0 ? "Tree" : "Rock" }); } // Generate zombies for (var i = 0; i < zombies; ++i) { var x = rand.Next(-width, width); var y = rand.Next(-length, length); var o = (float)(rand.NextDouble() * Math.PI * 2); Actors.Add(new Zombie { Id = Guid.NewGuid(), Position = new Vec(x, y), Orientation = o }); } }