Esempio n. 1
0
 public Doodad(Doodad d)
 {
     id = d.id;
     position = d.position;
     up = d.up;
     activationCost = d.activationCost;
     targetBehavior = d.targetBehavior;
     targetObject = d.targetObject;
     expectBehavior = d.expectBehavior;
     fixedPosition = d.fixedPosition;
     type = d.type;
     ability = d.ability;
     behaviors = new List<Behavior>();
     foreach (Behavior b in d.behaviors)
     {
         behaviors.Add(new Behavior(b));
     }
 }
Esempio n. 2
0
    protected override void OnPEInstantiate(uLink.NetworkMessageInfo info)
    {
        objType = (DoodadType)info.networkView.initialData.Read <int>();
        int playerId = info.networkView.initialData.Read <int>();

        _teamId      = info.networkView.initialData.Read <int>();
        _assetId     = info.networkView.initialData.Read <int>();
        _id          = info.networkView.initialData.Read <int>();
        _protoTypeId = info.networkView.initialData.Read <int>();
        Vector3         scale  = info.networkView.initialData.Read <Vector3>();
        string          param  = info.networkView.initialData.Read <string>();
        SceneDoodadDesc doodad = null;

        _pos = transform.position;
        rot  = transform.rotation;

        if (null == ParentTrans)
        {
            ParentTrans = new GameObject("DoodadNetworkMgr").transform;
        }

        transform.parent = ParentTrans;

        if (PeGameMgr.IsMultiStory)
        {
            doodad = StoryDoodadMap.Get(_assetId);
        }

        if (objType == DoodadType.DoodadType_Drop || objType == DoodadType.DoodadType_Dead)
        {
            itemBox = ItemBoxMgr.Instance.AddItemMultiPlay(OwnerView.viewID.id, playerId, _pos, this);
        }
        else if (objType == DoodadType.DoodadType_SceneBox)
        {
            if (doodad != null)
            {
                entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id);
            }
            else
            {
                entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id);
            }

            if (entity != null)
            {
                WareHouseObject script = entity.gameObject.GetComponent <WareHouseObject>();
                if (script != null)
                {
                    script._id = _assetId;
                }
            }
        }
        else if (objType == DoodadType.DoodadType_SceneItem)
        {
            string[] str = param.Split('|');
            if (str.Length != 2)
            {
                return;
            }

            _sceneItemName = str[1];
            if (_sceneItemName == "ash_box")
            {
                itemBox = ItemBoxMgr.Instance.AddItemMultiPlay(OwnerView.viewID.id, _assetId, _pos, this);
            }
            else if (_sceneItemName == "ash_ball")
            {
                itemBox = ItemBoxMgr.Instance.AddItemMultiPlay(OwnerView.viewID.id, _assetId, _pos, this);
            }
            else
            {
                RequestItemList();
            }
        }
        else if (objType == DoodadType.DoodadType_Repair)
        {
            if (doodad != null)
            {
                entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id);
            }
            else
            {
                entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id);
            }
        }
        else if (objType == DoodadType.DoodadType_Power)
        {
            if (doodad != null)
            {
                entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id);
            }
            else
            {
                entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id);
            }
        }
        else if (objType == DoodadType.DoodadType_RandomBuilding ||
                 objType == DoodadType.DoodadType_RandomBuilding_Repair ||
                 objType == DoodadType.DoodadType_RandomBuilding_Power)
        {
            ExtractParam(param, out townId, out _campId, out _damageId, out _dPlayerId);
            if (doodad != null)
            {
                entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id);
            }
            else
            {
                entity = DoodadEntityCreator.CreateNetRandTerDoodad(Id, _protoTypeId, _pos, scale, rot, townId, _campId, _damageId, _dPlayerId);
            }
        }
        else
        {
            if (doodad != null)
            {
                entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id);
            }
            else
            {
                entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id);
            }
        }

        if (entity != null)
        {
            OnSpawned(entity.gameObject);
        }

        mapObjNetworkMgr.Add(this);
        gameObject.name = string.Format("Mapobj assetId:{0}, protoTypeId:{1}, objType:{2}, entityId:{3}", _assetId, _protoTypeId, objType, _id);
    }
Esempio n. 3
0
 public Doodad()
 {
     id = IDControl.GetID();
     behaviors = new List<Behavior>();
     type = DoodadType.PowerOrb;
     _name = "Doodad_" + id;
 }