void Start() { AudioSource audio = GetComponent<AudioSource>(); audio.Play(); levelManager = FindObjectOfType<LevelManager>(); GameObject sun = GameObject.Find("Directional Light"); globalLightning = sun.GetComponent<GlobalLightning>(); }
public virtual void Draw() { if (!IsEnabled) { return; } if (Model != null) { foreach (ModelMesh mesh in Model.Meshes) { if (mesh.Effects.All(e => e is BasicEffect)) { foreach (BasicEffect effect in mesh.Effects) { if (ToylandSiege.GetInstance().configurationManager.LigthningEnabled) { effect.EnableDefaultLighting(); } effect.AmbientLightColor = new Vector3(0, 0.3f, 0.3f); effect.View = Camera.GetCurrentCamera().ViewMatrix; effect.World = TransformationMatrix; effect.Projection = Camera.GetCurrentCamera().ProjectionMatrix; GlobalLightning.DrawGlobalLightning(effect); } } else if (AnimationPlayer != null && mesh.Effects.All(e => e is SkinnedEffect)) { Matrix[] bones = AnimationPlayer.GetSkinTransforms(); foreach (SkinnedEffect effect in mesh.Effects) { (effect).SetBoneTransforms(bones); if (ToylandSiege.GetInstance().configurationManager.LigthningEnabled) { effect.EnableDefaultLighting(); } effect.AmbientLightColor = new Vector3(0, 0.3f, 0.3f); effect.View = Camera.GetCurrentCamera().ViewMatrix; effect.World = TransformationMatrix; effect.Projection = Camera.GetCurrentCamera().ProjectionMatrix; GlobalLightning.DrawGlobalLightning(effect); } } mesh.Draw(); } } foreach (var child in Childs.Values) { child.Draw(); } }
public override void Draw() { if (!IsEnabled) { return; } UpdateColors(); if (Model != null) { foreach (ModelMesh mesh in Model.Meshes) { if (IsWater) { _DrawWater(mesh); } else { foreach (ModelMeshPart part in mesh.MeshParts) { part.Effect = effect; if (ToylandSiege.GetInstance().configurationManager.LigthningEnabled) { (effect as BasicEffect).EnableDefaultLighting(); } (effect as BasicEffect).AmbientLightColor = AmbientVector3; (effect as BasicEffect).DiffuseColor = ColorVector3; (effect as BasicEffect).View = Camera.GetCurrentCamera().ViewMatrix; (effect as BasicEffect).World = TransformationMatrix; (effect as BasicEffect).Projection = Camera.GetCurrentCamera().ProjectionMatrix; (effect as BasicEffect).Alpha = Alpha; GlobalLightning.DrawGlobalLightning(effect); } } mesh.Draw(); } } }