本文整理汇总了C#中World.CreateActor方法的典型用法代码示例。如果您正苦于以下问题:C# World.CreateActor方法的具体用法?C# World.CreateActor怎么用?C# World.CreateActor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.CreateActor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Player
public Player( World world, Session.Client client )
{
World = world;
Shroud = new ShroudRenderer(this, world.Map);
PlayerActor = world.CreateActor("Player", new int2(int.MaxValue, int.MaxValue), this);
if (client != null)
{
Index = client.Index;
Palette = PlayerColors[client.PaletteIndex % PlayerColors.Count()].a;
Color = PlayerColors[client.PaletteIndex % PlayerColors.Count()].c;
PlayerName = client.Name;
InternalName = "Multi{0}".F(client.Index);
}
else
{
Index = -1;
PlayerName = InternalName = "Neutral";
Palette = "neutral";
Color = Color.Gray; // HACK HACK
}
Country = world.GetCountries()
.FirstOrDefault(c => client != null && client.Country == c.Name)
?? world.GetCountries().Random(world.SharedRandom);
}
示例2: GameStarted
public void GameStarted(World w)
{
var map = w.Map;
for (int y = map.YOffset; y < map.YOffset + map.Height; y++)
for (int x = map.XOffset; x < map.XOffset + map.Width; x++)
if (info.OverlayTypes.Contains(w.Map.MapTiles[x, y].overlay))
w.CreateActor(info.ActorType, new int2(x, y), w.NeutralPlayer);
}
示例3: DoUndeploy
void DoUndeploy(World w,Actor self)
{
self.Health = 0;
foreach (var ns in self.traits.WithInterface<INotifySold>())
ns.Sold(self);
w.Remove(self);
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
mcv.traits.Get<Unit>().Facing = 96;
}
示例4: ExtractUnitWithChinook
public static Actor ExtractUnitWithChinook(World world, Player owner, Actor unit, CPos entry, CPos lz, CPos exit)
{
var chinook = world.CreateActor("tran", new TypeDictionary { new OwnerInit(owner), new LocationInit(entry) });
chinook.QueueActivity(new HeliFly(Util.CenterOfCell(lz)));
chinook.QueueActivity(new Turn(0));
chinook.QueueActivity(new HeliLand(true, 0));
chinook.QueueActivity(new WaitFor(() => chinook.Trait<Cargo>().Passengers.Contains(unit)));
chinook.QueueActivity(new Wait(150));
chinook.QueueActivity(new HeliFly(Util.CenterOfCell(exit)));
chinook.QueueActivity(new RemoveSelf());
return chinook;
}
示例5: Player
public Player(World world, Session.Client client, Session.Slot slot, PlayerReference pr)
{
World = world;
InternalName = pr.Name;
PlayerReference = pr;
string botType = null;
// Real player or host-created bot
if (client != null)
{
ClientIndex = client.Index;
Color = client.Color;
PlayerName = client.Name;
botType = client.Bot;
Country = ChooseCountry(world, client.Country);
}
else
{
// Map player
ClientIndex = 0; // Owned by the host (TODO: fix this)
Color = pr.Color;
PlayerName = pr.Name;
NonCombatant = pr.NonCombatant;
Playable = pr.Playable;
Spectating = pr.Spectating;
botType = pr.Bot;
Country = ChooseCountry(world, pr.Race);
}
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
Shroud = PlayerActor.Trait<Shroud>();
// Enable the bot logic on the host
IsBot = botType != null;
if (IsBot && Game.IsHost)
{
var logic = PlayerActor.TraitsImplementing<IBot>()
.FirstOrDefault(b => b.Info.Name == botType);
if (logic == null)
Log.Write("debug", "Invalid bot type: {0}", botType);
else
logic.Activate(this);
}
}
示例6: Player
public Player(World world, PlayerReference pr, int index)
{
World = world;
Index = index;
Palette = "player" + index;
ColorRamp = pr.ColorRamp;
ClientIndex = 0; /* it's a map player, "owned" by host */
PlayerName = InternalName = pr.Name;
NonCombatant = pr.NonCombatant;
Country = world.GetCountries()
.FirstOrDefault(c => pr.Race == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
PlayerRef = pr;
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
}
示例7: ConvertBridgeToActor
void ConvertBridgeToActor(World w, CPos cell)
{
// This cell already has a bridge overlaying it from a previous iteration
if (bridges[cell] != null)
return;
// Correlate the tile "image" aka subtile with its position to find the template origin
var tile = w.Map.MapTiles.Value[cell].Type;
var index = w.Map.MapTiles.Value[cell].Index;
var template = w.TileSet.Templates[tile];
var ni = cell.X - index % template.Size.X;
var nj = cell.Y - index / template.Size.X;
// Create a new actor for this bridge and keep track of which subtiles this bridge includes
var bridge = w.CreateActor(bridgeTypes[tile].First, new TypeDictionary
{
new LocationInit(new CPos(ni, nj)),
new OwnerInit(w.WorldActor.Owner),
new HealthInit(bridgeTypes[tile].Second, true),
}).Trait<Bridge>();
var subTiles = new Dictionary<CPos, byte>();
var mapTiles = w.Map.MapTiles.Value;
// For each subtile in the template
for (byte ind = 0; ind < template.Size.X * template.Size.Y; ind++)
{
// Where do we expect to find the subtile
var subtile = new CPos(ni + ind % template.Size.X, nj + ind / template.Size.X);
// This isn't the bridge you're looking for
if (!mapTiles.Contains(subtile) || mapTiles[subtile].Type != tile || mapTiles[subtile].Index != ind)
continue;
subTiles.Add(subtile, ind);
bridges[subtile] = bridge;
}
bridge.Create(tile, subTiles);
}
示例8: InsertUnitWithChinook
public static Pair<Actor, Actor> InsertUnitWithChinook(World world, Player owner, string unitName, CPos entry, CPos lz, CPos exit, Action<Actor> afterUnload)
{
var unit = world.CreateActor(false, unitName, new TypeDictionary { new OwnerInit(owner) });
var chinook = world.CreateActor("tran", new TypeDictionary { new OwnerInit(owner), new LocationInit(entry) });
chinook.Trait<Cargo>().Load(chinook, unit);
chinook.QueueActivity(new HeliFly(Util.CenterOfCell(lz)));
chinook.QueueActivity(new Turn(0));
chinook.QueueActivity(new HeliLand(true, 0));
chinook.QueueActivity(new UnloadCargo(true));
chinook.QueueActivity(new CallFunc(() => afterUnload(unit)));
chinook.QueueActivity(new Wait(150));
chinook.QueueActivity(new HeliFly(Util.CenterOfCell(exit)));
chinook.QueueActivity(new RemoveSelf());
return Pair.New(chinook, unit);
}
示例9: Paradrop
public static void Paradrop(World world, Player owner, IEnumerable<string> units, CPos entry, CPos location)
{
var badger = world.CreateActor("badr", new TypeDictionary
{
new LocationInit(entry),
new OwnerInit(owner),
new FacingInit(Util.GetFacing(location - entry, 0)),
new AltitudeInit(Rules.Info["badr"].Traits.Get<PlaneInfo>().CruiseAltitude),
});
badger.QueueActivity(new FlyAttack(Target.FromCell(location)));
badger.Trait<ParaDrop>().SetLZ(location);
var cargo = badger.Trait<Cargo>();
foreach (var unit in units)
{
cargo.Load(badger, world.CreateActor(false, unit, new TypeDictionary { new OwnerInit(owner) }));
}
}
示例10: Parabomb
public static void Parabomb(World world, Player owner, CPos entry, CPos location)
{
var badger = world.CreateActor("badr.bomber", new TypeDictionary
{
new LocationInit(entry),
new OwnerInit(owner),
new FacingInit(Util.GetFacing(location - entry, 0)),
new AltitudeInit(Rules.Info["badr.bomber"].Traits.Get<PlaneInfo>().CruiseAltitude),
});
badger.Trait<CarpetBomb>().SetTarget(location);
badger.QueueActivity(Fly.ToCell(location));
badger.QueueActivity(new FlyOffMap());
badger.QueueActivity(new RemoveSelf());
}
示例11: Player
public Player(World world, Session.Client client, Session.Slot slot, PlayerReference pr)
{
World = world;
InternalName = pr.Name;
PlayerReference = pr;
string botType = null;
// Real player or host-created bot
if (client != null)
{
ClientIndex = client.Index;
ColorRamp = client.ColorRamp;
PlayerName = client.Name;
botType = client.Bot;
Country = world.GetCountries()
.FirstOrDefault(c => client.Country == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
}
else
{
// Map player
ClientIndex = 0; // Owned by the host (todo: fix this)
ColorRamp = pr.ColorRamp;
PlayerName = pr.Name;
NonCombatant = pr.NonCombatant;
botType = pr.Bot;
Country = world.GetCountries()
.FirstOrDefault(c => pr.Race == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
}
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
// Enable the bot logic on the host
IsBot = botType != null;
if (IsBot && Game.IsHost)
{
var logic = PlayerActor.TraitsImplementing<IBot>()
.FirstOrDefault(b => b.Info.Name == botType);
if (logic == null)
Log.Write("debug", "Invalid bot type: {0}", botType);
else
logic.Activate(this);
}
}
示例12: ConvertBridgeToActor
void ConvertBridgeToActor(World w, int i, int j)
{
// This cell already has a bridge overlaying it from a previous iteration
if (Bridges[i,j] != null)
return;
// Correlate the tile "image" aka subtile with its position to find the template origin
var tile = w.Map.MapTiles[i, j].type;
var image = w.Map.MapTiles[i, j].image;
var template = w.TileSet.Templates[tile];
var ni = i - image % template.Size.X;
var nj = j - image / template.Size.X;
// Create a new actor for this bridge and keep track of which subtiles this bridge includes
var bridge = w.CreateActor(BridgeTypes[tile].First, new TypeDictionary
{
new LocationInit( new int2(ni, nj) ),
new OwnerInit( w.WorldActor.Owner ),
new HealthInit( BridgeTypes[tile].Second ),
}).Trait<Bridge>();
Dictionary<int2, byte> subTiles = new Dictionary<int2, byte>();
// For each subtile in the template
for (byte ind = 0; ind < template.Size.X*template.Size.Y; ind++)
{
// Is this tile actually included in the bridge template?
if (!template.Tiles.Keys.Contains(ind))
continue;
// Where do we expect to find the subtile
var x = ni + ind % template.Size.X;
var y = nj + ind / template.Size.X;
// This isn't the bridge you're looking for
if (!w.Map.IsInMap(x, y) || w.Map.MapTiles[x, y].image != ind)
continue;
subTiles.Add(new int2(x,y),ind);
Bridges[x,y] = bridge;
}
bridge.Create(tile, subTiles);
}
示例13: Player
public Player(World world, Session.Client client, PlayerReference pr)
{
string botType;
World = world;
InternalName = pr.Name;
PlayerReference = pr;
// Real player or host-created bot
if (client != null)
{
ClientIndex = client.Index;
Color = client.Color;
PlayerName = client.Name;
botType = client.Bot;
Faction = ChooseFaction(world, client.Faction, !pr.LockFaction);
DisplayFaction = ChooseDisplayFaction(world, client.Faction);
}
else
{
// Map player
ClientIndex = 0; // Owned by the host (TODO: fix this)
Color = pr.Color;
PlayerName = pr.Name;
NonCombatant = pr.NonCombatant;
Playable = pr.Playable;
Spectating = pr.Spectating;
botType = pr.Bot;
Faction = ChooseFaction(world, pr.Faction, false);
DisplayFaction = ChooseDisplayFaction(world, pr.Faction);
}
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
Shroud = PlayerActor.Trait<Shroud>();
fogVisibilities = PlayerActor.TraitsImplementing<IFogVisibilityModifier>().ToArray();
// Enable the bot logic on the host
IsBot = botType != null;
if (IsBot && Game.IsHost)
{
var logic = PlayerActor.TraitsImplementing<IBot>().FirstOrDefault(b => b.Info.Name == botType);
if (logic == null)
Log.Write("debug", "Invalid bot type: {0}", botType);
else
logic.Activate(this);
}
stanceColors.Self = ChromeMetrics.Get<Color>("PlayerStanceColorSelf");
stanceColors.Allies = ChromeMetrics.Get<Color>("PlayerStanceColorAllies");
stanceColors.Enemies = ChromeMetrics.Get<Color>("PlayerStanceColorEnemies");
stanceColors.Neutrals = ChromeMetrics.Get<Color>("PlayerStanceColorNeutrals");
}
示例14: Player
public Player(World world, Session.Client client, PlayerReference pr, int index)
{
World = world;
Index = index;
InternalName = pr.Name;
PlayerRef = pr;
if (client != null)
{
ClientIndex = client.Index;
ColorRamp = client.ColorRamp;
PlayerName = client.Name;
Country = world.GetCountries()
.FirstOrDefault(c => client.Country == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
}
else
{
ClientIndex = 0; /* it's a map player, "owned" by host */
ColorRamp = pr.ColorRamp;
PlayerName = pr.Name;
NonCombatant = pr.NonCombatant;
Country = world.GetCountries()
.FirstOrDefault(c => pr.Race == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
}
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
}