Example #1
0
        private void CreateTrigger()
        {
            trigger = GameObject.Instantiate(lightMotor.ab2TriggerPrefab, playerMotor.characterContainer);
            trigger.transform.localPosition = new Vector3(0f, .1f, 0f);
            trigger.transform.localRotation = Quaternion.identity;
            AbilityColliderTrigger act = trigger.GetComponent <AbilityColliderTrigger>();

            act.SetAbility(this);
        }
Example #2
0
        protected override void RunCollisionPart(int part)
        {
            if (part == 0)
            {
                // move Ray container
                float angle = CONE_STARTING + CONE_ANGLE * (Time.time - parts[0].startTime - startTime) / parts[0].duration;

                // compute length
                float      length = MAX_DISTANCE;
                RaycastHit hit;
                LayerMask  mask = LayerMask.GetMask("Environment");

                // If environment contact, shorter ray and explosion
                if (Physics.Raycast(groundRenderer.transform.position + km.attack1Container.transform.forward * DIST_FROM_CENTER_COLLIDER,
                                    Quaternion.Euler(0, angle, 0) * km.transform.forward, out hit, MAX_DISTANCE, mask))
                {
                    // ray length (collider)
                    length = hit.distance;
                }

                km.attack1actContainer.transform.localScale = new Vector3(1, 1, length);
                km.attack1RayRenderer.SetLength(length - 1);

                // Ground angle
                burningGround.SetAngle(angle);

                // Next sector
                if (angle > nextAngle)
                {
                    nextAngle = angle + ANGLE_SPACING - SAFETY_OVERLAP;

                    // Ground renderer
                    burningGround.addAngle3d(angle, length + DIST_FROM_CENTER_COLLIDER);

                    // new ground collider trigger for this sector
                    GameObject groundActGO = GameObject.Instantiate(groundActPrefab, groundRenderer.transform.position,
                                                                    em.transform.rotation * Quaternion.AngleAxis(angle, Vector3.up), null);
                    groundActGO.transform.localScale = new Vector3(length + DIST_FROM_CENTER_COLLIDER, 1, length + DIST_FROM_CENTER_COLLIDER);
                    GameObject.Destroy(groundActGO, GROUND_DURATION - (Time.time - startTime - DMG_START));

                    // Ability coolider trigger
                    AbilityColliderTrigger groundAct = groundActGO.GetComponent <AbilityColliderTrigger>();
                    groundAct.SetAbility(this, "ground");
                }
            }

            base.RunCollisionPart(part);
        }
Example #3
0
        private void SpawnLight()
        {
            Vector3 pos = new Vector3(lightMotor.sword.transform.position.x, .2f, lightMotor.sword.transform.position.z);

            GameObject lightZone = GameObject.Instantiate(lightMotor.lightZonePrefab, null);

            lightZone.transform.position = pos;

            // Particle effect
            lightMotor.LightSpawnPE(pos);

            // Damage zone (trigger)
            trigger = GameObject.Instantiate(lightMotor.lightSpawnTriggerPrefab, null);
            trigger.transform.position = pos;
            AbilityColliderTrigger act = trigger.GetComponent <AbilityColliderTrigger>();

            act.SetAbility(this);
        }
Example #4
0
        protected override void StartCollisionPart(int part)
        {
            if (part == 0)
            {
                float length = MAX_DISTANCE;

                // Create ray
                RaycastHit hit;
                LayerMask  mask = LayerMask.GetMask("Environment");

                // If environment contact, shorter ray and explosion
                if (Physics.Raycast(km.attack4Container.transform.position + km.attack4Container.transform.forward * DIST_FROM_CENTER_COLLIDER,
                                    km.attack4Container.transform.forward, out hit, MAX_DISTANCE, mask))
                {
                    // ray length
                    length = hit.distance;

                    // Activate explosion collider trigger
                    explActGO = GameObject.Instantiate(km.attack4ExplColliderPrefab, hit.point,
                                                       Quaternion.LookRotation(hit.normal, Vector3.up), null);
                    explActGO.transform.localScale = Vector3.one * EXPLOSION_RADIUS;
                    GameObject.Destroy(explActGO, DMG_DURATION);

                    // Explosion zone collider
                    explCols = new Dictionary <Collider, float>();
                    explAct  = explActGO.GetComponent <AbilityColliderTrigger>();
                    explAct.SetAbility(this, "explosion");

                    // Activate explosion renderer
                    explRenderer = GameObject.Instantiate(km.attack4ExplRendererPrefab, hit.point,
                                                          Quaternion.LookRotation(hit.normal, Vector3.up), null);
                    explRenderer.transform.localScale = Vector3.one * EXPLOSION_RADIUS;
                    GameObject.Destroy(explRenderer, EXPLOSION_RENDER_DURATION);
                }

                // Ray collider length
                km.attack4actContainer.transform.localScale = new Vector3(1, 1, length);

                // Instanciate ray renderer
                km.attack4RayRenderer.SetupAndStart(DMG_DURATION, length - (DIST_FROM_CENTER_RENDERER - DIST_FROM_CENTER_COLLIDER));
            }

            base.StartCollisionPart(part);
        }
Example #5
0
        private void SpawnLight()
        {
            Vector3 pos = playerMotor.transform.position + playerMotor.characterContainer.forward;

            pos.y = .2f;

            GameObject lightZone = GameObject.Instantiate(lightMotor.lightZonePrefab, null);

            lightZone.transform.position = pos;

            // Particle effect
            lightMotor.LightSpawnPE(pos);

            // Damage zone (trigger)
            trigger = GameObject.Instantiate(lightMotor.lightSpawnTriggerPrefab, null);
            trigger.transform.position = pos;
            AbilityColliderTrigger act = trigger.GetComponent <AbilityColliderTrigger>();

            act.SetAbility(this);
        }