コード例 #1
0
ファイル: Player.cs プロジェクト: mgWaring/unity-experiments
 void Awake()
 {
     //wire this into the stolen character class and remove the imput processing code that already exists there
     input = new PlayerInput();
     input.Player.Jump.performed += ctx => character.Jump();
     input.Player.Jump.canceled  += ctx => character.JumpReleased();
     input.Player.Swap.performed += ctx => ammo.Cycle_ammo();
     input.Player.Fire.performed += ctx =>
     {
         if (ammo.Available() > 0)
         {
             gun.Shoot(ammo.UseRound());
         }
         else
         {
             gun.Empty();
         }
     };
     input.Player.Move.started  += move => move_val = input.Player.Move.ReadValue <Vector2>();
     input.Player.Move.canceled += move => move_val = new Vector2(0, 0);
     input.Player.Aim.started   += move => move_val = input.Player.Move.ReadValue <Vector2>();
     input.Player.Aim.canceled  += move => move_val = new Vector2(0, 0);
 }
コード例 #2
0
 public void UpdateAmmoDisplay(AmmoBelt ammo)
 {
     ammo_renderer.GetComponent <Image> ().sprite     = ammo.ActiveAmmo().GetComponent <SpriteRenderer> ().sprite;
     ammo_text.GetComponent <TextMeshProUGUI> ().text = ammo.Available().ToString();
 }