Наследование: MonoBehaviour
Пример #1
0
 public FallingSand(WorldManager world, Location pos)
     : base(world, pos)
 {
     Type = Net.Packets.AddObjectVehiclePacket.ObjectType.FallingSand;
     BlockId = (byte) BlockData.Blocks.Sand;
     Velocity = new Vector3(0, -0.4D, 0);
 }
	public WorldManager()
	{
		currinst = this;
		
		lastChunkPos.x = -1;
		lastChunkPos.y = -1;
	}
Пример #3
0
 public StructBlock(UniversalCoords coords, byte type, byte metaData, WorldManager world)
 {
     Type = type;
     Coords = coords;
     MetaData = metaData;
     World = world;
 }
Пример #4
0
        public CowMouseComponent(CowMouseGame game, WorldManager worldManager)
            : base(game)
        {
            this.Game = game;

            this.WorldManager = worldManager;
        }
Пример #5
0
 public StructBlock(int worldX, int worldY, int worldZ, byte type, byte metaData, WorldManager world)
 {
     Type = type;
     Coords = UniversalCoords.FromWorld(worldX, worldY, worldZ);
     MetaData = metaData;
     World = world;
 }
Пример #6
0
    void Start()
    {
        worldManager = (WorldManager)FindObjectOfType (typeof(WorldManager));
        guiManager = (GUIManager)FindObjectOfType (typeof(GUIManager));

        characterMotor=worldManager.getPlayer().GetComponent<CharacterMotor>();
    }
Пример #7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            this.spriteBatch = new SpriteBatch(this.GraphicsDevice);

            // in case a texture fails to load, this is used in its place
            var nullTexture = new Texture2D(this.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            nullTexture.SetData(new[] { Color.White });

            // loads and provides content
            var contentProvider = new ContentProvider(this.Content, nullTexture);
            
            var worldManager = new WorldManager();

            this.screenControlHost = new ScreenControlHost(worldManager, contentProvider, new Rectangle(0, 0, 800, 600));

            // graphical interface
            // this.gameCanvasScreen = new GameCanvasScreen(contentProvider);

            // ViewportHelper.CurrentDevice = GraphicsDevice;
            // ViewportHelper.DefaultViewport = GraphicsDevice.Viewport;
            // Viewport viewport = GraphicsDevice.Viewport;
            // viewport.Width -= 100;
            // viewport.X = 100;
            // ViewportHelper.SpriteViewport = viewport;

            // viewport = GraphicsDevice.Viewport;
            // viewport.Width = 100;
            // ViewportHelper.MenuViewport = viewport;

            // GraphicsDevice.Viewport = ViewportHelper.SpriteViewport;
        }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        worldManager = ClientAPI.WorldManager;

        //worldManager.ObjectAdded += _handleObjectAdded;
        //worldManager.ObjectRemoved += _handleObjectRemoved;
    }
Пример #9
0
 public StructBlock(UniversalCoords coords, byte type, byte metaData, IWorldManager world)
 {
     _type = type;
     _coords = coords;
     _metaData = metaData;
     _world = world as WorldManager;
     _worldInterface = world;
 }
Пример #10
0
 public StructBlock(int worldX, int worldY, int worldZ, byte type, byte metaData, IWorldManager world)
 {
     _type = type;
     _coords = UniversalCoords.FromWorld(worldX, worldY, worldZ);
     _metaData = metaData;
     _world = world as WorldManager;
     _worldInterface = world;
 }
Пример #11
0
 public static WorldManager GetInstance ()
 {
     if (_instance == null)
     {
         _instance = Argamente.Managers.SingletonManager.AddComponent<WorldManager> ();
     }
     return _instance;
 }
Пример #12
0
 // Use this for initialization
 void Awake()
 {
     knife = (GameObject)Instantiate(knifePrefab, new Vector3(-4f, -6f, 5f), Quaternion.identity);
     em = GetComponent<EconomyManager>();
     wm = GetComponent<WorldManager>();
     downTime = 0;
     //knife.transform.position = new Vector3(100f, 100f);
 }
Пример #13
0
        public WorldCommandFactory(WorldManager worldManager)
        {
            if (worldManager == null) throw new ArgumentNullException("worldManager");

            this.worldManager = worldManager;

            pool.Register(typeof(SetBlockCommand), () => { return new SetBlockCommand(); });
        }
Пример #14
0
        /// <summary>
        /// Constructs a log at the specified square coordinates
        /// </summary>
        /// <param name="game"></param>
        /// <param name="squareX"></param>
        /// <param name="squareY"></param>
        /// <param name="usingTileCoordinates">True if x,y are referring to SQUARES, or False if they are in-world "pixels"</param>
        /// <param name="map"></param>
        public BasicResource(int squareX, int squareY, WorldManager manager)
            : base(manager)
        {
            this.xPos = squareX * Tile.TileInGameWidth + Tile.TileInGameWidthHalf;
            this.yPos = squareY * Tile.TileInGameHeight + Tile.TileInGameHeightHalf;

            this.currentState = CarryableState.LOOSE;
        }
Пример #15
0
    void Awake()
    {
        SceneFader.Instance.FillScreenBlack();
        bgmAudioSource = GetComponent<AudioSource>();
        worldMgr = GameObject.FindObjectOfType<WorldManager>();
        SetApprovalRatingImage();

        if (GameObject.Find("Title BGM") != null)
            Destroy(GameObject.Find("Title BGM"));
    }
Пример #16
0
 public StructBlock(int x, int y, int z, byte type, byte metaData, WorldManager world)
 {
     Type = type;
     X = x;
     Y = y;
     Z = z;
     MetaData = metaData;
     World = world;
     Chunk = World.GetBlockChunk(x, y, z);
 }
Пример #17
0
 public static void InitializeManager()
 {
     AddonMgr = AddonManager.GetInstance();
     DataMgr = DataManager.GetInstance();
     ObjectMgr = ObjectManager.GetInstance();
     SkillMgr = SkillManager.GetInstance();
     SpawnMgr = SpawnManager.GetInstance();
     SpellMgr = SpellManager.GetInstance();
     WorldMgr = WorldManager.GetInstance();
 }
 void Awake()
 {
     if (_instance != null && _instance != this)
     {
         //Zabezpieczamy sie przed istnieniem dwoch menedzerow
         Destroy(gameObject);
         return;
     }
     _instance = this;
 }
Пример #19
0
        public Torch(int xSquare, int ySquare, WorldManager manager)
            : base(manager)
        {
            this.xPosition = base.FindXCoordinate(xSquare, ySquare);
            this.yPosition = base.FindYCoordinate(xSquare, ySquare);

            sourceIndex = ran.Next(4);

            AmountOfLight = MinLight + ((float)ran.NextDouble()) * LightRange;
            lightChange = MinChange + ((float)ran.NextDouble()) * ChangeRange;
        }
Пример #20
0
 public Bedroom(int xMin, int xMax, int yMin, int yMax, WorldManager manager)
     : base(xMin, xMax, yMin, yMax, manager)
 {
     for (int x = xMin; x <= xMax; x++)
     {
         for (int y = yMin; y <= yMax; y++)
         {
             manager.MyMap.AddConstructedCell(unbuiltCell, x, y);
         }
     }
 }
Пример #21
0
 public Stockpile(int xmin, int xmax, int ymin, int ymax, WorldManager manager)
     : base(xmin, xmax, ymin, ymax, manager)
 {
     for (int x = xmin; x <= xmax; x++)
     {
         for (int y = ymin; y <= ymax; y++)
         {
             WorldManager.MyMap.AddConstructedCell(unbuiltCell, x, y);
         }
     }
 }
Пример #22
0
        protected BaseFallingPhysics(WorldManager world, AbsWorldCoords pos)
        {
            World = world;
            Position = pos;
            EntityId = world.Server.AllocateEntity();

            CreateEntityPacket entity = new CreateEntityPacket { EntityId = EntityId };
            World.Server.SendPacketToNearbyPlayers(World,
                                                   UniversalCoords.FromAbsWorld(Position.X, Position.Y, Position.Z),
                                                   entity);
        }
Пример #23
0
        protected BlockBasePhysics(WorldManager world, Location pos)
        {
            World = world;
            Position = pos;
            EntityId = world.Server.AllocateEntity();

            CreateEntityPacket entity = new CreateEntityPacket { EntityId = EntityId };
            foreach (var nearbyPlayer in World.Server.GetNearbyPlayers(World, new AbsWorldCoords(Position.X, Position.Y, Position.Z)))
            {
                nearbyPlayer.SendPacket(entity);
            }
        }
Пример #24
0
        public Building(int xMin, int xMax, int yMin, int yMax, WorldManager manager)
        {
            this.XMin = xMin;
            this.XMax = xMax;

            this.YMin = yMin;
            this.YMax = yMax;

            this.WorldManager = manager;

            InitializeSquareStates();
        }
 public void MarioQuestionBlockRightCollision()
 {
     TestGame = new MarioGame();
     TestWorld = TestGame.World;
     Content = TestGame.Content;
     TestMario = TestGame.World.Mario;
     //TestBlock = TestGame.World.QuestionBlockObject;
     TestCommand = new MarioRightCommand(TestGame);
     TestMario.PassCommand(TestCommand);
     //Check that question block is not changed
     //Assert.AreEqual(QuestionBlockSpriteState, TestBlock.SpriteState);
 }
Пример #26
0
    void Awake()
    {
        if (instance == null) {
            instance = this;

            if (seed == null) {
                seed = Time.time.GetHashCode ();
            }
        } else {
            Destroy (this);
        }
    }
        public void MarioQuestionBlockBottomCollision()
        {
            TestGame = new MarioGame();
            TestWorld = TestGame.World;
            Content = TestGame.Content;
            TestMario = TestGame.World.Mario;
            //TestBlock = TestGame.World.QuestionBlockObject;
            TestCommand = new MarioUpCommand(TestGame);
            TestMario.PassCommand(TestCommand);

            //Check that question block is now used block
            //Assert.AreEqual(UsedBlockSpriteState, TestBlock.SpriteState);
        }
Пример #28
0
        public ActorManager(WorldManager w, Random r)
        {
            worldManager = w;
            
            random = r;
            actorPrototypes = new Dictionary<string,Actor>();
            behaviorLists = new List<ActionList>();
            actors = new List<Actor>();

            Actor.Death += new EventHandler<EventArgs>(Actor_Death);
            Actor.Attack += new EventHandler<AttackEventArgs>(Actor_Attack);

        }
Пример #29
0
    public CollisionManager(WorldManager worldManager, string blobName2, BlobManager blobManager)
    {
        //make blobManager null when we just want to put blob2 contents into blob1
        this.worldManager = worldManager;

        blobName1 = "main blob";
        this.blobName2 = blobName2;
        this.newBlobManager = blobManager;
        isBlob2InsideBlob1 = newBlobManager == null;

        isDone = false;
        isStarted = false;
        subtaskCounter = 0;
    }
Пример #30
0
    //TimePlayerEnteredWarmth, TimeInverval
    // Use this for initialization
    void Start()
    {
        warmthCollider = this.gameObject.AddComponent<CircleCollider2D> ();
        //warmthCollider.radius = warmthBoundaries;
        dynamicLightScript = this.gameObject.GetComponent<DynamicLight> ();
        warmthCollider.radius = dynamicLightScript.lightRadius;
        warmthCollider.isTrigger = true;
        playerWarmthScript = GameObject.Find ("playerWolf").transform.Find ("playerWarmth").GetComponent<playerWarmth> ();
        worldManagerScript = GameObject.Find ("WorldManager").GetComponent<WorldManager> ();

        if (worldManagerScript.WorldType == 0) {
            //do what here?
        }
    }
Пример #31
0
 public static void HandleWorldPortAck(ref PacketReader packet, ref WorldManager manager)
 {
     GridManager.Instance.SendSurrounding(manager.Character.BuildUpdate(), manager.Character);
     manager.Character.FindObjectsInRange(true);
 }
Пример #32
0
 public virtual bool CanBeAppliedTo(GameComponent Entity, WorldManager World)
 {
     return(false);
 }
Пример #33
0
        protected override void Update(GameTime gameTime)
        {
            System.Threading.Thread.Sleep(5);

            Camera.Update(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            MouseState    mouseState    = Mouse.GetState();
            KeyboardState keyBoardState = Keyboard.GetState();

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            switch (_gameState)
            {
            case GameState.StartScreen:

                if (start.Tick(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed && _delay <= 0)
                {
                    _gameState = GameState.GameScreen;
                    _delay     = 10;
                    Camera.SetX(0);
                    Camera.SetY(0);
                    Update(gameTime);
                }
                break;

            case GameState.GameScreen:

                if (keyBoardState.IsKeyDown(Keys.A))
                {
                    Player.Angle -= .075f;
                    Player.Angle  = Player.Angle < 0 ? Player.Angle + (float)Math.PI * 2: Player.Angle;
                }


                if (keyBoardState.IsKeyDown(Keys.D))
                {
                    Player.Angle += .075f;
                    Player.Angle %= (float)Math.PI * 2;
                }

                if (keyBoardState.IsKeyDown(Keys.W) && Player.Fuel > 0)
                {
                    Player.AddToVelocity(.13f * WorldManager.AccelerationModifier, Player.Angle);
                    Player.Fuel -= 0.1f;
                }

                if (Player.Health <= 0)
                {
                    _gameState = GameState.LoseScreen;
                    Update(gameTime);
                }

                WorldManager.WorldTick();
                WorldManager.WorldTick2();
                Player.Tick();
                SupernovaObject.Tick();

                break;

            case GameState.LoseScreen:
                if (end.Tick(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed && _delay <= 0)
                {
                    _gameState = GameState.StartScreen;
                    Player.Reset();
                    SupernovaObject.Reset();
                    WorldManager.Reset();
                    _delay = 10;
                    Camera.SetX(0);
                    Camera.SetY(0);
                    Update(gameTime);
                }
                break;

            default:
                throw new Exception("Unknown Game State");
            }

            _delay = Math.Max(_delay - 1, 0);

            base.Update(gameTime);
        }
Пример #34
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(OnProcessExit);

            // Typically, you wouldn't force the current culture on an entire application unless you know sure your application is used in a specific region (which ACE is not)
            // We do this because almost all of the client/user input/output code does not take culture into account, and assumes en-US formatting.
            // Without this, many commands that require special characters like , and . will break
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            // Init our text encoding options. This will allow us to use more than standard ANSI text, which the client also supports.
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

            // Look for the log4net.config first in the current environment directory, then in the ExecutingAssembly location
            var exeLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var containerConfigDirectory = "/ace/Config";
            var log4netConfig            = Path.Combine(exeLocation, "log4net.config");
            var log4netConfigExample     = Path.Combine(exeLocation, "log4net.config.example");
            var log4netConfigContainer   = Path.Combine(containerConfigDirectory, "log4net.config");

            if (IsRunningInContainer && File.Exists(log4netConfigContainer))
            {
                File.Copy(log4netConfigContainer, log4netConfig, true);
            }

            var log4netFileInfo = new FileInfo("log4net.config");

            if (!log4netFileInfo.Exists)
            {
                log4netFileInfo = new FileInfo(log4netConfig);
            }

            if (!log4netFileInfo.Exists)
            {
                var exampleFile = new FileInfo(log4netConfigExample);
                if (!exampleFile.Exists)
                {
                    Console.WriteLine("log4net Configuration file is missing.  Please copy the file log4net.config.example to log4net.config and edit it to match your needs before running ACE.");
                    throw new Exception("missing log4net configuration file");
                }
                else
                {
                    if (!IsRunningInContainer)
                    {
                        Console.WriteLine("log4net Configuration file is missing,  cloning from example file.");
                        File.Copy(log4netConfigExample, log4netConfig);
                    }
                    else
                    {
                        if (!File.Exists(log4netConfigContainer))
                        {
                            Console.WriteLine("log4net Configuration file is missing, ACEmulator is running in a container,  cloning from docker file.");
                            var log4netConfigDocker = Path.Combine(exeLocation, "log4net.config.docker");
                            File.Copy(log4netConfigDocker, log4netConfig);
                            File.Copy(log4netConfigDocker, log4netConfigContainer);
                        }
                        else
                        {
                            File.Copy(log4netConfigContainer, log4netConfig);
                        }
                    }
                }
            }

            var logRepository = LogManager.GetRepository(System.Reflection.Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, log4netFileInfo);

            if (Environment.ProcessorCount < 2)
            {
                log.Warn("Only one vCPU was detected. ACE may run with limited performance. You should increase your vCPU count for anything more than a single player server.");
            }

            // Do system specific initializations here
            try
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    // On many windows systems, the default resolution for Thread.Sleep is 15.6ms. This allows us to command a tighter resolution
                    MM_BeginPeriod(1);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }

            log.Info("Starting ACEmulator...");
            var assembly        = Assembly.GetExecutingAssembly();
            var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
            var serverVersion   = fileVersionInfo.ProductVersion;

            Console.Title = @$ "ACEmulator - v{serverVersion}";

            var configFile            = Path.Combine(exeLocation, "Config.js");
            var configConfigContainer = Path.Combine(containerConfigDirectory, "Config.js");

            if (IsRunningInContainer && File.Exists(configConfigContainer))
            {
                File.Copy(configConfigContainer, configFile, true);
            }

            if (!File.Exists(configFile))
            {
                if (!IsRunningInContainer)
                {
                    DoOutOfBoxSetup(configFile);
                }
                else
                {
                    if (!File.Exists(configConfigContainer))
                    {
                        DoOutOfBoxSetup(configFile);
                        File.Copy(configFile, configConfigContainer);
                    }
                    else
                    {
                        File.Copy(configConfigContainer, configFile);
                    }
                }
            }

            log.Info("Initializing ConfigManager...");
            ConfigManager.Initialize();

            if (ConfigManager.Config.Offline.PurgeDeletedCharacters)
            {
                log.Info($"Purging deleted characters, and their possessions, older than {ConfigManager.Config.Offline.PurgeDeletedCharactersDays} days ({DateTime.Now.AddDays(-ConfigManager.Config.Offline.PurgeDeletedCharactersDays)})...");
                ShardDatabaseOfflineTools.PurgeCharactersInParallel(ConfigManager.Config.Offline.PurgeDeletedCharactersDays, out var charactersPurged, out var playerBiotasPurged, out var possessionsPurged);
                log.Info($"Purged {charactersPurged:N0} characters, {playerBiotasPurged:N0} player biotas and {possessionsPurged:N0} possessions.");
            }

            if (ConfigManager.Config.Offline.PurgeOrphanedBiotas)
            {
                log.Info($"Purging orphaned biotas...");
                ShardDatabaseOfflineTools.PurgeOrphanedBiotasInParallel(out var numberOfBiotasPurged);
                log.Info($"Purged {numberOfBiotasPurged:N0} biotas.");
            }

            log.Info("Initializing ServerManager...");
            ServerManager.Initialize();

            log.Info("Initializing DatManager...");
            DatManager.Initialize(ConfigManager.Config.Server.DatFilesDirectory, true);

            log.Info("Initializing DatabaseManager...");
            DatabaseManager.Initialize();

            log.Info("Starting DatabaseManager...");
            DatabaseManager.Start();

            log.Info("Starting PropertyManager...");
            PropertyManager.Initialize();

            log.Info("Initializing GuidManager...");
            GuidManager.Initialize();

            if (ConfigManager.Config.Server.ServerPerformanceMonitorAutoStart)
            {
                log.Info("Server Performance Monitor auto starting...");
                ServerPerformanceMonitor.Start();
            }

            if (ConfigManager.Config.Server.WorldDatabasePrecaching)
            {
                log.Info("Precaching Weenies...");
                DatabaseManager.World.CacheAllWeeniesInParallel();
                log.Info("Precaching Cookbooks...");
                DatabaseManager.World.CacheAllCookbooksInParallel();
                log.Info("Precaching Events...");
                DatabaseManager.World.GetAllEvents();
                log.Info("Precaching House Portals...");
                DatabaseManager.World.CacheAllHousePortals();
                log.Info("Precaching Points Of Interest...");
                DatabaseManager.World.CacheAllPointsOfInterest();
                log.Info("Precaching Spells...");
                DatabaseManager.World.CacheAllSpells();
                log.Info("Precaching Treasures - Death...");
                DatabaseManager.World.CacheAllTreasuresDeath();
                log.Info("Precaching Treasures - Material Base...");
                DatabaseManager.World.CacheAllTreasuresMaterialBaseInParallel();
                log.Info("Precaching Treasures - Material Groups...");
                DatabaseManager.World.CacheAllTreasuresMaterialGroupsInParallel();
                log.Info("Precaching Treasures - Material Colors...");
                DatabaseManager.World.CacheAllTreasuresMaterialColorInParallel();
                log.Info("Precaching Treasures - Wielded...");
                DatabaseManager.World.CacheAllTreasuresWieldedInParallel();
            }
            else
            {
                log.Info("Precaching World Database Disabled...");
            }

            log.Info("Initializing PlayerManager...");
            PlayerManager.Initialize();

            log.Info("Initializing HouseManager...");
            HouseManager.Initialize();

            log.Info("Initializing InboundMessageManager...");
            InboundMessageManager.Initialize();

            log.Info("Initializing SocketManager...");
            SocketManager.Initialize();

            log.Info("Initializing WorldManager...");
            WorldManager.Initialize();

            log.Info("Initializing EventManager...");
            EventManager.Initialize();

            // Free up memory before the server goes online. This can free up 6 GB+ on larger servers.
            log.Info("Forcing .net garbage collection...");
            for (int i = 0; i < 10; i++)
            {
                GC.Collect();
            }

            // This should be last
            log.Info("Initializing CommandManager...");
            CommandManager.Initialize();

            if (!PropertyManager.GetBool("world_closed", false).Item)
            {
                WorldManager.Open(null);
            }
        }
 public ExitWorldRequest(GameClient client, ReceivablePacket packet)
 {
     WorldManager.RemoveObject(client.GetActiveChar());
     client.SetActiveChar(null);
 }
Пример #36
0
 bool CanSwitchWorld()
 {
     return(!Physics2D.OverlapCircle(activableColliderCheck.position, crateCheckRadius, WorldManager.GetOppositeLayerMask()));
 }
Пример #37
0
 public override void Trigger(WorldManager world)
 {
     DiseaseLibrary.SpreadRandomDiseases(world.PlayerFaction.Minions);
     base.Trigger(world);
 }
Пример #38
0
        public async Task CompleteHunts()
        {
            int[]     dailyOrderTypes = { 0, 1, 2, 3, 6, 7, 8, 10, 11, 12 };
            const int flytoHunt       = 418;

            int[] umbra = { 107, 247 };
            var   hunts = new List <DailyHuntOrder>();

            foreach (var dailyOrderType in dailyOrderTypes)
            {
                hunts.AddRange(HuntHelper.GetAcceptedDailyHunts(dailyOrderType).Where(i => !i.IsFinished));
            }

            foreach (var hunt in hunts.OrderBy(i => i.MapId).ThenBy(j => j.Location.X))
            {
                Log($"{hunt}");
                while (Core.Me.InCombat)
                {
                    var target = GameObjectManager.Attackers.FirstOrDefault(i => i.InCombat && i.IsAlive);
                    if (target != default(BattleCharacter) && target.IsValid && target.IsAlive)
                    {
                        await Navigation.GetTo(WorldManager.ZoneId, target.Location);
                        await KillMob(target);
                    }
                }

                if (WorldManager.ZoneId == 401 && hunt.MapId == 401)
                {
                    var AE = WorldManager.AetheryteIdsForZone(hunt.MapId).OrderBy(i => i.Item2.DistanceSqr(hunt.Location)).First();
                    WorldManager.TeleportById(AE.Item1);
                    await Coroutine.Wait(20000, () => WorldManager.ZoneId == AE.Item1);

                    await Coroutine.Sleep(2000);
                }

                if (WorldManager.ZoneId == 402 && hunt.MapId == 402)
                {
                    var AE = WorldManager.AetheryteIdsForZone(hunt.MapId).OrderBy(i => i.Item2.DistanceSqr(hunt.Location)).First();
                    WorldManager.TeleportById(AE.Item1);
                    await Coroutine.Wait(20000, () => WorldManager.ZoneId == AE.Item1);

                    await Coroutine.Sleep(2000);
                }

                if (hunt.HuntTarget == flytoHunt)
                {
                    var AE = WorldManager.AetheryteIdsForZone(hunt.MapId).OrderBy(i => i.Item2.DistanceSqr(hunt.Location)).First();
                    WorldManager.TeleportById(AE.Item1);
                    await Coroutine.Wait(20000, () => WorldManager.ZoneId == AE.Item1);

                    await Coroutine.Sleep(2000);

                    await Navigation.FlightorMove(new Vector3(196.902f, -163.4457f, 113.3596f));

                    //
                    Navigator.PlayerMover.MoveTowards(new Vector3(208.712f, -165.4754f, 128.228f));

                    await Coroutine.Wait(10000, () => CommonBehaviors.IsLoading);

                    Navigator.Stop();
                    await Coroutine.Sleep(1000);

                    if (CommonBehaviors.IsLoading)
                    {
                        await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);
                    }
                    while (!hunt.IsFinished)
                    {
                        if (await FindAndKillMob(hunt.NpcID))
                        {
                            Log("Killed one");
                            await Coroutine.Sleep(1000);

                            if (!Core.Me.InCombat)
                            {
                                await Coroutine.Sleep(3000);
                            }
                        }
                        else
                        {
                            Log("None found, sleeping 10 sec.");
                            await Coroutine.Sleep(10000);
                        }
                    }
                }
                else if (umbra.Contains(hunt.HuntTarget))
                {
                    await Navigation.GetToIslesOfUmbra();

                    if (await Navigation.GetTo(hunt.MapId, hunt.Location))
                    {
                        while (!hunt.IsFinished)
                        {
                            if (await FindAndKillMob(hunt.NpcID))
                            {
                                Log("Killed one");
                                await Coroutine.Sleep(1000);

                                if (!Core.Me.InCombat)
                                {
                                    await Coroutine.Sleep(3000);
                                }
                            }
                            else
                            {
                                Log("None found, sleeping 10 sec.");
                                await Coroutine.Sleep(10000);
                            }
                        }
                    }
                }
                else if (await Navigation.GetTo(hunt.MapId, hunt.Location))
                {
                    while (!hunt.IsFinished)
                    {
                        if (await FindAndKillMob(hunt.NpcID))
                        {
                            Log("Killed one");
                            await Coroutine.Sleep(1000);

                            if (!Core.Me.InCombat)
                            {
                                await Coroutine.Sleep(3000);
                            }
                        }
                        else
                        {
                            Log("None found, sleeping max 10 sec.");
                            await Coroutine.Wait(10000, () => FindMob(hunt.NpcID));
                        }
                    }
                }

                Log($"Done: {hunt}");
                var newPlayerItems = InventoryManager.GetBagsByInventoryBagId(PlayerInventoryBagIds).Select(i => i.FilledSlots).SelectMany(x => x).AsParallel().ToList();
                var newitems       = newPlayerItems.Except(_playerItems, new BagSlotComparer());
                Log("New loot");
                Log($"{string.Join(",", newitems)}");
                Blacklist.Clear();
                await Coroutine.Sleep(1000);
            }

            /*foreach (var orderType in dailyOrderTypes)
             * {
             *  var dailies = HuntHelper.GetAcceptedDailyHunts(orderType).OrderBy(i=> i.MapId).ThenBy(j => j.Location.X);
             *  if (dailies.Any(i => !i.IsFinished))
             *  {
             *      foreach (var hunt in dailies.Where(i => !i.IsFinished))
             *      {
             *
             *  }
             * }*/

            while (Core.Me.InCombat)
            {
                var target = GameObjectManager.Attackers.FirstOrDefault(i => i.InCombat);
                if (target != default(BattleCharacter) && target.IsValid && target.IsAlive)
                {
                    await Navigation.GetTo(WorldManager.ZoneId, target.Location);
                    await KillMob(target);
                }
            }
        }
Пример #39
0
 private void Start()
 {
     worldManager = GameManager.Instance.worldManager;
 }
Пример #40
0
 private void Awake()
 {
     instance  = this;
     tilesRoot = worldRenderer.transform.Find("Tiles");
 }
Пример #41
0
 public static void HandleLogoutRequest(ref PacketReader packet, ref WorldManager manager)
 {
     manager.Send(new PacketWriter(Opcodes.SMSG_LOGOUT_COMPLETE));
     manager.Character.Logout();
 }
Пример #42
0
        private static async Task GetToResidential(uint aetheryteId)
        {
            if (!ConditionParser.HasAetheryte(aetheryteId))
            {
                return;
            }

            if (!WorldManager.TeleportById(aetheryteId))
            {
                return;
            }

            do
            {
                await Coroutine.Sleep(2000);
            } while (Core.Me.IsCasting);
            await Coroutine.Sleep(2000);

            if (CommonBehaviors.IsLoading)
            {
                await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);
            }

            await Coroutine.Wait(10000, () => GameObjectManager.GetObjectByNPCId(aetheryteId) != null);

            await Coroutine.Sleep(2000);

            var unit = GameObjectManager.GetObjectByNPCId(aetheryteId);

            if (!unit.IsWithinInteractRange)
            {
                Log($"Not in range {unit.Distance2D()}");
                var target = unit.Location;
                if (WorldManager.RawZoneId == 129)
                {
                    target = new Vector3(-89.30112f, 18.80033f, -2.019181f);
                }
                else if (WorldManager.RawZoneId == 628)
                {
                    target = new Vector3(48.03579f, 4.549999f, -31.83851f);
                }
                //await CommonTasks.MoveAndStop(new MoveToParameters(target.FanOutRandom(2f), unit.Name), 2f, true);
                await Navigation.GetTo(WorldManager.ZoneId, target);

/*                Navigator.PlayerMover.MoveTowards(target);
 *              while (!unit.IsWithinInteractRange)
 *              {
 *                  Navigator.PlayerMover.MoveTowards(target);
 *                  await Coroutine.Sleep(100);
 *              }
 *
 *              Navigator.PlayerMover.MoveStop();*/
            }
            else
            {
                Log($"In range {unit.Distance2D()}");
            }

            unit.Target();
            unit.Interact();

            await Coroutine.Wait(5000, () => SelectString.IsOpen);

            if (SelectString.IsOpen)
            {
                SelectString.ClickLineContains("Residential");
            }

            await Coroutine.Sleep(500);

            await Coroutine.Wait(5000, () => SelectString.IsOpen);
        }
        public IEnumerable <Entity> GenerateAvailableEntities(int chunkX, int chunkZ, WorldManager manager)
        {
            lock (CacheLock)
            {
                //the following is a big block of checks to avoid
                if (!IsReady(chunkX, chunkZ))
                {
                    yield break;
                }

                int dist = Math.Abs(chunkX - IntendedCenterX) + Math.Abs(chunkZ - IntendedCenterZ);
                if (dist > EntitySpawnRadius)
                {
                    yield break;
                }

                CacheData dat = this[chunkX, chunkZ];

                if (dat.EntitiesSpawned)
                {
                    yield break;
                }

                dat.Spawn();

                foreach (Entity e in dat.Chunk.MakeGeneratedEntities(manager))
                {
                    yield return(e);
                }
            }
        }
Пример #44
0
 public override void _Ready()
 {
     this.World         = (WorldManager)this.FindParent("WorldManager");
     this.lightDistance = this.TextureScale * 48;
 }
Пример #45
0
 private void Start()
 {
     current = this;
 }
Пример #46
0
 private void OnDisable() => instance = null;
Пример #47
0
 public static void HandleFriendListOpcode(ref PacketReader packet, ref WorldManager manager)
 {
     manager.Character.SendFriendList();
     manager.Character.SendIgnoreList();
 }
Пример #48
0
        public static void HandleCharCreate(ref PacketReader packet, ref WorldManager manager)
        {
            ulong guid = 1;

            if (Database.Players.Count() > 0)
            {
                guid = Database.Players.Keys.Max() + 1;
            }

            Player cha = new Player(guid)
            {
                Name       = packet.ReadString(),
                Race       = packet.ReadByte(),
                Class      = packet.ReadByte(),
                Gender     = packet.ReadByte(),
                Skin       = packet.ReadByte(),
                Face       = packet.ReadByte(),
                HairStyle  = packet.ReadByte(),
                HairColour = packet.ReadByte(),
                FacialHair = packet.ReadByte()
            };

            // Ugly but faster. In Alpha players were allowed to have, at least (looking at screnshots), 2 uppercase letters (seems like the first letter was mandatory).
            cha.Name = char.ToUpper(cha.Name[0]) + cha.Name.Substring(1);
            int upper_count = 0;

            for (int i = 0; i < cha.Name.Length; i++)
            {
                if (char.IsUpper(cha.Name[i]))
                {
                    upper_count++;
                }
            }
            if (upper_count > 2)
            {
                cha.Name = cha.Name[0] + cha.Name.Substring(1).ToLower(); //Format to UCFirst
            }
            packet.ReadByte();

            SetMasks(cha);

            PacketWriter writer = new PacketWriter(Opcodes.SMSG_CHAR_CREATE);

            if (Database.Players.TryGetName(cha.Name) != null)
            {
                writer.WriteUInt8((byte)CharCreate.CHAR_CREATE_NAME_IN_USE);
            }
            else
            {
                cha.AccountId = manager.Account.Id;
                cha.PreLoad();
                cha.Create();

                if (Database.Players.TryAdd(cha))
                {
                    writer.WriteUInt8((byte)CharCreate.CHAR_CREATE_SUCCESS);
                }
                else
                {
                    writer.WriteUInt8((byte)CharCreate.CHAR_CREATE_FAILED);
                }
            }

            manager.Send(writer);
        }
Пример #49
0
        public void DoWorldBroadcast(string message, ChatMessageType messageType)
        {
            GameMessageSystemChat sysMessage = new GameMessageSystemChat(message, messageType);

            WorldManager.BroadcastToAll(sysMessage);
        }
Пример #50
0
 public static void HandleNULL(ref PacketReader packet, ref WorldManager manager)
 {
 }                                                                                    //Prevents showing unhandled packets
Пример #51
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, DepthStencilState.DepthRead);


            switch (_gameState)
            {
            case GameState.StartScreen:
                title.Render(_spriteBatch);
                start.Render(_spriteBatch);


                break;

            case GameState.GameScreen:
                WorldManager.WorldRender(_spriteBatch);
                Player.Render(_spriteBatch);
                SupernovaObject.Render(_spriteBatch);
                InfoBar.Render(_spriteBatch);
                break;

            case GameState.LoseScreen:
                font = Content.Load <SpriteFont>("BaseFont");
                String score = Player.Score.ToString();

                _spriteBatch.DrawString(
                    font,
                    "GAME OVER",
                    new Vector2(640 * Camera.GetWidthScalar(), 50),
                    Color.Red,
                    0,
                    new Vector2(font.MeasureString("GAME OVER").X / 2, 0),
                    Vector2.One,
                    SpriteEffects.None,
                    0);

                _spriteBatch.DrawString(
                    font,
                    "Score",
                    new Vector2(640 * Camera.GetWidthScalar(), 200),
                    Color.Gray,
                    0,
                    new Vector2(font.MeasureString("Score").X / 2, 0),
                    new Vector2(0.5F, 0.5F),
                    SpriteEffects.None,
                    0);

                _spriteBatch.DrawString(
                    font,
                    score,
                    new Vector2(
                        640 * Camera.GetWidthScalar(),
                        360 * Camera.GetHeightScalar()),
                    Color.White,
                    0,
                    new Vector2(font.MeasureString(score).X / 2, font.MeasureString(score).Y / 2),
                    Vector2.One,
                    SpriteEffects.None,
                    0);
                end.Render(_spriteBatch);
                break;

            default:
                throw new Exception("Unknown Game State");
            }

            base.Draw(gameTime);

            _spriteBatch.End();
        }
Пример #52
0
 private void Awake()
 {
     Instance = this;
 }
Пример #53
0
 public virtual void Apply(GameComponent Entity, WorldManager World)
 {
 }
Пример #54
0
 void Awake()
 {
     wm = GetComponent <WorldManager>();
 }
Пример #55
0
 void Awake()
 {
     instance = this;
 }
Пример #56
0
 public static void HandleWorldTeleportAck(ref PacketReader packet, ref WorldManager manager)
 {
     HandleWorldPortAck(ref packet, ref manager);
 }
Пример #57
0
        static void Player_Moved(object sender, Events.PlayerMovedEventArgs e)
        {
            //abuse portal moved event and add in message blocks right here
            Vector3I oldPos = new Vector3I(e.OldPosition.X / 32, e.OldPosition.Y / 32, e.OldPosition.Z / 32); //get positions as block coords
            Vector3I newPos = new Vector3I(e.NewPosition.X / 32, e.NewPosition.Y / 32, e.NewPosition.Z / 32);

            if (oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z) //check if player has moved at least one block
            {
                //loop through all message blocks and check if we triggered one
                foreach (var messageBlock in e.Player.World.MessageBlocks)
                {
                    Tuple <Vector3I, string> tuple = messageBlock.Value;

                    //player is sitting on the message block, play the message
                    if (e.Player.Position.ToBlockCoords() == tuple.Item1)
                    {
                        e.Player.Message("__" + messageBlock.Key + "__");
                        e.Player.Message(messageBlock.Value.Item2);
                        e.Player.Message(e.Player.Position.ToBlockCoords().ToString());
                        e.Player.Message(tuple.Item1.ToString());
                    }
                }
            }

            try
            {
                if (e.Player.PortalsEnabled)
                {
                    lock (e.Player.PortalLock)
                    {
                        if (e.Player.CanUsePortal)
                        {
                            if ((e.OldPosition.X != e.NewPosition.X) || (e.OldPosition.Y != e.NewPosition.Y) || (e.OldPosition.Z != (e.NewPosition.Z)))
                            {
                                if (e.Player.Can(Permission.UsePortal))
                                {
                                    if (PortalHandler.GetInstance().GetPortal(e.Player) != null && !e.Player.StandingInPortal)
                                    {
                                        if (e.Player.LastUsedPortal != null && (DateTime.Now - e.Player.LastUsedPortal).TotalSeconds < 5)
                                        {
                                            // To prevent portal loops
                                            if (e.Player.LastWarnedPortal == null || (DateTime.Now - e.Player.LastWarnedPortal).TotalSeconds > 2)
                                            {
                                                e.Player.LastWarnedPortal = DateTime.Now;
                                                e.Player.Message("You can not use portals within 5 seconds of joining a world.");
                                            }

                                            return;
                                        }

                                        // Make sure this method isn't called twice
                                        e.Player.CanUsePortal = false;

                                        e.Player.StandingInPortal = true;
                                        Portal portal = PortalHandler.GetInstance().GetPortal(e.Player);

                                        World world = WorldManager.FindWorldExact(portal.World);
                                        // Teleport player, portal protection
                                        switch (world.AccessSecurity.CheckDetailed(e.Player.Info))
                                        {
                                        case SecurityCheckResult.Allowed:
                                        case SecurityCheckResult.WhiteListed:
                                            if (world.IsFull)
                                            {
                                                e.Player.Message("Cannot join {0}&S: world is full.", world.ClassyName);
                                                return;
                                            }
                                            e.Player.StopSpectating();
                                            e.Player.JoinWorld(WorldManager.FindWorldExact(portal.World), WorldChangeReason.Portal);
                                            e.Player.Message("You used portal: " + portal.Name);
                                            break;

                                        case SecurityCheckResult.BlackListed:
                                            e.Player.Message("Cannot join world {0}&S: you are blacklisted.",
                                                             world.ClassyName);
                                            break;

                                        case SecurityCheckResult.RankTooLow:
                                            e.Player.Message("Cannot join world {0}&S: must be {1}+",
                                                             world.ClassyName, world.AccessSecurity.MinRank.ClassyName);
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        e.Player.StandingInPortal = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogType.Error, "PortalHandler.Player_Moved: " + ex);
            }
        }
Пример #58
0
        public DebugManager(ILogger logger, Game game, GuiManager gui, IContentManager content, ISpriteBatch batch, InputManager input, WorldManager world, AlttpConsole console)
            : base(game)
        {
            Log      = logger;
            _gui     = gui;
            _content = content;
            _batch   = batch;
            _input   = input;
            _world   = world;
            _console = console;

            RenderOverlay = true;
        }
Пример #59
0
        protected bool RunBaseReflectionUnitTests()
        {
            bool result = true;

            if (!DedicatedServerAssemblyWrapper.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("DedicatedServerAssemblyWrapper reflection validation failed!");
            }

            if (!ServerNetworkManager.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("ServerNetworkManager reflection validation failed!");
            }

            if (!UtilityFunctions.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("UtilityFunctions reflection validation failed!");
            }

            if (!ChatManager.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("ChatManager reflection validation failed!");
            }

            if (!PlayerMap.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("PlayerMap reflection validation failed!");
            }

            if (!PlayerManager.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("PlayerManager reflection validation failed!");
            }

            if (!WorldManager.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("WorldManager reflection validation failed!");
            }

            if (!RadioManager.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("RadioManager reflection validation failed!");
            }

            if (!RadioManagerNetworkManager.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("RadioManagerNetworkManager reflection validation failed!");
            }

            if (!PowerManager.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("PowerManager reflection validation failed!");
            }

            if (!FactionsManager.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("FactionsManager reflection validation failed!");
            }

            if (!Faction.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("Faction reflection validation failed!");
            }

            if (!GameEntityManager.ReflectionUnitTest())
            {
                result = false;
                BaseLog.Warn("GameEntityManager reflection validation failed!");
            }

            if (result)
            {
                BaseLog.Info("All main types passed reflection unit tests!");
            }

            return(result);
        }
Пример #60
0
 private void OnEnable()
 {
     instance = this;
 }