//////////Methods////////// /// <summary> /// Creates a new treasure with the parameters given. /// carryingPirate can be null. /// </summary> public Treasure(int id, ILocateable location, TreasureState state, Pirate carryingPirate, int value) { this.Id = id; this.InitialLocation = location.GetLocation(); this.location = this.InitialLocation; this.state = state; this.carryingPirate = carryingPirate; this.Value = value; this.nativeObject = null; }
/// <summary> /// 退出金银岛场景. /// </summary> public static void OutTreasureScene() { if (TreasureScene.m_SceneState == TreasureState.CanvasEdit) { MainTownInit.s_currentState = MainTownState.None; } SceneM.Load(MainTownScene.GetSceneName(), false, false); // UniversalObj.s_instane.SetBackGroundByState(UniversalObjState.None); MainCameraM.s_Instance.EnableDrag(true); TreasureScene.m_SceneState = TreasureState.None; }
public void ChangeState(TreasureState newState) //this will be ran to change the state { switch (newState) { case TreasureState.pickedUp: //picked up is ran by the player when they collect it myState = newState; this.gameObject.SetActive(false); break; case TreasureState.lost: //lost is ran if the player takes damage after picking it up myState = newState; this.gameObject.SetActive(true); break; case TreasureState.notPickedUp: //not picked up is the default treasure state if the player has not picked it up myState = newState; break; } }
public void TreasureAlreadyOpen() { if (m_TreasureState == TreasureState.Opening) { // Dialog windows off m_DialogBox.SetActive(false); // Set the current item to empty m_PlayerInventory.m_currentItem = null; m_PlayerMovment.m_currentState = PlayerMovment.PlayerState.interact; // Raise the signal to the player to stop animating // RAISE // Item: Signal_ReceiveItem // Local: ScriptableObjects/Player // Capturado por: Player->Receive Item // Método: Scripts/Player Scripts/PlayerMovment.cs->RaiseItem() m_RaiseItem.Raise(); // Set the treasure opened m_TreasureState = TreasureState.Open; } }
private IEnumerator OpenTreasureAnimation() { m_PlayerMovment.m_currentState = PlayerMovment.PlayerState.receiving; m_Animator.SetBool("open", true); yield return(new WaitForSeconds(2f)); if (m_DialogBox != null) { // Dialog windows on m_DialogBox.SetActive(true); // Dialog Text = contensts text m_DialogText.text = m_Contents.m_ItemDescription; // Add contents to inventory m_PlayerInventory.AddItem(m_Contents); m_PlayerInventory.m_currentItem = m_Contents; // Raise the signal to the player to animate set the treasure to open // Raise the signal to the player to stop animating // RAISE // Item: Signal_ReceiveItem // Local: ScriptableObjects/Player // Capturado por: Player->Receive Item // Método: Scripts/Player Scripts/PlayerMovment.cs->RaiseItem() m_RaiseItem.Raise(); } else { m_TreasureState = TreasureState.Open; m_PlayerMovment.m_currentState = PlayerMovment.PlayerState.interact; } // RAISE // Signal: Signal_ContextClueOff // Local Signal: ScriptableObjects/Context Clue // Capturado por: Player // Método: Scripts/Player Scrips/ContextClue.cs->Disable() m_ContextOff.Raise(); m_UseContext = false; }
void SetTreasureState(TreasureState s) { if (s != _curTreasureState) { TreasureState prevState = _curTreasureState; _curTreasureState = s; Nights2Spot treasureSpot = GetTreasureSpot(); if (_curTreasureState == TreasureState.TreasureReveal) { //ping from treasure spot when its revealed if (Nights2SpotMgr.Instance != null) Nights2SpotMgr.Instance.TriggerSpotFX(Nights2SpotMgr.LightAction.Ping, 1.5f, treasureSpot, .5f); if (TreasureRevealSound != null) TreasureRevealSound.Play(); } if (_curTreasureState == TreasureState.TreasureCompleted) { if (Nights2SpotMgr.Instance != null) Nights2SpotMgr.Instance.TriggerSpotFX(Nights2SpotMgr.LightAction.TurnAllOn, 2.0f); } //light up spot if ((treasureSpot != null) && (_curTreasureState != TreasureState.NoProgress) && (_curTreasureState != TreasureState.TreasureCompleted)) { Nights2SpotMgr.Instance.MakeSpotActive(treasureSpot); } if (_curTreasureState == TreasureState.WaitingForTreasureReveal) { //TODO: light up spot! } else if (_curTreasureState == TreasureState.TreasureReveal) { //spawn treasure at spot Debug.Assert(TreasurePrefab != null); GameObject spawnedTreasure = Instantiate(TreasurePrefab) as GameObject; Debug.Assert(spawnedTreasure != null); _treasure = spawnedTreasure.GetComponent<Nights2Treasure>(); Debug.Assert(_treasure != null); Vector3 treasurePos = GetTreasureSpotOnGround(); _treasure.gameObject.transform.position = treasurePos; //face the torch carrier _treasure.gameObject.transform.LookAt(GetPlayerPosOnGround()); } else if (_curTreasureState == TreasureState.TreasureCompleted) { _treasure = null; //don't track it anymore, it will delete itself } } }
public void CheateTreasureState(TreasureState s) { if (s == TreasureState.TreasureWaitForCollection) _treasure.ForceOpen(); else if (s == TreasureState.TreasureCompleted) _treasure.ForceCollect(); SetTreasureState(s); }
public override void Start() { base.Start(); m_TreasureState = TreasureState.Close; }
public void OpenTreasure() { m_TreasureState = TreasureState.Opening; StartCoroutine(OpenTreasureAnimation()); }
/// <summary> /// Updates the treasure. All of the pirates' objects + some of the map object need to be updated BEFORE calling this method /// </summary> /// <param name="map">Both map.GetFreeToTakeTreasures() and map.GetPirateAt() need to be updated BEFORE calling this method</param> public void Update(Map map) { // if the pirate doesn't know in advance what he's carrying if (map.GetTreasures(TreasureState.FreeToTake).Contains(this)) { // the FreeToTake list is updated, thus this treasure is free to take this.state = TreasureState.FreeToTake; this.carryingPirate = null; this.location = this.InitialLocation; } else { // the treasure is NOT FreeToTake // lets divide the cases, based on the last state of the treasure switch (this.State) { case TreasureState.FreeToTake: // if the treasure was free to take last turn and now is not, then it must be carried right now by the pirate // who is at its initial location this.state = TreasureState.BeingCarried; this.carryingPirate = map.GetPirateOn(this.InitialLocation); // the map's pirate matrix is updated this.location = this.InitialLocation; break; case TreasureState.BeingCarried: // if the treasure was being carried last turn, the treasure will be taken if and only if the carrying pirate is now // at its initial location and is free. Otherwise, it will be carried by the same pirate (if it is still carrying something) // or by the pirate at the treasure's initial location (not sure if it is even possible) if (this.CarryingPirate.Location.Equals(this.CarryingPirate.InitialLocation) && this.CarryingPirate.State == PirateState.Free) { this.state = TreasureState.Taken; this.carryingPirate = null; this.location = null; } else { if (this.CarryingPirate.State == PirateState.CarryingTreasure) { // only need to update the location of the treasure this.location = this.CarryingPirate.Location; } else { // only need to update the location and the carrying pirate this.carryingPirate = map.GetPirateOn(this.InitialLocation); this.location = this.InitialLocation; } } break; case TreasureState.Taken: // if the treasure was taken last turn, then it must also be taken now; there is nothing to update break; } } // if the pirate DOES know in advance what he's carrying //// if the treasure is free //if (map.GetTreasures(TreasureState.FreeToTake).Contains(this)) //{ // // the FreeToTake list is updated, thus this treasure is free to take // this.state = TreasureState.FreeToTake; // this.carryingPirate = null; // this.location = this.InitialLocation; //} //else //{ // // else, assume the treasure is taken, and change it if the treasure is being carried // this.state = TreasureState.Taken; // this.carryingPirate = null; // this.location = null; // foreach (Pirate p in map.MyPirateManager.GetAllPirates().Union(map.EnemyPirateManager.GetAllPirates())) // { // if ("p carries this.Id") // <-- change the check here, to see if p actually carries this treasure // { // this.state = TreasureState.BeingCarried; // this.carryingPirate = p; // this.location = p.Location; // } // } //} }
public static void SetTreasureState(TreasureState state = TreasureState.None) { m_SceneState = state; }