Пример #1
0
        public CrateEntity(
            I2DRenderUtilities twodRenderUtilities,
            ICubeRenderer cubeRenderer,
            IAssetManagerProvider assetManagerProvider,
            INetworkAPI networkAPI,
            int id,
            int x,
            int y,
            Dictionary<string, string> attributes)
            : base(twodRenderUtilities,
                cubeRenderer,
                assetManagerProvider,
                networkAPI,
                Convert.ToInt32(attributes["NetworkID"]))
        {
            this.X = x / 16f;
            this.Z = y / 16f;
            this.JoinShouldOwn = Convert.ToBoolean(attributes["JoinOwns"]);
            this.CanPush = true;

            this.Width = 0.8f;
            this.Depth = 0.8f;

            this.m_BlueCrateTexture = assetManagerProvider.GetAssetManager().Get<TextureAsset>("texture.BlueCrate");
            this.m_RedCrateTexture = assetManagerProvider.GetAssetManager().Get<TextureAsset>("texture.RedCrate");
            this.m_CrateModel = assetManagerProvider.GetAssetManager().Get<ModelAsset>("model.Crate");
        }
Пример #2
0
        public GoalEntity(
            I2DRenderUtilities twodRenderUtilities,
            ICubeRenderer cubeRenderer,
            IAssetManagerProvider assetManagerProvider,
            INetworkAPI networkAPI,
            int id,
            int x,
            int y,
            Dictionary<string, string> attributes)
            : base(twodRenderUtilities,
                cubeRenderer,
                assetManagerProvider,
                networkAPI,
                Convert.ToInt32(attributes["NetworkID"]))
        {
            this.X = x / 16f + 0.4f;
            this.Z = y / 16f + 0.4f;
            this.CanPickup = false;
            this.JoinShouldOwn = Convert.ToBoolean(attributes["JoinOwns"]);

            this.Width = 0.2f;
            this.Depth = 0.2f;

            this.m_GoalTexture = assetManagerProvider.GetAssetManager().Get<TextureAsset>("texture.Goal");
            this.m_GoalModel = assetManagerProvider.GetAssetManager().Get<ModelAsset>("model.Goal");
        }
Пример #3
0
        public GoalEntity(
            I2DRenderUtilities twodRenderUtilities,
            ICubeRenderer cubeRenderer,
            IAssetManagerProvider assetManagerProvider,
            INetworkAPI networkAPI,
            int id,
            int x,
            int y,
            Dictionary <string, string> attributes)
            : base(twodRenderUtilities,
                   cubeRenderer,
                   assetManagerProvider,
                   networkAPI,
                   Convert.ToInt32(attributes["NetworkID"]))
        {
            this.X             = x / 16f + 0.4f;
            this.Z             = y / 16f + 0.4f;
            this.CanPickup     = false;
            this.JoinShouldOwn = Convert.ToBoolean(attributes["JoinOwns"]);

            this.Width = 0.2f;
            this.Depth = 0.2f;

            this.m_GoalTexture = assetManagerProvider.GetAssetManager().Get <TextureAsset>("texture.Goal");
            this.m_GoalModel   = assetManagerProvider.GetAssetManager().Get <ModelAsset>("model.Goal");
        }
Пример #4
0
        public CrateEntity(
            I2DRenderUtilities twodRenderUtilities,
            ICubeRenderer cubeRenderer,
            IAssetManagerProvider assetManagerProvider,
            INetworkAPI networkAPI,
            int id,
            int x,
            int y,
            Dictionary <string, string> attributes)
            : base(twodRenderUtilities,
                   cubeRenderer,
                   assetManagerProvider,
                   networkAPI,
                   Convert.ToInt32(attributes["NetworkID"]))
        {
            this.X             = x / 16f;
            this.Z             = y / 16f;
            this.JoinShouldOwn = Convert.ToBoolean(attributes["JoinOwns"]);
            this.CanPush       = true;

            this.Width = 0.8f;
            this.Depth = 0.8f;

            this.m_BlueCrateTexture = assetManagerProvider.GetAssetManager().Get <TextureAsset>("texture.BlueCrate");
            this.m_RedCrateTexture  = assetManagerProvider.GetAssetManager().Get <TextureAsset>("texture.RedCrate");
            this.m_CrateModel       = assetManagerProvider.GetAssetManager().Get <ModelAsset>("model.Crate");
        }
Пример #5
0
        public PlayerEntity(
            I2DRenderUtilities twodRenderUtilities,
            ICubeRenderer cubeRenderer,
            IAssetManagerProvider assetManagerProvider,
            INetworkAPI networkAPI,
            bool isRedColor,
            bool locallyOwned)
        {
            this.m_NetworkAPI = networkAPI;
            this.m_2DRenderUtilities = twodRenderUtilities;
            this.m_CubeRenderer = cubeRenderer;
            this.m_PlayerTexture = assetManagerProvider.GetAssetManager().Get<TextureAsset>("texture." + (isRedColor ? "Red" : "Blue"));

            this.LocallyOwned = locallyOwned;

            this.Width = 0.5f;
            this.Depth = 0.5f;

            if (!this.LocallyOwned)
            {
                networkAPI.ListenForMessage(
                    "player update",
                    a =>
                    {
                        var values = a.Split('|').Select(x => float.Parse(x)).ToArray();

                        this.X = values[0];
                        this.Y = values[1];
                        this.Z = values[2];
                    });
            }
        }
Пример #6
0
        public PlayerEntity(
            I2DRenderUtilities twodRenderUtilities,
            ICubeRenderer cubeRenderer,
            IAssetManagerProvider assetManagerProvider,
            INetworkAPI networkAPI,
            bool isRedColor,
            bool locallyOwned)
        {
            this.m_NetworkAPI        = networkAPI;
            this.m_2DRenderUtilities = twodRenderUtilities;
            this.m_CubeRenderer      = cubeRenderer;
            this.m_PlayerTexture     = assetManagerProvider.GetAssetManager().Get <TextureAsset>("texture." + (isRedColor ? "Red" : "Blue"));

            this.LocallyOwned = locallyOwned;

            this.Width = 0.5f;
            this.Depth = 0.5f;

            if (!this.LocallyOwned)
            {
                networkAPI.ListenForMessage(
                    "player update",
                    a =>
                {
                    var values = a.Split('|').Select(x => float.Parse(x)).ToArray();

                    this.X = values[0];
                    this.Y = values[1];
                    this.Z = values[2];
                });
            }
        }
        public BaseNetworkEntity(
            I2DRenderUtilities twodRenderUtilities,
            ICubeRenderer cubeRenderer,
            IAssetManagerProvider assetManagerProvider,
            INetworkAPI networkAPI,
            int id)
        {
            this.m_NetworkAPI = networkAPI;
            this.m_2DRenderUtilities = twodRenderUtilities;
            this.m_CubeRenderer = cubeRenderer;
            this.LocallyOwned = true;

            this.ID = id;

            networkAPI.ListenForMessage(
                "entity update",
                a =>
                {
                    if (!this.LocallyOwned)
                    {
                        var values = a.Split('|').Select(x => float.Parse(x)).ToArray();

                        if ((int)values[0] == id)
                        {
                            this.X = values[1];
                            this.Y = values[2];
                            this.Z = values[3];
                        }
                    }
                });

            networkAPI.ListenForMessage(
                "take object",
                a =>
                {
                    if (this.LocallyOwned)
                    {
                        var values = a.Split('|').Select(x => float.Parse(x)).ToArray();

                        if ((int)values[0] == id)
                        {
                            // other player is now owning this object
                            this.LocallyOwned = false;
                        }
                    }
                });
        }
Пример #8
0
        public BaseNetworkEntity(
            I2DRenderUtilities twodRenderUtilities,
            ICubeRenderer cubeRenderer,
            IAssetManagerProvider assetManagerProvider,
            INetworkAPI networkAPI,
            int id)
        {
            this.m_NetworkAPI        = networkAPI;
            this.m_2DRenderUtilities = twodRenderUtilities;
            this.m_CubeRenderer      = cubeRenderer;
            this.LocallyOwned        = true;

            this.ID = id;

            networkAPI.ListenForMessage(
                "entity update",
                a =>
            {
                if (!this.LocallyOwned)
                {
                    var values = a.Split('|').Select(x => float.Parse(x)).ToArray();

                    if ((int)values[0] == id)
                    {
                        this.X = values[1];
                        this.Y = values[2];
                        this.Z = values[3];
                    }
                }
            });

            networkAPI.ListenForMessage(
                "take object",
                a =>
            {
                if (this.LocallyOwned)
                {
                    var values = a.Split('|').Select(x => float.Parse(x)).ToArray();

                    if ((int)values[0] == id)
                    {
                        // other player is now owning this object
                        this.LocallyOwned = false;
                    }
                }
            });
        }
Пример #9
0
        public PerceptionWorld(
            IKernel kernel,
            I2DRenderUtilities twoDRenderUtilities,
            I3DRenderUtilities threeDRenderUtilities,
            IAssetManagerProvider assetManagerProvider,
            IEntityFactory entityFactory,
            ICubeRenderer cubeRenderer,
            ILevelManager levelManager,
            INetworkAPI networkAPI,
            int level)
        {
            this.Entities = new List <IEntity>();

            this.m_NetworkAPI        = networkAPI;
            this.m_2DRenderUtilities = twoDRenderUtilities;
            this.m_3DRenderUtilities = threeDRenderUtilities;
            this.m_AssetManager      = assetManagerProvider.GetAssetManager();
            this.m_DefaultFont       = this.m_AssetManager.Get <FontAsset>("font.Default");
            this.m_EntityFactory     = entityFactory;
            this.m_CubeRenderer      = cubeRenderer;
            this.m_CubeTexture       = assetManagerProvider.GetAssetManager().Get <TextureAsset>("texture.Terrain");
            this.m_LevelManager      = levelManager;

            this.m_GameBoard     = new int[10, 10];
            this.m_GameBoardMeta = new string[10, 10];
            this.m_GameBoardTX   = new int[10, 10];
            this.m_GameBoardTY   = new int[10, 10];

            this.m_LevelSuffix  = this.m_NetworkAPI.WasJoin ? 'b' : 'a';
            this.m_CurrentLevel = level;

            this.LoadLevel(level);

            this.m_NetworkAPI.ListenForMessage(
                "next level",
                a =>
            {
                this.HandleNextLevel();
            });

            this.m_NetworkAPI.ListenForMessage(
                "reset level",
                a =>
            {
                this.HandleResetLevel();
            });

            this.m_NetworkAPI.ListenForMessage(
                "door unlock",
                a =>
            {
                var values = a.Split('|').Select(x => int.Parse(x)).ToArray();

                var doorID = values[0];
                var keyID  = values[1];

                this.Entities.RemoveAll(x => x is KeyEntity && ((KeyEntity)x).ID == keyID);

                foreach (var door in this.Entities.OfType <DoorEntity>().Where(x => x.ID == doorID))
                {
                    door.Open = true;
                }
            });
        }
Пример #10
0
        public PerceptionWorld(
            IKernel kernel,
            I2DRenderUtilities twoDRenderUtilities,
            I3DRenderUtilities threeDRenderUtilities,
            IAssetManagerProvider assetManagerProvider,
            IEntityFactory entityFactory,
            ICubeRenderer cubeRenderer,
            ILevelManager levelManager,
            INetworkAPI networkAPI,
            int level)
        {
            this.Entities = new List<IEntity>();

            this.m_NetworkAPI = networkAPI;
            this.m_2DRenderUtilities = twoDRenderUtilities;
            this.m_3DRenderUtilities = threeDRenderUtilities;
            this.m_AssetManager = assetManagerProvider.GetAssetManager();
            this.m_DefaultFont = this.m_AssetManager.Get<FontAsset>("font.Default");
            this.m_EntityFactory = entityFactory;
            this.m_CubeRenderer = cubeRenderer;
            this.m_CubeTexture = assetManagerProvider.GetAssetManager().Get<TextureAsset>("texture.Terrain");
            this.m_LevelManager = levelManager;

            this.m_GameBoard = new int[10, 10];
            this.m_GameBoardMeta = new string[10, 10];
            this.m_GameBoardTX = new int[10, 10];
            this.m_GameBoardTY = new int[10, 10];

            this.m_LevelSuffix = this.m_NetworkAPI.WasJoin ? 'b' : 'a';
            this.m_CurrentLevel = level;

            this.LoadLevel(level);

            this.m_NetworkAPI.ListenForMessage(
                "next level",
                a =>
                {
                    this.HandleNextLevel();
                });

            this.m_NetworkAPI.ListenForMessage(
                "reset level",
                a =>
                {
                    this.HandleResetLevel();
                });

            this.m_NetworkAPI.ListenForMessage(
                "door unlock",
                a =>
                {
                    var values = a.Split('|').Select(x => int.Parse(x)).ToArray();

                    var doorID = values[0];
                    var keyID = values[1];

                    this.Entities.RemoveAll(x => x is KeyEntity && ((KeyEntity)x).ID == keyID);

                    foreach (var door in this.Entities.OfType<DoorEntity>().Where(x=>x.ID == doorID))
                    {
                        door.Open = true;
                    }
                });
        }