void Awake() { animator = GetComponent <Animator> (); rbody = GetComponent <Rigidbody> (); rbody.constraints = RigidbodyConstraints.FreezeRotation; meshRender = GetComponent <SkinnedMeshRenderer> (); capsule = GetComponent <CapsuleCollider> (); height = Height.Mid; startingHeight = Height.Mid; playerState = FSM.Fence; isDead = false; controlState = new PlayerControlState(); otherplayers = GetOtherPlayers(); gameController = FindObjectOfType <GameController>(); swordChecker = GetComponentInChildren <CheckForSwords> (); AttachNewSword(); tryToThrowSword = false; tryToCrouch = false; tryThrowSwordPos = swordInitPos + (swordHeightIncrement * Vector3.up) + (-5 * Vector3.right); /*Object sh = Instantiate (shadowPrefab); * CastShadow csh = ((GameObject)sh).GetComponent<CastShadow> (); * csh.casterPos = transform;*/ }
public void ChangeState(PlayerControlState state) { upgradeTowerButton.SetActive(false); randomTowerIcon.gameObject.SetActive(false); randomTowerButton.SetActive(false); randomTowerIconBG.SetActive(false); switch (state) { case PlayerControlState.Idle: randomTowerButton.SetActive(true); break; case PlayerControlState.PlacingTower: randomTowerIcon.gameObject.SetActive(true); randomTowerIconBG.SetActive(true); int type = (int)PlayerControlManager.S.GetRandomSelectedTower(); randomTowerIcon.sprite = towerIcons[type]; break; case PlayerControlState.TowerSelected: upgradeTowerButton.SetActive(true); break; } }
void Awake() { gameController = FindObjectOfType <GameController> (); character = GetComponent <CharController>(); playerID = character.playerid; cam = Camera.main.transform; controlState = new PlayerControlState(); }
public void SetPlayerState(PlayerControlState pcs, bool useRecord = true) { if (useRecord) { ((FirstViewDataEntity)FirstViewControlDataModel.instance.DataEntity).playerState = (int)pcs; } else { playerState = pcs; } }
public DungeonControls(RLRootConsole rootConsole) { _rootConsole = rootConsole; pressedKeys = new List <RLKey>(); controlState = PlayerControlState.Normal; controls = new Dictionary <PlayerControlState, Func <RLKey, bool> >() { { PlayerControlState.Debug, Debug }, { PlayerControlState.Normal, Normal }, { PlayerControlState.LightAttack, LightAttack }, { PlayerControlState.MediumAttack, MediumAttack } }; }
public void SwitchToGameMenu() { pc.left = false; pc.right = false; pc.up = false; pc.down = false; mm.left = false; mm.right = false; mm.up = false; mm.down = false; mm.back = false; mm.forth = false; thisPlayerControlState = PlayerControlState.Menu; }
void ChangeState(PlayerControlState _state) { state = _state; switch (state) { case PlayerControlState.Idle: break; case PlayerControlState.PlacingTower: break; case PlayerControlState.TowerSelected: break; } UIManager.S.ChangeState(state); }
public bool CheckInput(RLKeyPress keyPress) { RLKey key = keyPress.Key; map = GameController.CurrentMap; bool didPlayerAct = false; //check if pressedKeys is still up to date for (int i = 0; i < pressedKeys.Count; i++) { RLKey k = pressedKeys[i]; if (Keyboard.GetState().IsKeyUp((Key)k)) { pressedKeys.Remove(k); i--; } } //Add currently pressed key to the list if (!pressedKeys.Contains(key)) { pressedKeys.Add(key); } lastDirection = CheckDirection(key); controlState = CheckForState(); foreach (var control in controls) { if (control.Key.Equals(controlState)) { didPlayerAct = control.Value(key); } } if (didPlayerAct) { //Add the player back into scheduling system, after taking an action(and getting a new speed) GameController.SchedulingSystem.Add(player); GameController.EndPlayerTurn(); } controlState = ResetState(); return(didPlayerAct); }
IEnumerator GameScript() { pc.GetComponent <CharInventory>().weapons.Add(new Weapon("SOCOM MK2", 35, 5, AmmoType.Nine)); thisPlayerControlState = PlayerControlState.Player; yield return(new WaitForSeconds(3f)); mm.radioConversationAvailable = true; mm.radiosWithDialogue.Add(120.85f, 01f); mm.transceiverFreq = 120.85f; while (true) { if (thisPlayerControlState == PlayerControlState.Radio && GetComponent <MenuManager>().inConvo) { if (mm.currentTextLine == (mm.textList.Count - 1)) { break; } } yield return(new WaitForEndOfFrame()); } mm.radiosWithDialogue.Remove(120.85f); mm.radiosWithDialogue.Add(120.85f, 02f); while (true) { if (thisPlayerControlState == PlayerControlState.Radio && mm.inConvo) { if (mm.currentTextLine == (mm.textList.Count - 1)) { break; } } yield return(new WaitForEndOfFrame()); } }
private void DetermineControlState() { controlState = isFacingRight ? PlayerControlState.IdleRight : PlayerControlState.IdleLeft; if (isHit) { controlState = isFacingRight ? PlayerControlState.HitRight : PlayerControlState.HitLeft; return; } if (isUnderthrusting) { controlState = PlayerControlState.Underthrust; return; } if (isOverthrusting) { controlState = PlayerControlState.Overthrust; return; } if (isAttacking) { // If crouching, use crouch attack animation. if (isCrouching) { controlState = isFacingRight ? PlayerControlState.CrouchAttackRight : PlayerControlState.CrouchAttackLeft; } // Jumping/Falling attacks use the crouch attack animation. else if (_movement.MovementType != SidescrollingMovementType.Grounded && _movement.MovementType != SidescrollingMovementType.Hit) { controlState = isFacingRight ? PlayerControlState.CrouchAttackRight : PlayerControlState.CrouchAttackLeft; } // Otherwise use standing animation. else { controlState = isFacingRight ? PlayerControlState.AttackRight : PlayerControlState.AttackLeft; } return; } if (isCrouching) { controlState = isFacingRight ? PlayerControlState.CrouchRight : PlayerControlState.CrouchLeft; return; } if (isJumping) { controlState = isFacingRight ? PlayerControlState.JumpRight : PlayerControlState.JumpLeft; return; } if (isMovingHorizontally) { switch (_movement.MovementType) { case SidescrollingMovementType.Grounded: controlState = isFacingRight ? PlayerControlState.WalkRight : PlayerControlState.WalkLeft; break; case SidescrollingMovementType.Falling: controlState = isFacingRight ? PlayerControlState.FallRight : PlayerControlState.FallLeft; break; } return; } }
public void UpdateCharacter(PlayerControlState newControlState) { controlState = newControlState; //vXZ = Vector3.ProjectOnPlane(rbody.velocity, groundNormal); vXZ = Vector3.ProjectOnPlane(rbody.velocity, Vector3.up); lastFrameThrowSword = tryToThrowSword; tryToThrowSword = (controlState.heightHeldLongEnough && controlState.heightHold == 1); tryToCrouch = (controlState.heightHeldLongEnough && controlState.heightHold == -1); // handle sword height, if a sword is attached if (attachedSword) { if (controlState.heightChange != 0) { height += controlState.heightChange; height = (Height)Tools.Clamp((int)height, (int)Height.Low, (int)Height.High); } attachedSword.SendMessage("Activate", playerState == FSM.Stab || (playerState == FSM.Fence && !tryToThrowSword)); // this might be very slow //attachedSword.SendMessage ("Activate", playerState == FSM.Fence || playerState == FSM.Stab); // this might be very slow if (tryToThrowSword) { attachedSword.transform.localPosition = tryThrowSwordPos; attachedSword.transform.localRotation = tryThrowSwordRot; } else { if (lastFrameThrowSword) { attachedSword.transform.localPosition = new Vector3(swordInitPos.x, SwordHeightPos(), swordInitPos.z); attachedSword.transform.localRotation = swordLocalRot; } Vector3 pos = attachedSword.transform.localPosition; Vector3 newpos = new Vector3(pos.x, SwordHeightPos(), pos.z); //** there are probably more natural-looking interpolation curves for this than asymptotic-exponential attachedSword.transform.localPosition = Vector3.Lerp(pos, newpos, 30 * Time.deltaTime); attachedSword.transform.localRotation = swordLocalRot; bool isMoving = Mathf.Abs(pos.y - newpos.y) > 0.01 * swordHeightIncrement; attachedSword.SetDisarmStatus(isMoving, (int)startingHeight); if (!isMoving) // if you've finished moving, your starting height is the current height { startingHeight = height; } } } else if (controlState.heightChange == -1) // try to pick up a sword if you aren't holding one { Sword s = swordChecker.FirstElement(); if (s != null) { AttachSword(s); } } switch (playerState) { case FSM.Fence: LookAtNearestPlayer(); DoFence(); break; case FSM.Stab: LookAtNearestPlayer(); DoStab(); break; case FSM.Run: LookAtLastVelocity(); DoRun(); break; case FSM.Jump: if (tryToThrowSword) { LookAtNearestPlayer(); } else { LookAtLastVelocity(); } DoJump(); break; case FSM.Dead: DoDead(); break; } }