Esempio n. 1
0
    void MissileCollider()
    {
        Destroy(gameObject);

        if (ItemColliction.SuperMan.IsRun() || ItemColliction.Dash.IsRun() || ItemColliction.StartDash.IsRun())
        {
            //无敌碰撞的声音
            if (ItemColliction.SuperMan.IsRun() && gameObject.layer == MyTags.Obstacle_Layer)
            {
                MyAudio.PlayAudio(StaticParameter.s_Obstacle_Break, false, StaticParameter.s_Obstacle_Break_Volume);
            }
            //摄像机震动
            CameraShake.Is_Shake_Camera = true;
            StaticParameter.DestroyOrDespawn(transform);
        }
        else if (ItemColliction.Protect.IsRun())
        {
            //播放音效
            MyAudio.PlayAudio(StaticParameter.s_Sheld_Break, false, StaticParameter.s_Sheld_Break_Volume);

            ItemColliction.Protect.Exit();
            //摄像机震动
            CameraShake.Is_Shake_Camera = true;
        }
        else
        {
            HumanManager.Nature.HumanManager_Script.Collde = transform;
        }
    }
Esempio n. 2
0
    void Effect()
    {
        MyAudio.PlayAudio(StaticParameter.s_Bomb, false, StaticParameter.s_Bomb_Volume);
        if (_bomb_Effect != null)
        {
            GameObject copy = Instantiate(_bomb_Effect);
            copy.transform.position = transform.position;
        }

        //Destroy(gameObject);
        MyPool.Instance.Despawn(_fire_Effect);

        StaticParameter.DestroyOrDespawn(transform);
    }
    void ChangeItem(Collider other, HumanManager human, GameObject effect)
    {
        ItemState temp = ItemState.Null;

        switch (other.tag)
        {
        case "Dash":
            if (!ItemColliction.DeadDash.IsRun())
            {
                temp = ItemState.Dash;
            }
            else
            {
                temp = ItemState.DeadDash;
            }
            break;

        case "Double":
            temp = ItemState.Double;
            break;

        case "Protect":
            temp = ItemState.Protect;
            break;

        case "SuperMan":
            temp = ItemState.SuperMan;
            break;

        case "Magnet":
            temp = ItemState.Magnet;
            break;
        }
        if (temp == ItemState.Null)
        {
            return;
        }
        else
        {
            if (temp != ItemState.DeadDash)
            {
                human.ItemState = temp;
            }
            Effect(other, effect);
            StaticParameter.DestroyOrDespawn(other.transform);
        }
    }
Esempio n. 4
0
    void Dash(Collider other)    //冲锋
    {
        switch (other.gameObject.layer)
        {
        case MyTags.Fruit_Layer:
            FruitScript fruit = other.transform.GetComponent <FruitScript> ();
            fruit.CutFruit();
            break;

        case MyTags.Obstacle_Layer:
            //播放音效
            MyAudio.PlayAudio(StaticParameter.s_Obstacle_Break, false, StaticParameter.s_Obstacle_Break_Volume);
            //Destroy (other.gameObject);
            try
            {
                StaticParameter.DestroyOrDespawn(other.transform);
                GameObject _obstacle = (GameObject)StaticParameter.LoadObject("Other", "BrokenObstacle");
                GameObject copy      = Instantiate(_obstacle, other.transform.position, Quaternion.identity) as GameObject;
                Destroy(copy, 2);

                SkinnedMeshRenderer huamnRenderer = other.transform.GetComponent <SkinnedMeshRenderer>();
                huamnRenderer.material.DOFade(0, 1);
            }
            catch (Exception)
            {
            }

            //摄像机震动
            CameraShake.Is_Shake_Camera = true;

            break;

        case MyTags.Spring_Layer:
            //播放音效
            MyAudio.PlayAudio(StaticParameter.s_Obstacle_Break, false, StaticParameter.s_Obstacle_Break_Volume);
            //摄像机震动
            CameraShake.Is_Shake_Camera = true;
            //播放破坏动画
            Animator ani = other.transform.GetComponent <Animator>();
            ani.SetBool(StaticParameter.Ani_Key_Broke, true);
            //摄像机震动
            CameraShake.Is_Shake_Camera = true;

            break;
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (HumanManager.Nature.HumanManager_Script.CurrentState == HumanState.Dead)
        {
            return;
        }
        if (WideWallColliderBefore == other)
        {
            return;
        }

        ChangeItem(other, _nature.HumanManager_Script, _effect);

        //判断碰撞的物体
        switch (other.gameObject.layer)
        {
        case MyTags.Wide_Wall_Collider_Layer:
            WideWallColliderBefore = other;

            if (Judge(HumanManager.WallMark, other.transform))
            {
                _nature.HumanManager_Script.Collde = other.transform;
            }
            break;

        case MyTags.Toturial_Layer:
        case MyTags.Chest_Layer:
        case MyTags.Fruit_Layer:
            _nature.HumanManager_Script.Collde = other.transform;
            break;

        case MyTags.Spring_Layer:
            if (Judge(HumanManager.WallMark, other.transform))
            {
                _nature.HumanManager_Script.Collde = other.transform;
            }
            break;

        case MyTags.Obstacle_Layer:
        case MyTags.Missile_Layer:
        case MyTags.Sword_Layer:
            if (other.gameObject.layer == MyTags.Missile_Layer)
            {
                Destroy(other.gameObject);
            }

            StartCoroutine(CloseAndResetCollider(other));

            if (ItemColliction.SuperMan.IsRun() || ItemColliction.Dash.IsRun() || ItemColliction.StartDash.IsRun())
            {
                //无敌碰撞的声音
                if (ItemColliction.SuperMan.IsRun() && other.gameObject.layer == MyTags.Obstacle_Layer)
                {
                    MyAudio.PlayAudio(StaticParameter.s_Obstacle_Break, false, StaticParameter.s_Obstacle_Break_Volume);
                }
                //摄像机震动
                CameraShake.Is_Shake_Camera = true;
                if (other.gameObject.layer == MyTags.Missile_Layer)
                {
                    StaticParameter.DestroyOrDespawn(other.transform);
                }
                else
                {
                    //Destroy(other.gameObject);
                    StaticParameter.DestroyOrDespawn(other.transform);
                    GameObject _obstacle = (GameObject)StaticParameter.LoadObject("Other", "BrokenObstacle");
                    GameObject copy      = Instantiate(_obstacle, other.transform.position, Quaternion.identity) as GameObject;
                    Destroy(copy, 2);
                }
            }
            else if (ItemColliction.Protect.IsRun())
            {
                //播放音效
                MyAudio.PlayAudio(StaticParameter.s_Sheld_Break, false, StaticParameter.s_Sheld_Break_Volume);

                ItemColliction.Protect.Exit();
                //摄像机震动
                CameraShake.Is_Shake_Camera = true;
                //护盾破碎
                ProtectBroke();
            }
            else
            {
                _nature.HumanManager_Script.Collde = other.transform;
            }
            break;
        }
    }
Esempio n. 6
0
    IEnumerator StartToMove()
    {
        yield return(new WaitUntil(() =>
        {
            if (MyKeys.Pause_Game)
            {
                return false;
            }
            if (IsHighSpeed())
            {
                return transform.position.y - (Camera.main.transform.position.y - HumanManager.Nature.Difference_Y) < 22.5;
            }
            else
            {
                return transform.position.y - (Camera.main.transform.position.y - HumanManager.Nature.Difference_Y) < 15;
            }
        }));

        //显示导弹提示线
        MyPool.Instance.Spawn(StaticParameter.s_Prefab_Line, transform.position, _line_Rotation);

        yield return(new WaitUntil(() =>
        {
            if (MyKeys.Pause_Game)
            {
                return false;
            }
            if (IsHighSpeed())
            {
                _distance -= HumanManager.Nature.Run_Speed * 1.5f;
            }
            else
            {
                _distance -= HumanManager.Nature.Run_Speed;
            }

            return _distance <= 0;
        }));

        //开启火焰特效
        Transform fire = MyPool.Instance.Spawn(StaticParameter.s_Prefab_Fire);

        _fire_Effect  = fire;
        fire.position = transform.position;
        fire.rotation = transform.rotation;

        yield return(new WaitUntil(() =>
        {
            if (MyKeys.Pause_Game)
            {
                return false;
            }

            transform.Translate(0, -0.15f, 0, Space.World);
            fire.position = transform.position;
            return StaticParameter.ComparePosition(this.transform, HumanManager.Nature.Human) < -50;
        }));

        MyPool.Instance.Despawn(fire);
        //到达距离,销毁导弹,在无尽模式下回收对象
        //Destroy(gameObject);
        StaticParameter.DestroyOrDespawn(transform);
    }