Example #1
0
        public SubscriptionHandler(GameSession session)
        {
            session.RegisterUtilHandler(0, 314, OnUtilSubscribe, "OnUtilSubscribe");
            session.RegisterUtilHandler(0, 228, OnCloseAll, "OnCloseAll");

            Timeout = TimeSpan.FromSeconds(120);
        }
 public FlagDroppedEvent(GamePlayState _game, int droppedId, VTankObject.Point where, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.droppedId = droppedId;
     this.where = where;
     this.flagColor = flagColor;
 }
    private void OnEnable()
    {
        _session = GameSession.CURRENT;
        _session.ServerConnection.OtherJoinedRoom += ServerConnection_OtherJoinedRoom;
        _session.ServerConnection.OtherLeftRoom += ServerConnection_OtherLeftRoom;
        _session.ServerConnection.OtherChangedSetup += ServerConnection_OtherChangedSetup;
        _header.text = _session.ServerConnection.ConnectedRoom.Name;

        // Load current setup
        foreach (RoomPlayerInfo info in _session.ServerConnection.ConnectedRoom.Players)
        {
            if (info.PlayerID == _session.ServerConnection.PlayerID)
            {
                _setup = info.Setup;
                _boatInput.value = _setup.BoatID;
                _colorInput.value = _setup.FlagColorID;
                _readyInput.isOn = _setup.Ready;
                break;
            }
        }
        if (_setup == null)
        {
            Debug.Log("Failed to load player setup.");
            gameObject.SetActive(false);
        }

        _updateList = true;
    }
 public SetBaseHealthEvent(GameSession.Alliance color, int eventId, int health, VTankBot _game)
     : base(_game)
 {
     this.baseColor = color;
     this.baseEventId = eventId;
     this.newBaseHealth = health;
 }
Example #5
0
 /// <summary>
 /// Create a new Player object.
 /// </summary>
 /// <param name="_tank">Tank identifying this player.</param>
 public Player(GameSession.Tank _tank)
 {
     tank = _tank;
     MovementDirection = VTankObject.Direction.NONE;
     RotationDirection = VTankObject.Direction.NONE;
     Angle = _tank.angle;
     Weapon = WeaponLoader.GetWeapon(tank.attributes.weaponID);
 }
Example #6
0
        private byte[] OnAssetsVersion(GameSession session, byte[] body)
        {
            PegasusUtil.AssetsVersionResponse response = new PegasusUtil.AssetsVersionResponse() {
                Version = 0
            };

            return response.EncodeResponse(304);
        }
 public Base(int baseId, Point _position, GameSession.Alliance _team)
 {
     const int OFFSET = 8; // Offset the base ID for zero-based indexing.
     BaseID = baseId - OFFSET;
     health = DEFAULT_BASE_HEALTH;
     position = _position;
     Team = _team;
 }
Example #8
0
 private void OnEnable()
 {
     _session = GameSession.CURRENT;
     _joined = false;
     _session.ServerConnection.ReceivedRooms += ServerConnection_ReceivedRooms;
     _session.ServerConnection.JoinedRoom += ServerConnection_JoinedRoom;
     _session.ServerConnection.RequestRooms();
 }
Example #9
0
        private byte[] OnGetBattlePayStatus(GameSession session, byte[] body)
        {
            BattlePayStatusResponse response = new BattlePayStatusResponse() {
                Status = BattlePayStatusResponse.PurchaseState.PS_READY,
                BattlePayAvailable = false
            };

            return response.EncodeResponse(265);
        }
Example #10
0
 private void OnDisable()
 {
     if (_session != null)
     {
         _session.ServerConnection.OtherJoinedRoom -= ServerConnection_OtherJoinedRoom;
         _session.ServerConnection.OtherLeftRoom -= ServerConnection_OtherLeftRoom;
         _session = null;
     }
 }
Example #11
0
 public static Game CreateGame()
 {
     var session = new GameSession {Setup = new GameSetup()};
     var player = new Player(null, MockRepository.GenerateStub<IPlayerView>());
     session.Join(player);
     var game = new Game();
     game.Initialize(session);
     return game;
 }
Example #12
0
 // new world with the game
 public World(string filename, Drawing.DrawHandler drawHandler, GameEventHandler aiEventHandler, GameSession session, PlayMode playMode)
     : this(playMode)
 {
     this.DrawHandler = drawHandler;
     this.fileName = filename;
     this.aiEventHandler = aiEventHandler;
     this.session = session;
     Deserialize();
 }
 private void OnDisable()
 {
     if (_session != null)
     {
         _session.ServerConnection.CreatedRoom -= ServerConnection_CreatedRoom;
         _session.ServerConnection.JoinedRoom -= ServerConnection_JoinedRoom;
         _session = null;
     }
 }
Example #14
0
        private byte[] OnAckCardSeen(GameSession session, byte[] body)
        {
            AckCardSeen request = new AckCardSeen();
            using(Stream stream = new MemoryStream(body)) {
                request.Deserialize(stream);
            }

            return null;
        }
 public BaseCapturedEvent(int eventId, GameSession.Alliance newBaseColor, int capturerId, 
     GameSession.Alliance oldBaseColor, GamePlayState _game)
     : base(_game)
 {
     this.baseEventId = eventId;
     this.newBaseColor = newBaseColor;
     this.capturerId = capturerId;
     this.oldBaseColor = oldBaseColor;
 }
Example #16
0
 private void OnDisable()
 {
     if (_session != null)
     {
         _session.ServerConnection.ReceivedRooms -= ServerConnection_ReceivedRooms;
         _session.ServerConnection.JoinedRoom -= ServerConnection_JoinedRoom;
         _session = null;
     }
     _roomListView.Clear();
 }
 public DamageBaseByEnvironmentEvent(VTankBot _game, GameSession.Alliance baseColor, int baseId, int envId,
     int damage, bool isDestroyed)
     : base(_game)
 {
     this.baseColor = baseColor;
     this.baseId = baseId;
     this.environmentEffectId = envId;
     this.damage = damage;
     this.isDestroyed = isDestroyed;
 }
Example #18
0
        public void DespawnFlag(GameSession.Alliance alliance)
        {
            if (!flags.ContainsKey(alliance))
            {
                this.AddFlag(alliance, Vector3.Zero);
            }

            flags[alliance].Unattach();
            flags[alliance].ParticleEmitter0.Emitting = false;
            flags[alliance].ParticleEmitter1.Emitting = false;
            flags[alliance].Hidden = true;
        }
Example #19
0
        private byte[] OnCloseAll(GameSession session, byte[] body)
        {
            PegasusUtil.ClientTracking request = new PegasusUtil.ClientTracking();
            using(Stream stream = new MemoryStream(body)) {
                request.Deserialize(stream);
            }

            foreach (PegasusUtil.OneClientTracking tracking in request.Info.Where(t => !String.IsNullOrEmpty(t.Message))) {
                Debug.WriteLine("INFO OnCloseAll {0} {1}", tracking.Level_, tracking.Message);
            }

            return null;
        }
Example #20
0
 public AccountHandler(GameSession session)
 {
     session.RegisterUtilHandler(0, 201, OnGetAccountInfo, "OnGetAccountInfo");
     session.RegisterUtilHandler(0, 205, OnUpdateLogin, "OnUpdateLogin");
     session.RegisterUtilHandler(0, 223, OnAckCardSeen, "OnAckCardSeen");
     session.RegisterUtilHandler(0, 239, OnSetOptions, "OnSetOptions");
     session.RegisterUtilHandler(0, 240, OnGetOptions, "OnGetOptions");
     session.RegisterUtilHandler(0, 253, OnGetAchieves, "OnGetAchieves");
     session.RegisterUtilHandler(0, 267, OnCheckAccountLicenses, "OnCheckAccountLicenses");
     session.RegisterUtilHandler(1, 276, OnCheckGameLicenses, "OnCheckGameLicenses");
     session.RegisterUtilHandler(0, 284, OnValidateAchieve, "OnValidateAchieve");
     session.RegisterUtilHandler(0, 305, OnGetAdventureProgress, "OnGetAdventureProgress");
 }
Example #21
0
        public override bool OnFarmWork(GameSession session)
        {
            if (!Program.Instance.Config.ReadCustomBool("superplow", "maintainplots", false))
                return true;

            List<PlotDefinition> toPlot = new List<PlotDefinition>();
            foreach (PlotDefinition plotSetting in _plotDefinitions)
            {
                string hashKey = plotSetting.X.ToString() + "," + plotSetting.Y.ToString();
                if (session.World.SuperPlots.ContainsKey(hashKey))
                {
                    int leftOver = plotSetting.PlotCount - session.World.SuperPlots[hashKey].Count;
                    if ( leftOver > 0 )
                        toPlot.Add(new PlotDefinition() { PlotCount = leftOver, X = plotSetting.X, Y = plotSetting.Y });
                }
            }

            if ( toPlot.Count == 0 )
                return true;

            foreach ( PlotDefinition plot in toPlot )
            {
                int plotCount = plot.PlotCount;
                string hashKey = plot.X.ToString() + "," + plot.Y.ToString();
                for ( int  x = 0; x< plotCount; x++ )
                {

                    Game.Objects.PlotObject newplot = new Game.Objects.PlotObject();
                    newplot.ClassName = "Plot";
                    newplot.Giftable = false;
                    newplot.GiftSenderId = "";
                    newplot.HasGiftRemaining = false;
                    newplot.Id = 0;
                    newplot.IsBigPlot = false;
                    newplot.IsJumbo = false;
                    newplot.IsProduceItem = false;
                    newplot.ItemName = "";
                    newplot.State = "plowed";
                    newplot.UsesAltGraphic = false;
                    newplot.PlantTime = float.NaN;
                    newplot.Position = new Game.Classes.ObjectPosition() { X = plot.X, Y = plot.Y, Z = 0 };
                    if ( !newplot.Plow() )
                        return false;
                    session.World.ObjectsArray.Add(newplot);
                    if ( !session.World.SuperPlots.ContainsKey( hashKey ) )
                        session.World.SuperPlots.Add( hashKey, new List<Game.Objects.PlotObject>() );
                    session.World.SuperPlots[hashKey].Add(newplot);
                }
            }
            return true;
        }
Example #22
0
        public void FlagPickedUp(GameSession.Alliance alliance, Object3 tank)
        {
            if (!flags.ContainsKey(alliance))
            {
                this.AddFlag(alliance, tank.Position);
            }

            flags[alliance].ParticleEmitter0.Emitting = true;
            flags[alliance].ParticleEmitter1.Emitting = true;
            flags[alliance].MimicPosition(tank, new Vector3(0,0,70));
            flags[alliance].Hidden = false;
            //TODO add continuous particle emitter to flag
            //TODO stop emitter from base
        }
Example #23
0
        private byte[] OnUtilSubscribe(GameSession session, byte[] body)
        {
            if(session.Route == 0) {
                session.Route = 1;
            }

            Subscribed = DateTime.Now;

            PegasusUtil.SubscribeResponse response = new PegasusUtil.SubscribeResponse() {
                Route = session.Route,
                SupportedFeatures = 3,
                KeepAliveSecs = (ulong)Timeout.Seconds
            };

            return response.EncodeResponse(315);
        }
    private void OnEnable()
    {
        _session = GameSession.CURRENT;
        if (_session.ServerConnection.IsConnected)
        {
            _session = null;
            _loginMenu.Show(this);
            return;
        }

        _session.ServerConnection.Connected += ServerConnection_Connected;
        _session.ServerConnection.ConnectFailed += ServerConnection_ConnectFailed;
        _session.ServerConnection.ConnectionSecured += ServerConnection_ConnectionSecured;

        if (!_session.ServerConnection.IsConnecting)
            _session.ServerConnection.Connect(ClientToServerConnection.DEFAULT_IP, ClientToServerConnection.DEFAULT_PORT);
    }
Example #25
0
    private void Awake()
    {
        if (Application.isEditor)
            _remotePort = 20001;

        CURRENT = this;
        DontDestroyOnLoad(this);

        _localIP = GetIPAddress();

        UPnPHelper.RESULT += BindUPnPResult;

        ClientConnection = new ClientToClient();
        _clientManager = GetComponent<ClientManager>();
        ServerConnection = new ClientToServerConnection(ClientConnection);
        ServerConnection.GameLoad += LoadGame;
        ServerConnection.GameStart += StartGame;

        BindUPnP();
    }
Example #26
0
 public void AddFlag(GameSession.Alliance alliance, Vector3 spawnPosition)
 {
     if (!flags.ContainsKey(alliance))
     {
         string a = Enum.GetName(typeof(GameSession.Alliance), alliance);
         a = a.ToLower();
         Model mBase = ServiceManager.Resources.GetModel("events\\" + a + "_flag_spawn");
         Flag nFlag = new Flag(ServiceManager.Resources.GetModel("events\\flag_" + a), spawnPosition);
         //setup emitters
         nFlag.ParticleEmitter0 = new ParticleEmitter(a + "_flag");
         nFlag.ParticleEmitter0.Attach(nFlag, "Emitter0");
         ServiceManager.Scene.Add(nFlag.ParticleEmitter0, 3);
         nFlag.ParticleEmitter1 = new ParticleEmitter(a + "_flag");
         nFlag.ParticleEmitter1.Attach(nFlag, "Emitter1");
         ServiceManager.Scene.Add(nFlag.ParticleEmitter1, 3);
         //end emitters
         flags.Add(alliance, nFlag);
         flags[alliance].RenderID = ServiceManager.Scene.Add(flags[alliance], 0);
         nFlag.BaseRenderID = ServiceManager.Scene.Add(mBase, spawnPosition+ new Vector3(0,0,0.1f), 0);
     }
 }
Example #27
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.Register<GameSessionController>().SingletonScoped();
            builder.Register<GameSessionView>().SingletonScoped();

            if (IsAServer)
            {
                builder.Register((c, p) =>
                    {
                        IGameSession gameSession = new GameSession();
                        var gameSessionController = c.Resolve<GameSessionController>
                            (
                            new TypedParameter(typeof(IPlayer), null),
                            new TypedParameter(typeof(ICamera), null),
                            new TypedParameter(typeof(bool), true)
                            );
                        var gameSessionView = c.Resolve<GameSessionView>();
                        gameSession.GameSessionController = gameSessionController;
                        gameSession.GameSessionView = gameSessionView;
                        return gameSession;
                    });
            }
            else
            {
                builder.Register((c, p) =>
                    {
                        IGameSession gameSession = new GameSession();
                        var gameSessionController = c.Resolve<GameSessionController>
                            (
                            new TypedParameter(typeof(IPlayer), c.Resolve<IPlayer>(new NamedParameter("LocalPlayer", true))),
                            new TypedParameter(typeof(bool), false)
                            );
                        var gameSessionView = c.Resolve<GameSessionView>();
                        gameSession.GameSessionController = gameSessionController;
                        gameSession.GameSessionView = gameSessionView;
                        return gameSession;
                    });
            }
        }
            public ChessGameBoard()
                : base()
            {
                boardWidget =
                    new CairoViewerBoard (ChessGamePlayer.
                                  GetDefaultPosition
                                  ());
                gameSession = new GameSession ();
                bottomLabel = new Label ();
                topLabel = new Label ();
                bottomLabel.UseMarkup = true;
                topLabel.UseMarkup = true;
                topLabel.Yalign = 1;	// bottom
                bottomLabel.Yalign = 0;	// top
                PackStart (topLabel, false, false, 2);
                PackStart (boardWidget, true, true, 2);
                PackStart (bottomLabel, false, false, 2);

                UpdateLabels (null);

                ShowAll ();
            }
Example #29
0
        /// <summary>
        /// Constructor for a Base
        /// </summary>
        /// <param name="color">The team color of the base</param>
        /// <param name="position">The position to place the base at</param>
        /// <param name="eventId">The event ID of the base</param>
        /// <param name="_model">The model of the base.</param>
        public Base(GameSession.Alliance color, Vector3 position, int eventId, Model _model)
            : base(_model, position)
        {
            this.originalOwner = color;
            this.BaseColor = color;
            this.Position = position;
            this.eventId = eventId;
            this.health = Constants.MAX_BASE_HEALTH;
            this.destroyed = false;

            previousDamageState = DamageState.None;

            ParticleEmitter0 = new ParticleEmitter("DamagedBaseFire");
            ParticleEmitter1 = new ParticleEmitter("DamagedBaseFire");
            ParticleEmitter2 = new ParticleEmitter("DamagedBaseFire");
            ParticleEmitter3 = new ParticleEmitter("DamagedBaseFire");

            StopEmitters();

            ServiceManager.Scene.Add(ParticleEmitter0, 3);
            ServiceManager.Scene.Add(ParticleEmitter1, 3);
            ServiceManager.Scene.Add(ParticleEmitter2, 3);
            ServiceManager.Scene.Add(ParticleEmitter3, 3);
        }
Example #30
0
    //public TextMeshProUGUI ContinueText;



    private void Start()
    {
        gSession  = FindObjectOfType <GameSession>();
        loadScene = FindObjectOfType <LoadScene>();
    }
Example #31
0
 private static void HandleTrophy(GameSession session)
 {
     session.Send(UserEnvPacket.UpdateTrophy());
 }
        /// <summary>
        /// 还未连接上路由服情况处理
        /// </summary>
        public async System.Threading.Tasks.Task ProcessNotReady(RequestPackage package, GameSession session)
        {
            if (package == null)
            {
                return;
            }

            try
            {
                ActionGetter actionGetter;
                byte[]       data = new byte[0];
                if (!string.IsNullOrEmpty(package.RouteName))
                {
                    actionGetter = ActionDispatcher.GetActionGetter(package, session);
                    if (CheckRemote(package.RouteName, actionGetter))
                    {
                        MessageStructure response = new MessageStructure();
                        OnCallRemote(package.RouteName, actionGetter, response);
                        data = response.PopBuffer();
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    SocketGameResponse response = new SocketGameResponse();
                    response.WriteErrorCallback += ActionDispatcher.ResponseError;
                    actionGetter = ActionDispatcher.GetActionGetter(package, session);
                    response.WriteError(actionGetter, Language.Instance.ErrorCode, Language.Instance.ServerBusy);
                    data = response.ReadByte();
                }
                try
                {
                    if (session != null && data.Length > 0)
                    {
                        await session.SendAsync(actionGetter.OpCode, data, 0, data.Length, OnSendCompleted);
                    }
                }
                catch (Exception ex)
                {
                    TraceLog.WriteError("PostSend error:{0}", ex);
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("Task error:{0}", ex);
            }
            finally
            {
                if (session != null)
                {
                    session.ExitSession();
                }
            }
        }
Example #33
0
    //Main map gen method
    public string GenerateGameField(GameLevelType type, string seed = " ")
    {
        Vector2 playerSpawn = Vector2.zero;

        myMapStyle             = Resources.Load <GameMapStyle>(Path.Combine("MapStyles", mapStyles.GetCurrentMapStyle(Relocation.CurrentDungeonLevel)));
        postProccesing.profile = myMapStyle.levelPostProccess;
        CreateMapHolders();
        bool useRandomSeed = seed.Equals(" ") ? true : false;

        if (type == GameLevelType.SimpleLevel)
        {
            //Map base gen
            GenerateMap(useRandomSeed, seed);
            //Noise generation
            int     noiseSeed   = Random.Range(0, 999999);
            Vector2 noiseOffset = new Vector2(Random.Range(-9999, 9999), Random.Range(-9999, 9999));
            float[,] noise = Noise.GenerateNoiseMap(mapSize.xMapSize, mapSize.yMapSize, noiseSeed, scale, octaves, persistance, lacunarity, noiseOffset);
            var groundRegions = Noise.GetClearNoiseRegions(noise, myMapStyle.GetGroundSize(), mapMask);
            for (int i = 0; i < groundRegions.Length; i++)
            {
                var region = groundRegions[i];
                for (int k = 0; k < region.tiles.Count; k++)
                {
                    Vector2Int pos = region.tiles[k];
                    int        sum = 0;
                    if (region.tiles.Contains(new Vector2Int(pos.x, pos.y + 1)))
                    {
                        sum += 1;
                    }
                    if (region.tiles.Contains(new Vector2Int(pos.x + 1, pos.y)))
                    {
                        sum += 2;
                    }
                    if (region.tiles.Contains(new Vector2Int(pos.x, pos.y - 1)))
                    {
                        sum += 4;
                    }
                    if (region.tiles.Contains(new Vector2Int(pos.x - 1, pos.y)))
                    {
                        sum += 8;
                    }
                    SpawnGround(pos.x, pos.y, region.groundLayerIndex, sum);
                }
            }
            for (int x = 0; x < mapSize.xMapSize; x++)
            {
                for (int y = 0; y < mapSize.yMapSize; y++)
                {
                    if (mapMask[x, y] == 1)                    //if walls
                    {
                        bool canSpawnWall = false;
                        for (int k = x - 1; k <= x + 1; k++)
                        {
                            for (int j = y - 1; j <= y + 1; j++)
                            {
                                try{
                                    if (mapMask[k, j] == 0)
                                    {
                                        canSpawnWall = true;
                                        break;
                                    }
                                }catch (Exception ex) {
                                    continue;
                                }
                            }
                            if (canSpawnWall)
                            {
                                break;
                            }
                        }
                        if (canSpawnWall)
                        {
                            SpawnWall(x, y);
                        }
                    }
                }
            }
            playerSpawn = GeneratePlayerPos();
            SpawnLevelMobs(playerSpawn);
            SpawnBuildings(playerSpawn);
            SpawnProps(playerSpawn);
            SpawnBlocks();
            SpawnPlayerDeathPoint();
        }
        else if (type == GameLevelType.CheckPoint)
        {
            SpawnCheckPointRoom();
            playerSpawn = Vector2.zero;
        }
        else if (type == GameLevelType.BossLevel)
        {
            SpawnBossLevel();
        }
        GameSession.SpawnPlayer(new Vector3(playerSpawn.x, playerSpawn.y, 0f));
        return(this.seed);
    }
Example #34
0
        public void UpdateTurn(GameSession game, int id)
        {
            NeutronStarInfo nsi       = game.GameDatabase.GetNeutronStarInfo(id);
            FleetInfo       fleetInfo = nsi != null?game.GameDatabase.GetFleetInfo(nsi.FleetId) : (FleetInfo)null;

            if (fleetInfo == null)
            {
                game.GameDatabase.RemoveEncounter(id);
            }
            else
            {
                MissionInfo missionByFleetId = game.GameDatabase.GetMissionByFleetID(fleetInfo.ID);
                if (game.GameDatabase.GetMoveOrderInfoByFleetID(fleetInfo.ID) != null)
                {
                    FleetLocation fl = game.GameDatabase.GetFleetLocation(fleetInfo.ID, false);
                    if (!nsi.DeepSpaceSystemId.HasValue || game.GameDatabase.GetStarSystemInfos().Any <StarSystemInfo>((Func <StarSystemInfo, bool>)(x =>
                    {
                        if (x.ID != nsi.DeepSpaceSystemId.Value)
                        {
                            return((double)(game.GameDatabase.GetStarSystemOrigin(x.ID) - fl.Coords).LengthSquared < 9.99999974737875E-05);
                        }
                        return(false);
                    })))
                    {
                        return;
                    }
                    game.GameDatabase.UpdateStarSystemOrigin(nsi.DeepSpaceSystemId.Value, fl.Coords);
                }
                else
                {
                    if (missionByFleetId != null)
                    {
                        game.GameDatabase.RemoveMission(missionByFleetId.ID);
                    }
                    StarSystemInfo starSystemInfo = game.GameDatabase.GetStarSystemInfo(fleetInfo.SystemID);
                    foreach (int standardPlayerId in game.GameDatabase.GetStandardPlayerIDs())
                    {
                        if (StarMap.IsInRange(game.GameDatabase, standardPlayerId, game.GameDatabase.GetFleetLocation(fleetInfo.ID, false).Coords, 1f, (Dictionary <int, List <ShipInfo> >)null))
                        {
                            game.GameDatabase.InsertTurnEvent(new TurnEvent()
                            {
                                EventType    = TurnEventType.EV_NEUTRON_STAR_DESTROYED_SYSTEM,
                                EventMessage = TurnEventMessage.EM_NEUTRON_STAR_DESTROYED_SYSTEM,
                                SystemID     = starSystemInfo.ID,
                                PlayerID     = this.PlayerID,
                                TurnNumber   = game.GameDatabase.GetTurnCount()
                            });
                        }
                    }
                    if (nsi.DeepSpaceSystemId.HasValue)
                    {
                        game.GameDatabase.RemoveFleet(fleetInfo.ID);
                        game.GameDatabase.RemoveEncounter(id);
                        game.GameDatabase.DestroyStarSystem(game, nsi.DeepSpaceSystemId.Value);
                    }
                    if (fleetInfo.SystemID != 0)
                    {
                        game.GameDatabase.DestroyStarSystem(game, starSystemInfo.ID);
                    }
                    if (!(game.App.CurrentState is StarMapState))
                    {
                        return;
                    }
                    ((StarMapState)game.App.CurrentState).ClearSelectedObject();
                    ((StarMapState)game.App.CurrentState).RefreshStarmap(StarMapState.StarMapRefreshType.REFRESH_ALL);
                }
            }
        }
Example #35
0
 // Start is called before the first frame update
 void Start()
 {
     scoreText      = GetComponent <TextMeshProUGUI>();
     gameSession    = FindObjectOfType <GameSession>();
     scoreText.text = gameSession.GetCurrentScore().ToString();
 }
Example #36
0
 private void Start()
 {
     _gameSession = FindObjectOfType <GameSession>();
 }
 public void Execute(GameSession parentSession, bool visited)
 {
     parentSession.SendText("\nHello adventurer. Have you seen my brother Gymir? I haven't heard from him in ages... ");
     parentSession.SendText("In any case, I'm pretty busy right now, so perhaps you can come back later.");
 }
Example #38
0
 public ElfCave(GameSession session) : base(session)
 {
     Name = "interaction0011";
 }
        public WindowAlertModuleReloadingInProgress(IModule module, GameSession gameSession)
        {
            InitializeComponent();

            txtMessage.Text = $@"RELOAD WILL BE COMPLETE IN {Math.Round(module.ReloadTime - module.Reloading, 2)} SECONDS";
        }
Example #40
0
 public void Send()
 {
     CharacterManager.Spawn(GameSession.GetOnlineAll());
 }
 private static void HandleOpenSidebar(GameSession session)
 {
     session.Send(NewsNotificationPacket.OpenSidebar());
 }
Example #42
0
 // Use this for initialization
 void Start()
 {
     scoreText   = GetComponent <TextMeshProUGUI>();
     gameSession = FindObjectOfType <GameSession>();
 }
Example #43
0
        private void AddEasterEggs(
            Random random,
            GameDatabase gamedb,
            AssetDatabase assetdb,
            GameSession game,
            NamesPool namesPool,
            GameSetup gameSetup)
        {
            List <StarSystemInfo> list1 = gamedb.GetStarSystemInfos().ToList <StarSystemInfo>();

            foreach (StarSystemInfo starSystemInfo in new List <StarSystemInfo>((IEnumerable <StarSystemInfo>)list1))
            {
                List <OrbitalObjectInfo> list2 = gamedb.GetStarSystemOrbitalObjectInfos(starSystemInfo.ID).ToList <OrbitalObjectInfo>();
                if (list2.Count <OrbitalObjectInfo>() == 0)
                {
                    list1.Remove(starSystemInfo);
                }
                bool flag = false;
                foreach (OrbitalObjectInfo orbitalObjectInfo in list2)
                {
                    if (gamedb.GetColonyInfoForPlanet(orbitalObjectInfo.ID) != null)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    list1.Remove(starSystemInfo);
                }
            }
            using (List <StarSystemInfo> .Enumerator enumerator = list1.GetEnumerator())
            {
label_43:
                while (enumerator.MoveNext())
                {
                    StarSystemInfo current = enumerator.Current;
                    foreach (OrbitalObjectInfo orbit in gamedb.GetStarSystemOrbitalObjectInfos(current.ID).ToList <OrbitalObjectInfo>())
                    {
                        PlanetInfo planetInfo = gamedb.GetPlanetInfo(orbit.ID);
                        if (planetInfo != null && !(planetInfo.Type == "gaseous") && (gamedb.GetLargeAsteroidInfo(orbit.ID) == null && gamedb.GetAsteroidBeltInfo(orbit.ID) == null) && random.CoinToss((double)assetdb.RandomEncOddsPerOrbital * ((double)gameSetup._randomEncounterFrequency / 100.0)))
                        {
                            int maxValue = game.GetAvailableEEOdds().Sum <KeyValuePair <EasterEgg, int> >((Func <KeyValuePair <EasterEgg, int>, int>)(x => x.Value));
                            if (maxValue == 0)
                            {
                                return;
                            }
                            int       num1      = random.Next(maxValue);
                            int       num2      = 0;
                            EasterEgg easterEgg = EasterEgg.EE_SWARM;
                            foreach (KeyValuePair <EasterEgg, int> easterEggOdd in assetdb.EasterEggOdds)
                            {
                                num2 += easterEggOdd.Value;
                                if (num2 > num1)
                                {
                                    easterEgg = easterEggOdd.Key;
                                    break;
                                }
                            }
                            App.Log.Warn(string.Format("Spawning {0} at {1}", (object)easterEgg.ToString(), (object)current.ID), nameof(game));
                            switch (easterEgg)
                            {
                            case EasterEgg.EE_SWARM:
                                if (this.Swarmers != null)
                                {
                                    this.Swarmers.AddInstance(gamedb, assetdb, current.ID, orbit.ID);
                                    goto label_43;
                                }
                                else
                                {
                                    goto label_43;
                                }

                            case EasterEgg.EE_ASTEROID_MONITOR:
                                if (this.AsteroidMonitor != null)
                                {
                                    this.AsteroidMonitor.AddInstance(gamedb, assetdb, current.ID, orbit.ID);
                                    goto label_43;
                                }
                                else
                                {
                                    goto label_43;
                                }

                            case EasterEgg.EE_PIRATE_BASE:
                                if (this.Pirates != null)
                                {
                                    this.Pirates.AddInstance(gamedb, assetdb, game, current.ID, orbit.ID);
                                    goto label_43;
                                }
                                else
                                {
                                    goto label_43;
                                }

                            case EasterEgg.EE_VON_NEUMANN:
                                if (this.VonNeumann != null)
                                {
                                    this.VonNeumann.AddInstance(gamedb, assetdb, namesPool);
                                    goto label_43;
                                }
                                else
                                {
                                    goto label_43;
                                }

                            case EasterEgg.EE_GARDENERS:
                                if (this.Gardeners != null)
                                {
                                    this.Gardeners.AddInstance(gamedb, assetdb, current.ID);
                                    goto label_43;
                                }
                                else
                                {
                                    goto label_43;
                                }

                            case EasterEgg.EE_INDEPENDENT:
                                ScriptModules.InsertIndependentSystem(random, current, orbit, gamedb, assetdb);
                                goto label_43;

                            case EasterEgg.EE_MORRIGI_RELIC:
                                if (this.MorrigiRelic != null)
                                {
                                    this.MorrigiRelic.AddInstance(gamedb, assetdb, current.ID, orbit.ID);
                                    goto label_43;
                                }
                                else
                                {
                                    goto label_43;
                                }

                            default:
                                goto label_43;
                            }
                        }
                    }
                }
            }
        }
Example #44
0
 // Start is called before the first frame update
 void Start()
 {
     _scoreText   = GetComponent <Text>();
     _gameSession = FindObjectOfType <GameSession>();
 }
Example #45
0
        public void UpdateEasterEggs(GameSession game)
        {
            foreach (EncounterInfo encounterInfo in game.GameDatabase.GetEncounterInfos().ToList <EncounterInfo>())
            {
                switch (encounterInfo.Type)
                {
                case EasterEgg.EE_SWARM:
                    if (this.Swarmers != null)
                    {
                        this.Swarmers.UpdateTurn(game, encounterInfo.Id);
                        continue;
                    }
                    continue;

                case EasterEgg.EE_ASTEROID_MONITOR:
                    if (this.AsteroidMonitor != null)
                    {
                        this.AsteroidMonitor.UpdateTurn(game, encounterInfo.Id);
                        continue;
                    }
                    continue;

                case EasterEgg.EE_VON_NEUMANN:
                    if (this.VonNeumann != null)
                    {
                        this.VonNeumann.UpdateTurn(game, encounterInfo.Id);
                        continue;
                    }
                    continue;

                case EasterEgg.EE_GARDENERS:
                case EasterEgg.GM_GARDENER:
                    if (this.Gardeners != null)
                    {
                        this.Gardeners.UpdateTurn(game, encounterInfo.Id);
                        continue;
                    }
                    continue;

                case EasterEgg.EE_MORRIGI_RELIC:
                    if (this.MorrigiRelic != null)
                    {
                        this.MorrigiRelic.UpdateTurn(game, encounterInfo.Id);
                        continue;
                    }
                    continue;

                case EasterEgg.GM_SYSTEM_KILLER:
                    if (this.SystemKiller != null)
                    {
                        this.SystemKiller.UpdateTurn(game, encounterInfo.Id);
                        continue;
                    }
                    continue;

                case EasterEgg.GM_LOCUST_SWARM:
                    if (this.Locust != null)
                    {
                        this.Locust.UpdateTurn(game, encounterInfo.Id);
                        continue;
                    }
                    continue;

                case EasterEgg.GM_NEUTRON_STAR:
                    if (this.NeutronStar != null)
                    {
                        this.NeutronStar.UpdateTurn(game, encounterInfo.Id);
                        continue;
                    }
                    continue;

                case EasterEgg.GM_SUPER_NOVA:
                    if (this.SuperNova != null)
                    {
                        this.SuperNova.UpdateTurn(game, encounterInfo.Id);
                        continue;
                    }
                    continue;

                default:
                    continue;
                }
            }
        }
        private void OnHttpRequest(IAsyncResult result)
        {
            try
            {
                HttpListener        listener = (HttpListener)result.AsyncState;
                HttpListenerContext context  = listener.EndGetContext(result);
                listener.BeginGetContext(OnHttpRequest, listener);

                RequestPackage package;
                if (!ActionDispatcher.TryDecodePackage(context, out package))
                {
                    return;
                }

                GameSession session;
                if (package.ProxySid != Guid.Empty)
                {
                    session          = GameSession.Get(package.ProxySid) ?? GameSession.CreateNew(package.ProxySid, context.Request);
                    session.ProxySid = package.ProxySid;
                }
                else
                {
                    session = (string.IsNullOrEmpty(package.SessionId)
                            ? GameSession.GetSessionByCookie(context.Request)
                            : GameSession.Get(package.SessionId))
                              ?? GameSession.CreateNew(Guid.NewGuid(), context.Request);
                }
                package.Bind(session);

                ActionGetter httpGet = ActionDispatcher.GetActionGetter(package, session);
                if (package.IsUrlParam)
                {
                    httpGet["UserHostAddress"] = session.RemoteAddress;
                    httpGet["ssid"]            = session.KeyCode.ToString("N");
                    httpGet["http"]            = "1";
                }
                //set cookie
                var cookie = context.Request.Cookies["sid"];
                if (cookie == null)
                {
                    cookie         = new Cookie("sid", session.SessionId);
                    cookie.Expires = DateTime.Now.AddMinutes(5);
                    context.Response.SetCookie(cookie);
                }


                var httpresponse = new SocketGameResponse();
                httpresponse.WriteErrorCallback += new ScutActionDispatcher().ResponseError;

                var clientConnection = new HttpClientConnection
                {
                    Context      = context,
                    Session      = session,
                    ActionGetter = httpGet,
                    GameResponse = httpresponse
                };
                var section = GetSection();
                clientConnection.TimeoutTimer = new Timer(OnHttpRequestTimeout, clientConnection, section.HttpRequestTimeout, Timeout.Infinite);
                byte[] respData = new byte[0];
                if (!string.IsNullOrEmpty(package.RouteName))
                {
                    if (CheckRemote(package.RouteName, httpGet))
                    {
                        MessageStructure response = new MessageStructure();
                        OnCallRemote(package.RouteName, httpGet, response);
                        respData = response.PopBuffer();
                    }
                }
                else
                {
                    DoAction(httpGet, httpresponse);
                    respData = httpresponse.ReadByte();
                }
                OnHttpResponse(clientConnection, respData, 0, respData.Length);
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("OnHttpRequest error:{0}", ex);
            }
        }
 void Start()
 {
     textBox     = GetComponent <Text>();
     gameSession = FindObjectOfType <GameSession>();
 }
 public static bool IsLoggedIn(this GameSession session)
 {
     return(!string.IsNullOrWhiteSpace(session?.Player?.Account.Nickname) && session.IsConnected);
 }
Example #49
0
    [SerializeField] int timesHit;  // TODO, serialized only for debugging purpose

    private void Start()
    {
        CountBreakableBlocks();
        gameSession = FindObjectOfType <GameSession>();
    }
 public static ILogger ForAccount(this ILogger logger, GameSession session)
 {
     return(session.IsLoggedIn() ? logger.ForAccount(session.Player) : logger);
 }
Example #51
0
 // Use this for initialization
 void Start()
 {
     theGameSession = FindObjectOfType <GameSession>();
     theBall        = FindObjectOfType <Ball>();
 }
Example #52
0
        public static Packet UpdateGuild(GameSession session, Guild guild)
        {
            PacketWriter pWriter = PacketWriter.Of(SendOp.GUILD);

            pWriter.WriteEnum(GuildPacketMode.UpdateGuild);
            pWriter.WriteLong(guild.Id);
            pWriter.WriteUnicodeString(guild.Name);
            pWriter.WriteUnicodeString(""); // guildMark Url
            pWriter.WriteByte(0x3C);        // guild.Capacity
            pWriter.WriteUnicodeString("");
            pWriter.WriteUnicodeString(""); // guild.Notice
            pWriter.WriteLong(guild.Leader.AccountId);
            pWriter.WriteLong(guild.Leader.CharacterId);
            pWriter.WriteUnicodeString(guild.Leader.Name);
            pWriter.WriteLong(guild.CreationTimestamp); // guild creation timestamp
            pWriter.WriteByte(0x0);
            pWriter.WriteInt(1000);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteByte(0x1);
            pWriter.WriteInt(0);
            pWriter.WriteInt(guild.Exp);
            pWriter.WriteInt(guild.Funds);
            pWriter.WriteByte(0x0);
            pWriter.WriteInt(0);
            pWriter.WriteByte((byte)guild.Members.Count);

            foreach (Player member in guild.Members)
            {
                pWriter.WriteByte(0x3);
                pWriter.WriteByte(3); // rank
                pWriter.WriteLong(1); // guildmember UID?
                pWriter.WriteLong(member.AccountId);
                pWriter.WriteLong(member.CharacterId);
                pWriter.WriteUnicodeString(member.Name);
                pWriter.WriteByte();
                pWriter.WriteEnum(member.Job);
                pWriter.WriteEnum(member.JobCode);
                pWriter.WriteShort(member.Levels.Level);
                pWriter.WriteInt(member.MapId);
                pWriter.WriteInt();   // last seen mapID?
                pWriter.WriteShort(); // player.channel
                pWriter.WriteUnicodeString(member.ProfileUrl);
                pWriter.WriteInt();   // member house mapId
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteLong(); // member house plot expiration timestamp
                pWriter.WriteInt();  // combat trophy count
                pWriter.WriteInt();  // adventure trophy count
                pWriter.WriteInt();  // lifestyle trophy count
                pWriter.WriteUnicodeString("");
                pWriter.WriteLong(); // joined timestamp
                pWriter.WriteLong(); // last seen timestamp
                pWriter.WriteLong();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteLong();
                pWriter.WriteInt();
                pWriter.WriteByte(); // 00 = online, 01 = offline
            }

            pWriter.WriteByte(0x6); // loop for guild ranks ?
            pWriter.WriteByte(0x0);
            pWriter.WriteUnicodeString("Leader");
            pWriter.WriteInt(4095);
            pWriter.WriteByte(0x1);
            pWriter.WriteUnicodeString("Jr.Leader");
            pWriter.WriteInt(1);
            pWriter.WriteByte(0x2);
            pWriter.WriteUnicodeString("Member");
            pWriter.WriteInt(1);
            pWriter.WriteByte(0x3);
            pWriter.WriteUnicodeString("NewMember");
            pWriter.WriteInt(1);
            pWriter.WriteByte(0x4);
            pWriter.WriteUnicodeString("Member2");
            pWriter.WriteInt(1);
            pWriter.WriteByte(0x5);
            pWriter.WriteUnicodeString("NewMember2");
            pWriter.WriteInt(1);
            pWriter.WriteByte(0x9); // loop for all guild skills
            pWriter.WriteInt(1);    // guild skill ID
            pWriter.WriteInt(1);    // guild skill level
            pWriter.WriteLong(0);
            pWriter.WriteInt(2);
            pWriter.WriteInt(1);
            pWriter.WriteLong(0);
            pWriter.WriteInt(3);
            pWriter.WriteInt(1);
            pWriter.WriteLong(0);
            pWriter.WriteInt(4);
            pWriter.WriteInt(1);
            pWriter.WriteLong(0);
            pWriter.WriteInt(10001);
            pWriter.WriteInt(1);
            pWriter.WriteLong(0);
            pWriter.WriteInt(10002);
            pWriter.WriteInt(1);
            pWriter.WriteLong(0);
            pWriter.WriteInt(10003);
            pWriter.WriteInt(1);
            pWriter.WriteLong(0);
            pWriter.WriteInt(10004);
            pWriter.WriteInt(1);
            pWriter.WriteLong(0);
            pWriter.WriteInt(10005);
            pWriter.WriteInt(1);
            pWriter.WriteLong(0);
            pWriter.WriteByte(0x4); // another loop. unk
            pWriter.WriteInt(1);
            pWriter.WriteInt(0);
            pWriter.WriteInt(2);
            pWriter.WriteInt(0);
            pWriter.WriteInt(3);
            pWriter.WriteInt(0);
            pWriter.WriteInt(4);
            pWriter.WriteInt(0);
            pWriter.WriteInt(1);
            pWriter.WriteInt(1);
            pWriter.WriteInt(0);
            pWriter.WriteByte(0x0);
            pWriter.WriteByte(0x1);
            pWriter.WriteShort(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteUnicodeString("");
            pWriter.WriteLong(0);
            pWriter.WriteLong(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            pWriter.WriteInt(0);
            return(pWriter);
        }
Example #53
0
    [SerializeField] int timesHit;           //only serialized for debug pruposes

    private void Start()
    {
        CountBreakable();

        gameStatus = FindObjectOfType <GameSession>();
    }
Example #54
0
 // Use this for initialization
 void Start()
 {
     gameSession = FindObjectOfType <GameSession>();
 }
Example #55
0
        public override bool OnFarmWork(GameSession session)
        {
            if (!Program.Instance.Config.ReadCustomBool("neighborlynx", "active", false))
                return true;

            string[] rewardGiftTypes = new string[] {
                "CollectionsFriendReward",
                "DairyFarmFertilizerFriendReward",
                "EggFriendReward",
                "FlowerFriendReward",
                "HolidayTreeFriendReward",
                "HorseStableFriendReward",
                "lonelyAnimals",
                "StorageExpansionFriendReward",
                "ValentineFriendReward",
                "ValentineRedeemFriendReward"
               };
            string[] rewardCoinTypes = new string[] {
                "AchievementFriendReward",
                "CoinFriendReward",
                "FertilizeThankFriendReward",
                "MasteryFriendReward"
            };

            Dictionary<string, List<string>> links = new Dictionary<string, List<string>>();

            // if (!Program.Instance.Config.ReadCustomBool("neighborlinks", "active", false))
            //    return true;

            int x = 0;
            int y = 0;
            foreach (string info in Program.Instance.GameSession.Player.Neighbors)
            {
                Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "NeighborLynx", "Visiting {0} of {1}", ++x, Program.Instance.GameSession.Player.Neighbors.Count);
                Game.Requests.BatchRequest req = new Game.Requests.BatchRequest("test") { SessionInfo = new Game.Requests.BasicSessionInfo(float.NaN, Program.Instance.GameSession.ServerSession.Token, Program.Instance.GameSession.ServerSession.FlashRevision, Program.Instance.GameSession.ServerSession.FbId) };
                Game.Requests.LoadWorldRequest loadWorld = new Game.Requests.LoadWorldRequest(1, info);
                req.BatchedRequests.Add(loadWorld);
                Server.ServerSession.BlockingCallback callback = Program.Instance.GameSession.ServerSession.MakeBlockingRequest(req);
                object[] data;
                if (callback.Success == false || !Server.ServerSession.GetRequestData(callback, out data))
                    return false;

                FluorineFx.ASObject dataObj = data[0] as FluorineFx.ASObject;
                dataObj = dataObj["data"] as FluorineFx.ASObject;
                FluorineFx.ASObject playerObj = dataObj["player"] as FluorineFx.ASObject;
                FluorineFx.ASObject friendRewards = playerObj["friendRewards"] as FluorineFx.ASObject;
                if (friendRewards != null)
                {
                    foreach (string key in friendRewards.Keys)
                    {
                        if (!rewardGiftTypes.Contains(key))
                            Console.WriteLine("found unknown: " + key);
                    }
                    foreach (string reward in rewardGiftTypes)
                    {
                        if (friendRewards.ContainsKey(reward))
                        {
                            FluorineFx.ASObject theobj = friendRewards[reward] as FluorineFx.ASObject;
                            foreach (string key in theobj.Keys)
                            {
                                FluorineFx.ASObject rewardData = theobj[key] as FluorineFx.ASObject;
                                FluorineFx.ASObject helpers = rewardData["helpers"] as FluorineFx.ASObject;

                                if (reward == "FlowerFriendReward" && helpers != null && helpers.Count >= ((int)rewardData["m_numItems"]))
                                    continue;
                                else if (rewardData.ContainsKey("helpers") && helpers != null && helpers.Count >= 10)
                                    continue;
                                if (reward == "EggFriendReward" && helpers != null && helpers.Count >= 3)
                                    continue;
                                if (reward == "ValentineRedeemFriendReward" && helpers != null && helpers.Count >= 1)
                                    continue;
                                if (helpers == null || !helpers.ContainsKey(Program.Instance.GameSession.ServerSession.FbId))
                                {
                                    if (_visitedLinks.ContainsKey(key))
                                        continue;
                                    _visitedLinks.Add(key, key);
                                    // we haven't helped.

                                    string like = string.Format("http://apps.facebook.com/onthefarm/reward.php?frHost={0}&frId={1}&frType={2}", info, key, reward);
                                    if (!links.ContainsKey(reward))
                                        links.Add(reward, new List<string>());
                                    links[reward].Add(like);
                                }
                                y++;

                            }
                        }
                    }
                }

            }
            Program.Instance.Logger.Log(Everworld.Logging.Logger.LogLevel.Info, "NeighborLynx", "{0} links generated.", y);
            y = 0;
            using (System.IO.TextWriter tw = new System.IO.StreamWriter(string.Format("{0}.links.html", Everworld.Utility.Time.UnixTime())))
            {
                foreach (string key in links.Keys)
                {
                    List<string> linkslist = links[key];
                    linkslist.Sort();
                    tw.WriteLine(key+"<br />");
                    foreach (string str in linkslist)
                        tw.WriteLine("<a href=\"" + str + "\">" + (y++) + "</a><br />");
                }
                tw.Flush();
                tw.Close();
            }

            return false;
        }
Example #56
0
 // Use this for initialization
 void Start()
 {
     score = GetComponent <Text>();
     game  = FindObjectOfType <GameSession>();
 }
Example #57
0
    // Start is called before the first frame update

    private void Start()
    {
        gameStatus = FindObjectOfType <GameSession>();
        CountBreaklableBlocks();
    }
Example #58
0
 void Start()
 {
     gameSession = FindObjectOfType <GameSession>();
     ammos       = GetComponentsInChildren <Image>();
 }
Example #59
0
 public void ClientAction(GameSession gameSession)
 {
     FighterGame.Map.GameMap.SERVERCP = portablePolygon.DeployPolygon();
 }
Example #60
0
 private void Start()
 {
     session = FindObjectOfType <GameSession>();
     ball    = FindObjectOfType <Ball>();
 }