예제 #1
0
        void AssignBowDamageToTarget(Collider arrowHitCollider)
        {
            if (!isArrow || targetEntities.Count == 0)
            {
                return;
            }

            if (caster != GameManager.Instance.PlayerEntityBehaviour)
            {
                if (targetEntities[0] == caster.GetComponent <EnemySenses>().Target)
                {
                    EnemyAttack attack = caster.GetComponent <EnemyAttack>();
                    if (attack)
                    {
                        attack.BowDamage(goModel.transform.forward);
                    }
                }
            }
            else
            {
                Transform hitTransform = arrowHitCollider.gameObject.transform;
                GameManager.Instance.WeaponManager.WeaponDamage(GameManager.Instance.WeaponManager.LastBowUsed, true, isArrowSummoned, hitTransform, hitTransform.position, goModel.transform.forward);
            }
        }
예제 #2
0
        void AssignBowDamageToTarget(Collider arrowHitCollider)
        {
            if (!isArrow || targetEntities.Count == 0)
            {
                return;
            }

            if (caster != GameManager.Instance.PlayerEntityBehaviour)
            {
                if (targetEntities[0] == caster.GetComponent <EnemySenses>().Target)
                {
                    EnemyAttack attack = caster.GetComponent <EnemyAttack>();
                    if (attack)
                    {
                        attack.BowDamage(goModel.transform.forward);
                    }
                }
            }
            else
            {
                RaycastHit unused = new RaycastHit();
                GameManager.Instance.WeaponManager.WeaponDamage(unused, goModel.transform.forward, arrowHitCollider, true);
            }
        }
예제 #3
0
        private void Update()
        {
            // Exit if no caster
            if (!caster)
            {
                return;
            }

            // Execute based on target type
            if (!missileReleased)
            {
                switch (targetType)
                {
                case TargetTypes.ByTouch:
                    DoTouch();
                    break;

                case TargetTypes.SingleTargetAtRange:
                case TargetTypes.AreaAtRange:
                    DoMissile();
                    break;

                case TargetTypes.AreaAroundCaster:
                    DoAreaOfEffect(caster.transform.position, true);
                    break;

                default:
                    return;
                }
            }

            // Handle missile lifespan pre and post-impact
            if (!impactDetected)
            {
                // Transform missile along direction vector
                transform.position += (direction * MovementSpeed) * Time.deltaTime;

                // Update lifespan and self-destruct if expired (e.g. spell fired straight up and will never hit anything)
                lifespan += Time.deltaTime;
                if (lifespan > LifespanInSeconds)
                {
                    Destroy(gameObject);
                }
            }
            else
            {
                // Notify listeners work is done and automatically assign impact
                if (!impactAssigned)
                {
                    PlayImpactSound();
                    RaiseOnCompleteEvent();
                    AssignPayloadToTargets();
                    impactAssigned = true;

                    // Handle arrow
                    if (isArrow)
                    {
                        // Disable 3d arrow
                        goModel.gameObject.SetActive(false);

                        if (caster != GameManager.Instance.PlayerEntityBehaviour)
                        {
                            DaggerfallEntityBehaviour entityBehaviour = null;
                            if (arrowHit.transform)
                            {
                                entityBehaviour = arrowHit.transform.GetComponent <DaggerfallEntityBehaviour>();
                            }
                            if (entityBehaviour == caster.GetComponent <EnemySenses>().Target)
                            {
                                EnemyAttack attack = caster.GetComponent <EnemyAttack>();
                                if (attack)
                                {
                                    attack.BowDamage(goModel.transform.forward);
                                }
                            }
                        }
                        else
                        {
                            GameManager.Instance.WeaponManager.WeaponDamage(arrowHit, goModel.transform.forward, true);
                        }
                    }
                }

                // Track post impact lifespan and allow impact clip to finish playing
                postImpactLifespan += Time.deltaTime;
                if (postImpactLifespan > PostImpactLifespanInSeconds)
                {
                    myLight.enabled = false;
                    if (ImpactSound != SoundClips.None && !audioSource.IsPlaying())
                    {
                        Destroy(gameObject);
                    }
                }
            }

            // Update light
            UpdateLight();
        }