当前位置: 首页>>代码示例>>C#>>正文


C# World.CreateActor方法代码示例

本文整理汇总了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);
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:27,代码来源:Player.cs

示例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);
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:9,代码来源:WallLoadHook.cs

示例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;
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:10,代码来源:UndeployMcv.cs

示例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;
 }
开发者ID:VrKomarov,项目名称:OpenRA,代码行数:12,代码来源:MissionUtils.cs

示例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);
			}
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:43,代码来源:Player.cs

示例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) });
        }
开发者ID:FMode,项目名称:OpenRA,代码行数:20,代码来源:Player.cs

示例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);
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:40,代码来源:BridgeLayer.cs

示例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);
 }
开发者ID:VrKomarov,项目名称:OpenRA,代码行数:15,代码来源:MissionUtils.cs

示例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) }));
     }
 }
开发者ID:VrKomarov,项目名称:OpenRA,代码行数:17,代码来源:MissionUtils.cs

示例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());
 }
开发者ID:VrKomarov,项目名称:OpenRA,代码行数:14,代码来源:MissionUtils.cs

示例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);
            }
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:46,代码来源:Player.cs

示例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);
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:43,代码来源:BridgeLayer.cs

示例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");
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:53,代码来源:Player.cs

示例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) });
        }
开发者ID:katzsmile,项目名称:OpenRA,代码行数:31,代码来源:Player.cs


注:本文中的World.CreateActor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。