Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        if (cam == null)
        {
            cam = Camera.main;
        }

        if (dirLight == null)
        {
            dirLight = GameObject.Find("Directional Light").GetComponent <Light>();
        }

        if (fogController == null)
        {
            fogController = GameObject.Find("FogController").GetComponent <FogController>();
        }

        if (oceanFloorScript == null)
        {
            oceanFloorScript = GameObject.Find("OceanFloorLight").GetComponent <SetupOceanFloorScript>();
        }

        if (watersurface == null)
        {
            watersurface = GameObject.Find("WaterSurface").GetComponent <WaterSurfaceScript>();
        }


        currentIndex  = 1;
        currentTarget = timeSettings[currentIndex];

        StartCoroutine(StartInTime(30));
    }
Beispiel #2
0
 private void PerformAction(string type)
 {
     switch (type)
     {
     case "light":
         FogController.SwitchLight();
         break;
     }
     GameManager.instance.playersTurn = false;
 }
Beispiel #3
0
    private IEnumerator FogWallCoroutine(GameObject target, float lerpDuration)
    {
        FogController fogWallController = null;

        if (fogWall != null)
        {
            fogWallController = fogWall.GetComponent <FogController>();
        }

        float targetPositionX;
        float targetPositionY;

        if (target == player)
        {
            targetPositionX = fogWallLerpStartingPosition.x;
            targetPositionY = fogWallLerpStartingPosition.y;
            yield return(new WaitForSeconds(fogWallFadeDuration));
        }
        else
        {
            targetPositionX = target.transform.position.x;
            targetPositionY = target.transform.position.y;
        }

        float   currentDuration  = 0.0f;
        Vector3 startingPosition = transform.position;

        while (currentDuration < 1.0f)
        {
            currentDuration   += Time.deltaTime * (Time.timeScale / lerpDuration);
            transform.position = Vector3.Lerp(startingPosition, new Vector3(targetPositionX, targetPositionY, -10.0f), currentDuration);
            yield return(0);
        }

        if (fogWallController.gameObject.activeSelf)
        {
            fogWallController.ClearFogWall();
        }

        if (target == player)
        {
            disableStandardCameraControls = false;
            if (transform.position.x == targetPositionX && transform.position.y == targetPositionY)
            {
                foreach (var photoPickup in photoPickups)
                {
                    photoPickup.ReturnActiveMusic();
                }
                gameController.StartCharacter();
            }
        }
    }
    void Awake()
    {
        //Check if instance already exists
        if (instance == null)

            //if not, set instance to this
            instance = this;

        //If instance already exists and it's not this:
        else if (instance != this)

            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);

        DontDestroyOnLoad(gameObject);
    }
Beispiel #5
0
    void Awake()
    {
        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        _fowGrid = new GridController(_width, _height, new [] { _fog }, gameObject);
//		_fowGrid.DrawGrid();
        _fowGrid.InitVariable <bool>("visible", item =>
        {
            var pos       = _fowGrid.GetPosition(item._gridCoords);
            var isVisible = _player.HasLineOfSight(new Vector3(
                                                       pos.x,
                                                       2,
                                                       pos.y));

            FogController fog = item.GetPayload <FogController>(0);

            fog.SetVisibily(isVisible);

            return(isVisible);
        });
    }
Beispiel #7
0
        public new void Init()
        {
            this.SharedTexture2 = true;
            this.tex2 = world.LightmapTexture;
            this.stride = VertexPositionNormalTexturedLightmap.SizeInBytes;

            // Make renderitem for each face
            for (int fi = 0; fi < world.faces.Length;fi++ )
            {
                Face face = world.faces[fi];
                face.Format = VertexPositionNormalTexturedLightmap.Format;
                RenderItem item = new RenderItem(this, face.texinfo.texdata_t.mat);

                //if (face.texinfo.texdata_t.mat != null && face.texinfo.texdata_t.mat.Bumpmap)
                //    face.Format = VertexPositionNormalTexturedLightmapTangent.Format;

                // Create index list for non-displacement faces only
                if (face.face_t.dispinfo == -1 && !face.HasDisplacement && face.VertexOffset != -1)
                {
                    // Make TriangleList
                    int newIndices = (face.face_t.numedges - 2) * 3;
                    face.indices = new uint[newIndices];
                    face.nVerts = HagsIndexBuffer.GetVertexCount(item.indices);
                    for (int i = 0; i < (face.face_t.numedges - 2); i++)
                    {
                        face.indices[3 * i] = (uint)(face.VertexOffset);
                        face.indices[3 * i + 1] = (uint)(face.VertexOffset + i + 1);
                        face.indices[3 * i + 2] = (uint)(face.VertexOffset + i + 2);
                    }
                    item.indices = new List<uint>(face.indices);
                }
                else
                {
                    // Use pre-generated displacement index list
                    if (face.indices != null)
                    {
                        item.indices = new List<uint>(face.indices);
                        //face.nVerts = HagsIndexBuffer.GetVertexCount(item.indices);
                    }
                }

                // Setup item
                item.DontOptimize = true;
                item.face = face;
                item.Type = PrimitiveType.TriangleList;
                item.nVerts = face.nVerts;
                item.Init();
                world.faces[fi].item = item;
                items.Add(item);
            }

            // Create shared vertex buffer
            int vertexBytes = world.verts.Count * VertexPositionNormalTexturedLightmap.SizeInBytes;
            vb = new HagsVertexBuffer();
            vb.SetVB<VertexPositionNormalTexturedLightmap>(world.verts.ToArray(), vertexBytes, VertexPositionNormalTexturedLightmap.Format, Usage.WriteOnly);
            ib = new HagsIndexBuffer();

            Entity light_environment = null;
            foreach (Entity ent in world.Entities)
            {
                //System.Console.WriteLine("\n"+ ent.ClassName);
                foreach (string val in ent.Values.Keys)
                {
                    //System.Console.WriteLine("\t"+val + ": " + ent.Values[val]);
                }
                if (ent.ClassName == "light_environment")
                {
                    light_environment = ent;
                }
                else if (ent.ClassName.Equals("sky_camera"))
                {
                    skybox3d = new SkyBox3D(this, ent);
                }
                else if (ent.ClassName.Equals("env_fog_controller"))
                {
                    fogController = new FogController(ent.Values);
                    fogController.Init();
                }
            }

            if (skybox3d == null)
            {
                // Look for area 1
            }

            // Handle worldspawn entity (skybox)
            if (world.Entities[0].ClassName == "worldspawn")
            {
                if (world.Entities[0].Values.ContainsKey("skyname"))
                {
                    string skyname = world.Entities[0].Values["skyname"];
                    skybox = new SkyBox(this, skyname, light_environment);
                }
            }

            // Make leafs point towards nodes also
            SetParent(ref world.nodes[0], ref world.nodes[0]);
            world.nodes[0].parent = null;

            // Prepare visibleRenderItems memorisation structure
            foreach (RenderItem item in items)
            {
                if (!visibleRenderItems.ContainsKey(item.material.MaterialID))
                {
                    visibleRenderItems.Add(item.material.MaterialID, new List<RenderItem>());
                    if (skybox3d != null)
                        skybox3d.visibleRenderItems.Add(item.material.MaterialID, new List<RenderItem>());
                }

            }
        }