コード例 #1
0
        public override void PlayerJoinedEvent(PlayerProfile profile)
        {
            List <MineralRock> AllRocks = new List <MineralRock>();

            foreach (MineralRock r in Enumerate(typeof(MineralRock)))
            {
                if (r.IsStartingZone.get() == 1 && r.miningPlatform == null)
                {
                    AllRocks.Add(r);
                }
            }

            if (AllRocks.Count == 0)
            {
                return;
            }

            PlayerShip p = (PlayerShip)ParentLevel.AddObject(new PlayerShip(-1, profile));

            ChooseStartState.AddPlayer();
            MineralRock SelectedRock = AllRocks[Rand.r.Next(AllRocks.Count)];

            p.Position.set(SelectedRock.Position.get());
            SelectedRock.Interact(p);
        }
コード例 #2
0
        public override void PlayerQuitEvent(PlayerProfile p)
        {
            int        FactionNumber = -1;
            PlayerShip playerShip    = null;

            foreach (PlayerShip s in Enumerate(typeof(PlayerShip)))
            {
                if (s.MyProfile == p)
                {
                    playerShip    = s;
                    FactionNumber = s.FactionNumber;
                }
            }

            if (playerShip != null)
            {
                playerShip.Destroy();

                LinkedList <BasicShipGameObject> toDestroy = new LinkedList <BasicShipGameObject>();

                foreach (BasicShipGameObject o in Enumerate(typeof(BasicShipGameObject)))
                {
                    if (o.FactionNumber == FactionNumber)
                    {
                        toDestroy.AddLast(o);
                    }
                }

                foreach (BasicShipGameObject o in toDestroy)
                {
                    o.Destroy();
                }

                ChooseStartState.RemovePlayer();
                FactionManager.Remove(FactionNumber);
            }

            base.PlayerQuitEvent(p);
        }