// Use this for initialization
    void Awake()
    {
        //IEnumerator

        CoolDownVar   = ICoolDown();
        JumpVar       = Jump();
        RollVar       = Roll();
        ShakeVar      = Shake();
        LookAroundVar = LookAround();


        shaderHandler = GetComponent <ShaderHandler>();

        mat          = GetComponent <MeshRenderer>().material;
        audioSource  = GetComponent <AudioSource>();
        eggMovement  = GetComponent <EggMovement>();
        eggParameter = GetComponent <EggParameter>();
        exHandler    = GameObject.Find("IIncubate").transform.Find("EggExpression").gameObject.GetComponent <expressionHandler>();
        faceHandler  = GetComponent <FaceExpressionHandler>();

        initPos = transform.localPosition;
        initRot = transform.eulerAngles;
        pos     = transform.position;
        rg      = transform.parent.gameObject.GetComponent <Rigidbody>();
        tf      = transform.parent;

        //Standard PID
        PIDx = new PID(0.4f, 0, 2f);
        PIDy = new PID(0.4f, 0, 2f);
        PIDz = new PID(0.4f, 0, 2f);
    }
Esempio n. 2
0
        static void Main()
        {
            RNG   = new Random();
            IdGen = new IdGen();

            LogHandler      = new LogHandler();
            ShaderHandler   = new ShaderHandler();
            KeyboardHandler = new KeyboardHandler(false); // we don't want repeat enabled for a video game (except in menus or when writing something)
            ResourceHandler = new ResourceHandler();
            switch (Config.TextureDisplayMode)
            {
            case TextureDisplayMode.Smooth:
                RenderHandler = new RenderHandlerSmooth();
                break;

            default:
                RenderHandler = new RenderHandlerPixelPerfect();
                break;
            }
            SceneHandler = new SceneHandler();

            Camera = new Camera(50, 100);

            SpriteSets = new Dictionary <string, SpriteSet>
            {
                { "cube", new SpriteSet("cube.png", 79, 71) },
                { "tileset1", new SpriteSet("tileset.png", 3, 2, 16, 16) },
            }; // TODO do an enum and a GetSpriteSet like for Scenes?

            Window = new MainWindow();
            Window.Run(Config.UPS); // option sets the amount of times OnUpdateFrame(e) is called every second
        }
 void Awake()
 {
     gameController = GameObject.Find("IIncubate").GetComponent <GameController>();
     eggPhysicalAI  = GetComponent <EggPhysicalAI>();
     eggMovement    = GetComponent <EggMovement>();
     shaderHandler  = GetComponent <ShaderHandler>();
 }
    // Use this for initialization

    void Awake()
    {
        gameController  = GameObject.Find("IIncubate").GetComponent <GameController>();
        eggParameter    = GameObject.Find("Egg").transform.Find("clean").GetComponent <EggParameter>();
        shaderHandler   = GameObject.Find("Egg").transform.Find("clean").GetComponent <ShaderHandler>();
        dialogueHandler = GameObject.Find("DialogueText").GetComponent <DialogueHandler>();
        hatchlingLight  = transform.Find("Light").GetComponent <Light>();
    }
    void Awake()
    {
        exHandler      = GameObject.Find("IIncubate").transform.Find("EggExpression").gameObject.GetComponent <expressionHandler>();
        faceHandler    = GetComponent <FaceExpressionHandler>();
        gameController = transform.parent.parent.gameObject.GetComponent <GameController>();
        shaderHandler  = GetComponent <ShaderHandler>();

        tf = transform.parent;
        rg = transform.parent.gameObject.GetComponent <Rigidbody>();

        initialPosition = tf.position;
        initialRotation = tf.eulerAngles;

        eggParameter  = GetComponent <EggParameter>();
        eggPhysicalAI = GetComponent <EggPhysicalAI>();
        eggMovement   = GetComponent <EggMovement>();
    }
Esempio n. 6
0
    // Use this for initialization
    void Awake()
    {
        eggParameter    = GameObject.Find("Egg").transform.Find("clean").GetComponent <EggParameter>();
        gameController  = GameObject.Find("IIncubate").GetComponent <GameController>();
        eggParameter    = GameObject.Find("Egg").transform.Find("clean").GetComponent <EggParameter>();
        shaderHandler   = GameObject.Find("Egg").transform.Find("clean").GetComponent <ShaderHandler>();
        dialogueHandler = GameObject.Find("DialogueText").GetComponent <DialogueHandler>();
        hatchlingLight  = transform.Find("Light").GetComponent <Light>();


        chick  = transform.Find("Chick").gameObject;
        cHead  = chick.transform.Find("Head").gameObject;
        cBody  = chick.transform.Find("Body").gameObject;
        cFeet  = chick.transform.Find("Feet").gameObject;
        cWings = chick.transform.Find("Wings").gameObject;

        rg = GetComponent <Rigidbody>();
        tf = gameObject.transform;
    }
Esempio n. 7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            GL.ClearColor(0.2f, 0.2f, 0.2f, 1.0f);
            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Less);

            //! Load model for a boid
            vao = GL.GenVertexArray();
            GL.BindVertexArray(vao);

            vbo = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * modelVertices.Length, modelVertices, BufferUsageHint.DynamicDraw);

            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0);
            GL.EnableVertexArrayAttrib(vao, 0);


            //! Set up matrix instanced arrays
            _ModelMatrixArrayVBO = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, _ModelMatrixArrayVBO);
            GL.BufferData(BufferTarget.ArrayBuffer, flock.Boids.Count * (Vector4.SizeInBytes * 4), IntPtr.Zero, BufferUsageHint.DynamicDraw);

            GL.EnableVertexArrayAttrib(vao, 1);
            GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 4 * Vector4.SizeInBytes, 0);
            GL.EnableVertexArrayAttrib(vao, 2);
            GL.VertexAttribPointer(2, 4, VertexAttribPointerType.Float, false, 4 * Vector4.SizeInBytes, Vector4.SizeInBytes);
            GL.EnableVertexArrayAttrib(vao, 3);
            GL.VertexAttribPointer(3, 4, VertexAttribPointerType.Float, false, 4 * Vector4.SizeInBytes, Vector4.SizeInBytes * 2);
            GL.EnableVertexArrayAttrib(vao, 4);
            GL.VertexAttribPointer(4, 4, VertexAttribPointerType.Float, false, 4 * Vector4.SizeInBytes, Vector4.SizeInBytes * 3);

            GL.VertexAttribDivisor(1, 1);
            GL.VertexAttribDivisor(2, 1);
            GL.VertexAttribDivisor(3, 1);
            GL.VertexAttribDivisor(4, 1);

            shader = ShaderHandler.LoadShader("vertex.shader", "fragment.shader");

            view_id       = GL.GetUniformLocation(shader, "view");
            projection_id = GL.GetUniformLocation(shader, "projection");
        }
Esempio n. 8
0
    void Start()
    {
//arrays are by default passed as references! no special treatment is required for map to act as a reference variable. I checked: it's working.
        mapTiles   = gameObject.GetComponent <GameState>().map;
        sideLength = mapTiles.GetLength(0);
//this offset is crucial: the tilemap has negative values, but the list does not. note that as this is currently set up, only square maps are possible.
        offset            = sideLength / 2;
        mapBaseVerdancy   = new byte [sideLength, sideLength];
        resourceDirectory = Directory.GetParent(Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).ToString()).ToString());
        if (Path.GetFileName(resourceDirectory.ToString()) == "Build")
        {
            resourceDirectory = resourceDirectory.GetDirectories("Proto-RTS_Data/Resources")[0];
        }
        else
        {
            resourceDirectory = resourceDirectory.GetDirectories("Assets/Resources")[0];
        }
        if (File.Exists(resourceDirectory.ToString() + storedMapName) == false || remake_tileMap == true)
        {
            buildMap();
        }
        loadMap();
        AstarPath.active.threadCount = Pathfinding.ThreadCount.AutomaticHighLoad;
        if (File.Exists(resourceDirectory.ToString() + storedNodesName) == false || remake_navmap == true)
        {
            AstarPath.active.data.gridGraph.SetDimensions(sideLength, sideLength, 1);
            AstarPath.active.data.gridGraph.Scan();
            var settings = new Pathfinding.Serialization.SerializeSettings();
            settings.nodes = true;
            File.WriteAllBytes(resourceDirectory.ToString() + storedNodesName, AstarPath.active.data.SerializeGraphs(settings));
        }
        else
        {
            AstarPath.active.data.DeserializeGraphs(File.ReadAllBytes(resourceDirectory + storedNodesName));
        }
        shaderGateway = Camera.main.transform.GetChild(0).GetChild(0).GetComponent <ShaderHandler>();
        shaderGateway.On();
    }
Esempio n. 9
0
        protected override void OnLoad()
        {
            // Debug stuff
            _debugProcCallbackHandle = GCHandle.Alloc(_debugProcCallback);

            GL.DebugMessageCallback(_debugProcCallback, IntPtr.Zero);
            GL.Enable(EnableCap.DebugOutput);
            //GL.Enable(EnableCap.DebugOutputSynchronous);
            // End debug stuff


            //GL.ClearColor(0.3f, 0.3f, 0.3f, 1.0f);
            GL.Enable(EnableCap.DepthTest);

            // Create spheres
            var bigspheresize = 1f;

            Spheres.Add(new Sphere(0.0f, bigspheresize + 1.0f, 0.0f, bigspheresize));
            Spheres.Add(new Sphere(0.5f, bigspheresize + 1.0f, -5.0f, bigspheresize));
            Spheres.Last().Velocity.X = 1.0f;

            texturedata = new float[]
            {
                //! Positions			texture coords
                -1.0f, -1.0f, 0.0f,                 //! bottom left corner
                -1.0f, 1.0f, 0.0f,                  //! top left corner
                1.0f, 1.0f, 0.0f,                   //! top right corner
                1.0f, -1.0f, 0.0f,                  //! bottom right corner
            };

            // Create texture vao
            GL.GenVertexArrays(1, out texture_vao);
            GL.BindVertexArray(texture_vao);

            // Texture vbo
            GL.GenBuffers(1, out texture_vbo);
            GL.BindBuffer(BufferTarget.ArrayBuffer, texture_vbo);
            GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * texturedata.Length, texturedata, BufferUsageHint.DynamicDraw);

            // Vertex position attributes
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0);
            GL.EnableVertexArrayAttrib(texture_vao, 0);

            // Create texture to draw pixels onto
            GL.GenTextures(1, out texture);
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, texture);
            GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, new int[] { (int)TextureParameterName.ClampToEdge });
            GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, new int[] { (int)TextureParameterName.ClampToEdge });
            GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, new int[] { (int)All.Linear });
            GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, new int[] { (int)All.Linear });
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba32f, Width, Height, 0, PixelFormat.Rgba, PixelType.Float, IntPtr.Zero);
            GL.BindImageTexture(0, texture, 0, false, 0, TextureAccess.WriteOnly, SizedInternalFormat.Rgba32f);

            texture_shader      = ShaderHandler.LoadShader("vertex.shader", "fragment.shader");
            rays_compute_shader = ShaderHandler.LoadSingleShader("compute.shader", ShaderType.ComputeShader);

            //! Send texture resolution to fragment shader
            GL.UseProgram(texture_shader);
            GL.Uniform1(GL.GetUniformLocation(texture_shader, "width"), (float)Width);
            GL.Uniform1(GL.GetUniformLocation(texture_shader, "height"), (float)Height);

            // Initialise Camera
            camera = new Camera(this);

            // Initialise compute shader uniforms
            GL.UseProgram(rays_compute_shader);
            GL.Uniform1(GL.GetUniformLocation(rays_compute_shader, "_randseed"), (float)random_seed);
            camera_id      = GL.GetUniformLocation(rays_compute_shader, "camera");
            rayBottomLeft  = GL.GetUniformLocation(rays_compute_shader, "rayBottomLeft");
            rayBottomRight = GL.GetUniformLocation(rays_compute_shader, "rayBottomRight");
            rayTopLeft     = GL.GetUniformLocation(rays_compute_shader, "rayTopLeft");
            rayTopRight    = GL.GetUniformLocation(rays_compute_shader, "rayTopRight");
            sphereUniform  = GL.GetUniformLocation(rays_compute_shader, "spheres");
            //skybox_id = GL.GetUniformLocation(rays_compute_shader, "skybox");

            base.OnLoad();
        }