private void Update() { if (!pivit) { pivit = transform.Find("pivot"); } switch (state) { case ChestState.Open: if (x < 150) { x += 75 * Time.deltaTime; } else if (x >= 150) { state = ChestState.Animation; } break; case ChestState.Animation: break; case ChestState.Closed: if (x > 0) { x -= 75 * Time.deltaTime; } break; } x = Mathf.Clamp(x, 0f, 150f); pivit.localRotation = Quaternion.Euler(locked ? 0f : -x, 0f, 0f); }
protected virtual void Start() { _scene = SceneManager.GetActiveScene(); if (_scene.name == "EnemyA") { int treasureChance = Random.Range(0, 3); if (treasureChance >= 1) { this.gameObject.SetActive(false); } else { int id = this.chestID; while (ChestManager.chestManager.chestList.ContainsKey(id)) { id = Random.Range(1, 193734); this.chestID = id; this.status = ChestState.CLOSED; } } coinAmount = Random.Range(5, 11); } dialogBox.SetActive(false); if (item.Length != 0) { itemChoice = Random.Range(0, item.Length); } }
void Awake() { openAnim = GetComponent <Animator>(); openAnim.enabled = false; itemLoot = GetComponent <ItemLoot>(); chestState = ChestState.closed; }
private void Open() { state = ChestState.animationInProgress; GetComponent<Animation>().Play("ChestAnim"); GetComponent<AudioSource>().Play(); state = ChestState.open; }
// Update is called once per frame void Update() { if (onTrigger) { if (state == ChestState.closed) { button.SetActive(true); if (inputDevice.Action2.WasPressed) { animator.SetTrigger("Open"); state = ChestState.opening; Invoke("SetStateToOpened", 1.5f); button.SetActive(false); } } else if (state == ChestState.opened) { button.SetActive(true); if (inputDevice.Action2.WasPressed) { // give gem TransferGems(playerOnTrigger); button.SetActive(false); } } } }
void OnTriggerEnter2D(Collider2D Finish) { if (Finish.tag == "Player") { state = ChestState.finish; } else { state = ChestState.Chest1; } }
protected virtual void Awake() { if (ChestManager.chestManager.chestList.ContainsKey(chestID)) { this.status = ChestManager.chestManager.chestList[chestID]; } else { this.status = ChestState.CLOSED; ChestManager.chestManager.UpdateChest(chestID, status); } }
public override void _Ready() { openedSprite = GetNode <Sprite>(openedSpritePath); closedSprite = GetNode <Sprite>(closedSpritePath); animationPlayer = GetNode <AnimationPlayer>(animationPlayerPath); if (isLocked) { currentState = ChestState.LOCKED; } ScanChildren(); }
// public Prize prize; public SaveableChest(int chestID, ChestState chestState, DateTimeSaveable openOrderTimeArg, DateTimeSaveable openDurationArg, ChestType chestType) { this.chestType = chestType; this.chestID = chestID; this.chestState = chestState; openDurationSaveable = openDurationArg; this.openOrderTimeInSystem = new DateTime(openOrderTimeArg.year, openOrderTimeArg.month, openOrderTimeArg.day, openOrderTimeArg.hour, openOrderTimeArg.minute, openOrderTimeArg.seconds); this.openDurationSaveable = openDurationArg; // this.prize = prize; openDuration = new TimeSpan(openDurationArg.hour, openDurationArg.minute, openDurationArg.seconds); // Debug.Log( " sss " + openDuration); // openOrderTimeSaveable = new DateTimeSaveable(0, 0, 0, openOrderTimeInSystem.Hour, openOrderTimeInSystem.Minute, openOrderTimeInSystem.Second); }
private void OpenChest() { openAnim.enabled = openAnim.enabled == false ? true : false; for (int i = 0; i < itemSpawners.Count; i++) { spawnPoints.Add(new SpawnPoint (RandomPointInBounds(spawnArea.bounds), false)); drop.Add(itemLoot.RollLoot()); itemSpawners[i].GetComponent <Light>().color = drop[i].GetRarityHaloColor(); } chestState = ChestState.isOpening; }
public void OnUnlockClicked() { if (chestClickedOn) { Debug.Log("chest unlock: "); thisChest.chestState = ChestState.InOpening; chestState = ChestState.InOpening; thisChest.openOrderTimeInSystem = System.DateTime.Now; SaveableChest newChest = new SaveableChest(chestID, chestState, System.DateTime.Now, openDuration, thisChest.chestType); OnChestUnlocked(newChest); OnChestChanged(newChest); OnChestAssigned(newChest); OnChestAssignedSingle(newChest); } }
IEnumerator CloseChestAfterOpened() { while (true) { print("running"); if (state == ChestState.opened) { animator.SetTrigger("Close"); state = ChestState.closed; closeChestAfterOpened = null; break; } yield return(null); } }
void ChangeChestState(SaveableChest saveableChest) { chestReady = true; // Debug.Log("in vhange: "+saveableChest.chestState); thisChest.chestState = saveableChest.chestState; chestState = saveableChest.chestState; if (chestState == ChestState.InOpening) { OnChestUnlocked(thisChest); } if (chestState == ChestState.Ready) { OnChestReady(); } }
private void OpenChest() { chestState = ChestState.x; openAnim.enabled = openAnim.enabled == false ? true : false; for (int i = 0; i < itemSpawners.Count; i++) { spawnPoints.Add(new SpawnPoint (RandomPointInBounds(spawnArea.bounds), false)); drop.Add(itemLoot.RollLoot()); } chestState = ChestState.isOpening; }
void CheckState() { if(Flags.Instance.HasFlag("Chest01")) { state = ChestState.empty; gameObject.GetComponent<AtlasManager>().SetAtlas(16,16,0,1); } else if(CharacterItems.Instance.CarryItem.ContainsKey(0)) { state = ChestState.wait; gameObject.GetComponent<AtlasManager>().SetAtlas(16,16,0,0); } else { state = ChestState.idle; gameObject.GetComponent<AtlasManager>().SetAtlas(16,16,0,0); } }
public void OnBuyWithGems(int gemVal) { if (chestClickedOn) { if (PlayerPrefs.GetInt("Gem") > gemVal)//TODO change fixed { if (thisChest.chestState == ChestState.InOpening) { Debug.Log("gem bbbbbbbbbb"); InOpeningChestBought(); } OnChargeGem(-gemVal); thisChest.chestState = ChestState.Ready; chestState = ChestState.Ready; OnChestAssignedSingle(thisChest); OnChestBuyGems(); } } }
public ChestUpdatePacket(GameLocation loc, Vector2 pos) : base(loc, pos) { Chest chest = (Chest)loc.objects[pos]; ChestState state = new ChestState(chest); // Slightly cheating, but whatever opener = state.opener; // The chest is open, nobody else can open it. So why should we send // the reserialized chest? It'd be a huge waste of bandwidth (although // I do plenty of that already). // However, when it closes (opener == -1), we need to know what changed // for when someone else opens it. // I guess I could just overwrite read/write, but I like this better. // I don't have copy the contents of read/write, just add to it if (opener != -1) { str = ""; } }
public void AssignValues(SaveableChest saveableChest) { thisChest = saveableChest; chestID = saveableChest.chestID; if (saveableChest.chestState == ChestState.InOpening) { OnChestBrowsedUnlocking(thisChest); } if (chestReady == false) { chestState = saveableChest.chestState; } // prize = saveableChest.prize; openDuration = saveableChest.openDurationSaveable; openOrderTime = saveableChest.openOrderTimeSaveable; Debug.Log("chest dur: " + saveableChest.openDuration + " " + saveableChest.chestState); remainingTimeToOpen = System.DateTime.Now - saveableChest.openOrderTimeInSystem; GetComponent <ChessMenuUI>().EnrollInEvent(); OnChestAssignedSingle(saveableChest); }
/// <summary> /// controlling what reward should given when box open /// </summary> public void OnTriggered() { switch (CurrentMode) { case ChestState.Closed: if (Knight.knights.Ispowerpup == false) { CurrentMode = ChestState.Reward1; } else if (Knight.knights.Ispowerpup == true) { CurrentMode = ChestState.Reward2; } break; case ChestState.Empty: break; } }
void Update() { if (chestState == ChestState.isOpening) { for (int i = 0; i < itemSpawners.Count; i++) { if (spawnPoints[i].Spawned == false) { itemSpawners[i].gameObject.SetActive(true); } itemSpawners[i].position = Vector3.MoveTowards(itemSpawners[i].position, spawnPoints[i].position, spawningSpeed * Time.deltaTime); if (itemSpawners[i].position == spawnPoints[i].position) { if (spawnPoints[i].Spawned != true) { Instantiate(drop[i], spawnPoints[i].position, Quaternion.identity); spawnPoints[i] = new SpawnPoint(spawnPoints[i].position, true); itemSpawners[i].gameObject.SetActive(false); } } } foreach (SpawnPoint sp in spawnPoints) { if (sp.Spawned == true) { chestState = ChestState.opened; } else { chestState = ChestState.isOpening; break; } } } }
void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Player") { //set icons inputDevice = null; if (state == ChestState.opened) { animator.SetTrigger("Close"); state = ChestState.closed; } else if (state == ChestState.opening) { closeChestAfterOpened = StartCoroutine(CloseChestAfterOpened()); } button.SetActive(false); onTrigger = false; playerOnTrigger = null; } }
public void OperateChest(string command) { if (command == "exit") Environment.Exit(0); else switch (current) { case ChestState.open: if (command == "close") current = ChestState.closed; else Console.WriteLine("Unauthorized operation"); break; case ChestState.closed: if (command == "open") current = ChestState.open; else if (command == "lock") current = ChestState.locked; else Console.WriteLine("Unauthorized operation"); break; case ChestState.locked: if (command == "unlock") current = ChestState.closed; else Console.WriteLine("Unauthorized operation"); break; } }
public Chest(ChestState currentState) { current = currentState; }
void OpenChest() { chestState = ChestState.unlocked; itemDrop.gameObject.SetActive(true); }
// Use this for initialization void Start() { gameObject.tag = "INTERACTABLE"; chest = gameObject.GetComponentInParent <ChestState>(); }
//Frees item drop and detaches it void OpenChest() { chestState = ChestState.unlocked; itemDrop.gameObject.SetActive(true); this.transform.DetachChildren(); }
// Use this for initialization void Start() { this.state = ChestState.closed; }
public void Open() { ChestState = ChestState.Open; }
// 자신의 상자 설정 public void AddChest(ChestKind kind, ChestState state = ChestState.Idle, string startTime = "", int index = 0) { if (curHaveChests == 3 || kind == ChestKind.NONE) { return; } myChests[index].chestKind = kind; myChests[index].chestState = state; if (startTime == "") { myChests[index].startTime = System.DateTime.Now; } else { myChests[index].startTime = System.DateTime.Parse(startTime); } myChests[index].disTime = 1; myChests[index].diamondPrice = ((int)kind + 1) * 10; myChests[index].idleTimeText.text = myChests[index].disTime + "분"; myChests[index].idleArenaText.text = myChests[index].chestKind.ToString(); myChests[index].disTimeText.text = myChests[index].disTime + "분"; myChests[index].disDiamondText.text = myChests[index].diamondPrice.ToString(); // 아레나 설정 등등 해주기 ... switch (myChests[index].chestState) { case ChestState.Idle: myChests[index].idleChest.SetActive(true); myChests[index].disChest.SetActive(false); myChests[index].openChest.SetActive(false); break; case ChestState.Dismissing: myChests[index].idleChest.SetActive(false); myChests[index].disChest.SetActive(true); myChests[index].openChest.SetActive(false); StartCoroutine(CheckingChest(index)); break; case ChestState.Open: myChests[index].idleChest.SetActive(false); myChests[index].disChest.SetActive(false); myChests[index].openChest.SetActive(true); break; default: break; } BackEndServerManager.instance.myInfo.haveChestKind[index] = (int)kind; BackEndServerManager.instance.myInfo.haveChestState[index] = (int)state; curHaveChests++; BackEndServerManager.instance.myInfo.haveChests = curHaveChests; BackEndServerManager.instance.myInfo.disStartTime = startTime; PlayerStats.instance.SaveChest(); }
public RewardChest(bool goldOnly, bool shardsOnly) { Dictionary <string, int> possibleRewards = new Dictionary <string, int> (); // System.Random rand = new System.Random (); if (!goldOnly) { int costLength = /*rand.Next (1, 6);*/ Random.Range(1, 3); for (int j = 0; j < costLength; j++) { List <Item> validItems = new List <Item> (); foreach (var item in Player.Instance.DataBase.TempItemLibrary) { if (!possibleRewards.ContainsKey(item.Name)) { validItems.Add(item); } } int index = /*rand.Next (0, validItems.Count - 1);*/ Random.Range(0, validItems.Count - 1); possibleRewards.Add(validItems [index].Name, /*rand.Next (1, 10)*/ Random.Range(1, 5)); } } if (!shardsOnly) { possibleRewards.Add("Gold", Random.Range(5, 10)); } float roll = Random.Range(0.0f, 1.0f); if (roll > 0.5f && roll <= 0.85f) { possibleRewards.Add("Exp", Random.Range(1, 5)); } else if (roll > 0.85f && roll <= 0.95f) { possibleRewards.Add("Exp", Random.Range(5, 10)); } else if (roll > 0.95f) { possibleRewards.Add("Exp", 15); } foreach (var shipData in Player.Instance.ShipDatas) { if (Random.Range(0.0f, 1.0f) >= 0.3f) { if (shipData.IsUnlocked) { continue; } possibleRewards.Add(shipData.Name, Random.Range(1, 10)); break; } } /*float roll = Random.Range (0.0f, 1.0f); * if (roll > 0.5f && roll <= 0.85f) { * possibleRewards.Add ("Small healing potion", Random.Range (1, 5)); * } else if (roll > 0.85f && roll <= 0.95f) { * possibleRewards.Add ("Medium healing potion", Random.Range (1, 3)); * } else if (roll > 0.95f) { * possibleRewards.Add ("Big healing potion", 1); * }*/ /*if (goldOnly) { * float diceRoll = Random.Range (0.0f, 1.0f); * * if (diceRoll < 0.75f) { * possibleRewards.Add ("Copper lockpick", Random.Range (1, 4)); * } else if (diceRoll < 0.95f) { * possibleRewards.Add ("Silver lockpick", Random.Range (1, 3)); * } else { * possibleRewards.Add ("Golden lockpick", Random.Range (1, 2)); * } * }*/ Ocean = Player.Instance.CurrentAdventure.Ocean; List <int> seconds = OpenTimesByOcean [Player.Instance.CurrentAdventure.Ocean]; int randIndex = Random.Range(0, seconds.Count); SecondsToOpen = seconds [randIndex]; RewardItems = new Dictionary <string, int> (possibleRewards); ChestState = ChestState.Closed; }
public BlockActionChest(byte byte1, byte byte2, int blockType) { Byte1 = 1; // Not used - always 1. ChestState = (ChestState)byte2; BlockType = blockType; }
void SetStateToOpened() { state = ChestState.opened; }
//Unity Hook private void Start() { CurrentMode = ChestState.Closed; }
// Update is called once per frame void Update() { ChestState state = targetAngles[0]; top.transform.localRotation = Quaternion.Slerp(top.transform.localRotation, Quaternion.Euler(state.angle), state.speed * 0.5f * Time.deltaTime); }
public BlockActionChest(byte byte1, byte byte2, int blockType) { Byte1 = 1; // Not used - always 1. ChestState = (ChestState) byte2; BlockType = blockType; }