コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (isBombBase)
        {
            if (startTime == 0f)
            {
                startTime = Time.time;
            }
            if (move == transform.position && Time.time - startTime >= 1f)
            {
                Thanos.AudioManager.Instance.StopBgAudio();
                AudioSource soul = null;
                if (move == posDest)
                {
                    /*
                     * Animator ani = this.gameObject.GetComponent<Animator>();
                     * ani.enabled = true;
                     */
                    //soul = HolyTech.AudioManager.Instance.PlayEffectAudio(Resources.Load(AudioDefine.PATH_GAME_OVER_FAILE) as AudioClip);

                    ResourceItem clipUnit = ResourcesManager.Instance.loadImmediate(AudioDefine.PATH_GAME_OVER_FAILE, ResourceType.ASSET);
                    AudioClip    clip     = clipUnit.Asset as AudioClip;

                    soul = Thanos.AudioManager.Instance.PlayEffectAudio(clip);
                }
                else
                {
                    //soul = HolyTech.AudioManager.Instance.PlayEffectAudio(Resources.Load(AudioDefine.PATH_GAME_OVER_VICTORY) as AudioClip);

                    ResourceItem clipUnit = ResourcesManager.Instance.loadImmediate(AudioDefine.PATH_GAME_OVER_VICTORY, ResourceType.ASSET);
                    AudioClip    clip     = clipUnit.Asset as AudioClip;

                    soul = Thanos.AudioManager.Instance.PlayEffectAudio(clip);
                }
                isBombBase = false;
                if (StartEffectEvent != null)
                {
                    StartEffectEvent(4f);
                }

                if (Entity != null)
                {
                    GameMethod.SetLoadJianTaBaoZha(Entity, false);

                    Entity.OnEnterDead();
                }

                return;
            }
            float time = Vector3.Distance(Camera.main.transform.position, move) / 60f;
            Camera.main.transform.position = Vector3.SmoothDamp(Camera.main.transform.position, move, ref res, time);

            GameMethod.GetMainCamera.RefreshFrustumPlanes();
            //Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, move,Time.deltaTime * time);
        }
    }
コード例 #2
0
        // Entity死亡
        public virtual void OnEnterDead() //实体进入死亡状态   如果是本地玩家,则执行Iselfplayer中的OnEnterDead()
        {
            //目标死亡主角相关处理
            Iselfplayer player = PlayerManager.Instance.LocalPlayer;

            if (player != null && player.SyncLockTarget != null && GameObjGUID == player.SyncLockTarget.GameObjGUID)
            {
                player.SetSyncLockTarget(null); //锁定目标为空
            }

            //播放死亡声音
            Vector3 pos = PlayerManager.Instance.LocalPlayer.RealEntity.transform.position;

            if (GetDistanceToPos(pos) <= 30)//获取某个位置的距离
            {
                this.PlayDeadSound();
            }

            //建筑物更换模型和表现特效
            if (this.entityType == EntityType.Building && this.NPCCateChild != ENPCCateChild.eNPCChild_BUILD_Base)
            {
                if (!EntityManager.GetHomeBaseList().Contains(this))
                {
                    GameMethod.SetLoadJianTaBaoZha(this);                         //爆炸特效
                    int ret = EntityManager.HandleDelectEntity(this.GameObjGUID); //删除实体
                    if (ret != 0)
                    {
                        Debug.LogError("OnEnterDead HandleDelectEntity:" + GameObjGUID + "failed");
                    }
                }
                //广播建筑销毁消息,移除警告等
                EventCenter.Broadcast <Ientity>((Int32)GameEventEnum.GameEvent_NotifyBuildingDes, this);
                return;
            }

            //非建筑物播死亡动画和清理血条寻路代理条等状态
            this.DoEntityDead();
            RealEntity.PlayerDeadAnimation();
        }