public FaceDirType CheckFaceDir() { FaceDirType tmpDir = FaceDirType.mdtNone; if (m_h > 0) { tmpDir |= FaceDirType.mdtRight; } else if (m_h < 0) { tmpDir |= FaceDirType.mdtLeft; } if (m_v > 0) { tmpDir |= FaceDirType.mdtUp; } else if (m_v < 0) { tmpDir |= FaceDirType.mdtDown; } if (tmpDir != FaceDirType.mdtNone) { dir = tmpDir; } return(dir); }
private void FixedUpdate() { if (!GameManager.s_instance.IsGameStart()) { return; } if (GameManager.s_instance.IsGameEnd()) { return; } movement.CheckMove(); FaceDirType dir = movement.CheckFaceDir(); int x, y; movement.GetArrayPos(out x, out y); Vector3 aimPos = aim.SetAimPos(dir, x, y); weapon.CoolDownUpdate(Time.deltaTime); if (weapon.IsFire()) { int type = weapon.GetFireType(); switch (type) { case 0: break; case 1: weapon.Fire1(dir, x, y, m_otherPlayer); break; case 2: weapon.Fire2(dir, x, y, m_otherPlayer, aimPos); break; default: break; } } if (weapon.CanReload() && !weapon.IsAmmoMax() && weapon.IsReloading()) { reloadCoolDown.Show(); weapon.ReloadCoolDownUpdate(Time.deltaTime); } else { weapon.ResetReloadCoolDown(); reloadCoolDown.Hide(); } }
public Vector3 SetAimPos(FaceDirType _dir, int _x, int _y) { switch (_dir) { case FaceDirType.mdtNone: break; case FaceDirType.mdtUp: aimTF.position = new Vector3(_x * 0.2f, 0.01f, _y * 0.2f + (fireDistance + 1) * pixelSize); break; case FaceDirType.mdtDown: aimTF.position = new Vector3(_x * 0.2f, 0.01f, _y * 0.2f - (fireDistance + 1) * pixelSize); break; case FaceDirType.mdtLeft: aimTF.position = new Vector3(_x * 0.2f - (fireDistance + 1) * pixelSize, 0.01f, _y * 0.2f); break; case FaceDirType.mdtRight: aimTF.position = new Vector3(_x * 0.2f + (fireDistance + 1) * pixelSize, 0.01f, _y * 0.2f); break; case FaceDirType.mdtUpLeft: aimTF.position = new Vector3(_x * 0.2f - fireDistance * pixelSize, 0.01f, _y * 0.2f + fireDistance * pixelSize); break; case FaceDirType.mdtUpRight: aimTF.position = new Vector3(_x * 0.2f + fireDistance * pixelSize, 0.01f, _y * 0.2f + fireDistance * pixelSize); break; case FaceDirType.mdtDownLeft: aimTF.position = new Vector3(_x * 0.2f - fireDistance * pixelSize, 0.01f, _y * 0.2f - fireDistance * pixelSize); break; case FaceDirType.mdtDownRight: aimTF.position = new Vector3(_x * 0.2f + fireDistance * pixelSize, 0.01f, _y * 0.2f - fireDistance * pixelSize); break; default: break; } return(aimTF.position); }
public override void Fire2(FaceDirType _dir, int _x, int _y, GameObject _otherPlayer, Vector3 _aimPos) { if (m_inCoolDown) { return; } if (m_ammoNumRemain < attack2Cost) { Debug.Log("not enough ammo"); return; } Debug.Log("Fire2"); AddAmmo(-attack2Cost); m_curCoolDown = fire2CoolDown; m_inCoolDown = true; SoundManager.s_instance.PlayShoot(); PushPlayer(_otherPlayer, _aimPos); switch (_dir) { case FaceDirType.mdtNone: break; case FaceDirType.mdtUp: UpFire2(_x, _y); break; case FaceDirType.mdtDown: DownFire2(_x, _y); break; case FaceDirType.mdtLeft: LeftFire2(_x, _y); break; case FaceDirType.mdtRight: RightFire2(_x, _y); break; case FaceDirType.mdtUpLeft: UpLeftFire2(_x, _y); break; case FaceDirType.mdtUpRight: UpRightFire2(_x, _y); break; case FaceDirType.mdtDownLeft: DownLeftFire2(_x, _y); break; case FaceDirType.mdtDownRight: DownRightFire2(_x, _y); break; default: break; } }
public virtual void Fire2(FaceDirType _dir, int _x, int _y, GameObject _otherPlayer, Vector3 _aimPos) { }
public virtual void Fire1(FaceDirType _dir, int _x, int _y, GameObject _otherPlayer) { }