void Start() { furnace = furnaceObject.GetComponent<Furnace> (); game = GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameController> (); sounds = GameObject.FindGameObjectWithTag ("SoundBank").GetComponent<SoundBank> (); fireSounds.clip = sounds.firebreathing; }
void Start() { jawTriggerable = (ITriggerable)jawTriggerObject.GetComponent (typeof(ITriggerable)); emitterTriggerable = (ITriggerable)emitterTriggerObject.GetComponent (typeof(ITriggerable)); furnace = furnaceObject.GetComponent<Furnace> (); dragon = GameObject.FindGameObjectWithTag ("Dragon").GetComponent<Dragon> (); anim = buttonObject.GetComponent<Animator> (); game = GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameController> (); sounds = GameObject.FindGameObjectWithTag ("SoundBank").GetComponent<SoundBank> (); }
public override void OnTick(Level level) { if (Inventory == null) { return; } Furnace furnace = level.GetBlock(Coordinates) as Furnace; if (furnace == null) { return; } if (!(furnace is LitFurnace)) { if (GetFuel().Id != 0) { LitFurnace litFurnace = new LitFurnace { Coordinates = furnace.Coordinates, Metadata = furnace.Metadata }; level.SetBlock(litFurnace); furnace = litFurnace; BurnTime = GetFuelEfficiency(GetFuel()); FuelEfficiency = BurnTime; CookTime = 0; Inventory.DecreaseSlot(1); } } if (!(furnace is LitFurnace)) { return; } if (BurnTime > 0) { BurnTime--; BurnTick = (short)Math.Ceiling((double)BurnTime / FuelEfficiency * 200d); if (GetIngredient().Id != 0) { CookTime++; if (CookTime >= 200) { Item result = GetResult(GetIngredient()); if (result != null) { Inventory.DecreaseSlot(0); Inventory.IncreaseSlot(2, result.Id, result.Metadata); } CookTime = 0; } } else { CookTime = 0; } } if (BurnTime <= 0) { if (!Inventory.DecreaseSlot(1)) { //CookTime = 0; BurnTime = GetFuelEfficiency(GetFuel()); FuelEfficiency = BurnTime; BurnTick = (short)Math.Ceiling((double)BurnTime / FuelEfficiency * 200d); } else { // No more fule Furnace unlitFurnace = new Furnace { Coordinates = furnace.Coordinates, Metadata = furnace.Metadata }; level.SetBlock(unlitFurnace); FuelEfficiency = 0; BurnTick = 0; BurnTime = 0; CookTime = 0; } } level.RelayBroadcast(new McpeContainerSetData { windowId = Inventory.Id, property = 0, value = CookTime }); level.RelayBroadcast(new McpeContainerSetData { windowId = Inventory.Id, property = 1, value = BurnTick }); }
public override void OnTick(Level level) { if (Inventory == null) { return; } var furnace = level.GetBlock(Coordinates) as FurnaceBase; if (furnace == null) { return; } if (!(furnace is LitFurnace)) { Item fuel = GetFuel(); Item ingredient = GetIngredient(); Item smelt = ingredient.GetSmelt(); // To light a furnace you need both fule and proper ingredient. if (fuel.Count > 0 && fuel.FuelEfficiency > 0 && smelt != null) { LitFurnace litFurnace = new LitFurnace { Coordinates = furnace.Coordinates, }; litFurnace.SetState(furnace.GetState().States); level.SetBlock(litFurnace); furnace = litFurnace; BurnTime = GetFuelEfficiency(fuel); FuelEfficiency = BurnTime; CookTime = 0; Inventory.DecreaseSlot(1); } } if (furnace is LitFurnace) { if (BurnTime > 0) { BurnTime--; BurnTick = (short)Math.Ceiling((double)BurnTime / FuelEfficiency * 200d); Item ingredient = GetIngredient(); Item smelt = ingredient.GetSmelt(); if (smelt != null) { CookTime++; if (CookTime >= 200) { Inventory.DecreaseSlot(0); Inventory.IncreaseSlot(2, smelt.Id, smelt.Metadata); CookTime = 0; } } else { CookTime = 0; } } if (BurnTime <= 0) { var fuel = GetFuel(); Item ingredient = GetIngredient(); Item smelt = ingredient.GetSmelt(); if (fuel.Count > 0 && fuel.FuelEfficiency > 0 && smelt != null) { Inventory.DecreaseSlot(1); CookTime = 0; BurnTime = GetFuelEfficiency(fuel); FuelEfficiency = BurnTime; BurnTick = (short)Math.Ceiling((double)BurnTime / FuelEfficiency * 200d); } else { // No more fule or nothin more to smelt. var unlitFurnace = new Furnace { Coordinates = furnace.Coordinates, }; unlitFurnace.SetState(furnace.GetState().States); level.SetBlock(unlitFurnace); FuelEfficiency = 0; BurnTick = 0; BurnTime = 0; CookTime = 0; } } } foreach (var observer in Inventory.Observers) { var cookTimeSetData = McpeContainerSetData.CreateObject(); cookTimeSetData.windowId = Inventory.WindowsId; cookTimeSetData.property = 0; cookTimeSetData.value = CookTime; observer.SendPacket(cookTimeSetData); var burnTimeSetData = McpeContainerSetData.CreateObject(); burnTimeSetData.windowId = Inventory.WindowsId; burnTimeSetData.property = 1; burnTimeSetData.value = BurnTick; observer.SendPacket(burnTimeSetData); } }
public virtual void Initialize(Furnace furnace) { this.furnace = furnace; }
private void OnTriggerStay(Collider other) { // if colliding with boxes and not carrying anything if (other.tag == "Plank Box" && !isCarrying) { //display button sprite other.transform.GetComponentInChildren <SpriteRenderer>().enabled = true; if (Input.GetButtonDown("joystick " + playerNumber + " A")) { PickUpPlank(); other.transform.GetComponentInChildren <SpriteRenderer>().enabled = false; } } if (other.tag == "Coal Box" && !isCarrying) { //display button sprite other.transform.GetComponentInChildren <SpriteRenderer>().enabled = true; if (Input.GetButton("joystick " + playerNumber + " A")) { PickUpCoal(); other.transform.GetComponentInChildren <SpriteRenderer>().enabled = false; } } if (other.tag == "Gun Box" && !isCarrying) { //display button sprite other.transform.GetComponentInChildren <SpriteRenderer>().enabled = true; if (Input.GetButton("joystick " + playerNumber + " A")) { PickUpGun(); ps.Reload(); other.transform.GetComponentInChildren <SpriteRenderer>().enabled = false; } } // Repair pad //Repairing if (other.tag == "Repair Pad" && !isCarrying) { RepairPad pad = other.GetComponent <RepairPad>(); if (Input.GetButton("joystick " + playerNumber + " X")) { pad.Repair(); } } //Placing planks if (other.tag == "Repair Pad" && carryingPlank) { RepairPad pad = other.GetComponent <RepairPad>(); if (Input.GetButtonDown("joystick " + playerNumber + " A")) { if (pad.CheckIfCanAdd()) { pad.AddPlank(1); Drop(); } else { return; } } } //Furnace if (other.tag == "Furnace" && carryingCoal) { Furnace fur = other.GetComponent <Furnace>(); if (Input.GetButtonDown("joystick " + playerNumber + " A")) { if (fur.CheckIfCanAdd()) { fur.AddCoal(1); Drop(); } else { return; } } } if (other.tag == "Gatling Gun" && !isCarrying) { //display button sprite //other.transform.GetComponentInChildren<SpriteRenderer>().enabled = true; other.GetComponentInChildren <GatlingGun>().aButton.enabled = true; if (Input.GetButtonDown("joystick " + playerNumber + " A")) { other.GetComponentInChildren <GatlingGun>().aButton.enabled = false; UseGatlingGun(other.gameObject); //other.transform.GetComponentInChildren<SpriteRenderer>().enabled = false; } } }
public void StopCooking() { PrintDebug("Stopping cooking.."); Furnace.CancelInvoke(Cook); Furnace.StopCooking(); }
public GuiFurnaceForm(Furnace furnace) { this.furnace = furnace; }
public void ButtonCraft() { Furnace fn = gameObject.AddComponent <Furnace>(); Anvil sm = gameObject.AddComponent <Anvil>(); switch (craftMe) { //Bars case Bourbon.BronzeBar: fn.SmeltBronze(PlayerInventory, 1); Debug.Log("!"); break; case Bourbon.IronBar: fn.SmeltIron(PlayerInventory, 1); break; case Bourbon.MithrilBar: fn.SmeltMithril(PlayerInventory, 1); break; //Bronze Items (Spear, Hatch, Hamm, Club) case Bourbon.BronzeSpear: sm.SmithSpears(PlayerInventory, 1, Macallen12.Bronze); break; case Bourbon.BronzeHatchet: sm.SmithHatchets(PlayerInventory, 1, Macallen12.Bronze); break; case Bourbon.BronzeHammer: sm.SmithHammers(PlayerInventory, 1, Macallen12.Bronze); break; case Bourbon.BronzeClub: sm.SmithHammers(PlayerInventory, 1, Macallen12.Bronze); break; //Iron Items case Bourbon.IronSpear: sm.SmithSpears(PlayerInventory, 1, Macallen12.Iron); break; case Bourbon.IronHatchet: sm.SmithHammers(PlayerInventory, 1, Macallen12.Iron); break; case Bourbon.IronHammer: sm.SmithHammers(PlayerInventory, 1, Macallen12.Iron); break; case Bourbon.IronClub: sm.SmithClubs(PlayerInventory, 1, Macallen12.Iron); break; //Mith Items case Bourbon.MithrilSpear: sm.SmithSpears(PlayerInventory, 1, Macallen12.Mithril); break; case Bourbon.MithrilHatchet: sm.SmithHammers(PlayerInventory, 1, Macallen12.Mithril); break; case Bourbon.MithrilHammer: sm.SmithHammers(PlayerInventory, 1, Macallen12.Mithril); break; case Bourbon.MithrilClub: sm.SmithHammers(PlayerInventory, 1, Macallen12.Mithril); break; default: Debug.Log("!"); break; } }
public ObjectGravitySystem(Furnace furnace, SoundEffect bonkSound) : base(Aspect.All(typeof(ObjectComponent), typeof(PositionComponent))) { _furnace = furnace; _bonkSound = bonkSound; }
private void Update() { if (_gameController.ColorBlindMode && Furnace != null) { Color color = Furnace.GetNextColor(); _isRightColor = Math.Abs(color.r - Color.r) < 0.1f && Math.Abs(color.g - Color.g) < 0.1f && Math.Abs(color.b - Color.b) < 0.1f; } if (_networkController.GetLocalRole() == _emissionVisibleBy && _isRightColor) { _renderer.material.SetColor("_EmissionColor", Color * _intensity); if (!_renderer.material.IsKeywordEnabled("_EMISSION")) { _renderer.material.EnableKeyword("_EMISSION"); } _xIntensity = _xIntensity + _directionIntensity * Time.deltaTime * _intensityGainSpeed; _intensity = _xIntensity * _xIntensity; if (_intensity < _intensityBottomBound) { _xIntensity = 0; _intensity = _intensityBottomBound; _directionIntensity = 1; } if (_intensity > _intensityUpperBound) { _intensity = _intensityUpperBound; _xIntensity = Mathf.Sqrt(_intensity); _directionIntensity = -1; } } else { if (_renderer.material.IsKeywordEnabled("_EMISSION")) { _directionIntensity = 1; _intensity = _intensityBottomBound; _renderer.material.DisableKeyword("_EMISSION"); } } if (!_photonView.IsMine && _conveyorSpeed == 0.0f) { if (Vector3.Distance(transform.position, _newPosition) > 3) { transform.position = _newPosition; } else { transform.position = Vector3.MoveTowards(transform.position, _newPosition, (_grabbed ? 4 : 10) * Time.deltaTime); } } if (_outline.enabled && !hovered) { _outline.enabled = false; } else if (hovered) { _outline.enabled = true; } hovered = false; }
public void OnAltInteract() { PrepTable prepTable = GetPrepTable(); BoatCoffin boat = GetBoatCoffin(); BookPile bookPile = GetBookPile(); Furnace furnace = GetFurnace(); if (prepTable != null) { if (prepTable.hasBody && !carriedCorpse) { carriedCorpse = prepTable.GetCleanBody(); if (carriedCorpse != null) { carriedCorpse.gameObject.SetActive(true); carriedCorpse.dragspot.GetComponent <Rigidbody>().isKinematic = true; } } else if (!prepTable.hasBody && carriedCorpse && carriedCorpse.canBePrepared && !carriedCorpse.isClean) { prepTable.PlaceBody(carriedCorpse); carriedCorpse.gameObject.SetActive(false); carriedCorpse = null; } } if (furnace != null) { if (carriedCorpse && carriedCorpse.canBeIncinerated) { furnace.PlaceBody(carriedCorpse); carriedCorpse.gameObject.SetActive(false); carriedCorpse = null; } } if (bookPile != null) { if (!carriedCorpse && !carriedItem) { carriedItem = bookPile.GetBook(); carriedItem.GetComponent <Rigidbody>().isKinematic = true; } } if (boat != null) { if (!boat.hasBody && carriedCorpse) { boat.PlaceBody(carriedCorpse); carriedCorpse.gameObject.SetActive(false); carriedCorpse.SummonCorpseCartIfNeeded(); carriedCorpse = null; } else if (boat.hasBody && !boat.hasItem && carriedItem) { boat.PlaceItem(carriedItem); carriedItem.gameObject.SetActive(false); carriedItem = null; } else if (boat.hasBody && boat.hasItem && !boat.hasBeenClosed) { boat.CloseLid(); } } }
void Update() { Player player = Player.localPlayer; if (player) { if (player.interaction.current != null && ((NetworkBehaviour)player.interaction.current).GetComponent <Furnace>() != null) { panel.SetActive(true); Furnace furnace = ((NetworkBehaviour)player.interaction.current).GetComponent <Furnace>(); if (furnace.ingredientSlot.amount > 0) { ingredientToolip.enabled = true; if (ingredientToolip.IsVisible()) { ingredientToolip.text = furnace.ingredientSlot.ToolTip(); } ingredient.dragable = true; if (furnace.ingredientSlot.item.maxDurability > 0) { if (furnace.ingredientSlot.item.durability == 0) { ingredientImage.color = brokenDurabilityColor; } else if (furnace.ingredientSlot.item.DurabilityPercent() < lowDurabilityThreshold) { ingredientImage.color = lowDurabilityColor; } else { ingredientImage.color = Color.white; } } else { ingredientImage.color = Color.white; } ingredientImage.sprite = furnace.ingredientSlot.item.image; ingredientOverlay.SetActive(furnace.ingredientSlot.amount > 1); ingredientAmountText.text = furnace.ingredientSlot.amount.ToString(); } else { ingredientToolip.enabled = false; ingredient.dragable = false; ingredientImage.color = Color.clear; ingredientImage.sprite = null; ingredientOverlay.SetActive(false); } if (furnace.fuelSlot.amount > 0) { fuelToolip.enabled = true; if (fuelToolip.IsVisible()) { fuelToolip.text = furnace.fuelSlot.ToolTip(); } fuel.dragable = true; if (furnace.fuelSlot.item.maxDurability > 0) { if (furnace.fuelSlot.item.durability == 0) { fuelImage.color = brokenDurabilityColor; } else if (furnace.fuelSlot.item.DurabilityPercent() < lowDurabilityThreshold) { fuelImage.color = lowDurabilityColor; } else { fuelImage.color = Color.white; } } else { fuelImage.color = Color.white; } fuelImage.sprite = furnace.fuelSlot.item.image; fuelOverlay.SetActive(furnace.fuelSlot.amount > 1); fuelAmountText.text = furnace.fuelSlot.amount.ToString(); } else { fuelToolip.enabled = false; fuel.dragable = false; fuelImage.color = Color.clear; fuelImage.sprite = null; fuelOverlay.SetActive(false); } if (furnace.resultSlot.amount > 0) { resultToolip.enabled = true; if (resultToolip.IsVisible()) { resultToolip.text = furnace.resultSlot.ToolTip(); } result.dragable = true; if (furnace.resultSlot.item.maxDurability > 0) { if (furnace.resultSlot.item.durability == 0) { resultImage.color = brokenDurabilityColor; } else if (furnace.resultSlot.item.DurabilityPercent() < lowDurabilityThreshold) { resultImage.color = lowDurabilityColor; } else { resultImage.color = Color.white; } } else { resultImage.color = Color.white; } resultImage.sprite = furnace.resultSlot.item.image; resultOverlay.SetActive(furnace.resultSlot.amount > 1); resultAmountText.text = furnace.resultSlot.amount.ToString(); } else { resultToolip.enabled = false; result.dragable = false; resultImage.color = Color.clear; resultImage.sprite = null; resultOverlay.SetActive(false); } double elapsedTime = NetworkTime.time - furnace.bakeTimeStart; double bakingTime = furnace.bakeTimeEnd - furnace.bakeTimeStart; progressSlider.value = furnace.IsBaking() ? (float)(elapsedTime / bakingTime) : 0; } else { panel.SetActive(false); } } }
protected override void Awake() { base.Awake(); furnance = GetComponentInParent <Furnace>(); }
public MinionSystem(Furnace furnace, SimpleTool musicBox) : base(Aspect.All(typeof(PositionComponent), typeof(ForceComponent), typeof(ObjectComponent), typeof(MinionComponent))) { _furnace = furnace; _musicBox = musicBox; }