コード例 #1
0
ファイル: Player.cs プロジェクト: takaaptech/ZooHalla
 void Move()
 {
     if (bMoveAccess)
     {
         _PlayerMoveVec = Vector2.zero;
         if (Input.GetKey(KeyCode.W))
         {
             direction         = PLAYERDIRECT.UP;
             _PlayerMoveVec.y += fMoveSpeed;
         }
         if (Input.GetKey(KeyCode.S))
         {
             direction         = PLAYERDIRECT.DOWN;
             _PlayerMoveVec.y -= fMoveSpeed;
         }
         if (Input.GetKey(KeyCode.A))
         {
             direction         = PLAYERDIRECT.LEFT;
             PlayerSr.flipX    = false;
             _PlayerMoveVec.x -= fMoveSpeed;
         }
         if (Input.GetKey(KeyCode.D))
         {
             direction         = PLAYERDIRECT.RIGHT;
             PlayerSr.flipX    = true;
             _PlayerMoveVec.x += fMoveSpeed;
         }
         PlayerRig.velocity = _PlayerMoveVec;
     }
     if (Input.GetMouseButton(0))
     {
         //Instantiate(BulletPre, transform.localPosition, Quaternion.Euler(0f, 0f, _fRotateDegree - 90f));
         Attack();
     }
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: takaaptech/ZooHalla
 // Start is called before the first frame update
 void Start()
 {
     direction   = PLAYERDIRECT.DONTMOVE;
     PlayerSr    = GetComponent <SpriteRenderer>();
     PlayerRig   = GetComponent <Rigidbody2D>();
     fMoveSpeed  = 5.0f;
     bMoveAccess = true;
 }