예제 #1
0
    public void AddPlaceableData(PlaceableData placeableData)
    {
        placeableData.ID = totalCreatedObjects;

        Placeables.Add(placeableData);
        totalCreatedObjects++;
    }
예제 #2
0
    public Placeable CreateNewPlaceable(PlaceableData data, GardenNode pos)
    {
        Placeable newplace = null;

        if (data)
        {
            GameObject pref = null;
            switch (data.placeableType)
            {
            case PlaceableData.ePlaceableType.DECORATION:
                pref = decorationPlaceablePrefab;
                break;

            case PlaceableData.ePlaceableType.HOME:
                pref = homePlaceablePrefab;
                break;

            case PlaceableData.ePlaceableType.GENERATOR:
                pref = generatorPlaceablePrefab;
                break;
            }

            newplace = Instantiate(pref, pos.transform.position, Quaternion.Euler(0, Random.value * (360f), 0), WorldManager.Instance.WorldParent.transform).GetComponent <Placeable>();

            if (newplace)
            {
                newplace.placeableData = data;
                newplace.nodeOccupied  = pos;
                pos.occupied           = newplace;
            }
        }
        return(newplace);
    }
예제 #3
0
 private bool isKey(PlaceableData pData)
 {
     if (pData.typeStr == "Key")
     {
         return(true);
     }
     return(false);
 }
예제 #4
0
    public PlaceableData GetPlaceableData(string PlaceableName)
    {
        PlaceableData p = placeableDatas.Where(e => e.plotName.Contains(PlaceableName)).FirstOrDefault();

        if (!p)
        {
            Debug.Log("Could not find Placeable with name:" + PlaceableName);
        }
        return(p);
    }
예제 #5
0
        public void SerializerConfig_PlaceableFileData_ShouldBeEqual()
        {
            PlaceableData data = new PlaceableData
            {
                AutoRemoveKey = true,
                Comment       = "it's a comment",
                Description   = "it's a description",
                IsKeyRequired = true,
                IsLocked      = true,
                IsPlot        = true,
                IsStatic      = true,
                IsUseable     = true,
                KeyTag        = "key tag 1",
                Name          = "it's a name",
                OnAttacked    = "onattacked script",
                OnClosed      = "onclosed script",
                OnDamaged     = "ondamaged script",
                OnDeath       = "ondeath script",
                OnDisturbed   = "ondisturbed script",
                OnHeartbeat   = "onheartbeat script",
                OnLocked      = "onlocked script",
                OnOpened      = "onopened script",
                OnUnlocked    = "onunlocked script",
                OnUsed        = "onused script",
                Resref        = "it's a resref",
                Tag           = "it's a tag"
            };
            PlaceableData result;

            using (MemoryStream stream = new MemoryStream())
            {
                Serializer.Serialize(stream, data);
                stream.Position = 0;

                result = Serializer.Deserialize <PlaceableData>(stream);
            }

            Assert.IsTrue(_compareLogic.Compare(data, result).AreEqual);
        }
예제 #6
0
 /// <inheritdoc />
 public void AddOrUpdateDirty(PlaceableData data)
 {
     DirtyPlaceables.Remove(data.GlobalID);
     DirtyPlaceables.Add(data.GlobalID, data, ActionType.AddOrChanged);
 }
예제 #7
0
 /// <inheritdoc />
 public void MarkForDeletion(PlaceableData data)
 {
     DirtyPlaceables.Remove(data.GlobalID);
     DirtyPlaceables.Add(data.GlobalID, data, ActionType.Delete);
 }
예제 #8
0
        public void PlaceableData_OnInstantiate_ShouldCreateGlobalID()
        {
            PlaceableData data = new PlaceableData();

            Assert.IsTrue(!string.IsNullOrWhiteSpace(data.GlobalID));
        }
예제 #9
0
        public void PlaceableData_OnInstantiate_ShouldCreateLocalVariables()
        {
            PlaceableData data = new PlaceableData();

            Assert.IsNotNull(data.LocalVariables);
        }
예제 #10
0
 public void RemovePlaceableData(PlaceableData placeableData)
 {
     Placeables.Remove(placeableData);
 }
예제 #11
0
 public void SetData(PlaceableData placeableData)
 {
     this._placeableData = placeableData;
 }
예제 #12
0
 public void SetData(PlaceableData keyData)
 {
     this.pData = keyData;
 }
예제 #13
0
 public void RemoveSeed(PlaceableData newPlot)
 {
     seeds[newPlot]--;
 }
예제 #14
0
 public void AddUnlockedPlot(PlaceableData newPlot)
 {
     seeds[newPlot]++;
 }