Esempio n. 1
0
        public void OnCustomFunction(string name)
        {
            if (name.StartsWith("turn", StringComparison.OrdinalIgnoreCase))
            {
                char direction = name[4];
                int  head      = name[5] - '1';
                int  target;

                if (direction == 'l' || direction == 'L')
                {
                    target = (_currentHeadTargets[head] + 1) % 5;
                }
                else
                {
                    target = (_currentHeadTargets[head] + 4) % 5;
                }

                Gk3Main.Graphics.ModelResource laserModel = SceneManager.GetModelByName("CS2LASER_0" + (head + 1), false);
                Gk3Main.Graphics.ModelResource headModel  = SceneManager.GetModelByName("CS2HEAD0" + (head + 1), false);
                laserModel.TempTransform = Math.Matrix.RotateY(_headRotations[head, target])
                                           * Math.Matrix.Translate(_headPositions[head][0], _headPositions[head][1], _headPositions[head][2]);
                headModel.TempTransform = Math.Matrix.RotateY(_headRotations[head, target])
                                          * Math.Matrix.Translate(_headPositions[head][0], _headPositions[head][1], _headPositions[head][2]);

                _currentHeadTargets[head] = target;
                GameManager.SetIntegerGameVariable("CS2HEAD" + (head + 1), target);

                if (isPuzzleComplete())
                {
                    GameManager.SetFlag("STAIRCASEOPEN");
                }
            }
            else if (name.Equals("ToggleLasers", StringComparison.OrdinalIgnoreCase))
            {
                _areLasersActive = !_areLasersActive;

                SceneManager.SetSceneModelVisibility("CS2LASER_01", _areLasersActive);
                SceneManager.SetSceneModelVisibility("CS2LASER_02", _areLasersActive);
                SceneManager.SetSceneModelVisibility("CS2LASER_03", _areLasersActive);
                SceneManager.SetSceneModelVisibility("CS2LASER_04", _areLasersActive);
                SceneManager.SetSceneModelVisibility("CS2LASER_05", _areLasersActive);
            }
        }
Esempio n. 2
0
        public void OnLoad()
        {
            // position the head models
            Gk3Main.Graphics.ModelResource[] heads = new Gk3Main.Graphics.ModelResource[] {
                SceneManager.GetModelByName("CS2HEAD01", false),
                SceneManager.GetModelByName("CS2HEAD02", false),
                SceneManager.GetModelByName("CS2HEAD03", false),
                SceneManager.GetModelByName("CS2HEAD04", false),
                SceneManager.GetModelByName("CS2HEAD05", false)
            };

            Gk3Main.Graphics.ModelResource[] lasers = new Gk3Main.Graphics.ModelResource[] {
                SceneManager.GetModelByName("CS2LASER_01", false),
                SceneManager.GetModelByName("CS2LASER_02", false),
                SceneManager.GetModelByName("CS2LASER_03", false),
                SceneManager.GetModelByName("CS2LASER_04", false),
                SceneManager.GetModelByName("CS2LASER_05", false)
            };

            // rotate and position each head
            for (int i = 0; i < 5; i++)
            {
                heads[i].TempTransform = Math.Matrix.RotateY(_headRotations[i, 2])
                                         * Math.Matrix.Translate(_headPositions[i][0], _headPositions[i][1], _headPositions[i][2]);
                lasers[i].TempTransform = Math.Matrix.RotateY(_headRotations[i, 2])
                                          * Math.Matrix.Translate(_headPositions[i][0], _headPositions[i][1], _headPositions[i][2]);
            }

            // this is so the Sheep scripts and stuff know the heads are facing the center
            GameManager.SetIntegerGameVariable("CS2HEAD1", 2);
            GameManager.SetIntegerGameVariable("CS2HEAD2", 2);
            GameManager.SetIntegerGameVariable("CS2HEAD3", 2);
            GameManager.SetIntegerGameVariable("CS2HEAD4", 2);
            GameManager.SetIntegerGameVariable("CS2HEAD5", 2);

            _currentHeadTargets[0] = 2;
            _currentHeadTargets[1] = 2;
            _currentHeadTargets[2] = 2;
            _currentHeadTargets[3] = 2;
            _currentHeadTargets[4] = 2;
        }