void Awake()
    {
        controllerScript = GetComponent <PlayerFSM>();

        DontDestroyOnLoad(gameObject);
        StartCoroutine(GetGameManager());            // 생성시 photonview 시간차로 코루틴으로 gameManager 얻음
    }
예제 #2
0
 private void Setup(PlayerFSM player)
 {
     leftGround           = false;
     player.coyoteTimer   = 0;
     player.bunnyHopTimer = 0;
     waitAnimations       = new string[] { "PlayerJump", "PlayerAttacking", "PlayerAttackingBoosted", "PlayerAppear" };
 }
예제 #3
0
        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();
        }
예제 #4
0
 public void PlayerWait(PlayerFSM player)
 {
     player.TransitionToState(player.InWindowState);
     player.InWindowState.OnWindowExit.AddListener(ExitWindow);
     spriteRenderer.sprite  = openedWithRopeWithPlayerSprite;
     currentWindowExitState = WindowExitState.PlayerInside;
 }
예제 #5
0
    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);
    }
예제 #6
0
    void Awake()
    {
        controllerScript = GetComponent <PlayerFSM>();

        DontDestroyOnLoad(gameObject);
        StartCoroutine(SetupGameManager());
    }
예제 #7
0
    // 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;
    }
예제 #8
0
 public override void EnterState(PlayerFSM player)
 {
     Setup(player);
     PlayAnimation(player);
     PlayParticles(player);
     WallJumpAction(player);
 }
예제 #9
0
 private void Setup(PlayerFSM player)
 {
     player.canDoubleJump = true;
     player.canDash       = true;
     wallJumpTimer        = player.config.startWallJumpDurationTime;
     base.SetLookingDirectionOppositeOfWall(player);
 }
예제 #10
0
    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);
    }
예제 #11
0
 private void Start()
 {
     if (player == null)
     {
         player = GameObject.FindObjectOfType <PlayerFSM>();
     }
 }
예제 #12
0
    private Vector3 CalculateDirection(PlayerFSM player)
    {
        float xInput = Input.GetAxisRaw("Horizontal");
        float yInput = Input.GetAxisRaw("Vertical");

        return(base.GetFourDirectionalInput(player, xInput, yInput));
    }
예제 #13
0
 private void Setup(PlayerFSM player)
 {
     startWalkParticlesCooldownTime    = player.config.startWalkParticlesCooldownTime;
     startCoyoteDurationTime           = player.config.startCoyoteDurationTime;
     player.walkParticlesCooldownTimer = 0f;
     waitAnimations = new string[] { "PlayerWalk", "PlayerAttacking", "PlayerAttackingBoosted", "PlayerExploding", "PlayerAppear" };
 }
예제 #14
0
 public override void onCreate(EntityInfo data)
 {
     base.onCreate(data);
     fsm = new PlayerFSM(this);
     onChangeState(StateType.spawn);
     this.BillBoard.setColorByType(PartType.namePart, Color.green);
 }
예제 #15
0
    private void ShakeCamera(PlayerFSM player)
    {
        float shakeDuration  = player.config.explosionShakeDuration;
        float shakeMagnitude = player.config.explosionShakeMagnitude;

        Manager.shaker.Shake(player.cameraObj, shakeDuration, shakeMagnitude);
    }
예제 #16
0
        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;
            }
        }
예제 #17
0
 void Awake()
 {
     player     = GameObject.FindGameObjectWithTag("Player").transform;
     finish     = GameObject.FindGameObjectWithTag("Finish").transform;
     camera     = GameObject.FindGameObjectWithTag("MainCamera").transform;
     _playerFSM = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerFSM>();
 }
예제 #18
0
    public void ClearMechanics(GameObject playerObj)
    {
        PlayerFSM player = playerObj.GetComponent <PlayerFSM>();

        player.mechanics.ResetMechanics();
        player.mechanics.EnableBasicMechanics();
    }
예제 #19
0
    // 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;
        }
    }
예제 #20
0
 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);
         }
     }
 }
예제 #21
0
    public PlayerJumpState(PlayerFSM player)
    {
        Player    = player;
        StateName = PLAYERSTATE.JUMP;

        jumpForce = new Vector2(0f, Player.JumpMagnitude);
    }
예제 #22
0
 private void CheckForAirJumpInputBuffer(PlayerFSM player)
 {
     if (Input.GetButtonDown("Jump"))
     {
         player.airJumpInputBufferTimer = player.config.startAirJumpInputBufferTime;
     }
 }
예제 #23
0
    private void BlinkAction(PlayerFSM player)
    {
        Vector3 blinkDirection      = base.GetFourDirectionalInput(player, xInput, yInput);
        Vector3 destinationPosition = ValidDestinationPosition(player, blinkDirection);

        player.transform.Translate(destinationPosition);
    }
예제 #24
0
 public override void EnterState(PlayerFSM player)
 {
     Setup(player);
     PlayAnimation(player);
     PlayAudio();
     DashAction(player);
 }
예제 #25
0
    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;
        }
    }
예제 #26
0
    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;
        }
    }
예제 #27
0
 public override void OnAssignFSM(PlayerFSM FSM)
 {
     this.FSM        = FSM;
     rb              = FSM.rb;
     inputController = FSM.InputController;
     Start();
 }
예제 #28
0
 public new void OnEnable()
 {
     base.OnEnable();
     if (playerFsm == null)
     {
         playerFsm = WeaponBase.instance.player;
     }
 }
예제 #29
0
 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;
    }
예제 #31
0
	protected override void Awake ()
	{
		base.Awake();
		
		_player = GameObject.FindGameObjectWithTag("Player").transform;
		_playerFSM = _player.GetComponent<PlayerFSM>();
		
		waypoints = waypoint.GetComponentsInChildren<Transform>();
		sight = GetComponentInChildren<Camera>();
	}
예제 #32
0
    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 ();
    }
예제 #33
0
 public Sliding(PlayerFSM fsm, PlayerBehaviour character)
     : base(fsm, character)
 {
     this.animation = new SlidingAnimation (this.character.gameObject);
 }
예제 #34
0
 public PlayerState(PlayerFSM fsm, PlayerBehaviour character)
 {
     this.fsm = fsm;
     this.character = character;
 }
예제 #35
0
		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);
		}
예제 #36
0
파일: Player.cs 프로젝트: OscarRPR/SR_PC
 void Start()
 {
     sceneManager = GameObject.Find("SceneManager").GetComponent<SceneManager>();
     animation= GetComponent<AnimationSprite>();
     fsm = new PlayerFSM();
 }
예제 #37
0
    void Start()
    {
        sceneManager = GameObject.Find("SceneManager").GetComponent<SceneManager>();
        controller = GetComponent<CharacterController>();
        fsm = GetComponent<PlayerFSM>();
        zone01 = sceneManager.getLevelsAttributes().getZone01();

        rayDistance = controller.height * .7f + controller.radius;
    }
예제 #38
0
		/// <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);
		}