Inheritance: IPlayer
Esempio n. 1
0
        public override LivingObject[] SetupWorldForNewPlayer(Player player)
        {
            const int NUM_DWARVES = 1;

            // XXX entry location
            var env = this.World.AllObjects.OfType<Dwarrowdelf.Server.EnvironmentObject>().First();

            var list = new List<LivingObject>();

            for (int i = 0; i < NUM_DWARVES; ++i)
            {
                IntPoint3 p;
                do
                {
                    p = new IntPoint3(m_random.Next(env.Width), m_random.Next(env.Height), env.HomeLocation.Z);
                } while (!EnvironmentHelpers.CanEnter(env, p));

                var l = CreateDwarf(i);

                if (!l.MoveTo(env, p))
                    throw new Exception();

                list.Add(l);
            }

            return list.ToArray();
        }
        public VisionTrackerGlobalFOV(Player player, EnvironmentObject env)
        {
            Debug.Assert(env.VisibilityMode == VisibilityMode.GlobalFOV);

            m_player = player;
            m_environment = env;
        }
Esempio n. 3
0
        public VisionTrackerLOS(Player player, EnvironmentObject env)
        {
            Debug.Assert(env.VisibilityMode == VisibilityMode.LivingLOS);

            m_player = player;
            m_environment = env;
        }
Esempio n. 4
0
        public AllVisibleVisionTracker(Player player, EnvironmentObject env)
        {
            Debug.Assert(env.VisibilityMode == VisibilityMode.AllVisible);

            m_player = player;
            m_environment = env;
        }
Esempio n. 5
0
 public void SetPlayer(Player player)
 {
     if (player != null)
     {
         m_exprScope.SetVariable("player", player);
         m_scopeVars["player"] = player;
     }
     else
     {
         m_exprScope.RemoveVariable("player");
         m_scopeVars.Remove("player");
     }
 }
Esempio n. 6
0
        public IPRunner(World world, GameEngine engine, Player player)
        {
            m_player = player;
            m_scriptOutputStream = new MyStream(player.Send);

            m_scriptEngine = IronPython.Hosting.Python.CreateEngine();

            InitRuntime(m_scriptEngine.Runtime);

            m_exprScope = m_scriptEngine.CreateScope();
            InitScope(m_exprScope, world, engine, player);

            m_scriptScope = m_scriptEngine.CreateScope();
            InitScope(m_scriptScope, world, engine, player);
        }
Esempio n. 7
0
        public LivingObject[] SetupWorldForNewPlayer(Player player)
        {
            const int NUM_DWARVES = 1;

            // XXX entry location
            var env = this.World.HackGetFirstEnv();

            var startRect = FindStartLocation(env);

            if (!startRect.HasValue)
                throw new Exception();

            var startLocs = startRect.Value.Range().ToArray();

            // clear trees
            foreach (var p in startLocs)
            {
                var td = env.GetTileData(p);
                if (td.InteriorID == InteriorID.Tree)
                {
                    td.InteriorID = InteriorID.Grass;
                    td.InteriorMaterialID = MaterialID.RyeGrass;
                    env.SetTileData(p, td);
                }
            }

            var list = new List<LivingObject>();

            for (int i = 0; i < NUM_DWARVES; ++i)
            {
                var p = startLocs[Helpers.GetRandomInt(startLocs.Length - 1)];

                var l = CreateDwarf(i);
                l.Strength = 100;

                if (!l.MoveTo(env, p))
                    throw new Exception();

                list.Add(l);
            }

            return list.ToArray();
        }
Esempio n. 8
0
        Player CreatePlayer(int userID)
        {
            var player = FindPlayer(userID);

            if (player != null)
                throw new Exception();

            trace.TraceInformation("Creating new player {0}", userID);
            player = new Player(userID, this);

            m_players.Add(player);
            InitPlayer(player);

            return player;
        }
Esempio n. 9
0
 public PlayerChangeHandler(Player player)
     : base(player)
 {
 }
Esempio n. 10
0
        void OnPlayerProceedTurnReceived(Player player)
        {
            switch (m_world.TickMethod)
            {
                case WorldTickMethod.Simultaneous:
                    if (m_players.Count > 0 && m_players.All(u => u.IsProceedTurnReplyReceived))
                    {
                        this.World.SetProceedTurn();
                        SignalWorld();
                    }

                    break;

                case WorldTickMethod.Sequential:
                    this.World.SetProceedTurn();
                    SignalWorld();
                    break;
            }
        }
Esempio n. 11
0
 public AdminChangeHandler(Player player)
     : base(player)
 {
 }
Esempio n. 12
0
 protected ChangeHandler(Player player)
 {
     m_player = player;
 }
Esempio n. 13
0
		void RemovePlayer(Player player)
		{
			VerifyAccess();
			bool ok = m_players.Remove(player);
			Debug.Assert(ok);

			player.ProceedTurnReceived -= OnPlayerProceedTurnReceived;
			player.DisconnectEvent -= OnPlayerDisconnected;
		}
Esempio n. 14
0
		void InitPlayer(Player player)
		{
			VerifyAccess();
			player.ProceedTurnReceived += OnPlayerProceedTurnReceived;
			player.DisconnectEvent += OnPlayerDisconnected;
		}
Esempio n. 15
0
        public void SetPlayer(Player player)
        {
            trace.TraceInformation("{0} takes control of {1}", this, player);
            this.Player = player;
            player.ConnectUser(this);

            if (m_ipStartTask != null)
                m_ipStartTask.Wait();

            if (m_ipRunner != null)
                m_ipRunner.SetPlayer(player);
        }
Esempio n. 16
0
        void InitScope(ScriptScope scope, World world, GameEngine engine, Player player)
        {
            var globals = new Dictionary<string, object>()
            {
                { "world", world },
                { "engine", engine },
                { "player", player},
                { "get", new Func<object, BaseObject>(world.IPGet) },
            };

            foreach (var kvp in globals)
                scope.SetVariable(kvp.Key, kvp.Value);

            // XXX perhaps this can also be done with C# somehow...
            m_scriptEngine.Execute("import Dwarrowdelf", scope);
        }
Esempio n. 17
0
		void OnPlayerProceedTurnReceived(Player player)
		{
			switch (this.World.TickMethod)
			{
				case WorldTickMethod.Simultaneous:
					if (m_players.Count > 0 && m_players.Where(p => p.IsConnected).All(p => p.IsProceedTurnReplyReceived))
					{
						this.World.SetProceedTurn();
						Signal();
					}

					break;

				case WorldTickMethod.Sequential:
					this.World.SetProceedTurn();
					Signal();
					break;
			}
		}
Esempio n. 18
0
		void OnPlayerDisconnected(Player player)
		{
			m_playersConnected--;

			Debug.Assert(m_players.Count(p => p.IsConnected) == m_playersConnected);
		}
Esempio n. 19
0
		protected void AddPlayer(Player player)
		{
			var playerID = m_playerIDCounter++;

			m_players.Add(player);
			InitPlayer(player);
		}