Exemplo n.º 1
0
    public void OnEnter()
    {
        _human.eulerAngles = Vector3.up * 180;

        //播放音效
        switch (MyKeys.CurrentSelectedHero)
        {
        case MyKeys.CurrentHero.GuiYuZi:
            MyAudio.PlayAudio(StaticParameter.s_GuiYuZi_Skill, false, StaticParameter.s_GuiYuZi_Skill_Volume);
            break;

        case MyKeys.CurrentHero.CiShen:
            MyAudio.PlayAudio(StaticParameter.s_CiShen_Skill, false, StaticParameter.s_CiShen_Skill_Volume);
            break;

        case MyKeys.CurrentHero.YuZi:
            MyAudio.PlayAudio(StaticParameter.s_YuZi_Skill, false, StaticParameter.s_YuZi_Skill_Volume);
            break;
        }
        MyAudio.PlayAudio(StaticParameter.s_Dash, false, StaticParameter.s_Dash_Volume);

        MoveToDashPosition(_nature);

        _Ani.SetInteger(StaticParameter.Ani_Key_HumanState, 6);

        //加载并实例化冲刺模型
        GameObject dash_Mobel = (GameObject)StaticParameter.LoadObject("Other", "Dash");
        GameObject temp       = Object.Instantiate(dash_Mobel);

        _dash_Mobel = temp.transform.GetChild(0);
        _dash_BG    = temp.transform.GetChild(1);
        //调整碰撞框大小及位置
        _item_Colloder_Transform = HumanColliderManager.Item_Collider.transform;
        _item_Colloder           = _item_Colloder_Transform.GetComponent <SphereCollider>();
        //_item_Colloder_Transform.localPosition = Vector3.up * (-1.42f);
        _item_Colloder.radius = 3.38f;
        //特效位置位置初始化
        _dash_Mobel.position = _human.position - Vector3.up * 2;
        _dash_BG.position    = Vector3.right * _dash_BG.position.x + Vector3.up * _human.position.y +
                               Vector3.forward * _human.position.z;
    }
Exemplo n.º 2
0
    public static void InitializePool(ObjectPool spawnPool, string folderName, string prefabName,
                                      int preloadAmount, bool limitInstances, bool limitFIFO, int limitAmount,
                                      bool cullDespawned, int cullAbove, int cullDelay, int cullMaxPerPass)
    {
        //加载资源
        Transform temp = ((GameObject)StaticParameter.LoadObject(folderName, prefabName)).transform;

        PrefabPool refabPool = new PrefabPool(temp)
        {
            preloadAmount          = preloadAmount,  //默认初始化两个Prefab
            limitInstances         = limitInstances, //开启限制
            limitFIFO              = limitFIFO,      //关闭无限取Prefab
            limitAmount            = limitAmount,    //限制池子里最大的Prefab数量
            AutoDestroy            = cullDespawned,  //开启自动清理池子
            DestroyExceptTheNumber = cullAbove,      //最终保留
            DestroyEachTime        = cullDelay,      //多久清理一次
            DestroyNumberEverytime = cullMaxPerPass  //每次清理几个
        };

        //初始化内存池
        spawnPool._perPrefabPoolOptions.Add(refabPool);
        spawnPool.CreatePrefabPool(spawnPool._perPrefabPoolOptions[spawnPool._perPrefabPoolOptions.Count - 1]);
    }
Exemplo n.º 3
0
    void Awake()
    {
        GameObject hero = null;

        switch (MyKeys.CurrentSelectedHero)
        {
        case MyKeys.CurrentHero.GuiYuZi:
            hero = StaticParameter.LoadObject("Ninja", "GuiYuZi") as GameObject;
            break;

        case MyKeys.CurrentHero.CiShen:
            hero = StaticParameter.LoadObject("Ninja", "CiShen") as GameObject;
            break;

        case MyKeys.CurrentHero.YuZi:
            hero = StaticParameter.LoadObject("Ninja", "Yuzi") as GameObject;
            break;

        case MyKeys.CurrentHero.ShouSi:
            hero = StaticParameter.LoadObject("Ninja", "Shousi") as GameObject;
            break;
        }

        Instantiate(hero);
        //if (SceneManager.GetActiveScene().name.Contains("Endless"))
        //{
        //    copy.transform.position = new Vector3(-4.2f, -25.3f, 1.06f);
        //}

        //初始化人物属性对象
        _nature = new GameResource.HumanNature(1);

        //初始化行为数据
        _state_Data = new BehaviourData();
        _item_Data  = new ItemColliction();
    }
Exemplo n.º 4
0
    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;
        }
    }
Exemplo n.º 5
0
 public void OnExit()
 {
     Object.Destroy(_copy);
     StaticParameter.ClearReference(ref _copy);
 }
Exemplo n.º 6
0
    void OnWizardCreate()
    {
        //GameObject[] ObstacleManagers = GameObject.FindGameObjectsWithTag("ObstacleManager");

        //foreach (GameObject child in ObstacleManagers)
        //{
        //    foreach (Transform transform in child.transform)
        //    {

        //        //修正障碍
        //        if (transform.gameObject.layer == MyTags.Obstacle_Layer)
        //        {
        //            if (transform.position.x < 0)
        //            {
        //                transform.tag = MyTags.Left_Tag;
        //                transform.localScale = Vector3.one * 10;
        //                transform.localEulerAngles = new Vector3(90, 180, -180);
        //                transform.position = new Vector3(-2.3f, transform.position.y, transform.position.z);
        //            }
        //            else if (transform.position.x > 0)
        //            {
        //                transform.tag = MyTags.Right_Tag;
        //                transform.localScale = Vector3.one * 10;
        //                transform.localEulerAngles = new Vector3(-90, 180, 0);
        //                transform.position = new Vector3(2.4f, transform.position.y, transform.position.z);
        //            }
        //            else
        //            {
        //                Debug.Log("没有标签");
        //            }
        //        }
        //        //修正移动障碍
        //        if (transform.gameObject.layer == MyTags.Sword_Layer)
        //        {
        //            if (transform.tag == MyTags.Left_Tag)
        //            {
        //                transform.localScale = Vector3.one;
        //                transform.localEulerAngles = Vector3.zero;
        //                transform.position = new Vector3(-4.3f, transform.position.y, transform.position.z);
        //            }
        //            else if (transform.tag == MyTags.Right_Tag)
        //            {
        //                transform.localScale = Vector3.one;
        //                transform.localEulerAngles = new Vector3(0, 180, 0);
        //                transform.position = new Vector3(4.3f, transform.position.y, transform.position.z);
        //            }
        //            else
        //            {
        //                Debug.Log("没有标签");
        //            }
        //        }

        //    }
        //}

        GameObject[] fruitManagers = GameObject.FindGameObjectsWithTag("FruitManager");
        GameObject   shoulijian    = StaticParameter.LoadObject("Prefab/New", "shoulijian") as GameObject;

        foreach (GameObject i in fruitManagers)
        {
            foreach (Transform tr in i.transform)
            {
                GameObject temp = Instantiate(shoulijian);
                temp.transform.position = tr.position;
                temp.transform.parent   = tr.parent;
            }
        }
    }
Exemplo n.º 7
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);
    }
Exemplo n.º 8
0
 public void OnDisable()
 {
     Destroy(_copy_Effect);
     StaticParameter.ClearReference(ref _copy_Effect);
 }
Exemplo n.º 9
0
    private GameObject _copy_Effect; //光圈特效的副本
                                     // Use this for initialization
    //void Start()
    //{
    //    Initialize();
    //    //   GameObject effect_Mobel = (GameObject)StaticParameter.LoadObject("Other", "effect");
    //    //GameObject copy = Instantiate(effect_Mobel);
    //    //copy.transform.position = transform.position;
    //    //   copy.transform.localScale = Vector3.one*1.3f;
    //    //   copy.transform.eulerAngles = Vector3.zero;
    //    _copy_Effect = StaticParameter.ItemEffect(transform);

    //}
    public void OnEnable()
    {
        Initialize();
        _copy_Effect = StaticParameter.ItemEffect(transform);
    }
Exemplo n.º 10
0
    public void OnEnter()
    {
        if (ItemColliction.Dash.IsRun() ||
            ItemColliction.StartDash.IsRun())
        {
            _nature.HumanManager_Script.CurrentState = _nature.HumanManager_Script.BeforeTheState;
            return;
        }
        if (ItemColliction.DeadDash.IsRun())
        {
            return;
        }
        //统计死亡步数
        StatisticsSteps();

        //播放音效
        switch (MyKeys.CurrentSelectedHero)
        {
        case MyKeys.CurrentHero.GuiYuZi:
            MyAudio.PlayAudio(StaticParameter.s_GuiYuZi_Dead, false, StaticParameter.s_GuiYuZi_Dead_Volume);
            break;

        case MyKeys.CurrentHero.CiShen:
            MyAudio.PlayAudio(StaticParameter.s_CiShen_Dead, false, StaticParameter.s_CiShen_Dead_Volume);
            break;

        case MyKeys.CurrentHero.YuZi:
            MyAudio.PlayAudio(StaticParameter.s_YuZi_Dead, false, StaticParameter.s_YuZi_Dead_Volume);
            break;
        }
        MyAudio.PlayAudio(StaticParameter.s_Damage, false, StaticParameter.s_Damage_Volume);

        //判断是否购买死亡冲刺
        if (ItemColliction.DeadDash.IsBuy() && !ItemColliction.DeadDash.IsRun())
        {
            HumanManager.Nature.HumanManager_Script.ItemState = ItemState.DeadDash;
        }
        else
        {
            HumanManager.Nature.ColliderManager.SetActive(false);

            //判断碰撞物体,选择死亡方式
            if (HumanManager.Nature.HumanManager_Script.CurrentCollide != null &&
                HumanManager.Nature.HumanManager_Script.CurrentCollide.gameObject.layer == MyTags.Sword_Layer)
            {
                _human.gameObject.SetActive(false);
                MyAudio.PlayAudio(StaticParameter.s_Sword_Death, false, StaticParameter.s_Sword_Death_Volume);
                GameObject hero = null;
                switch (MyKeys.CurrentSelectedHero)
                {
                case MyKeys.CurrentHero.GuiYuZi:
                    hero = StaticParameter.LoadObject("Ninja", "GuiYuZiDead") as GameObject;
                    break;

                case MyKeys.CurrentHero.CiShen:
                    hero = StaticParameter.LoadObject("Ninja", "CiShenDead") as GameObject;
                    break;

                case MyKeys.CurrentHero.YuZi:
                    hero = StaticParameter.LoadObject("Ninja", "YuZiDead") as GameObject;
                    break;

                case MyKeys.CurrentHero.ShouSi:
                    hero = StaticParameter.LoadObject("Ninja", "ShouSiDead") as GameObject;
                    break;
                }

                GameObject copy = Object.Instantiate(hero);
                copy.transform.position    = _human.position;
                copy.transform.eulerAngles = Vector3.left * 90 + Vector3.down * 90;
            }
            else
            {
                _ani.SetInteger(StaticParameter.Ani_Key_HumanState, 4);
            }
            //死亡后人物掉落的移动
            HumanManager.Nature.HumanManager_Script.StartCoroutine(FallDown(12f, 3f));

            GameUIManager method = Transform.FindObjectOfType <GameUIManager>();

            method.TheClicked(GameUI.GameUI_Resurgence);

            //调整人物角度
            switch (HumanManager.WallMark)
            {
            case WallMark.Left:
                _human.eulerAngles = Vector3.right * 20 + Vector3.up * 90;
                break;

            case WallMark.Right:
                _human.eulerAngles = Vector3.right * 20 + Vector3.up * 270;
                break;
            }
        }
    }
Exemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     _monster_Dead = (GameObject)StaticParameter.LoadObject("Other", "MonsterDead");
 }