Exemple #1
0
    public void Build(int id, bool playEffects = true)
    {
        Constructible selectedObject = builder.Build(id, objectsToConstruct, selectedCell, playEffects);

        if (selectedCell.CompareTag("RoomCell"))
        {
            roomCells.Remove(selectedCell.gameObject);
        }
        selectedCell.AddObject(selectedObject);
    }
    public void Construct(int id)
    {
        if (selectedCell.transform.childCount >= 1)
        {
            return;
        }
        Constructible selectedObject = builder.Build(id, objectsToConstruct, selectedCell);

        selectedCell.AddObject(selectedObject);
        Player.instance.ChangeBalance(-objectsToConstruct[id].description.buyPrice);
        Abort();
        ConstructOFF();
    }
Exemple #3
0
    public Constructible Build(int id, Constructible[] objectsArray, Cell cell, bool playEffects = true)
    {
        Constructible selectedObject = objectsArray[id];

        if (selectedObject.gameObject.tag == "Room")
        {
            EventManager.TriggerEvent("OnBuildRoom", 1);
            if (onRoomBuild != null)
            {
                if (playEffects)
                {
                    ParticleSystem particle = Instantiate(onRoomBuild, cell.transform.position, Quaternion.identity);
                    particle.gameObject.SetActive(true);
                    particle.Play();
                }
                PlayGameScript.UnlockAchievement(GPGSIds.achievement_builder);
            }
        }
        else
        {
            EventManager.TriggerEvent("OnBuildObject", 1);
            PlayGameScript.IncrementAchievement(GPGSIds.achievement_a_new_beginning, 1);
            if (onObjectBuild != null)
            {
                if (playEffects)
                {
                    ParticleSystem particle = Instantiate(onObjectBuild, cell.transform.position, Quaternion.identity);
                    particle.gameObject.SetActive(true);
                    particle.Play();
                }
            }
        }
        if (playEffects)
        {
            GameController.instance.player.GainExperience(100 * GameController.instance.roomOverseer.rooms.Count);
            GameController.instance.player.finances.AddToActiveExpences(selectedObject.description.buyPrice);
            GameController.instance.audio.MakeSound(onBuildSounds[Random.Range(0, onBuildSounds.Length)]);
        }
        Constructible toReturn = Instantiate(selectedObject, new Vector3(cell.transform.position.x, cell.transform.position.y, cell.transform.position.z - 0.5f), cell.transform.rotation);

        StartCoroutine(Camera.main.gameObject.GetComponent <CameraController>().FocusCamera(toReturn.transform.position));

        return(toReturn);
    }
Exemple #4
0
    public void AddObject(Constructible obj)
    {
        room.info.objectsInRoom.Add(obj);
        if (tag == "RoomCell")
        {
            obj.transform.parent = GameController.instance.roomOverseer.factory.transform;
            obj.adjacent.UpdateConnections(this);
            room.info.cells.Remove(this);

            Destroy(gameObject);
        }
        else
        {
            obj.transform.parent = transform;
            isOccupied           = true;
            UpdateColor();
            //check if object has adjacent sscript attached
            if (obj.adjacent != null)
            {
                obj.adjacent.UpdateConnections(this);
            }
        }
    }
Exemple #5
0
    public Constructible Build(int id, Constructible[] objectsArray, Cell cell)
    {
        Constructible selectedObject = objectsArray[id];

        return(Instantiate(selectedObject, new Vector3(cell.transform.position.x, cell.transform.position.y, cell.transform.position.z - 0.5f), cell.transform.rotation));
    }
 public void Call()
 {
     _constructible = new Constructible();
 }
 public void Call()
 {
     _constructible = Activator.CreateInstance<Constructible>();
 }
Exemple #8
0
 public void Call()
 {
     _constructible = (Constructible) Activator.CreateInstance(typeof (Constructible));
 }
Exemple #9
0
 private void Start()
 {
     constructible = GetComponent <Constructible>();
 }