public void Receive(MemoryStream allDataReceivedBuffer = null) { // inicjowanie zmiennych Aborted = false; BlockNumExpected = 1; Remainder = new byte[0]; DataPacketNumBytesStored = 0; ExpectingFirstPacket = true; ValidPacketReceived = false; FileInitiationByteToSend = C; CurrentState = Stances.ReceiverFileInitiation; if (Port.IsOpen == false) // jesli port zamkniety { Port.Open(); // to otworz } Port.DiscardInBuffer(); // czyszczenie bufforow Port.DiscardOutBuffer(); // czyszczenie bufforow AllDataReceivedBuffer = allDataReceivedBuffer; Port.DataReceived += Port_DataReceived; //event odebranych danych if (ReceiverFileInitiationTimer == null) { ReceiverFileInitiationTimer = new Timer(ReceiverFileInitiationRoutine, null, 0, ReceiverFileInitiationRetryMillisec); //inicjacja timera } else { ReceiverFileInitiationTimer.Change(0, ReceiverFileInitiationRetryMillisec); // jesli istnieje to wyzeruj } ReceiverUserBlock.Reset(); ReceiverUserBlock.WaitOne(); ReceiverUserBlock.Reset(); // czyszczenie bloków }
private void Port_DataReceived(object sender, SerialDataReceivedEventArgs e) //event DataReceived { SerialPort sp = sender as SerialPort; int numBytes = sp.BytesToRead; byte[] recv = new byte[numBytes]; sp.Read(recv, 0, numBytes); if (numBytes > 0) { switch (CurrentState) { case Stances.ReceiverFileInitiation: if (ReceiverFileInitiationTimer != null) { ReceiverFileInitiationTimer.Change(Timeout.Infinite, Timeout.Infinite); } CurrentState = Stances.ReceiverHeaderSearch; ReceiverPacketBuilder(recv); break; case Stances.ReceiverHeaderSearch: case Stances.ReceiverBlockNumSearch: case Stances.ReceiverBlockNumComplementSearch: case Stances.ReceiverDataBytesSearch: case Stances.ReceiverErrorCheckSearch: ReceiverPacketBuilder(recv); break; } } }
// Converts the stance enum to a string public static string StanceToString(Stances stance) { if (stance == Stances.STANDING) { return("STANDING"); } else if (stance == Stances.CROUCHING) { return("CROUCHING"); } else if (stance == Stances.LAYING) { return("LAYING"); } else if (stance == Stances.RUNNING) { return("RUNNING"); } else if (stance == Stances.LUNGEING) { return("LUNGEING"); } else if (stance == Stances.FALLING) { return("FALLING"); } else { return(""); } }
// Returns whether or not the two stances transition to each other public static bool CheckStanceTransition(Stances fromStance, Stances toStance) { if (fromStance == Stances.STANDING && toStance == Stances.RUNNING || fromStance == Stances.STANDING && toStance == Stances.LUNGEING || fromStance == Stances.STANDING && toStance == Stances.FALLING || fromStance == Stances.STANDING && toStance == Stances.CROUCHING || fromStance == Stances.CROUCHING && toStance == Stances.STANDING || fromStance == Stances.CROUCHING && toStance == Stances.LAYING || fromStance == Stances.CROUCHING && toStance == Stances.LUNGEING || fromStance == Stances.LAYING && toStance == Stances.STANDING || fromStance == Stances.LAYING && toStance == Stances.CROUCHING || fromStance == Stances.RUNNING && toStance == Stances.STANDING || fromStance == Stances.RUNNING && toStance == Stances.LUNGEING || fromStance == Stances.LUNGEING && toStance == Stances.FALLING || fromStance == Stances.LUNGEING && toStance == Stances.CROUCHING || fromStance == Stances.FALLING && toStance == Stances.LAYING ) { return(true); } return(false); }
void ChangeIncline(Ray reachFor, float reachDistance) { RaycastHit reachedFor; if (Physics.Raycast(reachFor, out reachedFor, reachDistance)) { reachedNothing = false; //CHANGE INCLINE if (reachedFor.collider.CompareTag("Floor") || reachedFor.collider.CompareTag("Wall") || reachedFor.collider.CompareTag("Ceiling")) { actionText.text = "Press E to change incline"; //print("Press E key to change incline"); if (Input.GetKeyDown(KeyCode.E)) { Physics.gravity = -reachedFor.normal * 9.8f; myStance = Stances.crawling; currentSurface = reachedFor.collider.tag; lerping = true; } } } else { reachedNothing = true; } }
public void ChangePlayerStance(Stances requestedStance) { if (requestedStance != currentStance) { currentStance = requestedStance; stanceChargeLevel = 0; switch (requestedStance) { case Stances.Agility: blockRotationPlayer = false; speed = speed * 2; anim.SetInteger("Stance", 0); nextStance = Stances.Aggro; evasionSpeed = 15; break; case Stances.Aggro: blockRotationPlayer = true; speed = speed * 0.5f; anim.SetInteger("Stance", 1); nextStance = Stances.Agility; evasionSpeed = 1; break; } } }
public void SetStance(Stances stance) { switch (stance) { case Stances.Neutral: //Neutral currentStance = Stances.Neutral; RemoveStatusEffecMultiplet <StanceEffects>(); break; case Stances.Life: //Life RemoveStatusEffecMultiplet <StanceEffects>(); AddStatusEffect <WardingStance>(); currentStance = Stances.Life; break; case Stances.Death: //Death RemoveStatusEffecMultiplet <StanceEffects>(); AddStatusEffect <StrengthStance>(); AddStatusEffect <FortitudeStance>(); currentStance = Stances.Death; break; case Stances.Elemental: //Elemental RemoveStatusEffecMultiplet <StanceEffects>(); AddStatusEffect <WardingStance>(); AddStatusEffect <PowerStance>(); currentStance = Stances.Elemental; break; } }
void ChangeStance() { if (myStance == Stances.standing) { Vector3 playerScale = Vector3.one * 0.5f; transform.localScale = playerScale; if (Input.GetKeyDown(KeyCode.LeftControl)) { myStance = Stances.crawling; } } else if (myStance == Stances.crawling) { Vector3 playerScale = new Vector3(0.5f, 0.25f, 0.5f); transform.localScale = playerScale; if (Input.GetKeyDown(KeyCode.LeftControl)) { myStance = Stances.standing; if (currentSurface == "Wall" || currentSurface == "Ceiling") { FallToFloor(); } } } }
void Awake() { globs = GameObject.FindGameObjectWithTag("GameController").GetComponent <Globals>(); anim = new Animation_Handler(gameObject.GetComponent <Animator> ()); currStance = Stances.Stand; charController = GetComponent <CharacterController> (); }
public void Stance(float stance) { if (stance != 0) { anim.ChangeStance(stance); } if ((stance > 0f && currStance == Stances.Prone) || (stance < 0f && currStance == Stances.Stand)) { currStance = Stances.Crouch; speed = CrouchWalkSpeed; charController.height = CrouchColliderHeight; charController.center = new Vector3(0f, CrouchColliderYPos, 0f); FootStepNoiseRadius = 0f; } else if (stance > 0f && currStance == Stances.Crouch) { currStance = Stances.Stand; speed = WalkSpeed; charController.height = NormalColliderHeight; charController.center = new Vector3(0f, StandColliderYPos, 0f); FootStepNoiseRadius = 10f; } else if (stance < 0f && currStance == Stances.Crouch) { currStance = Stances.Prone; speed = CrawlSpeed; charController.height = ProneColliderHeight; charController.center = new Vector3(0f, ProneColliderYPos, 0f); FootStepNoiseRadius = 5f; } print(currStance.ToString()); }
public void TestEffectsDef() { Character toon = new Character(); toon.SetBaseStat(Stat.Dexterity, 25); // regular conc pot: toon.AddEffect(Effects.Get("Blessing of Dexterity", 35)); toon.AddEffect(Effects.Get("Blessed Protection", 35)); toon.AddEffect(Effects.Get("Prayer of Protection", 35)); toon.AddEffect(Effects.Get("Charm of Illumination (Spirit)", 35)); toon.AddEffect(Effects.Get("Charm of Illumination (Intelligence)", 35)); toon.Stance = Stances.Get("HealerOffense", 25); Assert.That(toon.Defense, Is.EqualTo(239)); toon.Stance = Stances.Get("HealerDefense", 20); Assert.That(toon.Defense, Is.EqualTo(345)); // perfect conc pot: toon.AddEffect(Effects.Get("Blessing of Dexterity", 40)); toon.AddEffect(Effects.Get("Blessed Protection", 40)); toon.AddEffect(Effects.Get("Prayer of Protection", 40)); toon.AddEffect(Effects.Get("Charm of Illumination (Spirit)", 40)); toon.AddEffect(Effects.Get("Charm of Illumination (Intelligence)", 40)); toon.Stance = Stances.Get("HealerOffense", 25); Assert.That(toon.Defense, Is.EqualTo(259)); toon.Stance = Stances.Get("HealerDefense", 20); Assert.That(toon.Defense, Is.EqualTo(374)); }
public int EndFile() { if (NumUserDataBytesAddedToCurrentPacket > 0) { TransmitPacket(); _TotalUserDataBytesSent += NumUserDataBytesAddedToCurrentPacket; } CurrentStance = Stances.SenderAwaitingEndOfFileConfirmation; int numEndOfFileBytesSent = 0; while (EndOfFileAcknowledgementReceived == false) { WaitForResponseFromReceiver.Reset(); Port.Write(new byte[] { EndOfFileByteToSend }, 0, 1); numEndOfFileBytesSent += 1; WaitForResponseFromReceiver.WaitOne(); } if (EndOfFileAcknowledgementReceived) { Abort(); return(NumUserDataBytesAddedToCurrentPacket); } Abort(); return(0); }
private void Start() { sprite = GetComponent <SpriteRenderer>(); player = GameObject.Find("Player"); playerStance = player.GetComponent <Stances>(); }
public static States GetState(Context context, States currentState, Stances currentStance, int size, bool matured) { // check for STANCE change Stances newStance = UpdateStance(currentStance, size, matured); // check for STATE change int contextFPrint = context.fPrint; // TODO HERE - calculate selfFPrint based on size and stance; then compare to contextFPrint }
void Start() { gravity = Physics.gravity; playerView = Camera.main; rb = GetComponent <Rigidbody> (); rotSpeed = 40; myStance = Stances.standing; }
private void Start() { oldSprite = this.GetComponent <SpriteRenderer>().sprite; player = GameObject.Find("Player"); stance = player.GetComponent <Stances>(); gameController = GameObject.Find("GameController"); script = gameController.GetComponent <GameController>(); }
public void TestStanceDef() { Character toon = new Character(); toon.SetBaseStat(Stat.Dexterity, 25); toon.SetBaseStat(Stat.Intelligence, 145); toon.Stance = Stances.Get("HealerDefense", 20); // defense +17% tt Assert.That(toon.Defense, Is.EqualTo(59)); toon.Stance = Stances.Get("HealerOffense", 25); // defense -19% tt Assert.That(toon.Defense, Is.EqualTo(41)); }
void Awake() { hp = get_hpMax_actual(); mp = get_mpMax_actual(); status = new Stances(); status.set_to_default(); focus.focus_setup(this); //equipTypes = new int[3]; //passiveEquipped = new Passive(); //nextMove = new PlayerMove(); }
private void Abort() { CurrentStance = Stances.Idle; TerminateSend = true; SenderInitialized = false; Aborted = true; Port.DataReceived -= Port_DataReceived; // Usuniecie zbednego eventu WaitForResponseFromReceiver.Set(); // Jesli dane sa wysylane, przestajemy oczekiwac na odpowiedzi odbiornika SenderPacketResponseWatchdog?.Change(Timeout.Infinite, Timeout.Infinite); Port.DiscardInBuffer(); // Wyczysc dane portu Port.DiscardOutBuffer(); }
public static void ChangeStance(this ActorExt actor, Stances stance, byte skillSession, uint additionID, int stance2 = -1) { if (actor.Status.Stance != stance) { actor.Status.Stance = stance; UpdateEvent evt = UpdateEvent.NewActorAdditionEvent(actor, actor, skillSession, 0, additionID, UpdateEvent.ExtraUpdateModes.None); //evt.AddActorPara(PacketParameter.Stance, (int)stance); if (stance2 >= 0) { //evt.AddActorPara(PacketParameter.Stance2, stance2); MapManager.Instance.GetMap(actor.MapInstanceID).SendEventToAllActorsWhoCanSeeActor(MapEvents.EVENT_BROADCAST, evt, actor, true); } } }
void Start() { camObject = transform.GetChild(0); rb = gameObject.GetComponent <Rigidbody> (); levMan = GameObject.Find("LevelManager").GetComponent <LevelManager>(); //actionText = GameObject.Find("ActionText").GetComponent<Text>(); myStance = Stances.standing; rotControl = new GameObject("RotationControl"); rotControl.transform.position = transform.position; rotControl.transform.Rotate(rotControl.transform.right, -90f, Space.Self); rotControl.transform.parent = transform; }
private void Abort() { CurrentState = Stances.Inactive; Aborted = true; Port.DataReceived -= Port_DataReceived; if (ReceiverFileInitiationTimer != null) { ReceiverFileInitiationTimer.Change(Timeout.Infinite, Timeout.Infinite); } if (ReceiverStillAliveWatchdog != null) { ReceiverStillAliveWatchdog.Change(Timeout.Infinite, Timeout.Infinite); } Port.DiscardInBuffer(); Port.DiscardOutBuffer(); }
private static Stances UpdateStance(Stances currentStance, int size, bool matured) { int stanceUpperBound = StanceData.StanceBounds[(int)currentStance, 0]; int stanceLowerBound = StanceData.StanceBounds[(int)currentStance, 1]; int newStanceIndex = 0; // are we NOT a berserk AND are we above the upper bound? if (currentStance != Stances.Berserk && size > stanceUpperBound) { // move one stance up newStanceIndex = (int)currentStance + 1; } // if we are NOT a coward AND are we matured AND are we below the lower bound? if (currentStance != Stances.Coward && matured && size <= stanceLowerBound) { // move one stance down newStanceIndex = (int)currentStance - 1; } return((Stances)newStanceIndex); }
private void TransmitPacket() { byte[] checkValueBytes; // pojemnik na CRC ushort checkValueShort = CRC.ComputeChecksum(DataPacketToSend); checkValueBytes = UShortToBytes(checkValueShort); byte packetSizeHeader; // rozmiar pakietu packetSizeHeader = SOH; PacketSuccessfullySent = false; while (PacketSuccessfullySent == false && TerminateSend == false) { Port.Write(new byte[] { packetSizeHeader }, 0, 1); // Naglowek Port.Write(new byte[] { _BlockNumToSend }, 0, 1); // liczba bloku Port.Write(new byte[] { (byte)(255 - _BlockNumToSend) }, 0, 1); // Uzupelniona liczba bloku Port.Write(DataPacketToSend, 0, DataPacketToSend.Length); // Wyslij pakiet WaitForResponseFromReceiver.Reset(); CurrentStance = Stances.SenderPacketSent; Port.Write(checkValueBytes, 0, checkValueBytes.Length); // Wyslij CRC WaitForResponseFromReceiver.WaitOne(); // Oczekiwanie na ACK/NAK WaitForResponseFromReceiver.Reset(); } }
public void TestArmorDef() { Character toon = new Character(); toon.SetBaseStat(Stat.Dexterity, 25); toon.SetBaseStat(Stat.Intelligence, 145); // perfect conc pot: toon.AddEffect(Effects.Get("Blessing of Dexterity", 40)); toon.AddEffect(Effects.Get("Blessed Protection", 40)); toon.AddEffect(Effects.Get("Prayer of Protection", 40)); toon.AddEffect(Effects.Get("Charm of Illumination (Spirit)", 40)); toon.AddEffect(Effects.Get("Charm of Illumination (Intelligence)", 40)); toon.Stance = Stances.Get("HealerDefense", 20); toon.TrainSkill("Wear Armor, Light", 61); Assert.That(toon.GetSkill("Wear Armor, Light").UnbuffedSkill, Is.EqualTo(100m)); Assert.That(toon.GetSkillValue("Wear Armor, Light"), Is.EqualTo(118m)); toon.EquipItem(Equipments.Get("Hunting Leather Hood", "Aegis", null)); Assert.That(toon.Dexterity, Is.EqualTo(85)); Assert.That(toon.Defense, Is.EqualTo(484)); toon.EquipItem(Equipments.Get("Hunting Leather Vest", "Aegis", null)); Assert.That(toon.Defense, Is.EqualTo(677)); toon.EquipItem(Equipments.Get("Hunting Leather Sleeves", "Aegis", null)); Assert.That(toon.Defense, Is.EqualTo(768)); toon.EquipItem(Equipments.Get("Hunting Leather Leggings", "Aegis", null)); Assert.That(toon.Defense, Is.EqualTo(899)); toon.EquipItem(Equipments.Get("Hunting Leather Boots", "Aegis", null)); Assert.That(toon.Defense, Is.EqualTo(980)); toon.EquipItem(Equipments.Get("Hunting Leather Gloves", "Aegis", null)); //Todo: armor dex penalty is throwing this off Warn.Unless(toon.Dexterity, Is.EqualTo(88)); Warn.Unless(toon.Defense, Is.EqualTo(1061)); }
public int Send(byte[] dataToSend = null) { SendInit(); //inicjalizacja danych przed rozpoczeciem wysylania, konstruktor wysylania Aborted = false; _BlockNumToSend = 1; // Obecny numer bloku wychodzacego PacketSuccessfullySent = false; DataPacketToSend = null; NumUserDataBytesAddedToCurrentPacket = 0; _TotalUserDataBytesSent = 0; _NumCancellationBytesReceived = 0; TerminateSend = false; EndOfFileAcknowledgementReceived = false; SenderInitialized = true; // zabezpiecznie blokujace wywolanie AddToOutboundPacket() przed Send() WaitForResponseFromReceiver.Reset(); CurrentStance = Stances.SenderAwaitingFileInitiation; if (Port.IsOpen == false) // Jesli port jest zamkniety, to otworz { Port.Open(); } Port.DiscardInBuffer(); Port.DiscardOutBuffer(); Port.DataReceived += Port_DataReceived; // dodaj event odbioru WaitForResponseFromReceiver.WaitOne(); // oczekiwanie na bit potwierdzenia rozpoczecia transferu od odbiornika WaitForResponseFromReceiver.Reset(); if (dataToSend != null && Aborted == false) { AddToOutboundPacket(dataToSend); if (TerminateSend == false) { EndFile(); } return(_TotalUserDataBytesSent); } return(0); }
private void Start() { scriptStances = GetComponent <Stances>(); }
IEnumerator RollRoutine() { yield return new WaitForSeconds((1f / 30f) * 15); overrideMovement = Vector3.zero; overrideRotation = Vector3.zero; stance = Stances.Stand; }
private void ReceiverPacketBuilder(byte[] freshBytes) { if (freshBytes.Length == 0) { return; } if (Remainder.Length > 0 && CurrentState == Stances.ReceiverHeaderSearch) { BytesToParse = CombineArrays(Remainder, freshBytes); } else { BytesToParse = freshBytes; } int headerByteSearchStartIndex = 0; int searchStartIndex = 0; while (searchStartIndex < BytesToParse.Length && headerByteSearchStartIndex < BytesToParse.Length) { if (CurrentState == Stances.ReceiverHeaderSearch) { if (Remainder.Length > 0) { Remainder = new byte[0]; } if (BytesToParse[headerByteSearchStartIndex] == EOT) { SendACK(); Abort(); if (PacketReceived != null && ValidPacketReceived && DataPacketReceived != null && DataPacketReceived.Length > 0) { PacketReceived(this, DataPacketReceived, true); } ReceiverUserBlock.Set(); return; } else { if (PacketReceived != null && ValidPacketReceived == true && DataPacketReceived != null && DataPacketReceived.Length > 0) { PacketReceived(this, DataPacketReceived, false); } } ValidPacketReceived = false; int foundIndex = Array.IndexOf(BytesToParse, SOH, headerByteSearchStartIndex); if (foundIndex == -1) // Nie znaleziono naglowka { return; } else if (foundIndex > -1) { headerByteSearchStartIndex = foundIndex + 1; ExpectedDataPacketSize = PacketSize; searchStartIndex = foundIndex + 1; CurrentState = Stances.ReceiverBlockNumSearch; continue; } } if (CurrentState == Stances.ReceiverBlockNumSearch) { BlockNumReceived = BytesToParse[searchStartIndex]; if (BlockNumReceived == SOH) { Remainder = new [] { BlockNumReceived }; // Inicjalizacja remindera } searchStartIndex += 1; CurrentState = Stances.ReceiverBlockNumComplementSearch; continue; } if (CurrentState == Stances.ReceiverBlockNumComplementSearch) { BlockNumComplementCandidateReceived = BytesToParse[searchStartIndex]; if (BlockNumComplementCandidateReceived == 255 - BlockNumReceived) { if (Remainder.Length > 0) { Remainder = new byte[0]; } DataPacketReceived = new byte[ExpectedDataPacketSize]; DataPacketNumBytesStored = 0; searchStartIndex += 1; CurrentState = Stances.ReceiverDataBytesSearch; continue; } else { if (Remainder.Length > 0 && BlockNumReceived == SOH) { Remainder = CombineArrays(Remainder, new [] { BlockNumComplementCandidateReceived }); // Uzupelnianie remindera } CurrentState = Stances.ReceiverHeaderSearch; continue; } } if (CurrentState == Stances.ReceiverDataBytesSearch) { int numUnparsedBytesRemaining = BytesToParse.Length - searchStartIndex; int numDataPacketBytesStillMissing = DataPacketReceived.Length - DataPacketNumBytesStored; int numDataBytesToPull; if (numUnparsedBytesRemaining >= numDataPacketBytesStillMissing) { numDataBytesToPull = numDataPacketBytesStillMissing; } else { numDataBytesToPull = numUnparsedBytesRemaining; } Array.Copy(BytesToParse, searchStartIndex, DataPacketReceived, DataPacketNumBytesStored, numDataBytesToPull); DataPacketNumBytesStored += numDataBytesToPull; searchStartIndex += numDataBytesToPull; if (DataPacketNumBytesStored >= ExpectedDataPacketSize) { CurrentState = Stances.ReceiverErrorCheckSearch; ErrorCheck = new byte[0]; } continue; } if (CurrentState == Stances.ReceiverErrorCheckSearch) { if (ErrorCheck.Length < 2) { ErrorCheck = CombineArrays(ErrorCheck, new byte[] { BytesToParse[searchStartIndex] }); } if (ErrorCheck.Length >= 2) { ValidatePacket(); headerByteSearchStartIndex = searchStartIndex + 1; CurrentState = Stances.ReceiverHeaderSearch; } else { searchStartIndex += 1; } } } }
IEnumerator AttackRoutine(Attacks attack, int animMoveFrame, int animRollFrame, int animAttackFrame, int animParryFrame) { prevAttack = attack; stance = Stances.Stand; nextMoveTime = Time.time + (1f / 30f) * animMoveFrame; nextRollTime = Time.time + (1f / 30f) * animRollFrame; nextAttackTime = Time.time + (1f / 30f) * animAttackFrame; nextParryTime = Time.time + (1f / 30f) * animParryFrame; CmdAnimAttack((int)attack); yield return new WaitForSeconds((1f / 30f) * animMoveFrame); prevAttack = Attacks.Right; overrideRotation = Vector3.zero; }
void Roll() { if (!AllowRoll) return; if (Input.GetKeyDown(KeyCode.Space) && inputVector != Vector3.zero) { if (weaponMain != null) weaponMain.GetComponent<WeaponMelee>().weaponTrail.SetActive(false); prevAttack = Attacks.Right; stance = Stances.Roll; overrideRotation = inputVector.normalized; overrideMovement = overrideRotation * moveSpeedRoll; nextMoveTime = Time.time + (1f / 30f) * 20; nextRollTime = Time.time + (1f / 30f) * 20; nextAttackTime = Time.time + (1f / 30f) * 20; nextParryTime = Time.time + (1f / 30f) * 20; CmdAnimRoll(); StopAllCoroutines(); StartCoroutine(RollRoutine()); } }
void ChangeIncline() { if (myStance == Stances.standing) { Ray reachForWall = new Ray(transform.position, transform.forward); RaycastHit reachedWall; Debug.DrawRay(transform.position, transform.forward); if (Physics.Raycast(reachForWall, out reachedWall, 1.0f)) { //Climbing from floor(standing) to wall(crawling) if (reachedWall.collider.CompareTag("Wall")) { Debug.Log("Press G to crawl onto the wall"); if (Input.GetKeyDown(KeyCode.G)) { StickToSurface(-reachedWall.normal * 9.8f); StartCoroutine(ChangingSurface(reachedWall, Vector3.Normalize(rb.transform.forward))); myStance = Stances.crawling; } } else if (reachedWall.collider.CompareTag("ExitDoor")) { GameObject hitDoor = reachedWall.collider.gameObject; Debug.Log("Press R to open the door"); if (Input.GetKeyDown(KeyCode.R)) { /* Position player in front of door */ //StartCoroutine(MoveToDoor (reachedWall)); //StickToSurface (Vector3.down*9.8f); //Switch to "Lock" scene EventSystem.current.enabled = false; SceneManager.LoadSceneAsync("Test_Door_Keypad", LoadSceneMode.Additive); SceneManager.MoveGameObjectToScene(hitDoor.transform.parent.gameObject, SceneManager.GetSceneByName("Test_Door_Keypad")); SceneManager.MoveGameObjectToScene(gameObject, SceneManager.GetSceneByName("Test_Door_Keypad")); /* Disable player movement/rotation Input and enable door Input * * Offer a button input to allow player to step back away from door and resume movement/rotation/etc. in current room * Will this wipe away any failed attempts on the door, or are they persistent? */ } } else if (reachedWall.collider.CompareTag("DisplayCase")) { Debug.Log("Press R to open the display case"); if (Input.GetKeyDown(KeyCode.R)) { Debug.Log("You attempted to open the display case"); } } } Ray reachForFloor = new Ray(transform.position, -transform.up); RaycastHit reachedFloor; Debug.DrawRay(transform.position, -transform.up); if (Physics.Raycast(reachForFloor, out reachedFloor, 1.0f)) { //Input to Crawl if (Input.GetKeyDown(KeyCode.LeftControl)) { StartCoroutine(ChangingSurface(reachedFloor, Vector3.Normalize(rb.transform.forward))); myStance = Stances.crawling; //playerView.rotate (Vector3.up * 90); Debug.Log("Crawling"); } } } else if (myStance == Stances.crawling) { Ray reachForSky = new Ray(transform.position, transform.up); RaycastHit reachedSky; Debug.DrawRay(transform.position, transform.up); if (Physics.Raycast(reachForSky, out reachedSky, 1.0f)) { if (reachedSky.collider.CompareTag("Wall") || reachedSky.collider.CompareTag("Floor") || reachedSky.collider.CompareTag("Ceiling")) { Debug.Log("Press G to crawl onto the wall"); if (Input.GetKeyDown(KeyCode.G)) { StickToSurface(-reachedSky.normal * 9.8f); StartCoroutine(ChangingSurface(reachedSky, Vector3.Normalize(rb.transform.forward))); } } else if (reachedSky.collider.CompareTag("ExitDoor")) { Debug.Log("Press R to open the door"); if (Input.GetKeyDown(KeyCode.R)) { myStance = Stances.standing; StartCoroutine(MoveToDoor(reachedSky)); StickToSurface(Vector3.down * 9.8f); } } } Ray reachDown = new Ray(transform.position, transform.forward); RaycastHit reachedDown; Debug.DrawRay(transform.position, transform.forward); if (Physics.Raycast(reachDown, out reachedDown, 1.0f)) { //Input to Stand if (Input.GetKeyDown(KeyCode.LeftControl)) { if (reachedDown.collider.CompareTag("Floor")) { StartCoroutine(ChangingSurface(reachedDown, Vector3.Normalize(-rb.transform.up))); myStance = Stances.standing; Debug.Log("Standing"); } else if (reachedDown.collider.CompareTag("Ceiling")) { StickToSurface(reachedDown.normal * 9.8f); StartCoroutine(ChangingSurface(reachedDown, Vector3.Normalize(rb.transform.up))); myStance = Stances.standing; Debug.Log("Dropping from ceiling"); } } } } }
void Sprint() { if (!AllowMove) return; if (Input.GetKey(KeyCode.LeftShift) && stance != Stances.Sprint) stance = Stances.Sprint; else if (!Input.GetKey(KeyCode.LeftShift) && stance == Stances.Sprint) stance = Stances.Stand; }