Exemplo n.º 1
0
    public bool Initialize(ICommandArgs args)
    {
        ChopCommandArgs commandArgs = args as ChopCommandArgs;

        if (commandArgs == null)
        {
            successful = false;
            finished   = true;
            throw new UnityException("Wrong type of args");
        }

        node = commandArgs.node;

        GameObject tree = node.GetBlock();

        if (!tree)
        {
            Stop();
            Debug.Log("No tree to chop");
            return(false);
        }

        spriteRenderer = tree.GetComponent <SpriteRenderer>();
        TickSystem.Subscribe(Chop);

        return(true);
    }
        public override void Dispose()
        {
            TickSystem.RemoveRenderItemT(this);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
            GL.BindVertexArray(0);

            GL.BindVertexArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.DisableVertexAttribArray(0);

            GL.BindVertexArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.DisableVertexAttribArray(1);

            GL.BindVertexArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.DisableVertexAttribArray(2);

            GL.BindVertexArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.DisableVertexAttribArray(3);

            GL.DeleteBuffer(IBO);

            GL.DeleteBuffer(vbo);
            GL.DeleteBuffer(dbo);
            GL.DeleteBuffer(tbo);
            GL.DeleteBuffer(nbo);

            GL.DeleteVertexArray(VAO);
            base.Dispose();
        }
        public override void Dispose()
        {
            if (isReady)
            {
                TickSystem.RemoveRenderItem(this);

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
                GL.BindVertexArray(0);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(0);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(1);

                GL.DeleteBuffer(C_IBO);

                GL.DeleteBuffer(C_vbo);
                GL.DeleteBuffer(C_tbo);

                GL.DeleteVertexArray(C_VAO);
            }
            base.Dispose();
        }
Exemplo n.º 4
0
        public WorldBase()
        {
#if Client
            TickSystem.AddTick(this);
#elif Server
            Server.Tick += Tick;
#endif
        }
Exemplo n.º 5
0
        public override void Dispose()
        {
            OnDisposeWorld();
#if Client
            TickSystem.RemoveTick(this);
#elif Server
            Server.Tick -= Tick;
#endif
        }
Exemplo n.º 6
0
        public override void Dispose()
        {
#if Client
            TickSystem.RemoveTick(this);
#elif Server
            Server.Tick -= Tick;
#endif

            _IsEntityReady = false;
        }
Exemplo n.º 7
0
    public void Plant(Seed seed)
    {
        this.seed      = seed;
        numberOfStages = seed.stageSprites.Length;
        ticksPerStage  = seed.ticksToGrow / numberOfStages;

        cropRenderer.sprite  = seed.stageSprites[stage];
        cropRenderer.enabled = true;

        TickSystem.Subscribe(Grow);
    }
Exemplo n.º 8
0
    private void Grow()
    {
        growth++;
        SetStage();

        if (stage == numberOfStages - 1)
        {
            grown = true;
            TickSystem.Unsubscribe(Grow);
        }
    }
        public MeshRender(Transform transformParent, Mesh mesh, Shader shader, Texture texture)
        {
            _cullType = CullFaceMode.Front;

            transform = transformParent;

            _mesh    = mesh;
            _shader  = shader;
            _texture = texture;

            /*if (_shader != null)
             * {
             *  _shader.Use();
             * }*/

            IBO = GL.GenBuffer();
            VAO = GL.GenVertexArray();

            vbo = GL.GenBuffer();
            dbo = GL.GenBuffer();
            tbo = GL.GenBuffer();
            nbo = GL.GenBuffer();

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, IBO);
            GL.BufferData(BufferTarget.ElementArrayBuffer, _mesh._indices.Length * sizeof(int), _mesh._indices, BufferUsageHint.StaticDraw);

            GL.BindVertexArray(VAO);

            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.BufferData(BufferTarget.ArrayBuffer, _mesh._vertices.Length * Vector3.SizeInBytes, _mesh._vertices, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(0);

            //Colors
            GL.BindBuffer(BufferTarget.ArrayBuffer, dbo);
            GL.BufferData(BufferTarget.ArrayBuffer, _mesh._Colors.Length * sizeof(float), _mesh._Colors, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(1);

            //Texture
            GL.BindBuffer(BufferTarget.ArrayBuffer, tbo);
            GL.BufferData(BufferTarget.ArrayBuffer, _mesh._texCoords.Length * Vector2.SizeInBytes, _mesh._texCoords, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(2);

            GL.BindBuffer(BufferTarget.ArrayBuffer, nbo);
            GL.BufferData(BufferTarget.ArrayBuffer, _mesh._Normals.Length * Vector3.SizeInBytes, _mesh._Normals, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(3, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(3);

            TickSystem.AddRenderItemT(this);
        }
    // Start is called before the first frame update
    void Awake()
    {
        if (!instance)
        {
            instance = this;
        }
        else
        {
            Destroy(this);
        }

        onTurnPassed = new UnityEvent();
    }
Exemplo n.º 11
0
        public Entity()
        {
#if Client
            TickSystem.AddTick(this);
#elif Server
            Server.Tick += Tick;
#endif

            transform = new Transform();
            OnConstruc();

            Debug.Log("Entity Creator1");
        }
Exemplo n.º 12
0
    void Plant()
    {
        if (finished)
        {
            return;
        }

        plantTicks++;
        if (plantTicks >= plantNeededTicks)
        {
            TickSystem.Unsubscribe(Plant);
            FinishPlanting();
        }
    }
    void Build()
    {
        if (finished)
        {
            return;
        }

        buildTicks++;
        buildable.BuildTick(buildTicks);
        if (buildTicks >= buildable.neededTicks)
        {
            TickSystem.Unsubscribe(Build);
            FinishBuilding();
        }
    }
Exemplo n.º 14
0
    void Chop()
    {
        if (finished)
        {
            return;
        }

        ticks++;
        UpdateSprite();
        if (ticks >= neededTicks)
        {
            TickSystem.Unsubscribe(Chop);
            Finish();
        }
    }
        public override void Dispose()
        {
            if (isReady)
            {
                TickSystem.RemoveRenderItem(this);

                isReady = false;

                _Mesh.Dispose();
                _Mesh = null;

                /*_mesh.Clear();
                 * _mesh = null;
                 *
                 * _shader = null;
                 * _texture = null;*/

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
                GL.BindVertexArray(0);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(0);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(1);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(2);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(3);

                GL.DeleteBuffer(IBO);

                GL.DeleteBuffer(vbo);
                GL.DeleteBuffer(dbo);
                GL.DeleteBuffer(tbo);
                GL.DeleteBuffer(nbo);

                GL.DeleteVertexArray(VAO);
            }
            base.Dispose();
        }
        public ChunkCloudRender(Transform transformParent)
        {
            isReady   = false;
            _cullType = CullFaceMode.Front;

            transform          = new Transform();
            transform.Position = new Vector3(transformParent.Position.X, 50, transformParent.Position.Z);
            transform.Rotation = new Quaternion(MathHelper.DegreesToRadians(90), 0, 0, 1);
            transform.Size     = new Vector3(10, 10, 1);

            C_shader  = AssetsManager.GetShader("Cloud");
            C_texture = AssetsManager.GetTexture("Cloud");

            CreteCloudMesh();

            if (mesh != null)
            {
                if (C_shader != null)
                {
                    C_shader.Use();
                }

                C_VAO = GL.GenVertexArray();
                C_IBO = GL.GenBuffer();
                C_vbo = GL.GenBuffer();
                C_tbo = GL.GenBuffer();

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, C_IBO);
                GL.BufferData(BufferTarget.ElementArrayBuffer, mesh._indices.Length * sizeof(int), mesh._indices, BufferUsageHint.StaticDraw);

                GL.BindVertexArray(C_VAO);
                GL.BindBuffer(BufferTarget.ArrayBuffer, C_vbo);
                GL.BufferData(BufferTarget.ArrayBuffer, mesh._vertices.Length * Vector3.SizeInBytes, mesh._vertices, BufferUsageHint.StaticDraw);
                GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(0);

                //Texture
                GL.BindBuffer(BufferTarget.ArrayBuffer, C_tbo);
                GL.BufferData(BufferTarget.ArrayBuffer, mesh._texCoords.Length * Vector2.SizeInBytes, mesh._texCoords, BufferUsageHint.StaticDraw);
                GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(1);

                TickSystem.AddRenderItem(this);

                isReady = true;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// this is for network, instance entity and setup netview
        /// </summary>
        /// <param name="entity"></param>
        public Entity(NetViewSerializer entity)
        {
#if Client
            TickSystem.AddTick(this);
#elif Server
            Server.Tick += Tick;
#endif

            transform = new Transform();

            transform.Position = new Vector3(entity.p_x, entity.p_y, entity.p_z);
            transform.Rotation = new Quaternion(entity.r_x, entity.r_y, entity.r_z, 0);

            SetUpNet(entity.ViewID, entity.Owner, NetDeliveryMethod.Unreliable);
            OnConstruc();
            Debug.Log("Entity Creator2");
        }
        private void SetUpGL()
        {
            _cullType = CullFaceMode.Front;

            IBO = GL.GenBuffer();
            VAO = GL.GenVertexArray();

            vbo = GL.GenBuffer();
            dbo = GL.GenBuffer();
            tbo = GL.GenBuffer();
            nbo = GL.GenBuffer();

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, IBO);
            GL.BufferData(BufferTarget.ElementArrayBuffer, AssetsManager.GetMesh(_mesh)._indices.Length *sizeof(int), AssetsManager.GetMesh(_mesh)._indices, BufferUsageHint.StaticDraw);

            GL.BindVertexArray(VAO);

            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.BufferData(BufferTarget.ArrayBuffer, AssetsManager.GetMesh(_mesh)._vertices.Length *Vector3.SizeInBytes, AssetsManager.GetMesh(_mesh)._vertices, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(0);

            //Colors
            GL.BindBuffer(BufferTarget.ArrayBuffer, dbo);
            GL.BufferData(BufferTarget.ArrayBuffer, AssetsManager.GetMesh(_mesh)._Colors.Length *sizeof(float), AssetsManager.GetMesh(_mesh)._Colors, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(1);

            //Texture
            GL.BindBuffer(BufferTarget.ArrayBuffer, tbo);
            GL.BufferData(BufferTarget.ArrayBuffer, AssetsManager.GetMesh(_mesh)._texCoords.Length *Vector2.SizeInBytes, AssetsManager.GetMesh(_mesh)._texCoords, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(2);

            GL.BindBuffer(BufferTarget.ArrayBuffer, nbo);
            GL.BufferData(BufferTarget.ArrayBuffer, AssetsManager.GetMesh(_mesh)._Normals.Length *Vector3.SizeInBytes, AssetsManager.GetMesh(_mesh)._Normals, BufferUsageHint.StaticDraw);
            GL.VertexAttribPointer(3, 3, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(3);

            TickSystem.AddRenderItem(this);
        }
Exemplo n.º 19
0
    public HomelandsGame(GameManager gameManager, GameSettings settings)
    {
        Debug.Log("Constructing Homelands Game");

        _gameManager = gameManager;
        _settings    = settings;

        _tickSystem   = FTickSystem.Make(this, _settings._tickSettings);
        _statsBuilder = new StatsBuilderBasic(this);
        _viewer       = new Viewer(this);

        IMapBuilder mapBuilder = MapBuilderFactory.Make(_settings._mapSettings._mapType, _settings._mapSettings._tileShape, this);

        _locations    = mapBuilder.Make(_settings._mapSettings);
        _inputHandler = new InputHandler(this);

        _playerSystem    = new PlayerSystem(this, _settings._playerSettings._numberOfPlayers);
        _endSystem       = FEndSystem.Make(_settings._endCondition, this);
        _startPositioner = FStartPositioner.Make(eStartPosition.OppositeCorners, this);
        InitializePlayerStarts();
    }
    public bool Initialize(ICommandArgs args)
    {
        BuildCommandArgs commandArgs = args as BuildCommandArgs;

        if (commandArgs == null)
        {
            Abort();
            throw new UnityException("Wrong type of args");
        }

        buildable = commandArgs.node.GetBlock().GetComponent <Buildable>();
        if (!buildable)
        {
            Abort();
            Debug.LogError("Tried to build a non buildable object");
            return(false);
        }

        TickSystem.Subscribe(Build);

        return(true);
    }
Exemplo n.º 21
0
        public Chunk(Vector3 position)
        {
            transform = new Transform();
            System.Random rand = new System.Random();

            transform.Position = position;

            blocks = new Block[MidleWorld.ChunkSize, MidleWorld.ChunkSize];

            LockActionUpdateMEsh = new object();

            FirstChunkPopulation = true;

            double a = rand.NextDouble();
            double b = rand.NextDouble();

            ChunkSeed = transform.Position.X * a + transform.Position.Z * b + 0;

            TickSystem.AddTick(this);

            PopulateVoxel();
        }
Exemplo n.º 22
0
        public override void Dispose()
        {
            isReady = false;

            for (int i = 0; i < _trees.Count; i++)
            {
                _trees[i].OnDestroy();
            }

            _trees.Clear();

            TickSystem.RemoveTick(this);

            if (_meshRender != null)
            {
                _meshRender.Dispose();
            }

            if (_waterMeshRender != null)
            {
                _waterMeshRender.Dispose();
            }

            if (ChunkMesh != null)
            {
                ChunkMesh.Dispose();
            }

            if (WaterMesh != null)
            {
                WaterMesh.Dispose();
            }

            if (_meshCollider != null)
            {
                _meshCollider.Dispose();
            }
        }
Exemplo n.º 23
0
    public bool Initialize(ICommandArgs args)
    {
        PlantCommandArgs commandArgs = args as PlantCommandArgs;

        if (commandArgs == null)
        {
            Abort();
            throw new UnityException("Wrong type of args");
        }

        seed       = commandArgs.seed;
        cultivable = commandArgs.node.GetBlock().GetComponent <Cultivable>();
        if (!cultivable)
        {
            Abort();
            Debug.LogError("Tried to plant a non cultivable object");
            return(false);
        }

        TickSystem.Subscribe(Plant);

        return(true);
    }
Exemplo n.º 24
0
        public Client()
        {
            Game.Client = this;

            audioSourceTransform = new Transform(new Vector3(0, 2, 0), Quaternion.Identity, Vector3.One);
            audioSource          = new AudioSource(audioSourceTransform.Position, "Teste", true, 1, 0.0f, 1.0f);

            _RenderSystem = new TickSystem();

            //showCaseModelsList.Add(new ShowCaseModel("Ship01", "Default", "Wood02", true));
            showCaseModelsList.Add(new ShowCaseModel("Table", "Default", "Wood01", true));

            EvllyEngine.MouseCursor.UnLockCursor();

            CharacterSaveList = SaveManager.LoadChars();//Load All SinglePlayer CharInfo

            Network.OnServerStart += OnServerStart;
            Network.OnDisconnect  += OnDsiconnect;
            Network.OnServerStop  += OnServerClose;
            Network.OnClientStart += OnClientStart;
            Network.OnConnect     += OnConnect;

            LoadMainMenu();
        }
Exemplo n.º 25
0
 private void GameWin()
 {
     Time.timeScale = 0f;
     _ui.ShowWinMenu(TickSystem.GetTick());
 }
Exemplo n.º 26
0
 private void Awake()
 {
     TickSystem.Create();
 }
Exemplo n.º 27
0
 private void Connect()
 {
     ChangeColor();
     TickSystem.SpeedThingsUp();
 }
Exemplo n.º 28
0
        public WaterMeshRender(Transform transformParent, Mesh mesh, Shader shader, Texture texture, Texture texture2)
        {
            isReady   = false;
            _cullType = CullFaceMode.FrontAndBack;

            transform = transformParent;

            _mesh = mesh;

            if (_mesh != null)
            {
                _shader          = shader;
                _WaterOnetexture = texture;
                _WaterTwotexture = texture2;

                shader.SetInt("texture0", 0);

                /*if (_shader != null)
                 * {
                 *  _shader.Use();
                 * }*/

                System.Random random = new System.Random(transform.GetHashCode());

                animTime = random.Next();

                IBO = GL.GenBuffer();
                VAO = GL.GenVertexArray();

                vbo = GL.GenBuffer();
                dbo = GL.GenBuffer();
                tbo = GL.GenBuffer();
                nbo = GL.GenBuffer();

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, IBO);
                GL.BufferData(BufferTarget.ElementArrayBuffer, _mesh._indices.Length * sizeof(int), _mesh._indices, BufferUsageHint.StaticDraw);

                GL.BindVertexArray(VAO);

                //Vertices(Vector3)
                GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _mesh._vertices.Length * Vector3.SizeInBytes, _mesh._vertices, BufferUsageHint.StaticDraw);
                GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(0);

                //Colors(Vectro4|Color)
                GL.BindBuffer(BufferTarget.ArrayBuffer, dbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _mesh._Colors.Length * sizeof(float), _mesh._Colors, BufferUsageHint.StaticDraw);
                GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(1);

                //Mesh Normals(Vector3)
                GL.BindBuffer(BufferTarget.ArrayBuffer, nbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _mesh._Normals.Length * Vector3.SizeInBytes, _mesh._Normals, BufferUsageHint.StaticDraw);
                GL.VertexAttribPointer(2, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(2);

                isReady = true;

                TickSystem.AddRenderItemT(this);
            }
        }
        public ChunkMeshRender(Transform transformParent, Mesh mesh, Shader shader, Texture texture)
        {
            isReady   = false;
            _cullType = CullFaceMode.Front;

            transform = transformParent;

            _Mesh = new Mesh(mesh);

            if (_Mesh != null)
            {
                _shader  = shader;
                _texture = texture;

                shader.SetInt("texture0", 0);

                /*if (_shader != null)
                 * {
                 *  _shader.Use();
                 * }*/

                IndiceLength = _Mesh._indices.Length;

                IBO = GL.GenBuffer();
                VAO = GL.GenVertexArray();

                vbo = GL.GenBuffer();
                dbo = GL.GenBuffer();
                tbo = GL.GenBuffer();
                nbo = GL.GenBuffer();

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, IBO);
                GL.BufferData(BufferTarget.ElementArrayBuffer, _Mesh._indices.Length * sizeof(int), _Mesh._indices, BufferUsageHint.StreamDraw);

                GL.BindVertexArray(VAO);

                //Vertices(Vector3)
                GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._vertices.Length * Vector3.SizeInBytes, _Mesh._vertices, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(0);

                //Colors(Vectro4|Color)
                GL.BindBuffer(BufferTarget.ArrayBuffer, dbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._Colors.Length * Vector4.SizeInBytes, _Mesh._Colors, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(1);

                //Texture(Vector2)
                GL.BindBuffer(BufferTarget.ArrayBuffer, tbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._texCoords.Length * Vector2.SizeInBytes, _Mesh._texCoords, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(2);

                //Mesh Normals(Vector3)
                GL.BindBuffer(BufferTarget.ArrayBuffer, nbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._Normals.Length * Vector3.SizeInBytes, _Mesh._Normals, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(3, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(3);

                isReady = true;

                TickSystem.AddRenderItem(this);
            }
        }
Exemplo n.º 30
0
 public void Awake()
 {
     instance = this;
 }