public Actor SpawnActor(Actor.Brains brain = Actor.Brains.Player1, int id = 0) { Vector3 pos = RandomActorSpawn(); ActorData dat = new ActorData(); dat.id = id; dat.pos = pos; dat.health = dat.healthMax = 100; if (settings.useKits) { dat.inventory.ReceiveItem(Item.Factory(Item.Types.Rifle)); List <Item> kitItems = Item.BulkFactory(Item.Types.Ammo, 100); dat.inventory.ReceiveItem(kitItems[0]); } Actor actor = Actor.Factory(brain, dat); actor.NameHand(actor.Name + "(Hand)"); actors.Add(actor); AddChild(actor); if (settings.useKits) { EquipActor(actor, Item.Types.Rifle, "Rifle"); } return(actor); }
public void HandleActorDead(SessionEvent sessionEvent) { string[] actors = sessionEvent.args; if (actors == null || actors.Length == 0 || actors[0] == "") { GD.Print("Arena.HandleActorDead: Insufficient args"); return; } Node actorNode = GetNode(new NodePath(actors[0])); Actor actor = actorNode as Actor; Actor.Brains brain = actor.brainType; int id = actor.worldId; actorNode.Name = "Deadplayer" + id; actor.QueueFree(); SpawnActor(brain, id); if (actors.Length < 2 || actors[1] == "") { return; } Node killerNode = GetNode(new NodePath(actors[1])); Actor killer = killerNode as Actor; scores[killer.worldId]++; }
public Actor InitActor(Actor.Brains brain, int id) { scores.Add(id, 0); if (!Session.NetActive()) { SpawnActor(brain, id); if (brain == Actor.Brains.Player1) { playerWorldId = id; } return(null); } Actor ret = null; if (id == playerWorldId) { ret = SpawnActor(Actor.Brains.Player1, id); } else { ret = SpawnActor(brain, id); } return(ret); }
public Actor SpawnActor(ActorData dat) { Actor.Brains brain = dat.GetBrain(); Vector3 pos; if (brain == Actor.Brains.Player1) { pos = RandomSpawn(playerSpawnPoints); } else { pos = RandomSpawn(enemySpawnPoints, usedEnemySpawnPoints); usedEnemySpawnPoints.Add(pos); } dat.pos = pos; Actor actor = Actor.Factory(brain, dat); actor.NameHand(actor.Name + "(Hand)"); actors.Add(actor); AddChild(actor); return(actor); }
public void HandleActorDead(SessionEvent sessionEvent) { string[] actorPaths = sessionEvent.args; if (actorPaths == null || actorPaths.Length == 0 || actorPaths[0] == "") { return; } Node actorNode = GetNode(new NodePath(actorPaths[0])); Actor actor = actorNode as Actor; Actor.Brains brain = actor.brainType; ClearActor(actor); if (actor.brainType == Actor.Brains.Player1) { Session.session.career.FailEncounter(); return; } AwardPoints(actorPaths); if (PlayerWon()) { Session.session.career.CompleteEncounter(); } }
public Actor SpawnActor(Actor.Brains brain = Actor.Brains.Player1, int id = 0) { Vector3 pos = RandomActorSpawn(); Actor actor = Actor.ActorFactory(brain); actor.netId = id; actor.worldId = id; actors.Add(actor); actor.SetPos(pos); Node actorNode = actor as Node; if (id != 0) { actorNode.Name = "Player" + id; } AddChild(actorNode); return(actor); }
public int GetActorByBrain(Actor.Brains brain) { foreach (int key in actors.Keys) { if (actors[key].brainType == brain) { return(key); } } foreach (int key in actorsData.Keys) { if (actorsData[key].brain == brain) { return(key); } } return(-1); }
public void HandleActorDead(SessionEvent sessionEvent) { string[] actors = sessionEvent.args; if (actors == null || actors.Length == 0 || actors[0] == "") { return; } Node actorNode = GetNode(new NodePath(actors[0])); Actor actor = actorNode as Actor; Actor.Brains brain = actor.brainType; int id = actor.id; actorNode.Name = "Deadplayer" + id; actor.QueueFree(); actor = SpawnActor(brain, id); if (actor.brainType == Actor.Brains.Player1) { Session.ChangeMenu(Menu.Menus.HUD); } if (actors.Length < 2 || actors[1] == "") { return; } Node killerNode = GetNode(new NodePath(actors[1])); Actor killer = killerNode as Actor; if (killer != null) { scores[killer.id]++; } }
public void InitActor(Actor.Brains brain, int id) { scores.Add(id, 0); if (!Session.NetActive()) { SpawnActor(brain, id); if (brain == Actor.Brains.Player1) { playerWorldId = id; } return; } if (id == playerWorldId) { SpawnActor(Actor.Brains.Player1, id); } else { SpawnActor(brain, id); } }