示例#1
0
 void OnTriggerStay2D(Collider2D col)
 {
     if (col.gameObject.layer == LayerMask.NameToLayer(Layers.PlSpot))
     {
         var fireplace = col.gameObject.GetComponent <FirePlace>();
         if (fireplace != null && fireplace.IsHeatSource && fireplace.IsLit == false)
         {
             var stove = fireplace as Stove;
             if (stove != null)
             {
                 if (stove.AllChimneysAreClosed())
                 {
                     _motor.BeginLighting(fireplace);
                 }
             }
         }
         else if (fireplace.IsHeatSource && _fireplace == null)
         {
             _fireplace     = fireplace;
             SatAtFireplace = true;
             if (_fireplace.transform.position.x > transform.position.x)
             {
                 _motor.SetDirectionFacing(DirectionFacing.Right);
             }
             else
             {
                 _motor.SetDirectionFacing(DirectionFacing.Left);
             }
         }
     }
 }
示例#2
0
 void Update()
 {
     if (_fireplace != null && _fireplace.IsLit == false)
     {
         _fireplace     = null;
         SatAtFireplace = false;
     }
 }
示例#3
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (ShouldTrigger(col))
     {
         if (col.GetComponent <FirePlace>().IsAccessible)
         {
             _fireplace = col.GetComponent <FirePlace>();
             MovementState.SetPivotCollider(col, ColliderPoint.Centre, ColliderPoint.Centre);
             MovementState.MovementOverridden = true;
             _isFireplaceActive = true;
         }
     }
 }
示例#4
0
        public bool SwitchFireplace(Vector2 direction)
        {
            FirePlace switchedFireplace = GetSwitchedFireplace(_fireplace, direction);

            if (switchedFireplace != null)
            {
                _fireplace.PlLeave();
                _fireplace = switchedFireplace;
                MoveToFireplace();
                return(true);
            }
            return(false);
        }
示例#5
0
        public void LeaveSpot()
        {
            _movement.IgnorePlatforms(false);
            _renderer.enabled = true;
            _particles.Play();
            _noGravity = false;

            if (IsScouting == false)
            {
                _fireplace.PlLeave();
            }

            _fireplaceWasLit = false;
            _fireplace       = null;
        }
示例#6
0
        private FirePlace GetSwitchedFireplace(FirePlace currentFireplace, Vector2 direction)
        {
            foreach (FirePlace fireplace in currentFireplace.GetConnectedFireplaces())
            {
                if (Vector2.Angle(direction, fireplace.transform.position - transform.position) < 10f)
                {
                    FirePlace switchedFireplace = fireplace is Pipe && fireplace.IsAccessible == false
                                                ? fireplace.GetConnectedFireplaces().First(fp => fp != currentFireplace)
                                                : switchedFireplace = fireplace;

                    if (switchedFireplace is Pipe && fireplace.IsAccessible == false)
                    {
                        switchedFireplace = switchedFireplace.GetConnectedFireplaces().First(fp => fp != fireplace);
                    }

                    return(switchedFireplace);
                }
            }
            return(null);
        }
    public static Tavern GenerateTavern(GenerationRandom genRan, Tavern tavern, out BuildingVoxels vox, BuildingGenerationPlan plan)
    {
        vox = new BuildingVoxels(tavern.Width, World.ChunkHeight, tavern.Height);
        BuildingGenerator.BuildBoundingWallRect(vox, tavern.Width, tavern.Height, 6, Voxel.wood);
        BuildingGenerator.ChooseEntrancePoint(genRan, vox, tavern, plan);

        Tile[,] tileMap = new Tile[tavern.Width, tavern.Height];

        BuildingGenerator.SetTiles(tileMap, 0, 0, tavern.Width, tavern.Height, Tile.WOOD_FLOOR);
        tavern.SetBuilding(tileMap);
        BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: true);
        BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: true);
        BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: true);
        BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: false);
        BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: false);
        FirePlace fp = new FirePlace();

        BuildingGenerator.PlaceObjectAgainstWall(genRan, fp, 0, vox, tavern, 0, true, 4, true, 20);
        BuildingGenerator.PlaceObjectAgainstWall(genRan, new WallTorch(), 1.5f, vox, tavern, 0, true, 2);
        NPCJob[] jobs = new NPCJob[] { new NPCJobMerchant(tavern, "Tavern Keep"), new NPCJobMerchant(tavern, "Tavern Keep") };
        tavern.SetWorkBuildingData(new WorkBuildingData(jobs));
        BuildingGenerator.AddRoof(genRan, vox, tavern, Voxel.thatch);
        return(tavern);
    }
示例#8
0
 public void LeaveFireplace(FirePlace fireplace)
 {
     BaseStability -= fireplace.HeatRayDistance * ConstantVariables.StabilityHeatRangeModifier;
     BaseIntensity -= fireplace.HeatIntensity;
     ResetVariables();
 }
    void Update()
    {
        AudioSource fire = FirePlace.GetComponent <AudioSource>();

        ChsdCell = InventoryScript.ChsdCell;
        if (Fire == true && int.Parse(OvenInv[1, 1]) != 0)
        {
            Timer += Time.timeScale / 10;
            if (fire.isPlaying == false)
            {
                fire.Play();
            }
        }
        else
        {
            fire.Stop();
            Timer = 0;
            Fire  = false;
        }
        if (Timer > CookingTime)
        {
            for (int i = 0; i < Items.Length; i++)
            {
                if (OvenInv[0, 6] == Items[i])
                {
                    for (int k = 0; k < 7; k++)
                    {
                        OvenInv[2, k] = Food[i].GetComponent <ItemScript>().Item[0, k];
                        if (k != 1)
                        {
                            OvenInv[0, k] = null;
                        }
                        else
                        {
                            OvenInv[0, k] = "" + 0;
                        }
                    }
                }
            }
            Timer         = 0;
            Fire          = false;
            OvenInv[1, 1] = "" + (int.Parse(OvenInv[1, 1]) - 1);
        }
        if (Active == true)
        {
            if (OvenInv[0, 3] != null)
            {
                if (int.Parse(OvenInv[0, 1]) != 0)
                {
                    ItemC.GetComponentInChildren <RawImage>().texture = InventoryScript.ICONS[int.Parse(OvenInv[0, 3])];
                }
                else
                {
                    ItemC.GetComponentInChildren <RawImage>().texture = null;
                }
            }
            else
            {
                ItemC.GetComponentInChildren <RawImage>().texture = null;
            }
            if (OvenInv[1, 3] != null)
            {
                if (int.Parse(OvenInv[1, 1]) != 0)
                {
                    FuelC.GetComponentInChildren <RawImage>().texture = InventoryScript.ICONS[int.Parse(OvenInv[1, 3])];
                }
                else
                {
                    FuelC.GetComponentInChildren <RawImage>().texture = null;
                }
            }
            else
            {
                FuelC.GetComponentInChildren <RawImage>().texture = null;
            }
            if (OvenInv[2, 3] != null)
            {
                if (int.Parse(OvenInv[2, 1]) != 0)
                {
                    FoodC.GetComponentInChildren <RawImage>().texture = InventoryScript.ICONS[int.Parse(OvenInv[2, 3])];
                }
                else
                {
                    FoodC.GetComponentInChildren <RawImage>().texture = null;
                }
            }
            else
            {
                FoodC.GetComponentInChildren <RawImage>().texture = null;
            }
            Timeleft.GetComponent <Text>().text = Timer.ToString("f0") + " / 30";
        }
    }
    IEnumerator CookAfter(float time, GameObject Obj, Consumable consu, int index)
    {
        FirePlace _fp      = this.GetComponentInChildren <FirePlace>();
        float     iterator = time;
        //Debug.Log(iterator);
        bool isRoutine = false;
        bool stop      = false;

        while (iterator > 0)
        {
            Debug.Log("DOWHILE: " + iterator.ToString());
            if (isRoutine == false)
            {
                if (_fp.isLit == false)
                {
                    Obj.layer = 8;

                    // COULD MAKE SO IT CARRIES ON IF LIT INSTEAD OF THROWING IT OFF.
                    _CookingSlots[index].used = false;
                    _CookingSlots[index].obj  = null;

                    for (int i = 0; i < Obj.GetComponent <ID>().Colliders.Length; i++)
                    {
                        Obj.GetComponent <ID>().Colliders[i].enabled = true;
                    }

                    Obj.GetComponent <Rigidbody>().isKinematic = false;
                    Obj.GetComponent <Rigidbody>().useGravity  = true;
                    stop = true;
                    yield return(null);

                    StopCoroutine("CookAfter");
                    break;
                }

                isRoutine = true;
                yield return(new WaitForSeconds(1));

                iterator--;
                consu.timeToCook--; // remove line if want to start from start
                isRoutine = false;
            }
        }

        // every second -= 1
        // check if fireplace still lit
        if (stop == false)
        {
            Debug.Log("enterpass");
            consu.enabled = true;
            consu.Cook();
            Obj.layer = 8;

            _CookingSlots[index].used = false;
            _CookingSlots[index].obj  = null;

            for (int i = 0; i < Obj.GetComponent <ID>().Colliders.Length; i++)
            {
                Obj.GetComponent <ID>().Colliders[i].enabled = true;
            }
        }
    }
示例#11
0
 public void BeginLighting(FirePlace fireplace)
 {
     _fireplace = fireplace;
     _atStove   = true;
 }