示例#1
0
        public static bool IsColliding(SphereCollider collider)
        {
            foreach (var sphereCollider in Colliders)
            {
                if (collider != sphereCollider && sphereCollider.IsColliding(collider))
                {
                    return true;
                }
            }

            return false;
        }
 void Start()
 {
     rb       = GetComponent <Rigidbody>();
     collider = GetComponent <SphereCollider>();
 }
示例#3
0
 private void Start()
 {
     stageManager   = GameObject.Find("StageManager").GetComponent <StageManager>();
     sphereCollider = GetComponent <SphereCollider>();
 }
        public void DrawColliders(GameObject gameObject, bool useWireframe = true,
                                  bool traverseHierarchy = true,
                                  bool drawTriggers      = false)
        {
            PushMatrix();

            if (traverseHierarchy)
            {
                gameObject.GetComponentsInChildren(_colliderList);
            }
            else
            {
                gameObject.GetComponents(_colliderList);
            }

            for (int i = 0; i < _colliderList.Count; i++)
            {
                Collider collider = _colliderList[i];
                RelativeTo(collider.transform);

                if (collider.isTrigger && !drawTriggers)
                {
                    continue;
                }

                if (collider is BoxCollider)
                {
                    BoxCollider box = collider as BoxCollider;
                    if (useWireframe)
                    {
                        DrawWireCube(box.center, box.size);
                    }
                    else
                    {
                        DrawCube(box.center, box.size);
                    }
                }
                else if (collider is SphereCollider)
                {
                    SphereCollider sphere = collider as SphereCollider;
                    if (useWireframe)
                    {
                        DrawWireSphere(sphere.center, sphere.radius);
                    }
                    else
                    {
                        DrawSphere(sphere.center, sphere.radius);
                    }
                }
                else if (collider is CapsuleCollider)
                {
                    CapsuleCollider capsule = collider as CapsuleCollider;
                    if (useWireframe)
                    {
                        Vector3 capsuleDir;
                        switch (capsule.direction)
                        {
                        case 0: capsuleDir = Vector3.right; break;

                        case 1: capsuleDir = Vector3.up; break;

                        case 2:
                        default: capsuleDir = Vector3.forward; break;
                        }
                        DrawWireCapsule(capsule.center + capsuleDir * (capsule.height / 2F - capsule.radius),
                                        capsule.center - capsuleDir * (capsule.height / 2F - capsule.radius), capsule.radius);
                    }
                    else
                    {
                        Vector3 size = Vector3.zero;
                        size += Vector3.one * capsule.radius * 2;
                        size += new Vector3(capsule.direction == 0 ? 1 : 0,
                                            capsule.direction == 1 ? 1 : 0,
                                            capsule.direction == 2 ? 1 : 0) * (capsule.height - capsule.radius * 2);
                        DrawCube(capsule.center, size);
                    }
                }
                else if (collider is MeshCollider)
                {
                    MeshCollider mesh = collider as MeshCollider;
                    if (mesh.sharedMesh != null)
                    {
                        if (useWireframe)
                        {
                            DrawWireMesh(mesh.sharedMesh, Matrix4x4.identity);
                        }
                        else
                        {
                            DrawMesh(mesh.sharedMesh, Matrix4x4.identity);
                        }
                    }
                }
            }

            PopMatrix();
        }
示例#5
0
        private void Start()
        {
            AudioSource source = gameObject.AddComponent <AudioSource>();

            source.clip        = Res.ResourceLoader.instance.LoadedAudio[1000];
            source.volume      = 16;
            source.rolloffMode = AudioRolloffMode.Linear;
            source.maxDistance = 100;
            source.Play();
            if (particleMaterial == null)
            {
                particleMaterial = Core.CreateMaterial(new BuildingData()
                {
                    MainTexture = Res.ResourceLoader.instance.LoadedTextures[22],
                    Metalic     = 0.2f,
                    Smoothness  = 0.6f,
                    renderMode  = BuildingData.RenderMode.Cutout
                });
            }
            Destroy(gameObject, duration);
            if (!FromEnemy && !GameSetup.IsMpClient)
            {
                CoughtEnemies = new List <Transform>();
            }
            if (GameSetup.IsMpClient)
            {
                if (col != null)
                {
                    Destroy(col);
                }
            }
            else
            {
                col           = gameObject.AddComponent <SphereCollider>();
                col.radius    = radius;
                col.isTrigger = true;
            }
            scale      = 0;
            particleGO = new GameObject("BlackHoleParticles");
            particleGO.transform.position = transform.position;
            particleGO.transform.SetParent(transform);
            sys = particleGO.AddComponent <ParticleSystem>();
            ParticleSystem.ShapeModule shape = sys.shape;
            shape.shapeType = ParticleSystemShapeType.SphereShell;
            shape.radius    = radius * 2;
            //shape.radiusMode = ParticleSystemShapeMultiModeValue.Random;
            //shape.length = 0;
            ParticleSystem.MainModule main = sys.main;
            main.startSpeed    = -radius * 4;
            main.startLifetime = 0.5f;
            main.loop          = true;
            main.prewarm       = false;
            main.startSize     = 0.4f;
            main.maxParticles  = 500;

            ParticleSystem.EmissionModule emission = sys.emission;
            emission.enabled      = true;
            emission.rateOverTime = 500;
            Renderer rend = sys.GetComponent <Renderer>();

            rend.material = particleMaterial;

            WindZone wz = gameObject.AddComponent <WindZone>();

            wz.radius   = radius * 2;
            wz.mode     = WindZoneMode.Spherical;
            wz.windMain = 40;

            StartCoroutine(HitEverySecond());
        }
示例#6
0
 public static void InitializeConfigurableJoint(ref Item thisItem, ref GameObject slideObject, ref GameObject slideCenterPosition, ref ConstantForce slideForce, ref ConfigurableJoint connectedJoint, ref Rigidbody slideRB, ref SphereCollider slideCapsuleStabilizer, float stabilizerRadius, float slideTravelDistance, float slideMassOffset)
 {
     slideRB = slideObject.GetComponent <Rigidbody>();
     if (slideRB == null)
     {
         slideRB = slideObject.AddComponent <Rigidbody>();
     }
     slideRB.mass                            = 1.0f;
     slideRB.drag                            = 0.0f;
     slideRB.angularDrag                     = 0.05f;
     slideRB.useGravity                      = true;
     slideRB.isKinematic                     = false;
     slideRB.interpolation                   = RigidbodyInterpolation.None;
     slideRB.collisionDetectionMode          = CollisionDetectionMode.Discrete;
     slideCapsuleStabilizer                  = slideCenterPosition.AddComponent <SphereCollider>();
     slideCapsuleStabilizer.radius           = stabilizerRadius;
     slideCapsuleStabilizer.gameObject.layer = 21;
     Physics.IgnoreLayerCollision(21, 12);
     Physics.IgnoreLayerCollision(21, 15);
     Physics.IgnoreLayerCollision(21, 22);
     Physics.IgnoreLayerCollision(21, 23);
     slideForce     = slideObject.AddComponent <ConstantForce>();
     connectedJoint = thisItem.gameObject.AddComponent <ConfigurableJoint>();
     connectedJoint.connectedBody = slideRB;
     connectedJoint.anchor        = new Vector3(0, 0, -0.5f * slideTravelDistance);
     connectedJoint.axis          = Vector3.right;
     connectedJoint.autoConfigureConnectedAnchor = false;
     connectedJoint.connectedAnchor = Vector3.zero;//new Vector3(0.04f, -0.1f, -0.22f);
     connectedJoint.secondaryAxis   = Vector3.up;
     connectedJoint.xMotion         = ConfigurableJointMotion.Locked;
     connectedJoint.yMotion         = ConfigurableJointMotion.Locked;
     connectedJoint.zMotion         = ConfigurableJointMotion.Limited;
     connectedJoint.angularXMotion  = ConfigurableJointMotion.Locked;
     connectedJoint.angularYMotion  = ConfigurableJointMotion.Locked;
     connectedJoint.angularZMotion  = ConfigurableJointMotion.Locked;
     connectedJoint.linearLimit     = new SoftJointLimit {
         limit = 0.5f * slideTravelDistance, bounciness = 0.0f, contactDistance = 0.0f
     };
     connectedJoint.massScale          = 1.0f;
     connectedJoint.connectedMassScale = slideMassOffset;
 }
 public static void ToWorldSpaceSphere(this SphereCollider sphere, out Vector3 center, out float radius)
 {
     center = sphere.transform.TransformPoint(sphere.center);
     radius = sphere.radius * MaxVec3(AbsVec3(sphere.transform.lossyScale));
 }
示例#8
0
    public override void Awake()
    {
        base.Awake();

        SetSubClassInt(this);

        if (thisObj.collider == null)
        {
            SphereCollider col = thisObj.AddComponent <SphereCollider>();
            col.center = new Vector3(0, 0.0f, 0);
            col.radius = 0.25f;
        }

        if (animationBody != null)
        {
            if (aniBody == null)
            {
                aniBody = animationBody.GetComponent <Animation>();
                if (aniBody == null)
                {
                    aniBody = animationBody.AddComponent <Animation>();
                }
            }

            if (animationSpawn != null && animationSpawn.Length > 0)
            {
                foreach (AnimationClip clip in animationSpawn)
                {
                    aniBody.AddClip(clip, clip.name);
                    aniBody.animation[clip.name].layer    = 1;
                    aniBody.animation[clip.name].wrapMode = WrapMode.Once;
                }
            }

            if (animationMove != null && animationMove.Length > 0)
            {
                foreach (AnimationClip clip in animationMove)
                {
                    aniBody.AddClip(clip, clip.name);
                    aniBody.animation[clip.name].layer    = 0;
                    aniBody.animation[clip.name].wrapMode = WrapMode.Loop;
                }
            }

            if (animationHit != null && animationHit.Length > 0)
            {
                foreach (AnimationClip clip in animationHit)
                {
                    aniBody.AddClip(clip, clip.name);
                    aniBody.animation[clip.name].layer    = 3;
                    aniBody.animation[clip.name].wrapMode = WrapMode.Once;
                }
            }

            if (animationDead != null && animationDead.Length > 0)
            {
                foreach (AnimationClip clip in animationDead)
                {
                    aniBody.AddClip(clip, clip.name);
                    aniBody.animation[clip.name].layer    = 3;
                    aniBody.animation[clip.name].wrapMode = WrapMode.Once;
                }
            }

            if (animationScore != null && animationScore.Length > 0)
            {
                foreach (AnimationClip clip in animationScore)
                {
                    aniBody.AddClip(clip, clip.name);
                    aniBody.animation[clip.name].layer    = 3;
                    aniBody.animation[clip.name].wrapMode = WrapMode.Once;
                }
            }
        }

        if (spawnEffect != null)
        {
            ObjectPoolManager.New(spawnEffect, 5, false);
        }
        if (deadEffect != null)
        {
            ObjectPoolManager.New(deadEffect, 5, false);
        }
    }
示例#9
0
 private void Awake()
 {
     nav = GetComponent <NavMeshAgent>();
     col = GetComponent <SphereCollider>();
 }
示例#10
0
 void Start()
 {
     transform.position   = RandomizePosition();
     shockCollider        = GetComponent <SphereCollider>();
     shockCollider.radius = shockRadius;
 }
        protected override void AwakeOverride()
        {
            base.AwakeOverride();

            m_xyzMesh = m_xyz.sharedMesh;


            if (Editor.IsVR)
            {
                Destroy(m_innerCircle.gameObject);
                Destroy(m_outerCircle.gameObject);

                m_inner = m_innerCircleVR;
                m_outer = m_outerCircleVR;
            }
            else
            {
                Destroy(m_innerCircleVR.gameObject);
                Destroy(m_outerCircleVR.gameObject);

                m_inner = m_innerCircle;
                m_outer = m_outerCircle;
            }

            m_innerCircleMesh = m_inner.sharedMesh;
            m_outerCircleMesh = m_outer.sharedMesh;

            Renderer renderer = m_xyz.GetComponent <Renderer>();

            renderer.sharedMaterials = renderer.materials;
            m_xyzMaterials           = renderer.sharedMaterials;

            renderer = m_inner.GetComponent <Renderer>();
            renderer.sharedMaterials = renderer.materials;
            m_innerCircleMaterials   = renderer.sharedMaterials;

            renderer = m_outer.GetComponent <Renderer>();
            renderer.sharedMaterials = renderer.materials;
            m_outerCircleMaterial    = renderer.sharedMaterial;

            Mesh mesh = m_xyz.mesh;

            m_xyz.sharedMesh = mesh;

            mesh = m_inner.mesh;
            m_inner.sharedMesh = mesh;

            mesh = m_outer.mesh;
            m_outer.sharedMesh = mesh;

            if (m_useColliders)
            {
                GameObject colliders = new GameObject("Colliders");
                colliders.transform.SetParent(transform, false);
                colliders.layer                      = Editor.CameraLayerSettings.RuntimeGraphicsLayer + Window.Index;
                m_graphicsBlockingCollider           = colliders.AddComponent <SphereCollider>();
                m_graphicsBlockingCollider.isTrigger = true;

                GameObject xCollider = new GameObject("XAxis");
                xCollider.transform.SetParent(colliders.transform, false);
                xCollider.transform.localRotation = Quaternion.Euler(0, 90, 0);
                m_xCollider = xCollider.AddComponent <MeshCollider>();

                GameObject yCollider = new GameObject("YAxis");
                yCollider.transform.SetParent(colliders.transform, false);
                yCollider.transform.localRotation = Quaternion.Euler(90, 0, 0);
                m_yCollider = yCollider.AddComponent <MeshCollider>();

                GameObject zCollider = new GameObject("ZAxis");
                zCollider.transform.SetParent(colliders.transform, false);
                m_zCollider = zCollider.AddComponent <MeshCollider>();

                GameObject innerCollider = new GameObject("InnerAxis");
                innerCollider.transform.SetParent(colliders.transform, false);
                m_innerCollider = innerCollider.AddComponent <MeshCollider>();

                GameObject outerCollider = new GameObject("OuterCollider");
                outerCollider.transform.SetParent(colliders.transform, false);
                m_outerCollider = outerCollider.AddComponent <MeshCollider>();

                m_colliders = new[] { m_xCollider, m_yCollider, m_zCollider, m_innerCollider, m_outerCollider };
                foreach (Collider collider in m_colliders)
                {
                    collider.gameObject.SetActive(false);
                    collider.gameObject.layer = Editor.CameraLayerSettings.RuntimeGraphicsLayer + Window.Index;
                }
            }
        }
 private void DebugDraw(Vector3 center, SphereCollider sphere)
 {
     Debug.DrawLine(center + Vector3.up * sphere.radius, center - Vector3.up * sphere.radius);
     Debug.DrawLine(center + Vector3.forward * sphere.radius, center - Vector3.forward * sphere.radius);
     Debug.DrawLine(center + Vector3.right * sphere.radius, center - Vector3.right * sphere.radius);
 }
 private void Start()
 {
     highCollider          = GetComponent <CapsuleCollider>();
     lowCollider           = GetComponent <SphereCollider>();
     isHighColliderEnabled = true;
 }
示例#14
0
 private void Start()
 {
     _sphereCollider         = GetComponent <SphereCollider>();
     _sphereCollider.enabled = false;
 }
示例#15
0
 public void Start()
 {
     contador = 0;
     health   = GetComponentInParent <Health>();
     sphere   = GetComponent <SphereCollider>();
 }
示例#16
0
 void Awake()
 {
     t = target as Crab.Item;
     collider = t.GetComponent<SphereCollider>();
 }
 public void Start()
 {
     collider = GetComponent <SphereCollider>();
     shooter  = GetComponentInChildren <Shooter>();
 }
示例#18
0
 public static Vector3 closestPointOnSurface(this SphereCollider collider, Vector3 localPosition, float extrude = 0.0f)
 {
     return(getPointAtDistance(localPosition, collider.center, collider.radius + extrude));
 }
 // Use this for initialization
 void Start()
 {
     arenaAnimator  = GetComponent <Animator> ();
     sphereCollider = GetComponent <SphereCollider> ();
 }
示例#20
0
        private void Start()
        {
            // Setup light and shadows
            myLight                   = GetComponent <Light>();
            myLight.enabled           = EnableLight;
            forceDisableSpellLighting = !DaggerfallUnity.Settings.EnableSpellLighting;
            if (forceDisableSpellLighting)
            {
                myLight.enabled = false;
            }
            if (!DaggerfallUnity.Settings.EnableSpellShadows)
            {
                myLight.shadows = LightShadows.None;
            }
            initialRange     = myLight.range;
            initialIntensity = myLight.intensity;

            // Setup collider
            myCollider        = GetComponent <SphereCollider>();
            myCollider.radius = ColliderRadius;

            // Setup rigidbody
            myRigidbody            = GetComponent <Rigidbody>();
            myRigidbody.useGravity = false;

            // Use payload when available
            if (payload != null)
            {
                // Set payload missile properties
                caster      = payload.CasterEntityBehaviour;
                targetType  = payload.Settings.TargetType;
                elementType = payload.Settings.ElementType;

                // Set spell billboard anims automatically from payload for mobile missiles
                if (targetType == TargetTypes.SingleTargetAtRange ||
                    targetType == TargetTypes.AreaAtRange)
                {
                    UseSpellBillboardAnims();
                }
            }

            // Setup senses
            if (caster != GameManager.Instance.PlayerEntityBehaviour)
            {
                enemySenses = caster.GetComponent <EnemySenses>();
            }

            // Setup arrow
            if (isArrow)
            {
                // Create and orient 3d arrow
                goModel = GameObjectHelper.CreateDaggerfallMeshGameObject(99800, transform);

                Vector3 adjust;
                // Offset up so it comes from same place LOS check is done from
                if (caster != GameManager.Instance.PlayerEntityBehaviour)
                {
                    CharacterController controller = caster.transform.GetComponent <CharacterController>();
                    adjust    = caster.transform.forward * 0.6f;
                    adjust.y += controller.height / 3;
                }
                else
                {
                    // Offset forward to avoid collision with player
                    adjust = GameManager.Instance.MainCamera.transform.forward * 0.6f;
                    // Adjust slightly downward to match bow animation
                    adjust.y -= 0.11f;
                    // Adjust to the right or left to match bow animation
                    if (!GameManager.Instance.WeaponManager.ScreenWeapon.FlipHorizontal)
                    {
                        adjust += GameManager.Instance.MainCamera.transform.right * 0.15f;
                    }
                    else
                    {
                        adjust -= GameManager.Instance.MainCamera.transform.right * 0.15f;
                    }
                }

                goModel.transform.localPosition = adjust;
                goModel.transform.rotation      = Quaternion.LookRotation(GetAimDirection());
            }

            // Ignore missile collision with caster (this is a different check to AOE targets)
            if (caster)
            {
                Physics.IgnoreCollision(caster.GetComponent <Collider>(), this.GetComponent <Collider>());
            }
        }
示例#21
0
 private void Awake()
 {
     instance = this;
     col      = GetComponent <SphereCollider>();
 }
 void Start()
 {
     neighbors   = new List <Boid>();
     coll        = GetComponent <SphereCollider>();
     coll.radius = Spawner.S.neighborDist / 2; //15
 }
 // Use this for initialization
 void Start()
 {
     //enemy = LayerMask.GetMask ("Enemy");
     range = GetComponent <SphereCollider> ();
     anim  = GetComponent <Animator> ();
 }
示例#24
0
    public virtual void Copy(IControl ctl, ControlCopyFlags flags)
    {
        if (!(ctl is ControlBase))
        {
            return;
        }

        ControlBase c = (ControlBase)ctl;


        // Copy transitions:
        if ((flags & ControlCopyFlags.Transitions) == ControlCopyFlags.Transitions)
        {
            if (c is UIStateToggleBtn3D)
            {
                if (c.Transitions != null)
                {
                    ((UIStateToggleBtn3D)this).transitions = new EZTransitionList[c.Transitions.Length];
                    for (int i = 0; i < Transitions.Length; ++i)
                    {
                        c.Transitions[i].CopyToNew(Transitions[i], true);
                    }
                }
            }
            else
            {
                if (Transitions != null && c.Transitions != null)
                {
                    for (int i = 0; i < Transitions.Length && i < c.Transitions.Length; ++i)
                    {
                        c.Transitions[i].CopyTo(Transitions[i], true);
                    }
                }
            }
        }


        if ((flags & ControlCopyFlags.Text) == ControlCopyFlags.Text)
        {
            // See if we want to clone the other
            // control's text mesh:
            if (spriteText == null && c.spriteText != null)
            {
                GameObject newText = (GameObject)Instantiate(c.spriteText.gameObject);
                newText.transform.parent        = transform;
                newText.transform.localPosition = c.spriteText.transform.localPosition;
                newText.transform.localScale    = c.spriteText.transform.localScale;
                newText.transform.localRotation = c.spriteText.transform.localRotation;
            }

            Text = c.Text;
        }

        if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            // See if we can copy the other control's collider's settings:
            if (GetComponent <Collider>().GetType() == c.GetComponent <Collider>().GetType())
            {
                if (GetComponent <Collider>() is BoxCollider)
                {
                    BoxCollider bc1 = (BoxCollider)GetComponent <Collider>();
                    BoxCollider bc2 = (BoxCollider)c.GetComponent <Collider>();
                    bc1.center = bc2.center;
                    bc1.size   = bc2.size;
                }
                else if (GetComponent <Collider>() is SphereCollider)
                {
                    SphereCollider sc1 = (SphereCollider)GetComponent <Collider>();
                    SphereCollider sc2 = (SphereCollider)c.GetComponent <Collider>();
                    sc1.center = sc2.center;
                    sc1.radius = sc2.radius;
                }
                else if (GetComponent <Collider>() is CapsuleCollider)
                {
                    CapsuleCollider cc1 = (CapsuleCollider)GetComponent <Collider>();
                    CapsuleCollider cc2 = (CapsuleCollider)c.GetComponent <Collider>();
                    cc1.center    = cc2.center;
                    cc1.radius    = cc2.radius;
                    cc1.height    = cc2.height;
                    cc1.direction = cc2.direction;
                }
                else if (GetComponent <Collider>() is MeshCollider)
                {
                    MeshCollider mc1 = (MeshCollider)GetComponent <Collider>();
                    MeshCollider mc2 = (MeshCollider)c.GetComponent <Collider>();
                    mc1.smoothSphereCollisions = mc2.smoothSphereCollisions;
                    mc1.convex     = mc2.convex;
                    mc1.sharedMesh = mc2.sharedMesh;
                }

                GetComponent <Collider>().isTrigger = c.GetComponent <Collider>().isTrigger;
            }
        }

        if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
        {
            changeDelegate = c.changeDelegate;
            inputDelegate  = c.inputDelegate;
        }

        if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State)
        {
            Container = c.Container;

            if (Application.isPlaying)
            {
                controlIsEnabled = c.controlIsEnabled;
            }
        }
    }
示例#25
0
 // Use this for initialization
 void Start()
 {
     // Set up a reference to the capsule collider.
     headCollider = GetComponent <Collider>() as SphereCollider;
     grounded     = false;
 }
示例#26
0
    void Start()
    {
        healthManager = GetComponent <HealthManager>();
        rbody         = GetComponent <Rigidbody>();
        SFX           = GetComponent <AudioSource>();
        anim          = GetComponent <Animation>();

        //Setup colliders for NPC and its corpse
        if (normalCollider == corpseCollider)
        {
            Debug.Log("ERROR: normalCollider and corpseCollider cannot be the same on NPC!");
            return;
        }
        switch (normalCollider)
        {
        case collisionType.Box: boxCollider = GetComponent <BoxCollider>(); boxCollider.enabled = true; break;

        case collisionType.Sphere: sphereCollider = GetComponent <SphereCollider>(); sphereCollider.enabled = true; break;

        case collisionType.Mesh: meshCollider = GetComponent <MeshCollider>(); meshCollider.enabled = true; break;

        case collisionType.Capsule: capsuleCollider = GetComponent <CapsuleCollider>(); capsuleCollider.enabled = true; break;
        }
        switch (corpseCollider)
        {
        case collisionType.Box: boxCollider = GetComponent <BoxCollider>(); boxCollider.enabled = false; break;

        case collisionType.Sphere: sphereCollider = GetComponent <SphereCollider>(); sphereCollider.enabled = false; break;

        case collisionType.Mesh: meshCollider = GetComponent <MeshCollider>(); meshCollider.enabled = false; break;

        case collisionType.Capsule: capsuleCollider = GetComponent <CapsuleCollider>(); capsuleCollider.enabled = false; break;
        }

        currentState = Const.aiState.Idle;
        //currentWaypoint = 0;
        tick = 0.05f;         // Think every 0.05f seconds to save on CPU
        idealTransformForward = transform.forward;
        enemy    = null;
        attacker = null;

        firstSighting = true;
        goIntoPain    = false;
        dyingSetup    = false;
        hopDone       = false;

        idleTime             = Time.time + Random.Range(3f, 10f);
        attackFinished       = Time.time + 1f;
        tickFinished         = Time.time + tick;
        timeTillDeadFinished = Time.time;
        firingFinished       = Time.time;
        painFinished         = Time.time;
        fireDelayFinished    = Time.time;
        currentPainAnim      = painSelection.Pain1;

        if (SFX == null)
        {
            Debug.Log("WARNING: No audio source for npc at: " + transform.position.x.ToString() + ", " + transform.position.y.ToString() + ", " + transform.position.z + ".");
            hasSFX = false;
        }
        else
        {
            hasSFX = true;
        }

        if (healthManager.health > 0)
        {
            if (walkWaypoints.Length > 0 && walkWaypoints[0] != null)
            {
                currentState = Const.aiState.Walk;                 // If waypoints are set, start walking to them
            }
            else
            {
                currentState = Const.aiState.Idle;                 // Default to idle
            }
        }

        deathBody.SetActive(false);
        normalBody.SetActive(true);
        collisionAid1.SetActive(true);
        collisionAid2.SetActive(true);
    }
示例#27
0
 private void Awake()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     anim   = GetComponent <Animator>();
     col    = GetComponent <SphereCollider>();
 }
示例#28
0
 private void Awake()
 {
     radius = gameObject.AddComponent <SphereCollider>();
     tower  = gameObject.GetComponentInParent <AbstractTower>();
 }
示例#29
0
    void Update()
    {
        // As long as skip is not true, we will try and draw the route.
        // OBS: if (!skip) can maybe be deleted when skip is fully implmented (if it is made as a scene shift)?
        if (!skip)
        {
            // When the path is finished and has been drawn, we will make the bike animation follow the line's position:
            if (pathFinished)
            {
                // if the bike animation is not out of the map collider then
                if (currentPosition < 0.1)
                {
                    if (!movie.isPlaying)
                    {
                        voiceFile.clip = movie.audioClip;
                        movie.Play();
                        //voiceFile.Play();
                        //voiceFile.volume = 0.25f;
                    }
                    currentPosition += percentSec * Time.deltaTime;
                    iTween.PutOnPath(this.gameObject, pathLargeMap.ToArray(), currentPosition);
                }
                else if (currentPosition > 1.0)
                {
                    currentPosition = 1.1f;
                    movie.Stop();
                    //voiceFile.Stop();
                }
                else
                {
                    if (!movie.isPlaying)
                    {
                        voiceFile.clip = movie.audioClip;
                        movie.Play();
                        //voiceFile.Play();
                        //voiceFile.volume = 0.25f;
                    }
                    currentPosition += percentSec * Time.deltaTime;
                    iTween.PutOnPath(this.gameObject, pathLargeMap.ToArray(), currentPosition);
                }
                // if the bike animation is out of the map collider then:
                if (outOfMap)
                {
                    /*if (soundscapeHasStarted){
                     *      currentPosition = 1.1f;
                     *      movie.Stop();
                     *      voiceFile.Stop();
                     * }*/
                    if (!soundscapeHasStarted)
                    {
                        // Tænker at det er fint nok bare at gøre det oneshot
                        voiceFile.PlayOneShot(soundscape, 0.5f);
                        soundscapeHasStarted = true;
                    }
                    if (!voiceFile.isPlaying)
                    {
                        skipButton.onClick.Invoke();
                        skip = true;
                    }
                }
            }
            // Path finished, path done both ensures that we will only add hand position when the path is not finished
            // and that we will not start the animation until the path is done.
            // As long as path is not finished and done and that the hand is X amount close to the Kinect, this happens:
            else if (!pathFinished && !pathDone && udpRec.zVal < zValMax && udpRec.handPos.Count > 1)
            {
                length           = udpRec.handPos.Count;
                currentPosOfHand = new Vector3(udpRec.handPos[length - 1].x, udpRec.handPos[length - 1].y, 0f);

                // To take the mean position of e.g. 10 positions given via UDP
                for (int i = 0; i < handPosMax + 1; i++)
                {
                    meanPositionHand = new Vector3(meanPositionHand.x + udpRec.handPos[length - 1].x, meanPositionHand.y + udpRec.handPos[length - 1].y, 0f);
                }

                // When we have been through the for-loop we take the mean of the 10 entries of the position of the hand given by UDP
                meanPositionHand  = meanPositionHand / handPosMax;
                follower.position = meanPositionHand;
                meanPositionHand  = new Vector3(0f, 0f, 0f);

                //follower.position = currentPosOfHand;

                if (end.bounds.Contains(currentPosOfHand) && wereInsideStart)
                {
                    // Add end coordinates to path
                    path.Add(end.transform.position);
                    //pathLargeMap.Add(endLarge.transform.position);
                    pathLargeMap.Add(new Vector3(end.transform.position.x * largeMapMultiplyX + largeMapAddX, end.transform.position.y * largeMapMultiplyY + largeMapAddY, 200f));
                    pathDone = true;
                    print("Farm reached");
                    stopAllSounds.StopAllAudio();

                    //If statements about how many of the pathPoints the user went through - determines the type of feedback:
                    if (numberOfPathPoints < 2)
                    {
                        voiceFile.PlayOneShot(audioTooShortRoute, 0.5f);
                    }
                    else if (numberOfPathPoints > 1 && numberOfPathPoints < 5)
                    {
                        voiceFile.PlayOneShot(audioWellDone, 0.5f);
                    }
                    //else if (numberOfPathPoints > 4 && numberOfPathPoints < 4)
                    //	voiceFile.PlayOneShot(audioTooLongRouteAlmostThere, 0.5f);
                    else if (numberOfPathPoints > 4)
                    {
                        voiceFile.PlayOneShot(audioTooLongRoute, 0.5f);
                    }
                }
                // When we reach the start-collider
                else if (start.bounds.Contains(currentPosOfHand) && !wereInsideStart)
                {
                    //print("Start reached");
                    voiceFile.PlayOneShot(detectStart, 0.5f);
                    //print("position: " + start.transform.position);
                    wereInsideStart = true;
                    //Add start coordinates to path
                    path.Add(start.transform.position);
                    //pathLargeMap.Add(startLarge.transform.position);
                    pathLargeMap.Add(new Vector3(start.transform.position.x * largeMapMultiplyX + largeMapAddX, start.transform.position.y * largeMapMultiplyY + largeMapAddY, 200f));
                }
                //When we have reached Start, then we can start add things to the path:
                else if (wereInsideStart)
                {
                    //print("inside wereInsideStart");
                    for (int i = 0; i < pathPoints.Length; i++)
                    {
                        //print("length of pathPoints: " + pathPoints.Length);
                        currentPathPoint = pathPoints[i].GetComponent <SphereCollider>();
                        if (currentPathPoint.bounds.Contains(currentPosOfHand) && !haveBeenAtPathPoint[i])
                        {
                            print("path Point " + i + " reached");
                            path.Add(currentPathPoint.transform.position);
                            pathLargeMap.Add(new Vector3(currentPathPoint.transform.position.x * largeMapMultiplyX + largeMapAddX, currentPathPoint.transform.position.y * largeMapMultiplyY + largeMapAddY, 200f));
                            haveBeenAtPathPoint[i] = true;
                            numberOfPathPoints++;
                        }
                    }
                }
            }
            //}

            // If none of the above is true, but we do have something in the path, then path is done
            // OBS: Shouldn't we only stop the experience when path is completely done, then?
            else if (udpRec.zVal > zValMax)
            {
                // If only want to stop the experience when the route is done, we can just outcomment these lines:
                if (1 < path.Count)
                {
                    pathDone = true;
                }
                stopAllSounds.StopAllAudio();
                voiceFile.PlayOneShot(audioRouteNotFinished, 0.5f);
            }

            //currentPosOfHand = new Vector3(currentPosOfHand.x, currentPosOfHand.y, udpRec.zVal);

            // Plays the sound when the hand is detected the first time:
            if (lastPosition != null && currentPosOfHand != lastPosition && !detectSoundHasPlayed)
            {
                //print("1 if-sentence");
                detectSoundHasPlayed = true;
                voiceFile.PlayOneShot(soundHandDetected, 0.5f);
            }
            // Testing if it can say the sound the next times that a hand is detected. It does currently not work.
            //else if (lastPosition != null && currentPosOfHand==lastPosition && detectSoundHasPlayed){
            //	detectSoundHasPlayed = false;
            //print("2 if-sentence");
            //}
            //print("Last pos: " + lastPosition + "Current Pos: " + currentPosOfHand);

            lastPosition = currentPosOfHand;
        }
    }
示例#30
0
 public static void Add(SphereCollider sphereCollider)
 {
     Colliders.Add(sphereCollider);
 }
示例#31
0
 private void OnValidate()
 {
     _Collider           = GetComponent <SphereCollider>();
     _Collider.isTrigger = true;
 }
示例#32
0
 public static void Remove(SphereCollider sphereCollider)
 {
     Colliders.Remove(sphereCollider);
 }
示例#33
0
    //***************
    //SPHERE COLLIDER

    public static bool isPointInside(this SphereCollider collider, Vector3 localPosition, float tolerance = 0.0f)
    {
        localPosition -= collider.center;
        return(withinDistance(localPosition, collider.radius + tolerance));
    }
示例#34
0
 public dynamic LoadComponent(Stream stream, int index, NotLoaded comp)
 {
     stream.Position = comp.offset;
     try
     {
         switch (comp.classID1)
         {
         case UnityClassID.AnimationClip:
             {
                 AnimationClip animationClip = new AnimationClip(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, animationClip, comp);
                 animationClip.LoadFrom(stream);
                 return animationClip;
             }
         case UnityClassID.Animator:
             {
                 Animator animator = new Animator(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, animator, comp);
                 animator.LoadFrom(stream);
                 return animator;
             }
         case UnityClassID.AnimatorController:
             {
                 AnimatorController animatorController = new AnimatorController(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, animatorController, comp);
                 animatorController.LoadFrom(stream);
                 return animatorController;
             }
         case UnityClassID.AssetBundle:
             {
                 AssetBundle assetBundle = new AssetBundle(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, assetBundle, comp);
                 assetBundle.LoadFrom(stream);
                 return assetBundle;
             }
         case UnityClassID.AudioClip:
             {
                 if (loadingReferencials)
                 {
                     return comp;
                 }
                 AudioClip ac = new AudioClip(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, ac, comp);
                 ac.LoadFrom(stream);
                 return ac;
             }
         case UnityClassID.AudioListener:
             {
                 AudioListener audioListener = new AudioListener(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, audioListener, comp);
                 audioListener.LoadFrom(stream);
                 return audioListener;
             }
         case UnityClassID.AudioSource:
             {
                 AudioSource audioSrc = new AudioSource(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, audioSrc, comp);
                 audioSrc.LoadFrom(stream);
                 return audioSrc;
             }
         case UnityClassID.Avatar:
             {
                 if (loadingReferencials)
                 {
                     return comp;
                 }
                 Avatar avatar = new Avatar(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, avatar, comp);
                 avatar.LoadFrom(stream);
                 return avatar;
             }
         case UnityClassID.BoxCollider:
             {
                 BoxCollider boxCol = new BoxCollider(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, boxCol, comp);
                 boxCol.LoadFrom(stream);
                 return boxCol;
             }
         case UnityClassID.Camera:
             {
                 Camera camera = new Camera(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, camera, comp);
                 camera.LoadFrom(stream);
                 return camera;
             }
         case UnityClassID.CapsuleCollider:
             {
                 CapsuleCollider capsuleCol = new CapsuleCollider(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, capsuleCol, comp);
                 capsuleCol.LoadFrom(stream);
                 return capsuleCol;
             }
         case UnityClassID.Cubemap:
             {
                 Cubemap cubemap = new Cubemap(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, cubemap, comp);
                 cubemap.LoadFrom(stream);
                 Parser.Textures.Add(cubemap);
                 return cubemap;
             }
         case UnityClassID.EllipsoidParticleEmitter:
             {
                 EllipsoidParticleEmitter ellipsoid = new EllipsoidParticleEmitter(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, ellipsoid, comp);
                 ellipsoid.LoadFrom(stream);
                 return ellipsoid;
             }
         case UnityClassID.FlareLayer:
             {
                 FlareLayer flareLayer = new FlareLayer(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, flareLayer, comp);
                 flareLayer.LoadFrom(stream);
                 return flareLayer;
             }
         case UnityClassID.Light:
             {
                 Light light = new Light(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, light, comp);
                 light.LoadFrom(stream);
                 return light;
             }
         case UnityClassID.LinkToGameObject:
             {
                 LinkToGameObject link = new LinkToGameObject(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, link, comp);
                 link.LoadFrom(stream);
                 return link;
             }
         case UnityClassID.LinkToGameObject223:
             {
                 LinkToGameObject223 link = new LinkToGameObject223(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, link, comp);
                 link.LoadFrom(stream);
                 return link;
             }
         case UnityClassID.LinkToGameObject225:
             {
                 LinkToGameObject225 link = new LinkToGameObject225(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, link, comp);
                 link.LoadFrom(stream);
                 return link;
             }
         case UnityClassID.GameObject:
             {
                 GameObject gameObj = new GameObject(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, gameObj, comp);
                 gameObj.LoadFrom(stream);
                 return gameObj;
             }
         case UnityClassID.Material:
             {
                 Material mat = new Material(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, mat, comp);
                 mat.LoadFrom(stream);
                 return mat;
             }
         case UnityClassID.Mesh:
             {
                 if (loadingReferencials)
                 {
                     return comp;
                 }
                 Mesh mesh = new Mesh(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, mesh, comp);
                 mesh.LoadFrom(stream);
                 return mesh;
             }
         case UnityClassID.MeshCollider:
             {
                 MeshCollider meshCol = new MeshCollider(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, meshCol, comp);
                 meshCol.LoadFrom(stream);
                 return meshCol;
             }
         case UnityClassID.MeshFilter:
             {
                 MeshFilter meshFilter = new MeshFilter(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, meshFilter, comp);
                 meshFilter.LoadFrom(stream);
                 return meshFilter;
             }
         case UnityClassID.MeshRenderer:
             {
                 MeshRenderer meshRenderer = new MeshRenderer(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, meshRenderer, comp);
                 meshRenderer.LoadFrom(stream);
                 return meshRenderer;
             }
         default:
             if (comp.classID2 == UnityClassID.MonoBehaviour)
             {
                 if (Types.Count > 0)
                 {
                     MonoBehaviour monoBehaviour = new MonoBehaviour(this, comp.pathID, comp.classID1, comp.classID2);
                     ReplaceSubfile(index, monoBehaviour, comp);
                     monoBehaviour.LoadFrom(stream);
                     return monoBehaviour;
                 }
                 else
                 {
                     string message = comp.classID2 + " unhandled because of absence of Types in Cabinet (*.assets)";
                     if (!reported.Contains(message))
                     {
                         Report.ReportLog(message);
                         reported.Add(message);
                     }
                     return comp;
                 }
             }
             else
             {
                 string message = "Unhandled class: " + comp.classID1 + "/" + comp.classID2;
                 if (!reported.Contains(message))
                 {
                     Report.ReportLog(message);
                     reported.Add(message);
                 }
             }
             break;
         case UnityClassID.MonoScript:
             {
                 if (loadingReferencials)
                 {
                     return comp;
                 }
                 MonoScript monoScript = new MonoScript(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, monoScript, comp);
                 monoScript.LoadFrom(stream);
                 return monoScript;
             }
         case UnityClassID.MultiLink:
             {
                 MultiLink multi = new MultiLink(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, multi, comp);
                 multi.LoadFrom(stream);
                 return multi;
             }
         case UnityClassID.ParticleAnimator:
             {
                 ParticleAnimator particleAnimator = new ParticleAnimator(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, particleAnimator, comp);
                 particleAnimator.LoadFrom(stream);
                 return particleAnimator;
             }
         case UnityClassID.ParticleRenderer:
             {
                 ParticleRenderer particleRenderer = new ParticleRenderer(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, particleRenderer, comp);
                 particleRenderer.LoadFrom(stream);
                 return particleRenderer;
             }
         case UnityClassID.ParticleSystem:
             {
                 ParticleSystem particleSystem = new ParticleSystem(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, particleSystem, comp);
                 particleSystem.LoadFrom(stream);
                 return particleSystem;
             }
         case UnityClassID.ParticleSystemRenderer:
             {
                 ParticleSystemRenderer particleSystemRenderer = new ParticleSystemRenderer(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, particleSystemRenderer, comp);
                 particleSystemRenderer.LoadFrom(stream);
                 return particleSystemRenderer;
             }
         case UnityClassID.Projector:
             {
                 Projector projector = new Projector(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, projector, comp);
                 projector.LoadFrom(stream);
                 return projector;
             }
         case UnityClassID.Rigidbody:
             {
                 RigidBody rigidBody = new RigidBody(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, rigidBody, comp);
                 rigidBody.LoadFrom(stream);
                 return rigidBody;
             }
         case UnityClassID.Shader:
             {
                 Shader shader = new Shader(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, shader, comp);
                 shader.LoadFrom(stream);
                 return shader;
             }
         case UnityClassID.SkinnedMeshRenderer:
             {
                 SkinnedMeshRenderer sMesh = new SkinnedMeshRenderer(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, sMesh, comp);
                 sMesh.LoadFrom(stream);
                 return sMesh;
             }
         case UnityClassID.SphereCollider:
             {
                 SphereCollider sphereCol = new SphereCollider(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, sphereCol, comp);
                 sphereCol.LoadFrom(stream);
                 return sphereCol;
             }
         case UnityClassID.Sprite:
             {
                 Sprite sprite = new Sprite(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, sprite, comp);
                 sprite.LoadFrom(stream);
                 return sprite;
             }
         case UnityClassID.SpriteRenderer:
             {
                 SpriteRenderer spriteRenderer = new SpriteRenderer(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, spriteRenderer, comp);
                 spriteRenderer.LoadFrom(stream);
                 return spriteRenderer;
             }
         case UnityClassID.TextAsset:
             {
                 if (loadingReferencials)
                 {
                     return comp;
                 }
                 TextAsset ta = new TextAsset(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, ta, comp);
                 ta.LoadFrom(stream);
                 return ta;
             }
         case UnityClassID.Texture2D:
             {
                 if (loadingReferencials)
                 {
                     return comp;
                 }
                 Texture2D tex = new Texture2D(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, tex, comp);
                 tex.LoadFrom(stream);
                 Parser.Textures.Add(tex);
                 return tex;
             }
         case UnityClassID.Transform:
             {
                 Transform trans = new Transform(this, comp.pathID, comp.classID1, comp.classID2);
                 ReplaceSubfile(index, trans, comp);
                 trans.LoadFrom(stream);
                 return trans;
             }
         }
     }
     catch
     {
         Report.ReportLog("Failed to load " + comp.classID1 + "/" + comp.classID2 + " PathID=" + comp.pathID);
         foreach (NotLoaded notLoaded in RemovedList)
         {
             if (notLoaded == comp)
             {
                 RemovedList.Remove(notLoaded);
                 Components.RemoveAt(index);
                 notLoaded.replacement = null;
                 Components.Insert(index, notLoaded);
                 break;
             }
         }
     }
     return null;
 }
        // Parser apply event
        void IParserEventSubscriber.Apply(ConfigNode node)
        {
            // Get any existing material we might have on this scaled version
            ConfigNode data = node.GetNode(MATERIAL_NODE_NAME);

            // Check for bad condition (no material, no new material)
            if (Material == null && data == null)
            {
                throw new Exception("Scaled version has no material information");
            }

            // Are we a planet or moon?
            if (Type.Value != BodyType.Star)
            {
                // If we are not a star, we need a scaled space fader and a sphere collider
                ScaledSpaceFader fader = Value.scaledBody.GetComponent <ScaledSpaceFader>();
                if (fader == null)
                {
                    fader               = Value.scaledBody.AddComponent <SharedScaledSpaceFader>();
                    fader.floatName     = "_Opacity";
                    fader.celestialBody = Value;
                }
                else if (!(fader is SharedScaledSpaceFader))
                {
                    Utility.CopyObjectFields(fader, Value.scaledBody.AddComponent <SharedScaledSpaceFader>());
                    Object.DestroyImmediate(fader);
                }

                // Add a sphere collider if we need one
                if (Value.scaledBody.GetComponent <SphereCollider>() == null)
                {
                    SphereCollider collider = Value.scaledBody.AddComponent <SphereCollider>();
                    collider.center = Vector3.zero;
                    collider.radius = 1000.0f;
                }

                // Generate new atmospheric body material
                if (Type.Value == BodyType.Atmospheric)
                {
                    if (Material != null && ScaledPlanetRimAerial.UsesSameShader(Material))
                    {
                        Material = new ScaledPlanetRimAerialLoader(Material);
                    }
                    else
                    {
                        Material = new ScaledPlanetRimAerialLoader();
                    }

                    Material.name = Guid.NewGuid().ToString();
                }

                // Generate new vacuum body material
                else
                {
                    if (Material != null && ScaledPlanetSimple.UsesSameShader(Material))
                    {
                        Material = new ScaledPlanetSimpleLoader(Material);
                    }
                    else
                    {
                        Material = new ScaledPlanetSimpleLoader();
                    }

                    Material.name = Guid.NewGuid().ToString();
                }
            }

            // Otherwise we are a star
            else
            {
                // Add the SunShaderController behavior
                SunShaderController controller = Value.scaledBody.GetComponent <SunShaderController>();
                if (controller == null)
                {
                    Value.scaledBody.AddComponent <SharedSunShaderController>();
                }
                else if (!(controller is SharedSunShaderController))
                {
                    Utility.CopyObjectFields(controller, Value.scaledBody.AddComponent <SharedSunShaderController>());
                    Object.DestroyImmediate(controller);
                }

                // Add the ScaledSun behavior
                // TODO - apparently there can only be one of these (or it destroys itself)
                if (Value.scaledBody.GetComponent <ScaledSun>() == null)
                {
                    Value.scaledBody.AddComponent <ScaledSun>();
                }

                // Add the Kopernicus star component
                Value.scaledBody.AddComponent <StarComponent>();

                // Generate a new material for the star
                if (Material != null && EmissiveMultiRampSunspots.UsesSameShader(Material))
                {
                    Material = new EmissiveMultiRampSunspotsLoader(Material);
                }
                else
                {
                    Material = new EmissiveMultiRampSunspotsLoader();
                }

                Material.name = Guid.NewGuid().ToString();


                // Backup existing coronas
                foreach (SunCoronas corona in Value.scaledBody.GetComponentsInChildren <SunCoronas>(true))
                {
                    corona.transform.parent = Utility.Deactivator;
                }
            }

            // Event
            Events.OnScaledVersionLoaderApply.Fire(this, node);
        }