예제 #1
0
    public override void Tick()
    {
        base.Tick();
        SM.SceneRoom room = SM.RandomRoomLevel.Singleton.LookupRoom(RoomId);
        if (null != room)
        {
            bool tmpIsEnable = true;
            foreach (var hpData in mHPEventDataList)
            {
                mCurActor = GetEventActor(hpData.mNpcId, (ENActorType)hpData.mNpcType);
                float tmpCurActorHp = 0;
                float tmpCurMaxHp   = 1000;
                if (mCurActor != null)
                {
                    tmpCurActorHp = mCurActor.HP;
                    tmpCurMaxHp   = mCurActor.MaxHP;
                }
                else
                {
                    SM.ActorRefresh actorRefuresh = room.GetActorRefreshById(hpData.mNpcId);
                    if (actorRefuresh != null)
                    {
                        tmpIsEnable = false;
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                switch (hpData.mCompareType)
                {
                case ENCompareType.enValueLower:
                    tmpIsEnable = tmpCurActorHp < hpData.mHPValue;
                    break;

                case ENCompareType.enPercentLower:
                    tmpIsEnable = (tmpCurActorHp / tmpCurMaxHp) * 100 < hpData.mHPValue;
                    break;
//                     case ENCompareType.enValueGreater:
//                         IsEnabled = tmpCurActorHp > hpData.mHPValue;
//                         break;

//                     case ENCompareType.enPercentGreater:
//                         IsEnabled = (tmpCurActorHp / mCurActor.MaxHP) > hpData.mHPValue;
//                         break;
                default:
                    break;
                }
            }
            IsEnabled = tmpIsEnable;
        }
    }
예제 #2
0
    public override bool Execute()
    {
//        if (IsEnabled)
        {
            //刷新怪物
            //SM.ActorRefresh.RefreshCondDict.Add(mConditionID, true);
            SM.SceneRoom room = SM.RandomRoomLevel.Singleton.LookupRoom(RoomGUID);
            foreach (var refreshData in mRefreshMosterDataList)
            {
                SM.ActorRefresh actorRefuresh = room.GetActorRefreshById(refreshData.mMonsterId);
                if (actorRefuresh == null)
                {
                    continue;
                }
                actorRefuresh.SpawnMe();

                Actor sourceActor = null;
                switch (refreshData.mSwapPosType)
                {
                case ENSwapPosType.PlayerPositionOffset:
                    sourceActor = ActorManager.Singleton.MainActor;
                    break;

                case ENSwapPosType.triggerPositionOffset:
                    sourceActor = BattleArena.Singleton.m_blackBoard.GetBlackBoardActor("CurActor");
                    break;

                case ENSwapPosType.TargetActorOfTriggeringActor:
                    sourceActor = BattleArena.Singleton.m_blackBoard.GetBlackBoardActor("TargetActor");
                    break;

                case ENSwapPosType.CustomBlackboardStr:
                    sourceActor = BattleArena.Singleton.m_blackBoard.GetBlackBoardActor(refreshData.mBlackBoardActorStr);
                    break;

                case ENSwapPosType.ObjectPositionOffset:
                    sourceActor = room.GetMonsterByID(refreshData.mSwapActorId);
                    break;

                default:
                    break;
                }
                //Vector3 basePos = sourceActor.RealPos;// GetSwapBasePos(refreshData.mSwapPosType, refreshData.mSwapActorId, refreshData.mBlackBoardActorStr);
                if (sourceActor != null)
                {
                    Vector3 movePos = Vector3.zero;
                    movePos = sourceActor.RealPos + new Vector3(refreshData.mSwapPosX, 0, refreshData.mSwapPosZ);
                    actorRefuresh.m_curMonsterObj.ForceMoveToPosition(movePos);
                }
            }
        }
        return(base.Execute());
    }
예제 #3
0
        public void BuildRoomData(int levelId)
        {
            // generate monster data
            m_parentObj = GameObject.Instantiate(CurRoomInfo.m_roomData) as GameObject;
            m_parentObj.transform.localPosition = Vector3.zero;
            m_parentObj.transform.position      = CurRoomInfo.m_roomObj.transform.position;
            RoomDataCfg dataCfg = m_parentObj.GetComponent <RoomDataCfg>();

            for (int i = 1; i <= dataCfg.MonsterCount; i++)
            {
                string str;
                if (i < 10)
                {
                    str = string.Format("monster0{0}", i);
                }
                else
                {
                    str = string.Format("monster{0}", i);
                }
                GameObject  obj = m_parentObj.transform.Find(str).gameObject;
                RoomElement ele = obj.GetComponent <RoomElement>();
                ele.MonsterData              = new SM.MonsterRoomData();
                ele.MonsterData.monsterId    = i;
                ele.MonsterData.monsterObjId = ele.ObjSettingID;
                if (ele._PatrolList.Count <= 0)
                {
                    ele._PatrolList = dataCfg._GlobalPatrolList;
                }
                ActorRefresh actor = new ActorRefresh(obj.transform, this);
                m_actorRefreshList.Add(actor);
            }
            //出生点
            if (null == CurRoomInfo.m_parent)
            {
                Transform posTrans = m_parentObj.transform.Find("charPosition");
                if (null == posTrans)
                {
                    string     objName  = "charposition";
                    GameObject childObj = new GameObject(objName);
                    childObj.transform.parent        = m_parentObj.transform;
                    childObj.transform.localPosition = new Vector3(CurRoomInfo.m_charPosition.x * blockWidth, 0f, CurRoomInfo.m_charPosition.z * blockHeight);
                    CurRoomInfo.CharPosition         = new Vector3(childObj.transform.position.x, 0.15f, childObj.transform.position.z);;
                    CurRoomInfo.CharPosTransform     = childObj.transform;
                }
                else
                {
                    CurRoomInfo.CharPosition     = new Vector3(posTrans.position.x, 0.15f, posTrans.position.z);;
                    CurRoomInfo.CharPosTransform = posTrans;
                }
            }
            //激活检测开始战斗的刚体
            if (CurRoomInfo.m_monsterDataList.Count > 0)
            {
                Transform starBattleColliderTans = CurRoomInfo.m_roomObj.transform.Find("activeArea");
                if (starBattleColliderTans != null)
                {
                    for (int i = 0; i < starBattleColliderTans.transform.childCount; i++)
                    {
                        Transform       child           = starBattleColliderTans.transform.GetChild(i);
                        TriggerCallback triggerCallback = child.gameObject.AddComponent <TriggerCallback>();
                        triggerCallback.EnterCallback = OnCheckEnterCallBack;
                    }
                }
            }
        }
예제 #4
0
    public override void Tick()
    {
        base.Tick();
        SM.SceneRoom room = SM.RandomRoomLevel.Singleton.LookupRoom(RoomId);
        if (null != room)
        {
            bool tmpIsEnabled = true;
            foreach (var mosterData in mDeadMonsterList)
            {
//                 if (!room.IsMonsterDead(mosterData.actorId))
//                 {
//                     return;
//                 }
                Actor tmpActor = null;// room.GetMonsterByID(mosterData.actorId);
                switch (mosterData.actorType)
                {
                case ENDeadActorType.enMainPlayer:
                    tmpActor = ActorManager.Singleton.MainActor;
                    break;

                case ENDeadActorType.enSpicalNpc:
                    tmpActor = room.GetMonster(mosterData.actorId);
                    break;

                default:
                    break;
                }

                bool tmpActorIsDead = false;
                if (tmpActor == null)
                {
                    SM.ActorRefresh actorRefuresh = room.GetActorRefreshById(mosterData.actorId);
                    if (actorRefuresh == null)
                    {
                        tmpActorIsDead = true;
                    }
                }
                else if (tmpActor.IsRealDead)
                {
                    tmpActorIsDead = true;
                }
                if (tmpActorIsDead)
                {
                    if (!mDeadOrderList.Contains(mosterData.actorId))
                    {
                        mDeadOrderList.Add(mosterData.actorId);
                    }
                }
                else
                {
                    tmpIsEnabled = false;
                    break;
                }
            }
            if (tmpIsEnabled)
            {
                SM.BlackBoardActorData tmpActorData = new SM.BlackBoardActorData();
                tmpActorData.roomID          = RoomId;
                tmpActorData.actorID         = mDeadOrderList[mDeadOrderList.Count - 1];
                tmpActorData.mBlackActorType = LevelBlackboard.BlackActorType.enNPC;
                mCurActor = tmpActorData;// mDeadOrderList[mDeadOrderList.Count - 1];
                IsEnabled = true;
            }
        }
    }