void Place()
    {
        if (Cursor.CheckPlacement() == false)
        {
            return;
        }
        PixelCrushers.MessageSystem.SendMessage(this, "PropPlaced", CurrentItem.Name);

        GameObject spawnObj = Instantiate(ReferencedObject, Cursor.transform.position, Cursor.transform.rotation);

        spawnObj.transform.position = Cursor.transform.position;
        spawnObj.transform.rotation = Cursor.transform.rotation;
        spawnObj.GetComponent <ObjectPosition>().AdjustPositions();
        if (spawnObj.GetComponent <OccupySpace>() != null)
        {
            if (spawnObj.GetComponent <OccupySpace>().isActiveAndEnabled)
            {
                spawnObj.GetComponent <OccupySpace>().OccupyTiles();
            }
        }
        PlayerInventory.RemoveItem(CurrentItem);
        if (spawnObj.GetComponent <Hut>() != null)
        {
            Hut hut = spawnObj.GetComponent <Hut>();
            hut.Init();
            BlossomManager.Instance.AddHut(hut.Name);
        }

        if (spawnObj.GetComponent <PixelCrushers.SpawnedObject>() != null)
        {
            PixelCrushers.SpawnedObject spawnedObject = spawnObj.GetComponent <PixelCrushers.SpawnedObject>();
            spawnedObject.key += " PlayerPlaced";
        }
        AstarPath.active.Scan();
    }
Пример #2
0
    public override void Init()
    {
        hut     = GetComponent <Hut>();
        storage = GetComponent <Storage>();
        sink    = GetComponent <ResourceSink>();

        hut.health             = storage.health = sink.health = health;
        hut.owner              = storage.owner = sink.owner = owner;
        hut.refreshPerformTime = storage.refreshPerformTime = sink.refreshPerformTime = refreshPerformTime;

        hut.Init();

        // Spawn in starting units
        for (int i = 0; i < 5; i++)
        {
            hut.Perform();
        }

        StartTask();
    }