Ejemplo n.º 1
0
    private void OnTriggerExit(Collider other)
    {
        var delta = Time.fixedTime - _enterTime;

        if (delta > .2f)
        {
            var blockInteractor         = other.GetComponent <BlockInteractor>();
            var isSomeInteractionObject = blockInteractor != null && blockInteractor.IsActivated();
            if (isSomeInteractionObject)
            {
                var realCenterPoint = WorldPlane.Get().GetRealCenterPoint();

                var parentTransform = Camera.main.gameObject.transform.parent.gameObject.transform;

                parentTransform.position = new Vector3(
                    0,
                    parentTransform.position.y,
                    0
                    );
                var diff = Camera.main.transform.position - realCenterPoint;
                diff.y = 0;
                parentTransform.position -= diff;

                var currentPosition = parentTransform.position;
                parentTransform.position = new Vector3(currentPosition.x, .4f, currentPosition.z);

                GetComponent <AudioSource>().PlayOneShot(recenterSound);
            }
        }
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter(Collider other)
    {
        var farmSpawn = other.GetComponent <FarmSpawn>();

        if (farmSpawn && !farmSpawn.IsGrown())
        {
            farmSpawn.Grow();
            Destroy(gameObject);
        }
        else
        {
            var greenSpawn = other.GetComponent <GreensSpawn>();
            if (greenSpawn && !greenSpawn.IsGrown())
            {
                greenSpawn.Grow();
                Destroy(gameObject);
            }
            else
            {
                var block = other.GetComponent <Block>();
                if (block && block.IsSand())
                {
                    var grassBlockRoot = BlockFactory.Get().GrassBlock();
                    var grassBlock     = grassBlockRoot.GetComponentInChildren <Block>();
                    WorldPlane.Get().ReplaceBlock(block, grassBlock);

                    Destroy(gameObject);
                }
            }
        }
    }
Ejemplo n.º 3
0
 private void Start()
 {
     _sandSpreadController = SandSpreadController.Get();
     _worldPlane           = WorldPlane.Get();
     _block          = GetComponentInChildren <Block>();
     _featureToggles = FeatureToggles.Get();
 }
Ejemplo n.º 4
0
    protected void Start()
    {
        _originalLocalPosition = transform.localPosition;

        _originalScale       = transform.localScale * 1.5f;
        transform.localScale = _originalScale;

        _featureToggles = FeatureToggles.Get();
        _worldPlane     = WorldPlane.Get();

        if (isStartingInteractor)
        {
            GetComponentInParent <BlockInteractionPalette>().Select(this);
            Activate();
        }


        _ghost = Instantiate(BlockFactory.Get().interactableGhostTemplate);
        _ghost.SetActive(false);

        _nonInteractableGhost = Instantiate(BlockFactory.Get().nonInteractableGhostTemplate);
        _nonInteractableGhost.SetActive(false);

        _started = true;
    }
Ejemplo n.º 5
0
        public void Use(Block block)
        {
            var water      = Instantiate(waterBlockTemplate);
            var waterBlock = water.GetComponentInChildren <Block>();

            WorldPlane.Get().AddBlockOnTopOf(waterBlock, water, block);
            waterBlock.ShortFreeze();
        }
Ejemplo n.º 6
0
    public static void Highlight(List <Block> blocks)
    {
        var worldPlane = WorldPlane.Get();

        foreach (var block in blocks)
        {
            worldPlane.RemoveAndDestroyBlock(block);
        }
    }
Ejemplo n.º 7
0
    void Start()
    {
        _worldPlane      = WorldPlane.Get();
        _block           = GetComponent <BlockRelative>().block;
        _audioSource     = GetComponent <AudioSource>();
        _cityWoodcutters = CityWoodcutters.Get();

        var rotation = new Vector3(0, Random.value * 360, 0);

        var woodcutterTemplate = woodcutterTemplates[Random.Range(0, woodcutterTemplates.Length)];
        var woodcutter         = Instantiate(woodcutterTemplate);

        woodcutter.transform.SetParent(transform, false);
        woodcutter.transform.Rotate(rotation);
    }
Ejemplo n.º 8
0
 void Start()
 {
     _worldPlane = WorldPlane.Get();
     _block      = GetComponent <BlockRelative>().block;
 }
Ejemplo n.º 9
0
 private void Start()
 {
     _worldPlane = WorldPlane.Get();
 }
Ejemplo n.º 10
0
 void Start()
 {
     _worldPlane     = WorldPlane.Get();
     _workQueue      = WorkQueue.Get();
     _featureToggles = FeatureToggles.Get();
 }
Ejemplo n.º 11
0
 void Start()
 {
     _worldPlane = WorldPlane.Get();
     _workQueue  = WorkQueue.Get();
 }
Ejemplo n.º 12
0
 void Start()
 {
     _rigidbody  = GetComponent <Rigidbody>();
     _worldPlane = WorldPlane.Get();
 }
Ejemplo n.º 13
0
 private void Awake() // FarmController is only created during the game, and is used right after being created. Therefore we must store static instances in the Awake method instead of Start.
 {
     _worldPlane     = WorldPlane.Get();
     _featureToggles = FeatureToggles.Get();
 }