Ejemplo n.º 1
0
    public void ShootMissle()
    {
        Enemy      enemy = GetComponent <Enemy>();
        GameObject clone;

        if (enemy.FacingRight)
        {
            clone = Instantiate(missile, missleStartPoint.position, Quaternion.identity) as GameObject;
        }
        else
        {
            clone = Instantiate(missile, missleStartPoint.position, Quaternion.Euler(new Vector3(0f, 0f, 180f))) as GameObject;
        }
        Missle missle = clone.GetComponent <Missle>();

        missle.Init(enemy);
    }
Ejemplo n.º 2
0
    protected override CastResult OnCast()
    {
        for (int i = 0, length = Random.Range(MissleMinCount, MissleMaxCount + 1); i < length; ++i)
        {
            if (ReleaseFX)
            {
                EffectPlayer.PlayOnTransform(ReleaseFX, ReleaseFXPoint);
            }
            if (ReleaseSE)
            {
                AudioSystem.Instance.PlayOnTransform(ReleaseSE, ReleaseFXPoint);
            }
            Missle missle = Instantiate(MisslePrefab, transform.position, transform.rotation).GetOrAddComponent <Missle>();
            switch (LockType)
            {
            case SkillLockType.Position:
                switch (MissleType)
                {
                case Type.Bullet:
                    missle.InitBullet(TargetPos, MissileSpeed, Settlement);
                    break;

                default:
                    missle.Init(TargetPos, MissileSpeed, Settlement);
                    break;
                }
                break;

            case SkillLockType.NoLock:
                switch (MissleType)
                {
                case Type.Bullet:
                    //missle.InitBullet(TargetPos, MissileSpeed, Settlement);
                    break;

                default:
                    missle.gameObject.AddComponent <SphereCollider>().isTrigger = true;
                    missle.gameObject.AddComponent <Rigidbody>().isKinematic    = true;
                    missle.InitFlyFront(Master.transform.forward, MissileSpeed, SkillMaxRange, (hitObj, missleScript) =>
                    {
                        if (hitObj)
                        {
                            InteractiveObj target = hitObj.GetComponent <InteractiveObj>();
                            if (target)
                            {
                                if (target.IsAlive && target.IsEnemy(Master.Camp))
                                {
                                    Settlement(target);
                                    Destroy(missleScript.gameObject);
                                }
                                return;
                            }
                            Q_SceneObj sceneObj = hitObj.GetComponent <Q_SceneObj>();
                            if (sceneObj)
                            {
                                switch (sceneObj.objType)
                                {
                                case Q_SceneObj.Type.Skill:
                                case Q_SceneObj.Type.Item:
                                case Q_SceneObj.Type.NeedItem:
                                    break;

                                default:
                                    return;
                                }
                            }
                        }
                        if (HitFX)
                        {
                            EffectPlayer.PlayAtPos(HitFX, missleScript.transform.position);
                        }
                        if (HitSE)
                        {
                            AudioSystem.Instance.PlayAtPos(HitSE, missleScript.transform.position);
                        }
                        missleScript.Alive = false;
                        Destroy(missleScript.gameObject);
                    });
                    break;
                }
                break;

            default:
                if (Target)
                {
                    missle.Init(Target.transform, MissileSpeed, (tsf) => Settlement(tsf.GetComponent <InteractiveObj>()));
                }
                else
                {
                    missle.Init(TargetPos, MissileSpeed, Settlement);
                }
                break;
            }
            missle.SetLifeTime(MissleLifeTime);
            if (FlySE)
            {
                AudioSystem.Instance.PlayOnTransform(FlySE, missle.transform);
            }
        }
        return(CastResult.Success);
    }