public virtual void Inocation(weaponInfs infs, Vector3 pos, Vector2 dire, attributes atb) { weaponInfs = infs; //Som de saida do progetil AudioSource ad = repository.GetAudioSource(); ad.PlayOneShot(weaponInfs.clipExit); gameObject.SetActive(true); ownerAtb = atb; timeDelta = infs.GetReach() / velocity; transform.position = pos; VelocityChange(dire * velocity); }
public void InocationBullet() { if (weaponNow1) { weaponInfs wpInf = GetWeaponInfs(); progetile p = wpInf.GetBullet(); p = repository.GetBullets(p); //Posição da saida da bala Vector3 pos = hand1.position + transform.rotation * wpInf.GetPosExitBullet(); //Posição da mira do personagem Vector3 targetPos = transform.up * (wpInf.GetReach() + hand1.localPosition.y + wpInf.GetPosExitBullet().y) + transform.position; //Calculando direção do tiro Vector3 dire = targetPos - pos; dire.z = 0f; p.Inocation(wpInf, pos, dire.normalized, atb); //Consumo de balas int n = 1; //É uma arma dupla? if (wpInf.IsDual()) { n = 2; p = wpInf.GetBullet(); p = repository.GetBullets(p); //Posição da saida da bala pos = hand2.position + transform.rotation * wpInf.GetPosExitBullet(); //Posição da mira do personagem targetPos = transform.up * (wpInf.GetReach() + hand2.localPosition.y + wpInf.GetPosExitBullet().y) + transform.position; //Calculando direção do tiro dire = targetPos - pos; dire.z = 0f; p.Inocation(wpInf, pos, dire.normalized, atb); } if (playerControll) { playerControll.AddAmmunition(-n); } } }
// Update is called once per frame void Update() { if (canMove) { actions act = atb.GetActions(); //Movimentação Vector2 dire = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); movementPlayer.Move(dire); //Pegando posição do mouse no mundo /*Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); * Vector2 delta = mousePos; * delta.x -= transform.position.x; * delta.y -= transform.position.y; * //Rotacionar * float angZ = Vector2.SignedAngle(Vector2.up, delta); * movementPlayer.TurnTo(angZ);*/ weaponInfs wp = act.GetWeaponInfs(); //Comando de atirar /*if (Input.GetButton("Fire1")) * { * if (Input.GetButtonDown("Fire1")) * { * act.Fire(); * } * } * else if (wp && wp.IsContinuous()) * { * act.StopFire(); * }*/ } }
public override void Inocation(weaponInfs infs, Vector3 pos, Vector2 dire, attributes atb) { base.Inocation(infs, pos, dire, atb); ative = true; }