Пример #1
0
        public Player(World world, Session.Client client, PlayerReference pr, int index)
        {
            World = world;
            Index = index;
            Palette = "player" + 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) });
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
		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);
			}
		}
Пример #4
0
        public Player( World world, PlayerReference pr, int index )
        {
            World = world;
            Shroud = new ShroudRenderer(this, world.Map);

            Index = index;
            Palette = "player"+index;
            Color = pr.Color;
            Color2 = pr.Color2;
            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;

            RegisterPlayerColor(world, Palette);
            PlayerActor = world.CreateActor("Player", new TypeDictionary{ new OwnerInit( this ) });
        }
Пример #5
0
        public ProductionQueue( Actor self, Actor playerActor, ProductionQueueInfo info )
        {
            this.self = self;
            this.Info = info;
            playerResources = playerActor.Trait<PlayerResources>();
            PlayerPower = playerActor.Trait<PowerManager>();

            Race = self.Owner.Country;
            Produceable = InitTech(playerActor);
        }
Пример #6
0
        public Player(World world, Session.Client client, PlayerReference pr, int index)
        {
            World = world;
            Index = index;
            Palette = "player" + index;
            ColorRamp = client.ColorRamp;
            PlayerName = client.Name;

            InternalName = pr.Name;
            Country = world.GetCountries()
                .FirstOrDefault(c => client != null && client.Country == c.Race)
                ?? world.GetCountries().Random(world.SharedRandom);

            ClientIndex = client.Index;
            PlayerRef = pr;

            PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
        }
Пример #7
0
        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);
        }