Пример #1
0
    private void CreateTrap(IEntityDataStruct entityDataStruct)
    {
        SMsgPropCreateEntity_SC_Trap sMsgPropCreateEntity_SC_Trap = (SMsgPropCreateEntity_SC_Trap)entityDataStruct;
        string trapName   = "bushoujia";
        var    trapPrefab = this.FindByName(trapName);

        //var trapPrefab = EctypeConfigManager.Instance.TrapConfigList[sMsgPropCreateEntity_SC_Trap.BaseValue.OBJECT_FIELD_ENTRY_ID]._TrapPrefab;

        var pos = Vector3.zero;

        pos = pos.GetFromServer(sMsgPropCreateEntity_SC_Trap.TrapX, sMsgPropCreateEntity_SC_Trap.TrapY);
        //var pos = new Vector3(120, 0, -100);
        ////TraceUtil.Log("创建TrapID=====>>>>" + sMsgPropCreateEntity_SC_Trap.SMsg_Header.uidEntity);

        var trap          = (GameObject)GameObject.Instantiate(trapPrefab, pos, Quaternion.identity);
        var trapBehaviour = trap.GetComponent <TrapBehaviour>();

        trapBehaviour.TrapDataModel = sMsgPropCreateEntity_SC_Trap;

        EntityModel trapDataModel = new EntityModel();

        trapDataModel.GO               = trap;
        trapDataModel.Behaviour        = trapBehaviour;
        trapDataModel.EntityDataStruct = sMsgPropCreateEntity_SC_Trap;

        TrapManager.GetInstance();
        EntityController.Instance.RegisteEntity(sMsgPropCreateEntity_SC_Trap.SMsg_Header.uidEntity, trapDataModel);
    }