Beispiel #1
0
        private void Update()
        {
            if (interaction == null)
            {
                return;
            }
            Vector3 position = GetPosition(1f - interaction.NormalizedTime);

            if (position.x == float.NaN)
            {
                gameObject.SetActive(false);
                return;
            }
            Quaternion rotation = Quaternion.LookRotation(prevPosition - position) * Quaternion.Euler(90, 0, 0);

            prevPosition       = position;
            transform.rotation = rotation;
            transform.position = position;
            if (interaction.IsEnded)
            {
                var destroyVector = Vector3.zero;
                if (interaction.NormalizedTime > 0)
                {
                    var extrapolatedPosition = GetPosition((1f - interaction.NormalizedTime) + 0.01f / interaction.FlyTime);
                    destroyVector = (extrapolatedPosition - position) * 100f * destroySpeed;
                }
                const float explodeRadius = 0.15f;
                ExplosionPool.Explode(position, destroyVector, explodeRadius);
                interaction = null;
                Timer.Add(explosionDelay, (anim) => {
                    if (this == null)
                    {
                        return;
                    }
                    transform.position = transform.position + destroyVector * Time.deltaTime;
                }, () => {
                    if (this == null)
                    {
                        return;
                    }
                    Timer.Add(destroyDelay, () => {
                        if (this == null)
                        {
                            return;
                        }
                        gameObject.SetActive(false);
                    });
                });
            }
        }
Beispiel #2
0
        public void Init(RocketInteraction rocketInteraction)
        {
            interaction = rocketInteraction;
            var titanView = rocketInteraction.ParentTitan.View as TitanView;

            startPosition = titanView.GetHitPoint();

            target = rocketInteraction.TargetTitan.View as TitanView;
            // magic
            float maxHeight = Vector3.Distance(target.Titan.Position, titanView.Titan.Position) / 4f;

            heightVector = ((titanView.Titan.Position + target.Titan.Position).normalized + Random.insideUnitSphere * 0.3f) * maxHeight;
            gameObject.SetActive(true);
            prevPosition = Vector3.Lerp(startPosition, target.GetHitPoint(), 1.1f);
            Update();
            if (trail != null)
            {
                trail.Clear();
            }
        }
Beispiel #3
0
    public static void Fire(RocketInteraction rocketInteraction)
    {
        var rocketView = instance.cache.Get();

        rocketView.Init(rocketInteraction);
    }