void Awake() { controllerScript = GetComponent <PlayerFSM>(); DontDestroyOnLoad(gameObject); StartCoroutine(GetGameManager()); // 생성시 photonview 시간차로 코루틴으로 gameManager 얻음 }
private void Setup(PlayerFSM player) { leftGround = false; player.coyoteTimer = 0; player.bunnyHopTimer = 0; waitAnimations = new string[] { "PlayerJump", "PlayerAttacking", "PlayerAttackingBoosted", "PlayerAppear" }; }
public IEnumerator player_can_walk_to_the_left() { // ~~~~~~~~~~ // Load LoadTestScene(); yield return(new WaitWhile(() => sceneLoaded == false)); // ~~~~~~~~~~ // Prepare var playerAsset = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Prefabs/Characters/PlayerFSM.prefab"); GameObject player = GameObject.Instantiate(playerAsset, new Vector3(0, 0, 0), Quaternion.identity); PlayerFSM playerScript = player.GetComponent <PlayerFSM>(); playerScript.ignoreCheckpoints = true; playerScript.mechanics.SaveState(); playerScript.mechanics.ResetMechanics(); playerScript.mechanics.Activate("Walk"); yield return(new WaitForSeconds(0.3f)); // Act var initialX = player.transform.position.x; InputSimulator IS = new InputSimulator(); IS.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.LEFT); yield return(new WaitForSeconds(1f)); // Assert Assert.IsTrue(player.transform.position.x < initialX); playerScript.mechanics.RestoreState(); }
public void PlayerWait(PlayerFSM player) { player.TransitionToState(player.InWindowState); player.InWindowState.OnWindowExit.AddListener(ExitWindow); spriteRenderer.sprite = openedWithRopeWithPlayerSprite; currentWindowExitState = WindowExitState.PlayerInside; }
public virtual bool CheckTransitionToDashing(PlayerFSM player) { if (!player.mechanics.IsEnabled("Dash")) { return(false); } if (!player.canDash) { return(false); } if (!player.hasResetDashTrigger) { return(false); } if (player.dashCooldownTimer > 0) { return(false); } // GamePad || Keyboard if (Input.GetAxisRaw("Dash") > 0 || Input.GetButtonDown("Dash")) { player.TransitionToState(player.DashingState); return(true); } return(false); }
void Awake() { controllerScript = GetComponent <PlayerFSM>(); DontDestroyOnLoad(gameObject); StartCoroutine(SetupGameManager()); }
// Start is called before the first frame update void Start() { go_Player = GameObject.Find("Player"); pfsm = go_Player.GetComponent <PlayerFSM>(); radius = rect_Background.rect.width * 0.5f; }
public override void EnterState(PlayerFSM player) { Setup(player); PlayAnimation(player); PlayParticles(player); WallJumpAction(player); }
private void Setup(PlayerFSM player) { player.canDoubleJump = true; player.canDash = true; wallJumpTimer = player.config.startWallJumpDurationTime; base.SetLookingDirectionOppositeOfWall(player); }
private void SetPlayerVerticalVelocity(PlayerFSM player) { float yVelocity = player.rb.velocity.y + upwardsVelocityBoost; float yVelocityClamped = Mathf.Clamp(yVelocity, 0f, maxPlayerVelocity); player.rb.velocity = new Vector2(player.rb.velocity.x, yVelocityClamped); }
private void Start() { if (player == null) { player = GameObject.FindObjectOfType <PlayerFSM>(); } }
private Vector3 CalculateDirection(PlayerFSM player) { float xInput = Input.GetAxisRaw("Horizontal"); float yInput = Input.GetAxisRaw("Vertical"); return(base.GetFourDirectionalInput(player, xInput, yInput)); }
private void Setup(PlayerFSM player) { startWalkParticlesCooldownTime = player.config.startWalkParticlesCooldownTime; startCoyoteDurationTime = player.config.startCoyoteDurationTime; player.walkParticlesCooldownTimer = 0f; waitAnimations = new string[] { "PlayerWalk", "PlayerAttacking", "PlayerAttackingBoosted", "PlayerExploding", "PlayerAppear" }; }
public override void onCreate(EntityInfo data) { base.onCreate(data); fsm = new PlayerFSM(this); onChangeState(StateType.spawn); this.BillBoard.setColorByType(PartType.namePart, Color.green); }
private void ShakeCamera(PlayerFSM player) { float shakeDuration = player.config.explosionShakeDuration; float shakeMagnitude = player.config.explosionShakeMagnitude; Manager.shaker.Shake(player.cameraObj, shakeDuration, shakeMagnitude); }
public void Interact(PlayerFSM player) { if (!canBeOpened) { return; } switch (windowEnterState) { case WindowEnterState.Closed: OpenWindow(); windowEnterState = WindowEnterState.Opened; break; case WindowEnterState.Opened: if (player.Inventory.HasItem(typeof(Rope)) && windowExit != null) { SetRope(player); windowEnterState = WindowEnterState.OpenedWithRope; } break; case WindowEnterState.PlayerInside: break; case WindowEnterState.OpenedWithRope: if (windowExit != null) { StartCoroutine(EnterWindowAnimation(player)); } break; } }
void Awake() { player = GameObject.FindGameObjectWithTag("Player").transform; finish = GameObject.FindGameObjectWithTag("Finish").transform; camera = GameObject.FindGameObjectWithTag("MainCamera").transform; _playerFSM = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerFSM>(); }
public void ClearMechanics(GameObject playerObj) { PlayerFSM player = playerObj.GetComponent <PlayerFSM>(); player.mechanics.ResetMechanics(); player.mechanics.EnableBasicMechanics(); }
// Use this for initialization void Awake() { anim = transform.parent.GetComponent <Animator>(); state = transform.GetComponent <BossState>(); hp = transform.parent.GetComponent <HP>(); bossPage = 1; playerGroundCheck = false; playerMove = player.GetComponent <PlayerMove>(); playerFsm = player.transform.GetChild(0).GetComponent <PlayerFSM>(); oldHp = hp.hp; Boss_State[] stateValues = (Boss_State[])System.Enum.GetValues(typeof(Boss_State)); foreach (Boss_State s in stateValues) { System.Type FSMType = System.Type.GetType("Boss" + s.ToString()); BossFSMState state = (BossFSMState)GetComponent(FSMType); if (null == state) { state = (BossFSMState)gameObject.AddComponent(FSMType); } _states.Add(s, state); state.enabled = false; } }
void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag.Contains("GesturePrefab")) { if (coll.contacts[0].normal.y < -0.9f) { Rigidbody2D rigid = coll.rigidbody; if (rigid.mass > 1.5f) { if (!b_hasTriggered) { b_hasTriggered = true; iTween.ScaleTo(this.gameObject, Vector3.zero, 0.75f); SoundManager.SharedInstance.PlayClip("EnemyDestroy"); Destroy(this.gameObject, 0.8f); } } } else { EventHandler.TriggerEvent(EEventID.EVENT_GESTURE_OBJET_DESTROY, coll.gameObject); } } if (coll.gameObject.tag == "Player") { PlayerFSM player = coll.gameObject.GetComponent <PlayerFSM>(); if (player != null) { player.ChangeState(player.deadState); } } }
public PlayerJumpState(PlayerFSM player) { Player = player; StateName = PLAYERSTATE.JUMP; jumpForce = new Vector2(0f, Player.JumpMagnitude); }
private void CheckForAirJumpInputBuffer(PlayerFSM player) { if (Input.GetButtonDown("Jump")) { player.airJumpInputBufferTimer = player.config.startAirJumpInputBufferTime; } }
private void BlinkAction(PlayerFSM player) { Vector3 blinkDirection = base.GetFourDirectionalInput(player, xInput, yInput); Vector3 destinationPosition = ValidDestinationPosition(player, blinkDirection); player.transform.Translate(destinationPosition); }
public override void EnterState(PlayerFSM player) { Setup(player); PlayAnimation(player); PlayAudio(); DashAction(player); }
public override void FixedUpdate(PlayerFSM player) { CheckForAirJumpInputBuffer(player); if (dashTimer > 0) { dashTimer -= Time.deltaTime; return; } StopDashing(player); if (base.CheckTransitionToGunBoots(player)) { return; } if (base.CheckTransitionToGrounded(player)) { return; } if (base.CheckTransitionToDoubleJumping(player)) { return; } if (CheckTransitionToWallSliding(player)) { return; } if (CheckTransitionToFalling(player)) { return; } }
void Awake() { player = GameObject.Find("Player"); mRb2d = gameObject.GetComponent <Rigidbody2D>(); target = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); anim = transform.GetComponent <Animator>(); state = transform.GetComponent <MonsterState>(); hp = transform.GetComponent <HP>(); rb = transform.GetComponent <Rigidbody2D>(); playerMove = player.GetComponent <PlayerMove>(); playerFsm = player.transform.GetChild(0).GetComponent <PlayerFSM>(); Monster_State[] stateValues = (Monster_State[])System.Enum.GetValues(typeof(Monster_State)); foreach (Monster_State s in stateValues) { System.Type mFSMType = System.Type.GetType("Monster" + s.ToString()); MonsterFSMState state = (MonsterFSMState)GetComponent(mFSMType); if (null == state) { state = (MonsterFSMState)gameObject.AddComponent(mFSMType); } _states.Add(s, state); state.enabled = false; } }
public override void OnAssignFSM(PlayerFSM FSM) { this.FSM = FSM; rb = FSM.rb; inputController = FSM.InputController; Start(); }
public new void OnEnable() { base.OnEnable(); if (playerFsm == null) { playerFsm = WeaponBase.instance.player; } }
private void OnCollisionStay2D(Collision2D other) { if (other.gameObject.CompareTag("Player")) { PlayerFSM player = other.gameObject.GetComponent <PlayerFSM>(); player.TransitionToState(player.DyingState); } }
public PlayerWallAttackState(PlayerFSM stateMachine, Player player) { _stateMachine = stateMachine; _player = player; _movement = player.Movement; _weaponSystem = player.WeaponSystem; }
protected override void Awake () { base.Awake(); _player = GameObject.FindGameObjectWithTag("Player").transform; _playerFSM = _player.GetComponent<PlayerFSM>(); waypoints = waypoint.GetComponentsInChildren<Transform>(); sight = GetComponentInChildren<Camera>(); }
void Start() { this.totalCoins = 0; this.velocity = new Vector2 (0.15f, 0); this.gravity = new Vector2 (0, -0.01f); this.fsm = new PlayerFSM (this); this.fsm.start (); }
public Sliding(PlayerFSM fsm, PlayerBehaviour character) : base(fsm, character) { this.animation = new SlidingAnimation (this.character.gameObject); }
public PlayerState(PlayerFSM fsm, PlayerBehaviour character) { this.fsm = fsm; this.character = character; }
void Init () { //玩家属性 player_characrer = GetComponent<PlayerCharacter> (); if (player_characrer == null) player_characrer = gameObject.AddComponent<PlayerCharacter> (); //玩家生命魔法 player_health = GetComponent<PlayerHealth> (); if (player_health == null) player_health = gameObject.AddComponent<PlayerHealth> (); player_health.deathDelegate = new Callback(Death); //玩家攻击受击 player_attack = GetComponent<PlayerAttack> (); if (player_attack == null) player_attack = gameObject.AddComponent<PlayerAttack> (); //玩家AI player_AI = GetComponent<PlayerAI> (); if (player_AI == null) player_AI = gameObject.AddComponent<PlayerAI> (); player_AI.activeAI = false; //搜索敌人 seclectTarget = GetComponent<SeclectTargetting> (); if (seclectTarget == null) seclectTarget = gameObject.AddComponent<SeclectTargetting> (); //动画管理器 animator = GetComponent<Animator> (); if (animator == null) Debug.LogError ("PlayerController Init Error Animator is Null"); //Animator HashIDs hashIDs = GetComponent<AnimatorHashIDs>(); if(hashIDs = null) hashIDs = gameObject.AddComponent<AnimatorHashIDs>(); //玩家状态机 player_fsm = new PlayerFSM (); player_fsm.start (this); player_fsm.change (PlayerFSMStandState.STATE_NAME); }
void Start() { sceneManager = GameObject.Find("SceneManager").GetComponent<SceneManager>(); animation= GetComponent<AnimationSprite>(); fsm = new PlayerFSM(); }
void Start() { sceneManager = GameObject.Find("SceneManager").GetComponent<SceneManager>(); controller = GetComponent<CharacterController>(); fsm = GetComponent<PlayerFSM>(); zone01 = sceneManager.getLevelsAttributes().getZone01(); rayDistance = controller.height * .7f + controller.radius; }
/// <summary> /// Enter the specified fsm. /// </summary> /// <param name="fsm">Fsm.</param> public override void enter (FSM fsm) { this_fsm = fsm as PlayerFSM; //base.enter (fsm); }