public void OnHit(string id, bool fromAI, float damage)
        {
            //单机状态
            if (GameMgr.instance == null)
            {
                HitImplement(damage);
            }
            //本地玩家造成伤害
            else if (GameMgr.instance.id == id)
            {
                //自己对自己不能造成的伤害
                if (gameObject.name == id)
                {
                    return;
                }

                if (AS != null)
                {
                    AS.Play();
                }

                HitImplement(damage);
                m_NetSyncController.RPC(this, "HitImplement", damage);
            }
            //MasterClient上的AI造成的伤害,其他玩家只进行伤害同步
            else if (fromAI && GameMgr.instance.isMasterClient)
            {
                HitImplement(damage);
                m_NetSyncController.RPC(this, "HitImplement", damage);
            }
        }
예제 #2
0
 private void OnElevatorOpen()
 {
     if (state == Room1State.EscapingRoom)
     {
         ElevatorOpenImpl();
         m_controller.RPC(this, "ElevatorOpenImpl");
     }
 }
예제 #3
0
        //行走函数
        public void Walk(float h, float v)
        {
            //调用RPC
            if (IsLocalObject)
            {
                if (Mathf.Abs(m_Input.x - m_PreInput.x) > 0.05f || Mathf.Abs(m_Input.y - m_PreInput.y) > 0.05f)
                {
                    m_NetSyncController.RPC(this, "Walk", h, v);
                }
            }


            SendMessage("SetWalkAnimationParamters", new Vector2(h, v), SendMessageOptions.DontRequireReceiver);
        }
예제 #4
0
    public void CreateAI(int num, int type, string swopPoints)
    {
        if (!GameMgr.instance)//离线状态
        {
            createAIImpl(num, type, swopPoints);
            return;
        }

        if (GameMgr.instance.isMasterClient)
        {
            createAIImpl(num, type, swopPoints);
            m_NetSyncController.RPC(this, "createAIImpl", num, type, swopPoints);
        }
    }
예제 #5
0
        // Update is called once per frame
        void Update()
        {
            if (!isLocalPlayer)
            {
                return;
            }

            //响应鼠标按键
            if (Input.GetMouseButtonDown(0) || Input.GetMouseButton(0) && canShoot
                //&&  !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()
                )
            {
                StartCoroutine(ShootRoutine());
                Vector3 point     = new Vector3(camera.pixelWidth / 2, camera.pixelHeight / 2, 0); //屏幕中心
                Ray     ray       = camera.ScreenPointToRay(point);                                //在摄像机所在位置创建射线
                Vector3 direction = ray.direction;
                Vector3 origin    = ray.origin;
                ShootWithRay(direction.x, direction.y, direction.z, origin.x, origin.y, origin.z);
                if (m_NetSyncController != null)
                {
                    m_NetSyncController.RPC(this, "ShootWithRay", direction.x, direction.y, direction.z, origin.x, origin.y, origin.z);
                }
                // 是否开启镜头抖动
                if (jitterOn)
                {
                    // 镜头随机的抖动!!
                    float rotationX = camera.transform.localEulerAngles.x + Random.Range(-jitterFactorX, jitterFactorX / 4);
                    float rotationY = camera.transform.localEulerAngles.y + Random.Range(-jitterFactorY, jitterFactorY);
                    float rotationZ = camera.transform.localEulerAngles.z;
                    camera.transform.localEulerAngles = new Vector3(rotationX, rotationY, rotationZ);
                }
            }
        }
예제 #6
0
        //切换下一把武器
        public void NextWeapon()
        {
            //调用RPC函数
            if (IsLocalObject)
            {
                m_NetSyncController.RPC(this, "NextWeapon");
            }

            m_WeaponIndex++;
            if (m_WeaponIndex > m_WeaponNumber - 1)
            {
                m_WeaponIndex = 0;
            }

            SetActiveWeapon(m_WeaponIndex);
        }
예제 #7
0
 /// <summary>
 /// @brief 两次碰撞体检测
 /// @param i 碰撞体提供的magic number,相当于注册的事件
 /// </summary>
 /// <param name="i"></param>
 public override void notify(int i)
 {
     if (this.enabled)
     {
         if (i == 1)
         {
             near_Room2();
             m_controller.RPC(this, "near_Room2");
             //初始化
             becomeDark_Room2();
             m_controller.RPC(this, "becomeDark_Room2");
         }
         else if (i == 2)
         {
             enter_Room2();
             m_controller.RPC(this, "enter_Room2");
         }
     }
 }
예제 #8
0
        // Update is called once per frame
        void Update()
        {
            if (m_IsStop)
            {
                m_CoreInteractiveObj.UpdateState();
                //拿到了托卡马克之心就
                if (m_CoreInteractiveObj.IsInteractionDone())
                {
                    mSynControler.RPC(this, "destroyCore");
                    destroyCore();
                }
            }
            else
            {
                //Quaternion rot =  Quaternion.Euler(0, Time.deltaTime * m_RotatingVelocity, 0);
                this.transform.Rotate(new Vector3(0, 1, 0), Time.deltaTime * m_RotatingVelocity, Space.World);

                m_Time += Time.deltaTime;
                this.transform.position = m_OriginPos + new Vector3(0, Mathf.Sin(m_Time * m_FloatingFrequency), 0) * m_FloatingAmplitude;
            }
        }
예제 #9
0
        //射线武器,开火
        public void Fire()
        {
            //调用RPC函数
            if (IsLocalObject)
            {
                m_NetSyncController.RPC(this, "Fire");
            }


            //重置计时器
            FireTimer = 0.0f;

            //增加已射击的子弹数
            BurstCounter++;

            //半自动武器不能连续射击
            if (AutoMode == Auto.Semi)
            {
                m_CanFire = false;
            }

            //判断当前是否仍有弹药
            if (m_CurrentAmmo <= 0)
            {
                DryFire();
                return;
            }

            //能够开枪,发送开枪消息
            SendMessage("StartShooting", SendMessageOptions.DontRequireReceiver);

            //如果不是无线弹药模式,减少弹药量
            if (!InfiniteAmmo)
            {
                m_CurrentAmmo--;
            }

            //单次射击,射出shotPerRound颗子弹
            for (int i = 0; i < ShotPerRound; i++)
            {
                Vector3 direction = m_CurrentShootPoint.forward;

                //计算当前的精确度
                float accuracyVary = (100 - CurrentAccuracy) / 1000;

                //根据精确度确定散射范围
                direction.x     += UnityEngine.Random.Range(-accuracyVary, accuracyVary);
                direction.y     += UnityEngine.Random.Range(-accuracyVary, accuracyVary);
                direction.z     += UnityEngine.Random.Range(-accuracyVary, accuracyVary);
                CurrentAccuracy -= AccuracyDropPerShot;
                if (CurrentAccuracy <= 0.0f)
                {
                    CurrentAccuracy = 0.0f;
                }

                //创建射线
                Ray ray = new Ray(m_CurrentShootPoint.position, direction);

                bool       hitResult;
                RaycastHit hit;

                int layer = LayerMask.NameToLayer(LayerMaskName);
                if (layer != -1)
                {
                    //过滤LayerMaskName这一层
                    LayerMask mask = ~(1 << layer);
                    hitResult = Physics.Raycast(ray, out hit, Range, mask);
                }
                else
                {
                    hitResult = Physics.Raycast(ray, out hit, Range);
                }

                if (hitResult)
                {
                    //蓄力
                    float damage = Power;
                    if (Warmup)
                    {
                        damage *= m_Heat * PowerMultiplier;
                        m_Heat  = 0.0f;
                    }

                    //造成伤害
                    ReactiveTarget target = hit.collider.gameObject.GetComponent <ReactiveTarget>();
                    if (target)
                    {
                        target.OnHit(this.transform.root.name, false, Power);
                    }
                    else
                    {
                        target = hit.collider.transform.root.gameObject.GetComponent <ReactiveTarget>();
                        if (target)
                        {
                            target.OnHit(this.transform.root.name, false, Power);
                        }
                    }


                    //判断被击中物体是否满足不产生弹孔的条件
                    bool exception = false;
                    if (BHSystem == BulletHoleSystem.Tag)
                    {
                        foreach (SmartBulletHoleGroup bhg in BulletHoleExceptions)
                        {
                            if (hit.collider.gameObject.tag == bhg.Tag)
                            {
                                exception = true;
                                break;
                            }
                        }
                    }
                    else if (BHSystem == BulletHoleSystem.Material)
                    {
                        foreach (SmartBulletHoleGroup bhg in BulletHoleExceptions)
                        {
                            MeshRenderer mesh = FindMeshRenderer(hit.collider.gameObject);
                            if (mesh != null)
                            {
                                if (mesh.sharedMaterial == bhg.Material)
                                {
                                    exception = true;
                                    break;
                                }
                            }
                        }
                    }
                    else if (BHSystem == BulletHoleSystem.Physic_Material)
                    {
                        foreach (SmartBulletHoleGroup bhg in BulletHoleExceptions)
                        {
                            if (hit.collider.sharedMaterial == bhg.PhysicMaterial)
                            {
                                exception = true;
                                break;
                            }
                        }
                    }

                    //如果需要生成弹孔,且物体满足生成弹孔条件
                    if (MakeBulletHoles && !exception)
                    {
                        //保存所有符合条件的SmartBulletHoleGroup
                        List <SmartBulletHoleGroup> holes = new List <SmartBulletHoleGroup>();

                        if (BHSystem == BulletHoleSystem.Tag)
                        {
                            foreach (SmartBulletHoleGroup bhg in BulletHoleGroups)
                            {
                                if (hit.collider.gameObject.tag == bhg.Tag)
                                {
                                    holes.Add(bhg);
                                }
                            }
                        }
                        else if (BHSystem == BulletHoleSystem.Material)
                        {
                            MeshRenderer mesh = FindMeshRenderer(hit.collider.gameObject);

                            foreach (SmartBulletHoleGroup bhg in BulletHoleGroups)
                            {
                                if (mesh != null)
                                {
                                    if (mesh.sharedMaterial == bhg.Material)
                                    {
                                        holes.Add(bhg);
                                    }
                                }
                            }
                        }
                        else if (BHSystem == BulletHoleSystem.Physic_Material)
                        {
                            foreach (SmartBulletHoleGroup bhg in BulletHoleGroups)
                            {
                                if (hit.collider.sharedMaterial == bhg.PhysicMaterial)
                                {
                                    holes.Add(bhg);
                                }
                            }
                        }

                        //保存被选中的SmartBulletHoleGroup
                        SmartBulletHoleGroup sbhg = null;

                        //没有满足条件的弹孔,使用默认弹孔
                        if (holes.Count == 0)
                        {
                            List <SmartBulletHoleGroup> defaultsToUse = new List <SmartBulletHoleGroup>();
                            foreach (BulletHolePool h in DefaultBulletHoles)
                            {
                                defaultsToUse.Add(new SmartBulletHoleGroup("Default", null, null, h));
                            }

                            //随机选择一个SmartBulletHoleGroup
                            sbhg = defaultsToUse[Random.Range(0, defaultsToUse.Count)];
                        }
                        else
                        {
                            //随机选择一个SmartBulletHoleGroup
                            sbhg = holes[Random.Range(0, holes.Count)];
                        }

                        //在场景中生成弹孔
                        if (sbhg.BulletHole != null)
                        {
                            sbhg.BulletHole.PlaceBulletHole(hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
                        }
                    }

                    //击中的特效
                    if (MakeHitEffects)
                    {
                        foreach (GameObject hitEffect in HitEffects)
                        {
                            if (hitEffect != null)
                            {
                                Instantiate(hitEffect, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
                            }
                        }
                    }

                    //给被射中的物体加上一个击退的力
                    if (UseForce && hit.rigidbody)
                    {
                        hit.rigidbody.AddForce(ray.direction * Power * ForceMultiplier);
                    }
                }
            }

            //如果使用后坐力,调用后坐力函数
            if (UseRecoil)
            {
                Recoil();
            }

            //如果使用枪口火焰效果,就显示枪口火焰
            if (MakeMuzzleEffects)
            {
                GameObject muzfx = MuzzleEffects[Random.Range(0, MuzzleEffects.Length)];
                if (muzfx != null)
                {
                    Instantiate(muzfx, MuzzleEffectsPosition.position, MuzzleEffectsPosition.rotation);
                }
            }

            //创建弹壳
            if (UseSpitShells)
            {
                GameObject shellGO = Instantiate(Shell, ShellSpitPosition.position, ShellSpitPosition.rotation) as GameObject;
                shellGO.GetComponent <Rigidbody>().AddRelativeForce(new Vector3(ShellSpitForce + Random.Range(0, ShellForceRandom), 0, 0), ForceMode.Impulse);
                shellGO.GetComponent <Rigidbody>().AddRelativeTorque(new Vector3(ShellSpitTorqueX + Random.Range(-ShellTorqueRandom, ShellTorqueRandom), ShellSpitTorqueY + Random.Range(-ShellTorqueRandom, ShellTorqueRandom), 0), ForceMode.Impulse);
            }

            //播放射击音效
            GetComponent <AudioSource>().PlayOneShot(FireSound);
        }
예제 #10
0
        /// <summary>
        /// @brief 判断timeline播放阶段,生成AI,boss,激活玩家
        /// </summary>
        void Update()
        {
            if (getCamera != null)
            {
                mCamera = getCamera.GetCurrentUsedCamera();
            }
            if (!isTimelinePaused)//bool值作为flag
            {
                if (director.time > 30.0f)
                {
                    isTimelinePaused            = true;
                    trueBoss.transform.position = bossInitPos.position;
                    trueBoss.SetActive(true);

                    Destroy(boss.gameObject);
                    //动画位置同步
                    AIController.instance.AddAIObject(trueBoss);

                    foreach (var p in SceneNetManager.instance.list)
                    {
                        p.Value.GetComponent <ReactiveTarget>().CanBeHurt = true;
                        p.Value.SetActive(true);
                    }

                    AIController.instance.CreateAI(1, 0, "EnemyInitPos4", wanderAIAgentParams[4]);
                    AIController.instance.CreateAI(1, 0, "EnemyInitPos4", wanderAIAgentParams[5]);
                    AIController.instance.CreateAI(1, 0, "EnemyInitPos4", wanderAIAgentParams[6]);
                    AIController.instance.CreateAI(3, 2, "EnemyInitPos5", turretAIAgentParams);
                    AIController.instance.CreateAI(3, 1, "EnemyInitPos6", turretAIAgentParams);
                    AIController.instance.CreateAI(1, 0, "EnemyInitPos7", wanderAIAgentParams[0]);
                    AIController.instance.CreateAI(1, 0, "EnemyInitPos7", wanderAIAgentParams[1]);
                    AIController.instance.CreateAI(1, 0, "EnemyInitPos7", wanderAIAgentParams[2]);
                    AIController.instance.CreateAI(1, 0, "EnemyInitPos7", wanderAIAgentParams[3]);
                    AIController.instance.CreateAI(2, 2, "EnemyInitPos7", turretAIAgentParams);
                }
            }
            else//播放台词
            {
                if (!playOnce)
                {
                    playOnce    = true;
                    source.clip = clips[0];
                    source.Play();
                    source.priority = TimelineSource.priority + 1;
                }

                if (lastTimeInitAI >= 10.0f)
                {
                    AIController.instance.CreateAI(1, 0, "EnemyInitPos5", wanderAIAgentParams[3]);
                    AIController.instance.CreateAI(1, 0, "EnemyInitPos4", wanderAIAgentParams[4]);
                    lastTimeInitAI = 0.0f;
                }
                else
                {
                    lastTimeInitAI += Time.deltaTime;
                }
            }
            //TODO:测试,删除
            if (trueBoss == null)
            {
                if (!destoryBoss)
                {
                    openDoor_Room2();
                    mController.RPC(this, "openDoor_Room2");
                    destoryBoss = true;
                }
            }
        }
예제 #11
0
 //发信息
 private void closeDoor()
 {
     closeDoor_Imp();
     m_controller.RPC(this, "closeDoor_Imp");
 }
예제 #12
0
 public void RPC(Action func)
 {
     m_Controller.RPC(this, func.Method.Name);
     func();
 }
예제 #13
0
        /// <summary>
        /// 状态机
        /// </summary>
        void mind()
        {
            {
                //获取动画状态
                AnimatorTransitionInfo transitioInfo = animator.GetAnimatorTransitionInfo(0);
                AnimatorStateInfo      stateInfo     = animator.GetCurrentAnimatorStateInfo(0);

                switch (currentState)
                {
                //停住
                case fireState.Idle:
                {
                    //一定要转到idle动画为止
                    animator.SetBool("StopFire", false);
                    //转完再说
                    if (beginTurnAround)
                    {
                        break;
                    }
                    //想一下

                    if (thinkTime < 0.5f)
                    {
                        thinkTime += Time.deltaTime;
                    }
                    else
                    {
                        thinkTime    = 0.0f;
                        currentState = fireState.SeekingPlayer;
                    }
                }
                break;

                //看看谁是下一个倒霉蛋
                case fireState.SeekingPlayer:
                {
                    isFoundPlayer = false;
                    foreach (var a in SceneNetManager.instance.list)
                    {
                        if (a.Value != null)
                        {
                            //用头比较清真
                            Vector3 dir = (a.Value.transform.Find("Head").position - new Vector3(0.0f, 0.5f, 0.0f)) - head.position;
                            Ray     ray = new Ray(head.position, dir);

                            RaycastHit hit;
                            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                            {
#if UNITY_EDITOR
                                Debug.DrawLine(ray.origin, hit.point, Color.red, 2.0f);
                                Debug.Log(hit.collider.tag);
#endif
                                if (hit.collider.tag == "Player")
                                {
                                    isFoundPlayer = true;
                                    target        = a.Value.transform;
#if UNITY_EDITOR
                                    Debug.Log(target);
#endif
                                    break;
                                }
                            }
                        }
                    }
                    //找到了
                    if (isFoundPlayer)
                    {
                        int choice = (int)UnityEngine.Random.Range(0, 3);
                        switch (choice)
                        {
                        case 0:
                        {
                            //转移到下一个状态
                            currentState = fireState.OpenFire;
                            handup       = true;
                            animator.SetBool("handup", true);
                            //netSyncController.SyncVariables();
                        }
                        break;

                        case 1:
                        case 2:
                        {
                            //转移到下一个状态
                            currentState = fireState.MissileLaunch;
                            //同步
                            animator.SetBool("missileLaunch", true);
                            missilLaunch = true;
                            //netSyncController.SyncVariables();
                        }
                        break;
                        }
                    }
                    //维持seek状态2秒
                    if (thinkTime >= 2.0f)
                    {
                        thinkTime    = 0.0f;
                        currentState = fireState.wandering;
                    }
                    else
                    {
                        thinkTime += Time.deltaTime;
                    }
                }
                break;

                case fireState.wandering:
                {
                    //TODO:之前状态要加一下isStartWalking的初始化
                    //先转过去再走
                    if (!isStartWalking)
                    {
                        //选个目标
                        currentWanderTarget = wanderPath[UnityEngine.Random.Range(0, wanderPath.Length)];
                        StartCoroutine(turnAround(currentWanderTarget));
                        isStartWalking = true;
                    }
                    else
                    {
                        //转到位了
                        if (!beginTurnAround)
                        {
                            if (!isBeginWandering)
                            {
                                animator.SetBool("walk", true);
                                isWalking = true;
                                //netSyncController.SyncVariables();
                                isBeginWandering = true;
                            }
                            else
                            {
                                if (Vector3.Distance(transform.position, currentWanderTarget.position) < 10.0f)
                                {
                                    isStartWalking   = false;
                                    isBeginWandering = false;

                                    isWalking = false;
                                    animator.SetBool("walk", false);
                                    //netSyncController.SyncVariables();
                                    currentState = fireState.SeekingPlayer;
                                }
                            }
                        }
                    }
                }
                break;

                //抬起手为止
                case fireState.OpenFire:
                {
                    //切换完毕了
                    if (stateInfo.IsName("shoot"))
                    {
                        //动画状态转移,同步
                        if (stateInfo.normalizedTime >= 0.5f)
                        {
                            animator.SetBool("handup", false);
                            animator.SetBool("shoot", true);

                            handup = false;
                            shoot  = true;

                            //netSyncController.SyncVariables();
                            //转移状态
                            currentState = fireState.KeepFire;
                        }
                    }
                }
                break;

                //抬手到播完再换手
                case fireState.KeepFire:
                {
                    if (stateInfo.IsName("keepShooting"))
                    {
                        //开火
                        if (fireFromLastTime > intervalBetweenShot)
                        {
                            if (target != null)
                            {
                                //开火
                                leftHandFireImpl(target.transform.Find("Head").position - new Vector3(0.0f, 0.5f, 0.0f));
                                netSyncController.RPC(this, "leftHandFireImpl", target.transform.Find("Head").position - new Vector3(0.0f, 0.5f, 0.0f));
                                fireFromLastTime = 0.0f;
                            }
                        }
                        else
                        {
                            fireFromLastTime += Time.deltaTime;
                        }
                        //直到开火完毕,抬起另一只手
                        if (animationCurrentTime >= 2.0f)
                        {
                            animator.SetBool("rightHandup", true);
                            animator.SetBool("shoot", false);

                            rightHandup = true;
                            shoot       = false;
                            //同步
                            //netSyncController.SyncVariables();
                            //下一个状态
                            currentState = fireState.RightFire;

                            animationCurrentTime = 0.0f;
                        }
                        else
                        {
                            animationCurrentTime += Time.deltaTime;
                        }
                    }
                }
                break;

                //另一只手抬起完成
                case fireState.RightFire:
                {
                    //切换完毕了
                    if (stateInfo.IsName("shootback"))
                    {
                        //开火
                        if (stateInfo.normalizedTime >= 0.5f)
                        {
                            animator.SetBool("rightHandup", false);
                            animator.SetBool("shootAgain", true);

                            rightHandup = false;
                            shootAgain  = true;
                            //同步
                            //netSyncController.SyncVariables();
                            //下一个状态
                            currentState = fireState.KeepFireAgain;
                        }
                    }
                }
                break;

                case fireState.KeepFireAgain:
                {
                    Debug.Log("fire");
                    if (stateInfo.IsName("keepShootingBack"))
                    {
                        if (fireFromLastTime > intervalBetweenShot)
                        {
                            if (target != null)
                            {
                                //开火
                                rightHandFireImpl(target.transform.Find("Head").position - new Vector3(0.0f, 0.5f, 0.0f));
                                netSyncController.RPC(this, "rightHandFireImpl", target.transform.Find("Head").position - new Vector3(0.0f, 0.5f, 0.0f));
                                fireFromLastTime = 0.0f;
                            }
                        }
                        else
                        {
                            fireFromLastTime += Time.deltaTime;
                        }
                        //直到开火完毕
                        if (animationCurrentTime >= 2.0f)
                        {
                            animator.SetBool("StopFire", true);
                            animator.SetBool("shootAgain", false);

                            stopFire = true;
                            shoot    = false;
                            //netSyncController.SyncVariables();

                            currentState = fireState.StopFire;

                            animationCurrentTime = 0.0f;
                        }
                        else
                        {
                            animationCurrentTime += Time.deltaTime;
                        }
                    }
                }
                break;

                case fireState.StopFire:
                {
                    Debug.Log("stop");
                    if (stateInfo.IsName("idle"))
                    {
                        Debug.Log("end of fire");
                        if (!beginTurnAround)
                        {
                            StartCoroutine(turnAround(target));
                            currentState = fireState.Idle;
                        }
                    }
                }
                break;

                case fireState.MissileLaunch:
                {
                    if (stateInfo.IsName("missileLaunch"))
                    {
                        if (stateInfo.normalizedTime >= 0.8f)
                        {
                            animator.SetBool("missileLaunch", false);

                            missilLaunch = false;
                            //同步
                            //netSyncController.SyncVariables();
                            if (target != null)
                            {
                                missileLaunchImpl(target.position);
                                netSyncController.RPC(this, "missileLaunchImpl", target.position);
                            }
                            currentState = fireState.StopFire;
                        }
                    }
                }
                break;

                default:
                    break;
                }
            }
            bool[] states =
            {
                shoot,
                handup,
                rightHandup,
                shootAgain,
                stopFire,
                missilLaunch,
                isWalking
            };
            netSyncController.RPC(this, "updateAState_Room2", states);
        }
예제 #14
0
        // Update is called once per frame
        void Update()
        {
            Debug.Log(state);
            switch (state)
            {
            case ElevatorState.Initing:
                if (GameMgr.instance && flag)
                {
                    foreach (var player in SceneNetManager.instance.list)
                    {
                        GameObject temp = player.Value;
                        temp.transform.localScale = new Vector3(3f, 3f, 3f);
                    }
                    flag = false;
                }
                break;

            case ElevatorState.Ready:
                if (change)
                {
                    //开始计时
                    s_time = Time.time;
                    c_time = s_time;
                    e_time = s_time + r_time;

                    bcollider.size = new Vector3(bcollider.size.x * 2f, bcollider.size.y, bcollider.size.z);

                    change = false;

                    GameObject.Find("BGM").GetComponent <AudioSource>().Play();
                }
                else
                {
                    c_time += Time.deltaTime;


                    //准备时间结束,切换到下一个场景
                    if (c_time >= e_time && GameMgr.instance.isMasterClient)
                    {
                        changeState();
                        m_controller.RPC(this, "changeState");
                    }
                }
                break;

            case ElevatorState.Start_Fighting:
                //开始计时
                s_time = Time.time;
                c_time = s_time;
                e_time = s_time + d_time;

                t_time = s_time + 5;

                if (GameMgr.instance.isMasterClient)
                {
                    changeState();
                    m_controller.RPC(this, "changeState");
                }
                break;

            case ElevatorState.Fighting:
                c_time += Time.deltaTime;

                if (!flag)
                {
                    StartCoroutine(coroutine1);
                    flag = true;
                }

                if (flag1 && c_time >= t_time)
                {
                    StartCoroutine(coroutine2);
                    flag1 = false;
                }

                if (c_time >= e_time && GameMgr.instance.isMasterClient)
                {
                    changeState();
                    m_controller.RPC(this, "changeState");
                }

                break;

            case ElevatorState.End:
                //Messenger.Broadcast(GameEvent.End);

                //开门
                GameObject.Find("DoorTrigger").SendMessage("openDoor", SendMessageOptions.DontRequireReceiver);
                if (GameObject.Find("f") != null)
                {
                    GameObject.Find("f").SetActive(false);
                }

                if (OperationTrident.Elevator.Wall.state)
                {
                    changeState();
                }

                break;

            case ElevatorState.Escape:
                StopCoroutine(coroutine1);
                StopCoroutine(coroutine2);
                break;
            }
        }