コード例 #1
0
ファイル: UIGame.cs プロジェクト: llikdowk/MusesSextonRecoded
        public void Awake()
        {
            if (_instance == null)
            {
                _instance = this;
                _canvas   = transform.FindChild("Canvas");
                if (!_canvas)
                {
                    DebugMsg.GameObjectNotFound(Debug.LogError, "Canvas");
                }

                foreach (Transform child in _canvas.transform.GetComponentsInChildren <Transform>())
                {
                    if (child.name.Equals("Crosshair"))
                    {
                        _crosshair = child.gameObject;
                    }
                }
                GameObject black = new GameObject("_blackImage");
                black.transform.parent = _canvas.transform;
                black.transform.LocalReset();
                _blackImage       = black.AddComponent <Image>();
                _blackImage.color = new Color(0, 0, 0, 0);
                DontDestroyOnLoad(this);
            }
            else
            {
                Destroy(gameObject);
            }
        }
コード例 #2
0
 public void Start()
 {
     _player = Player.GetInstance();
     foreach (Transform t in transform.parent.GetComponentInChildren <Transform>())
     {
         if (t.gameObject.name == "CoffinSet")
         {
             _coffinSet = t;
         }
     }
     if (!_coffinSet)
     {
         DebugMsg.GameObjectNotFound(Debug.LogError, "CoffinSet");
     }
 }
コード例 #3
0
        // dynamic:
        //     cart
        //     coffin
        //     other grave
        //
        // not 3d-modelled:
        //     vulture
        //     well

        public void Awake()
        {
            TextAsset jsonText = Resources.Load <TextAsset>("poems");

            LandmarkVerses[] verses = JsonConvert.DeserializeObject <LandmarkVerses[]>(jsonText.text);
            foreach (Transform child in gameObject.GetComponentsInChildren <Transform>())
            {
                foreach (LandmarkVerses v in verses)
                {
                    if (child.name.Contains(v.LandmarkName))
                    {
                        child.gameObject.AddComponent <LandmarkVersesComponent>().LandmarkVerses = v;
                        break;
                    }
                }
            }

            if (!CartLandmark)
            {
                DebugMsg.GameObjectNotFound(Debug.LogWarning, "Cart", "Has not been set in the Inspector");
            }
            if (!Coffin0 || !Coffin1 || !Coffin2)
            {
                DebugMsg.GameObjectNotFound(Debug.LogWarning, "CoffinX", "One or more coffins have not been set in the Inspector");
            }

            foreach (LandmarkVerses v in verses)
            {
                if (v.LandmarkName.Contains("CART"))
                {
                    CartLandmark.AddComponent <LandmarkVersesComponent>().LandmarkVerses = v;
                }
                else if (v.LandmarkName.Contains("COFFIN"))
                {
                    Coffin0.AddComponent <LandmarkVersesComponent>().LandmarkVerses = v;
                    Coffin1.AddComponent <LandmarkVersesComponent>().LandmarkVerses = v;
                    Coffin2.AddComponent <LandmarkVersesComponent>().LandmarkVerses = v;
                }
            }
        }
コード例 #4
0
        public CarveTerrainInteraction()
        {
            if (_digMarker == null)
            {
                _digMarker = GameObject.CreatePrimitive(PrimitiveType.Cube);
                Object.Destroy(_digMarker.GetComponent <Collider>());
                _digMarker.SetActive(false);
                _digMarker.name = "_digMarker";
                _digMarker.transform.localScale = new Vector3(4, 0.1f, 4);
                _digMarker.layer = LayerMaskManager.Get(Layer.Outline);
                _digMarker.GetComponent <MeshRenderer>().material = new Material(Shader.Find("UI/Default"));
                IconMarkerComponent icon = _digMarker.AddComponent <IconMarkerComponent>();
                icon.Init("Sprites/dig", new Color(0, 81.0f / 255.0f, 240.0f / 255.0f));
            }

            _player = Player.GetInstance();

            string     terrainName = "Terrain Volume";
            GameObject terrain     = GameObject.Find(terrainName);

            if (!terrain)
            {
                DebugMsg.GameObjectNotFound(Debug.LogError, terrainName);
            }
            else
            {
                var terrainVolume = terrain.GetComponent <TerrainVolume>();
                if (!terrainVolume)
                {
                    DebugMsg.ComponentNotFound(Debug.LogError, typeof(TerrainVolume));
                }

                _terrainCarver = terrain.GetComponent <CarveTerrainVolumeComponent>();
                if (!_terrainCarver)
                {
                    DebugMsg.ComponentNotFound(Debug.LogError, typeof(CarveTerrainVolumeComponent));
                }
            }
        }