public override void attack(WeaponController weaponController, float attackRate, bool isNewAttack, Vector2 aiInput) { if (!isAttacking && isReady) { Vector2 rockPos = new Vector2(weaponController.transform.position.x, weaponController.transform.position.y); if (aiInput.Equals(Vector2.zero)) { return; } Vector2 lookAtDir = aiInput.normalized; GameObject rockWall = MonoBehaviour.Instantiate(weaponController.associatedPrefab, rockPos + (aiInput.normalized * wallDist), new Quaternion(0, 0, 0, 0)) as GameObject; rockWall.transform.Rotate(Vector3.forward, (180.0f / Mathf.PI) * Mathf.Atan2(lookAtDir.y, lookAtDir.x)); MonoBehaviour.Destroy(rockWall, coolDownTime); // Start cooldown if (coolDownCorout != null) { weaponController.StopCoroutine(coolDownCorout); } coolDownCorout = weaponController.StartCoroutine(coolDown()); } }
protected override void Start() { base.Start(); controller = GetComponent<PlayerController>(); weaponController = GetComponent<WeaponController>(); viewCamera = Camera.main; }
// Use this for initialization void Start() { Ship = GameObject.FindGameObjectWithTag("PlayerBattle"); handlerMovement = Ship.GetComponent<PlayerMovementSpaceBattle>(); m_CamControl = GameObject.Find("Main Camera").GetComponent<CameraControlNew>(); m_WeapControl = Ship.GetComponent<WeaponController>(); }
void Awake() { coords = new int[2]; lastCoords = new int[2]; canSee = new List<Player> (); m_AttackAxisInUse = false; tr = transform; CombatMode = false; pos = transform.position; currentPath = new List<Vector2> (); controller = GetComponent<PlayerController>(); workingAI = new AIBase (this); lastInput = Vector3.one; playerStats = new PlayerStats (); currentState = CharacterState.Still; controller.SetSpeed (playerStats.GetSpeed()); isStuck = 0; canAttack = "Enemy"; coolDownLimit = playerStats.GetAttackCooldown(); currentAttackCoolDown = 0; inventory = GetComponent<InventoryBase>(); weaponController = GetComponentInChildren<WeaponController> (); anim = GetComponent<Animator>(); spriteRen = GetComponent<SpriteRenderer> (); //seeker = GetComponent<Seeker> (); }
public void ChangeWeapon(bool ascending) { if(weaponList.Count > 0) { activeWeapon.equiped = false; if(ascending) { if(weaponNumber < weaponList.Count - 1) { weaponNumber++; } else { weaponNumber = 0; } } else { if(weaponNumber > 0) { weaponNumber--; } else { weaponNumber = weaponList.Count - 1; } } } activeWeapon = weaponList[weaponNumber].GetComponent<WeaponController>(); activeWeapon.equiped = true; }
public override void attack(WeaponController weaponController, float attackRate, bool isNewAttack, Vector2 aiInput) { if (!isAttacking) { Vector3 explVel; if (aiInput.x == 0 && aiInput.y == 0) { explVel = lastExplVel; } else { lastExplVel = explVel = new Vector3(aiInput.x, aiInput.y, -upForce); } Rigidbody bomb = (MonoBehaviour.Instantiate(weaponController.associatedPrefab, weaponController.owner.hand.position + Vector3.back, Quaternion.identity) as GameObject).GetComponent<Rigidbody>(); bomb.AddForce(explVel * throwSpeed * Time.deltaTime); MonoBehaviour.Destroy(bomb.gameObject, 2f); // Play bomb time cooldown if (curCooldown != null) { weaponController.StopCoroutine(curCooldown); } curCooldown = weaponController.StartCoroutine(bombCooldown()); } }
// Use this for initialization void Start () { rb = gameObject.GetComponent<Rigidbody2D>(); moveCharacter = gameObject.GetComponent<MoveCharacter>(); weaponController = gameObject.GetComponent<WeaponController>(); spellController = gameObject.GetComponent<SpellController>(); gameObject.GetComponent<Health>().OnDeath += onDeath; }
// Use this for initialization void Start () { //Enemy killed counter initialisation text = GetComponentInChildren<Text>(); text.text = ("Enemies killed : " + enemiesKilled); GameObject player = GameObject.FindGameObjectWithTag("Player"); health = player.GetComponent<HealthScript>(); playerHealth = health.health; totalHealth = playerHealth; weapon = player.GetComponent<WeaponController>(); skill = player.GetComponent<SkillController>(); GameObject skills = GameObject.Find("Skills"); //skills.gameObject. GameObject bullet = GameObject.Find("Bullet"); bulletCooldownBar = bullet.GetComponentInChildren<RectTransform>(); bulletCooldownBar = bulletCooldownBar.FindChild("Cooldown") as RectTransform; GameObject secondary = GameObject.Find("Secondary"); secondaryCooldownBar = secondary.GetComponentInChildren<RectTransform>(); secondaryCooldownBar = secondaryCooldownBar.FindChild("Cooldown") as RectTransform; GameObject dodge = GameObject.Find("Dodge"); dodgeCooldownBar = dodge.GetComponentInChildren<RectTransform>(); dodgeCooldownBar = dodgeCooldownBar.Find("Cooldown") as RectTransform; Image healthBarImage = GetComponentInChildren<Image>(); healthBar = healthBarImage.gameObject.GetComponent<RectTransform>(); }
// Use this for initialization void Awake (){ rb = GetComponent<Rigidbody>(); sightTrans = Instantiate(sightPrefab) as Transform; weapon = GetComponent<WeaponController>(); sprite = GetComponent<SpriteRenderer>(); skill = GetComponent<SkillController>(); }
public override void attack(WeaponController weaponController, float attackRate, bool isNewAttack, Vector2 aiInput) { if (!isAttacking) { damage = (int) (regDamage * weaponController.owner.msPhysAttack); weaponController.playAttack(); } }
// Use this for initialization void Start() { handlerMovement = Ship.GetComponent<PlayerShipMovementBattle>(); m_CamControl = GameObject.Find("Main Camera").GetComponent<CameraControlNew>(); m_WeapControl = Ship.GetComponent<WeaponController>(); // m_smoothFollow = GameObject.Find("Main Camera").GetComponent<SmoothFollow>(); // m_RotDamping = m_smoothFollow.RotationDamping; }
// Use this for initialization void Start () { controller = GetComponent<CharacterController> (); weapon = null; gravity = -(2 * jumpHeight) / Mathf.Pow (timeToJumpApex, 2); jumpSpeed = Mathf.Abs(gravity) * timeToJumpApex; print ("Gravity: " + gravity + " | Jump Speed: " + jumpSpeed); }
// Use this for initialization public void Shoot (WeaponController weaponController,bool trueBullet,byte shotID) { RaycastHit hit; if(Physics.Raycast(transform.position,transform.forward,out hit)){ Debug.DrawRay(transform.position,transform.forward,Color.green,1); Debug.DrawLine(transform.position,hit.point,Color.red,1); Instantiate(hitEffect,hit.point,Quaternion.LookRotation(hit.normal,Vector3.up)); if(trueBullet){ weaponController.CheckShot(shotID,hit.point); } } GameObject.Destroy (gameObject); }
public override void attack(WeaponController weaponController, float attackRate, bool isNewAttack, Vector2 aiInput) { // Set physical attack modifier for Sword attack msPhysAttack = weaponController.owner.msPhysAttack; if (!isNewAttack) { weaponController.endCombo(); } if (!isAttacking) { weaponController.playAttack(); } }
public static new void Fire(WeaponController weapctrl) { float accuracy = 70f; // TODO: DERIVE FROM STATS float damage = Random.Range(weapctrl.weapon.MinDamage, weapctrl.weapon.MaxDamage); // TODO: DERIVE FROM PLAYER WEAPON POWER RATHER THAN ITEM DAMAGE Camera cam = Camera.main; // TODO: DERIVE FROM CONTROLLER // Calculate hit range based on accuracy float portX = Random.Range(0.4f + (accuracy / 1000), 0.6f - (accuracy / 1000)); float portY = Random.Range(0.4f + (accuracy / 1000), 0.6f - (accuracy / 1000)); // Perform the shot Ray ray = cam.ViewportPointToRay(new Vector3(portX , portY , 0)); RaycastHit[] hits = Physics.RaycastAll(ray); if (hits.Length < 1) return; RaycastHit hit = hits[0]; List<RaycastHit> nonTriggers = new List<RaycastHit>(); // filter out triggers foreach(RaycastHit i in hits) { if (!i.collider.isTrigger) { nonTriggers.Add(i); } } // find closest hit if (nonTriggers.Count < 1) return; hit = nonTriggers[0]; foreach(RaycastHit h in nonTriggers) { if (h.distance < hit.distance) { hit = h; } } // If it's got physics, hit it. if (hit.rigidbody) { hit.rigidbody.AddForceAtPosition(cam.transform.forward * 500f, hit.point); } // Deal damage to damageables hit.collider.SendMessageUpwards("Damage", damage , SendMessageOptions.DontRequireReceiver); // Temporary AudioSource.PlayClipAtPoint(weapctrl.hitSound, hit.point); GameObject.Instantiate(weapctrl.hitParticle, hit.point, Quaternion.LookRotation(Vector3.up)); }
public IEnumerator DeflectCard(WeaponController weapon, bool attackingMonster) { if (attackingMonster){ BattleManager.instance.PlayerPostTurn(currentPosition); } else { gameObject.GetComponent<EnemyAI>().PostTurn(); BattleManager.instance.MonsterPostTurn(currentPosition); } Material mat = weapon.transform.GetChild(1).transform.GetChild(0).renderer.material; // remove bars // var emptyBar = weapon.transform.FindChild("EmptyBar").transform.GetChild(0); var timer = weapon.transform.FindChild("FirstBar").transform.GetChild(0); var secondtimer = weapon.transform.FindChild("SecondBar").transform.GetChild(0); // Reset timer bars to blank textures // timer.renderer.material.mainTexture = weapon.GetComponent<CardScript>().blank; secondtimer.renderer.material.mainTexture = weapon.GetComponent<CardScript>().blank; Color color = emptyBar.renderer.material.color; // create empty gameobject to parent card to, so that animation plays correctly // GameObject animParent = new GameObject("Parent"); animParent.transform.localPosition = weapon.transform.localPosition; weapon.transform.parent = animParent.transform; if (attackingMonster){ weapon.animation.Play("PlayerDeflect"); } else { weapon.animation.Play("EnemyDeflect"); } float t = 0f; while (t < 1.0f){ t += Time.deltaTime / 0.1f; mat.SetFloat("_Alpha", Mathf.Lerp(1.0f, 0.0f, t)); color.a = Mathf.Lerp(1.0f, 0.0f, t); emptyBar.renderer.material.color = color; yield return new WaitForEndOfFrame(); } // Reset empty bar to blank texture, reset alpha to 1 // emptyBar.renderer.material.mainTexture = weapon.GetComponent<CardScript>().blank; color.a = 1.0f; emptyBar.renderer.material.color = color; weapon.transform.parent = null; GameObject.Destroy(animParent); Teleport(weapon.gameObject); }
public void SetupProjectile(LayerMask collisionMask,LayerMask fightingMask, WeaponController AttachedTo,float speed,float damage,int facing,Vector3 shootdir, bool gravity){ imageTransform = transform.FindChild ("Image").transform; collider = imageTransform.GetComponent<BoxCollider2D> (); this.collisionMask = collisionMask; this.fightingMask = fightingMask; this.AttachedTo = AttachedTo; this.speed = speed; this.damage = damage; this.gravity = gravity; this.facing = facing; this.shootdir = shootdir; //* facing;//Vector3.right * facing; this.shootdir *= facing; if (facing < 0) { //GetComponent<SpriteRenderer> ().flipX = true; } velocity = this.shootdir * speed/50; imageTransform.rotation = Quaternion.Euler((this.shootdir.y < 0?-1:1) * new Vector3(0,0,Vector3.Angle(Vector3.right,this.shootdir))); //shootdir.y += Random.Range (-AttachedTo.variance/20, AttachedTo.variance/20); //print (imageTransform.rotation);; }
public void Initialize( Vector3 start, Vector3 target, float speed, int weaponId, WeaponController watcher, bool usePhysics = false ) { if( visualRepresentation != null ) visualRepresentation.SetActive( true ); passedTime = 0.0f; if( impactParticles == null ) impactParticles = GetComponent<ParticleSystem>(); if( impactParticles != null ) { impactParticles.loop = false; // don't loop that shit } else Debug.Log("WeaponProjectile: No impact particle effect found!"); startPosition = start; targetPosition = target; flyingSpeed = speed; myWeaponId = weaponId; myController = watcher; done = false; passedTime = 0.0f; }
/// <summary> /// Selects the weapon icon in the inventory /// </summary> private void setWeaponIcon() { if (selectedWeapon.weaponType == WeaponController.WEAPON_TYPE.NULL) { selectedWeapon = selectedWeapon.nextWeapon; } weaponPicker.SetParent(selectedWeapon.inventoryIcon); weaponPicker.localPosition = new Vector2(-weaponPicker.rect.width / 2f, 0); }
void Start() { cameraController = mainCamera.GetComponent <CameraController>(); weaponController = weapon.GetComponent <WeaponController>(); }
void Start() { rigidBody = GetComponent <Rigidbody>(); mainCamera = FindObjectOfType <Camera>(); weaponController = GetComponent <WeaponController>(); }
void Update() { //Testing //WeaponController t = controller.WeaponCollision (this.transform.position); Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); int wallDirX = (controller.collisions.left) ? -1 : 1; float targetVelocityX = input.x * moveSpeed; velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (controller.collisions.below)?accelerationTimeGrounded:accelerationTimeAirborne); bool wallSliding = false; if ((controller.collisions.left || controller.collisions.right) && !controller.collisions.below && velocity.y < 0) { wallSliding = true; if (velocity.y < -wallSlideSpeedMax) { velocity.y = -wallSlideSpeedMax; } if (timeToWallUnstick > 0) { velocityXSmoothing = 0; velocity.x = 0; if (input.x != wallDirX && input.x != 0) { timeToWallUnstick -= Time.deltaTime; } else { timeToWallUnstick = wallStickTime; } } else { timeToWallUnstick = wallStickTime; } } if (controller.collisions.below || controller.collisions.above) { velocity.y = 0; } if (Input.GetKeyDown("joystick button 3") || Input.GetKeyDown(KeyCode.E)) { if (weapon != null) { weapon.Thrown(); weapon = null; } else if (weapon == null) { weapon = controller.WeaponCollision(this.transform.position); if (weapon != null) { weapon.Equipped(this); } } } if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown("joystick button 0")) { if (wallSliding) { if (wallDirX == input.x) { velocity.x = -wallDirX * wallJumpClimb.x; velocity.y = wallJumpClimb.y; } else if (input.x == 0) { velocity.x = -wallDirX * wallJumpOff.x; velocity.y = wallJumpOff.y; } else if (wallDirX != input.x) { velocity.x = -wallDirX * wallLeap.x; velocity.y = wallLeap.y; } } if (controller.collisions.below) { velocity.y = jumpSpeed; } } velocity.y += gravity * Time.deltaTime; controller.Move(velocity * Time.deltaTime); }
public void Reload(WeaponController wpn, int amount) { StateManager.instance.Reload(playerController.weapons.IndexOf(wpn), amount); }
public IEnumerator MoveUp(WeaponController obj, float time) { float t = 0f; var card = obj.transform; var startingPlace = obj.transform.position; Vector3 endingPlace = new Vector3(0, 0.1f, -0.2f); endingPlace = startingPlace + endingPlace; while (t < 1.0f){ t += Time.deltaTime / time; card.transform.position = Vector3.Lerp(startingPlace, endingPlace, t); yield return new WaitForEndOfFrame(); } // StartCoroutine(TakeAttackDamage(obj.player, obj, obj.dmgMod)); }
private void Start() { _spaceship = GetComponentInChildren <Rigidbody2D>(); _weaponController = GetComponentInChildren <WeaponController>(); }
public void SetWeapons() { Transform mainBody = myTran.FindChild(Common.Func.GetBodyStructure()); animator = mainBody.GetComponent <Animator>(); Transform partsJoint = myTran.FindChild(Common.CO.PARTS_JOINT); foreach (Transform parts in partsJoint) { WeaponController wepCtrl = parts.GetComponentInChildren <WeaponController>(); if (wepCtrl != null) { wepCtrl.SetTarget(targetTran); switch (parts.name) { case Common.CO.PARTS_LEFT_HAND: //通常時左武器 wepCtrl.SetMotionCtrl(animator, Common.CO.MOTION_LEFT_ATTACK); break; case Common.CO.PARTS_LEFT_HAND_DASH: //ダッシュ時左武器 wepCtrl.SetMotionCtrl(animator, Common.CO.MOTION_LEFT_ATTACK); break; case Common.CO.PARTS_RIGHT_HAND: //通常時右武器 wepCtrl.SetMotionCtrl(animator, Common.CO.MOTION_RIGHT_ATTACK); break; case Common.CO.PARTS_RIGHT_HAND_DASH: //ダッシュ時右武器 wepCtrl.SetMotionCtrl(animator, Common.CO.MOTION_RIGHT_ATTACK); break; case Common.CO.PARTS_SHOULDER: //通常時背中武器 wepCtrl.SetMotionCtrl(animator, Common.CO.MOTION_SHOULDER_ATTACK); break; case Common.CO.PARTS_SHOULDER_DASH: //ダッシュ時背中武器 wepCtrl.SetMotionCtrl(animator, Common.CO.MOTION_SHOULDER_ATTACK); break; case Common.CO.PARTS_SUB: //サブ武器 wepCtrl.SetMotionCtrl(animator, Common.CO.MOTION_USE_SUB); break; case Common.CO.PARTS_EXTRA: //専用武器 extraCtrl = parts.GetComponentInChildren <ExtraWeaponController>(); if (extraCtrl != null) { extraCtrl.SetInit(wepCtrl, animator, status); } continue; } weapons.Add(wepCtrl); } } isSetWeapon = true; }
private void Start() { playerWeapon = GetComponent <WeaponController>(); currentQuality = playerWeapon.Quality; }
protected override void Awake() { base.Awake(); weaponController = GetComponentInChildren <WeaponController>(); }
void Awake() { health_controller = GetComponent <HealthController>(); weapon_controller = GetComponent <WeaponController>(); }
public void OnGUI() { if (skin) { GUI.skin = skin; } switch (Mode) { case 0: if (Input.GetKeyDown(KeyCode.Escape)) { Mode = 2; } if (play) { play.Active = true; GUI.skin.label.alignment = TextAnchor.UpperLeft; GUI.skin.label.fontSize = 30; GUI.Label(new Rect(20, 20, 200, 50), "Kills " + game.Killed.ToString()); GUI.Label(new Rect(20, 60, 200, 50), "Score " + game.Score.ToString()); GUI.skin.label.alignment = TextAnchor.UpperRight; GUI.Label(new Rect(Screen.width - 220, 20, 200, 50), "ARMOR " + play.GetComponent <DamageManager> ().HP); GUI.skin.label.fontSize = 16; // Draw Weapon system //if (weapon != null && weapon.WeaponLists.Length > 0 && weapon.WeaponLists.Length < weapon.CurrentWeapon && weapon.WeaponLists [weapon.CurrentWeapon] != null) { if (weapon.WeaponLists [weapon.CurrentWeapon].Icon) { GUI.DrawTexture(new Rect(Screen.width - 100, Screen.height - 100, 80, 80), weapon.WeaponLists [weapon.CurrentWeapon].Icon); } GUI.skin.label.alignment = TextAnchor.UpperRight; if (weapon.WeaponLists [weapon.CurrentWeapon].Ammo <= 0 && weapon.WeaponLists [weapon.CurrentWeapon].ReloadingProcess > 0) { if (!weapon.WeaponLists [weapon.CurrentWeapon].InfinityAmmo) { GUI.Label(new Rect(Screen.width - 230, Screen.height - 120, 200, 30), "Reloading " + Mathf.Floor((1 - weapon.WeaponLists [weapon.CurrentWeapon].ReloadingProcess) * 100) + "%"); } } else { if (!weapon.WeaponLists [weapon.CurrentWeapon].InfinityAmmo) { GUI.Label(new Rect(Screen.width - 230, Screen.height - 120, 200, 30), weapon.WeaponLists [weapon.CurrentWeapon].Ammo.ToString()); } } //}else{ //weapon = play.GetComponent<WeaponController> (); //} GUI.skin.label.alignment = TextAnchor.UpperLeft; GUI.Label(new Rect(20, Screen.height - 50, 250, 30), "R Mouse : Switch Guns C : Change Camera"); } else { play = (PlayerController)GameObject.FindObjectOfType(typeof(PlayerController)); weapon = play.GetComponent <WeaponController> (); } break; case 1: if (play) { play.Active = false; } MouseLock.MouseLocked = false; GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUI.Label(new Rect(0, Screen.height / 2 + 10, Screen.width, 30), "Game Over"); GUI.DrawTexture(new Rect(Screen.width / 2 - Logo.width / 2, Screen.height / 2 - 150, Logo.width, Logo.height), Logo); if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 50, 300, 40), "Never Give Up")) { Application.LoadLevel(Application.loadedLevelName); } if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 100, 300, 40), "Get The Hell Out Of Here")) { Application.LoadLevel("Mainmenu"); } break; case 2: if (play) { play.Active = false; } MouseLock.MouseLocked = false; Time.timeScale = 0; GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUI.Label(new Rect(0, Screen.height / 2 + 10, Screen.width, 30), "Tea Time"); GUI.DrawTexture(new Rect(Screen.width / 2 - Logo.width / 2, Screen.height / 2 - 150, Logo.width, Logo.height), Logo); if (GUI.Button(new Rect(Screen.width / 2 - 150, Screen.height / 2 + 50, 300, 40), "Back To Work")) { Mode = 0; Time.timeScale = 1; } if (GUI.Button(new Rect(Screen.width / 2 - 150, Screen.height / 2 + 100, 300, 40), "I was too Afraid to Continue")) { Time.timeScale = 1; Mode = 0; Application.LoadLevel("Mainmenu"); } break; } }
// Update is called once per frame void Update() { if (Input.GetAxisRaw("Horizontal") != 0f) { float deslocation = (Input.GetAxisRaw("Horizontal") > 0) ? 1f : -1f; transform.position += (Vector3.right * deslocation) * speed * Time.deltaTime; } if (Input.GetAxisRaw("Vertical") != 0f) { float deslocation = (Input.GetAxisRaw("Vertical") > 0) ? 1f : -1f; transform.position += (Vector3.up * deslocation) * speed * Time.deltaTime; } locked = Input.GetButton("LockAim"); if (!locked) { if (Input.GetAxisRaw("Horizontal") != 0f) { // verticalWeapon.SetActive(false); // horizontalWeapon.SetActive(true); WeaponController weaponController = weapon.GetComponent <WeaponController>(); // weaponController.muzzle = weaponController.horizontalMuzzle; float deslocation = (Input.GetAxisRaw("Horizontal") > 0) ? 1f : -1f; float nextPosition = deslocation; if ((nextPosition == -1 && facingRight) || (nextPosition == 1 && !facingRight)) { facingRight = !facingRight; } if (deslocation > 0) { transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); } else { transform.rotation = Quaternion.Euler(new Vector3(0, -180, 0)); } weapon.transform.rotation = Quaternion.Euler(new Vector3(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z)); currentPosition = new Vector3(nextPosition, 0f); animator.SetBool("RunningHorizontal", true); animator.SetBool("RunningUp", false); animator.SetBool("RunningDown", false); } else if (Input.GetAxisRaw("Vertical") != 0f) { // verticalWeapon.SetActive(true); // horizontalWeapon.SetActive(false); float deslocation = (Input.GetAxisRaw("Vertical") > 0) ? 1f : -1f; float nextPosition = deslocation; // SpriteRenderer weaponSprite = verticalWeapon.GetComponent<SpriteRenderer>(); if (deslocation > 0) { // verticalWeapon.SetActive(false); animator.SetBool("RunningUp", true); animator.SetBool("RunningDown", false); } else { animator.SetBool("RunningUp", false); animator.SetBool("RunningDown", true); } // WeaponController weaponController = weapon.GetComponent<WeaponController>(); // weaponController.muzzle = weaponController.verticalMuzzle; // weapon.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 90 * nextPosition)); // weapon.position = transform.position + upPosition; currentPosition = new Vector3(0f, nextPosition); animator.SetBool("RunningHorizontal", false); } else { animator.SetBool("RunningHorizontal", false); animator.SetBool("RunningUp", false); animator.SetBool("RunningDown", false); } } weapon.GetComponent <WeaponController>().heroPosition = currentPosition; }
public void OnPickUpWeapon(WeaponController weapon) { attack += weapon.GetAttack(); attackRange = Mathf.Max(attackRange, weapon.GetRange()); }
void Awake() { mc = GetComponent<IMovementController> (); weaponController = GetComponent<WeaponController> (); pd = GetComponent<PlayerData> (); }
public static void TestDebugRay(WeaponController self) { Debug.DrawLine(self.ProjectileExitPoint, self.Target.transform.position); }
private void Start() { stopShoot = GameObject.FindObjectOfType<WeaponController>(); }
public void Start() { shipPhysicsController = GetComponent <ShipPhysicsController>(); rb = shipPhysicsController.GetRigidbody(); weaponController = GetComponent <WeaponController>(); }
private bool can_drop_weapon(WeaponController weapon) { return(weapon != null && bag.Contains(weapon)); }
public void SetWeaponController(WeaponControllerBase value) { _weaponController = value as WeaponController; }
private void Update() { // shoot handling WeaponController activeWeapon = GetActiveWeapon(); if (activeWeapon && m_WeaponSwitchState == WeaponSwitchState.Up) { // handle aiming down sights isAiming = m_InputHandler.GetAimInputHeld(); // handle shooting bool hasFired = activeWeapon.HandleShootInputs( m_InputHandler.GetFireInputDown(), m_InputHandler.GetFireInputHeld(), m_InputHandler.GetFireInputReleased()); // Handle accumulating recoil if (hasFired) { m_AccumulatedRecoil += Vector3.back * activeWeapon.recoilForce; m_AccumulatedRecoil = Vector3.ClampMagnitude(m_AccumulatedRecoil, maxRecoilDistance); } } // weapon switch handling if (!isAiming && (activeWeapon == null || !activeWeapon.isCharging) && (m_WeaponSwitchState == WeaponSwitchState.Up || m_WeaponSwitchState == WeaponSwitchState.Down)) { int switchWeaponInput = m_InputHandler.GetSwitchWeaponInput(); if (switchWeaponInput != 0) { bool switchUp = switchWeaponInput > 0; SwitchWeapon(switchUp); } else { switchWeaponInput = m_InputHandler.GetSelectWeaponInput(); if (switchWeaponInput != 0) { if (GetWeaponAtSlotIndex(switchWeaponInput - 1) != null) { SwitchToWeaponIndex(switchWeaponInput - 1); } } } } // Pointing at enemy handling isPointingAtEnemy = false; if (activeWeapon) { if (Physics.Raycast(weaponCamera.transform.position, weaponCamera.transform.forward, out RaycastHit hit, 1000, -1, QueryTriggerInteraction.Ignore)) { if (hit.collider.GetComponentInParent <EnemyController>()) { hitscore++; isPointingAtEnemy = true; } } } }
private void Awake() { _weapon = GetComponent <WeaponController>(); _target = FindObjectOfType <PlayerController>().gameObject; }
public bool ContainsWeapon(WeaponController weapon) { return(bag.Contains(weapon)); }
public void pickUpWeapon(WeaponController newWeapon) { currentWeapon = newWeapon; setWeapon(); source.PlayOneShot(playerPickUpSound, 1f); }
void Start() { weaponController = GetComponent <WeaponController>(); ship = GameObject.FindGameObjectWithTag("Ship").GetComponent <Ship>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>(); }
private void Awake() { characterController = GetComponent <CharacterController>(); weaponController = GetComponent <WeaponController>(); }
/// <summary> /// Picks the member. /// </summary> private void pickMember() { // Set the new position of the member picker memberPicker.SetParent(selectedMember.inventoryIcon); memberPicker.localPosition = Vector2.zero; // Set camera on next member Vector3 camLocalPos = Camera.main.transform.localPosition; Camera.main.transform.SetParent(selectedMember.transform); Camera.main.transform.localPosition = camLocalPos; selectedWeapon = selectedMember.weapon; setWeaponIcon(); }
public void pickUpWeapon() //kiem tra xem co cam vu khi khong neu co thi set pickup cua vu khi vao button { if (weaponController) { checkWeapon = false; } if (!weaponController) { if (checkWeapon) { for (int i = 0; i < weaponManager.weaponItem.Length; i++) { if (weaponManager.weaponItem[i].id == idItem) { weapon = weaponManager.weaponItem[i]; } } text.text = "Throw"; GameObject mainWeapon; mainWeapon = Instantiate(weapon.weaponPrefab, weapon.position, Quaternion.identity) as GameObject; if (weapon.checkTwoHands) { GameObject CloneWeapon; CloneWeapon = Instantiate(weapon.weaponPrefabClone, weapon.position, Quaternion.identity) as GameObject; CloneWeapon.transform.SetParent(handRight); CloneWeapon.transform.localPosition = weapon.position2; CloneWeapon.transform.localRotation = Quaternion.Euler(weapon.rotation2); CloneWeapon.transform.localScale = weapon.Scale2; CloneWeapon.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic; CloneWeapon.tag = "weapon"; CloneWeapon.layer = 8; mainWeapon.GetComponent <WeaponController>().rightHands = CloneWeapon.GetComponent <CloneWeaponController>(); } switch (weapon.equipSlots) { case EquipmentSlot.Head: mainWeapon.transform.SetParent(head); break; case EquipmentSlot.Hands: mainWeapon.transform.SetParent(hand); break; case EquipmentSlot.Legs: mainWeapon.transform.SetParent(leg); break; default: break; } mainWeapon.transform.localPosition = weapon.position; mainWeapon.transform.localRotation = Quaternion.Euler(weapon.rotation); mainWeapon.transform.localScale = weapon.Scale; mainWeapon.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic; mainWeapon.tag = "weapon"; mainWeapon.layer = 8; mainWeapon.GetComponent <WeaponController>().DamageWeapon = weapon.damage; mainWeapon.GetComponent <WeaponController>().DamageSkill = weapon.skillDamage; weaponController = GetComponentInChildren <WeaponController>(); destroyweapon = true; quest.number++; if (GetComponentInParent <LocalForPVP>()) { GetComponentInParent <LocalForPVP>().VFX1.SetActive(false); GetComponentInParent <LocalForPVP>().VFX2.SetActive(false); } } } else { Debug.Log("don't see any weapon close!"); } }
void Update() { // Check for pausing if ((GameController.getInstance().gameState == GameController.GAME_STATE.PLAYING || GameController.getInstance().gameState == GameController.GAME_STATE.INVENTORY) && Input.GetButtonDown ("Menu")) { bool shouldPause = (GameController.getInstance().gameState == GameController.GAME_STATE.PLAYING); UIController.getInstance().setInventory(shouldPause); GameController.getInstance().pause(shouldPause); if (shouldPause) { selectedMember = PlayerController.getInstance().mainMember; selectedWeapon = selectedMember.weapon; pickMember(); pickWeapon(); } } // Open map if (GameController.getInstance().gameState != GameController.GAME_STATE.INVENTORY && Input.GetButtonDown("View")) { bool isMapOpen = GameController.getInstance().gameState == GameController.GAME_STATE.MAP; mapObject.gameObject.SetActive(!isMapOpen); if (isMapOpen) { GameController.getInstance().revertState(); } else { GameController.getInstance().changeGameState(GameController.GAME_STATE.MAP); } } // Input for movement across the inventory menu if (GameController.getInstance ().gameState == GameController.GAME_STATE.INVENTORY) { if (Input.GetButtonDown("Rejoin")) { selectedMember = selectedMember.memberFront == null ? PlayerController.getInstance().lastMember : selectedMember.memberFront; pickMember(); } else if (Input.GetButtonDown("Swap")) { selectedMember = selectedMember.memberBehind == null ? PlayerController.getInstance().mainMember : selectedMember.memberBehind; pickMember(); } float input = Input.GetAxisRaw("Vertical"); if (Mathf.Abs(input) >= MENU_THRESHOLD && isCooledDownV) { if (input < 0) { do { selectedWeapon = selectedWeapon.nextWeapon; } while (!selectedWeapon.unlocked); } else { do { selectedWeapon = selectedWeapon.prevWeapon; } while (!selectedWeapon.unlocked); } setWeaponIcon(); waitToMoveMenuV = StartCoroutine(waitToMoveMenu(MENU_DELAY_V)); } else if (Mathf.Abs(input) < MENU_THRESHOLD) { isCooledDownV = true; if (waitToMoveMenuV != null) { StopCoroutine(waitToMoveMenuV); } } if (Input.GetButtonDown(Constants.FACE_BUTTON_BOTTOM)) { pickWeapon(); } } if (isTextUp && (GameController.getInstance().gameState == GameController.GAME_STATE.PLAYING)) { if (Input.GetButtonDown (Constants.FACE_BUTTON_TOP)) { buttonsParent.GetChild (0).GetComponent<Button> ().onClick.Invoke (); } else if (Input.GetButtonDown (Constants.FACE_BUTTON_RIGHT)) { buttonsParent.GetChild (1).GetComponent<Button> ().onClick.Invoke (); } else if (Input.GetButtonDown (Constants.FACE_BUTTON_BOTTOM)) { buttonsParent.GetChild (2).GetComponent<Button> ().onClick.Invoke (); } else if (Input.GetButtonDown (Constants.FACE_BUTTON_LEFT)) { buttonsParent.GetChild (3).GetComponent<Button> ().onClick.Invoke (); } } }
void Awake() { DontDestroyOnLoad(gameObject); skillsController = new SkillsController(); allCharacters = new List<Character>(); unlockedCharacters = new List<Character>(); characters = new List<Character> (); weaponList = new WeaponController(); skillsController = new SkillsController(); //changeCharacter = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<ChangeCharacter>(); characterLimit = 3; skillLimit = 3; utilityLimit = skillLimit; equippedCharactersCount = 0; loadAdmin(); // levelControl (); }
// Use this for initialization void Start() { menu = MainMenuController.menu; if (primaryWeapon != null) { gun = primaryWeapon.GetComponent<WeaponController> (); } else if (secondaryWeapon != null) { gun = secondaryWeapon.GetComponent<WeaponController> (); } else { // If no weapon is selected } inMenu = false; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; health = 100f; lookSpeed = 5f; moveSpeed = 5f; sprintSpeedModifier = 1.5f; jumpHeight = 0.1f; }
// TODO need to fix a referncing issue from WeaponShot void Start() { //satelliteSystem = GetComponentInChildren<SatelliteController>(); if (base.isLocalPlayer){ weaponSystem = GetComponent<WeaponController>(); if (weaponSystem != null) { foreach (GameObject weaponShot in weaponSystem.shotWeaponsMap.Values) { WeaponShot shot = weaponShot.GetComponent<WeaponShot>(); shot.expSystem = this; } HUDCanvasManager.singleton.setExperienceMaxValue(maximumExperience); HUDCanvasManager.singleton.updateExperience(playerExperience); } } }
public void createWeapon() // khoi tao vu khi lan dau chon { int sum = 0; for (int i = 0; i < weaponManager.weaponItem.Length; i++) { if (weaponManager.weaponItem[i].checkUse) { weapon = weaponManager.weaponItem[i]; sum++; } if (weaponManager.weaponItem[i].id == "01") { weaponClone = weaponManager.weaponItem[i]; } } if (sum == 0) { weapon = weaponClone; } GameObject mainWeapon; mainWeapon = Instantiate(weapon.weaponPrefab, weapon.position, Quaternion.identity) as GameObject; if (weapon.checkTwoHands) { GameObject CloneWeapon; CloneWeapon = Instantiate(weapon.weaponPrefabClone, weapon.position, Quaternion.identity) as GameObject; CloneWeapon.transform.SetParent(handRight); CloneWeapon.transform.localPosition = weapon.position2; CloneWeapon.transform.localRotation = Quaternion.Euler(weapon.rotation2); CloneWeapon.transform.localScale = weapon.Scale2; CloneWeapon.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic; CloneWeapon.tag = "weapon"; CloneWeapon.layer = 8; mainWeapon.GetComponent <WeaponController>().rightHands = CloneWeapon.GetComponent <CloneWeaponController>(); } switch (weapon.equipSlots) { case EquipmentSlot.Head: mainWeapon.transform.SetParent(head); break; case EquipmentSlot.Hands: mainWeapon.transform.SetParent(hand); break; case EquipmentSlot.Legs: mainWeapon.transform.SetParent(leg); break; default: break; } mainWeapon.transform.localPosition = weapon.position; mainWeapon.transform.localRotation = Quaternion.Euler(weapon.rotation); mainWeapon.transform.localScale = weapon.Scale; mainWeapon.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic; mainWeapon.tag = "weapon"; mainWeapon.layer = 8; mainWeapon.GetComponent <WeaponController>().DamageWeapon = weapon.damage; mainWeapon.GetComponent <WeaponController>().DamageSkill = weapon.skillDamage; weaponController = GetComponentInChildren <WeaponController>(); }
private bool can_be_picked_up(WeaponController weapon) { return(bag.Count < MaxBagSize && Vector3.Distance(transform.position, weapon.transform.position) < PickUpRange); }
void Start () { weapon = (WeaponController)this.GetComponent<WeaponController>(); }
//게임 시작시 호출 void Start() { //타 게임오브젝트 참조 바인딩 sword_ani = GameObject.Find("sword").GetComponent <Animator>(); WeaponController = GameObject.Find("sword").GetComponent <WeaponController>(); }
void Update() { // shoot handling WeaponController activeWeapon = GetActiveWeapon(); UpdateProjectileTag(); if (activeWeapon != null && activeWeapon.IsReloading) { return; } if (activeWeapon != null && m_WeaponSwitchState == WeaponSwitchState.Up) { if (!activeWeapon.AutomaticReload && m_InputHandler.GetReloadButtonDown() && activeWeapon.CurrentAmmoRatio < 1.0f) { IsAiming = false; activeWeapon.StartReloadAnimation(); return; } // handle aiming down sights IsAiming = m_InputHandler.GetAimInputHeld(); // handle shooting bool hasFired = activeWeapon.HandleShootInputs( m_InputHandler.GetFireInputDown(), m_InputHandler.GetFireInputHeld(), m_InputHandler.GetFireInputReleased()); // Handle accumulating recoil if (hasFired) { m_AccumulatedRecoil += Vector3.back * activeWeapon.RecoilForce; m_AccumulatedRecoil = Vector3.ClampMagnitude(m_AccumulatedRecoil, MaxRecoilDistance); } } // weapon switch handling if (!IsAiming && (activeWeapon == null || !activeWeapon.IsCharging) && (m_WeaponSwitchState == WeaponSwitchState.Up || m_WeaponSwitchState == WeaponSwitchState.Down)) { int switchWeaponInput = m_InputHandler.GetSwitchWeaponInput(); if (switchWeaponInput != 0) { bool switchUp = switchWeaponInput > 0; SwitchWeapon(switchUp); } else { switchWeaponInput = m_InputHandler.GetSelectWeaponInput(); if (switchWeaponInput != 0) { if (GetWeaponAtSlotIndex(switchWeaponInput - 1) != null) { SwitchToWeaponIndex(switchWeaponInput - 1); } } } } // Pointing at enemy handling IsPointingAtEnemy = false; if (activeWeapon) { if (Physics.Raycast(WeaponCamera.transform.position, WeaponCamera.transform.forward, out RaycastHit hit, 1000, -1, QueryTriggerInteraction.Ignore)) { if (hit.collider.GetComponentInParent <Health>() != null) { IsPointingAtEnemy = true; } } } }
void Start() { weaponManager = this.GetComponent <WeaponController>(); }
public void Fire(WeaponController ctrl) { }
// Updates the animated transition of switching weapons void UpdateWeaponSwitching() { // Calculate the time ratio (0 to 1) since weapon switch was triggered float switchingTimeFactor = 0f; if (weaponSwitchDelay == 0f) { switchingTimeFactor = 1f; } else { switchingTimeFactor = Mathf.Clamp01((Time.time - m_TimeStartedWeaponSwitch) / weaponSwitchDelay); } // Handle transiting to new switch state if (switchingTimeFactor >= 1f) { if (m_WeaponSwitchState == WeaponSwitchState.PutDownPrevious) { // Deactivate old weapon WeaponController oldWeapon = GetWeaponAtSlotIndex(activeWeaponIndex); if (oldWeapon != null) { oldWeapon.ShowWeapon(false); } activeWeaponIndex = m_WeaponSwitchNewWeaponIndex; switchingTimeFactor = 0f; // Activate new weapon WeaponController newWeapon = GetWeaponAtSlotIndex(activeWeaponIndex); if (onSwitchedToWeapon != null) { onSwitchedToWeapon.Invoke(newWeapon); } if (newWeapon) { m_TimeStartedWeaponSwitch = Time.time; m_WeaponSwitchState = WeaponSwitchState.PutUpNew; } else { // if new weapon is null, don't follow through with putting weapon back up m_WeaponSwitchState = WeaponSwitchState.Down; } } else if (m_WeaponSwitchState == WeaponSwitchState.PutUpNew) { m_WeaponSwitchState = WeaponSwitchState.Up; } } // Handle moving the weapon socket position for the animated weapon switching if (m_WeaponSwitchState == WeaponSwitchState.PutDownPrevious) { m_WeaponMainLocalPosition = Vector3.Lerp(defaultWeaponPosition.localPosition, downWeaponPosition.localPosition, switchingTimeFactor); } else if (m_WeaponSwitchState == WeaponSwitchState.PutUpNew) { m_WeaponMainLocalPosition = Vector3.Lerp(downWeaponPosition.localPosition, defaultWeaponPosition.localPosition, switchingTimeFactor); } }
public IEnumerator TakeAttackDamage(PlayerController caster, WeaponController weapon, float dmgMod) { if (showingDamage){ showingDamage = false; damageTaken = 0; } BattleManager.instance.PlayerPostTurn(caster.currentPosition); // set secondary bar // var secondBar = weapon.transform.FindChild("SecondBar").transform.FindChild("mesh"); secondBar.renderer.material = new Material(secondBar.renderer.material); secondBar.renderer.material.mainTexture = weapon.GetComponent<CardScript>().defaultTimer; secondBar.renderer.material.SetFloat("_Cutoff", 1.0f); secondBar.renderer.material.mainTexture.mipMapBias = -0.5f; float t = 0f; // int stamp = attackedByHowMany; while (t < 1.0f){ t += Time.deltaTime / (float)weapon.speed; secondBar.renderer.material.SetFloat("_Cutoff", Mathf.Lerp(1.0f, 0.01f, t)); // if (stamp < attackedByHowMany){ // yield return new WaitForSeconds(1f); // } yield return new WaitForEndOfFrame(); } // remove bars // var emptyBar = weapon.transform.FindChild("EmptyBar").transform.GetChild(0); var timer = weapon.transform.FindChild("FirstBar").transform.GetChild(0); var secondtimer = weapon.transform.FindChild("SecondBar").transform.GetChild(0); // Reset timer bars to blank textures // timer.renderer.material.mainTexture = weapon.GetComponent<CardScript>().blank; secondtimer.renderer.material.mainTexture = weapon.GetComponent<CardScript>().blank; Color color = emptyBar.renderer.material.color; // flash effect // var mat = weapon.transform.GetChild(1).transform.GetChild(0).renderer; t = 0f; while (t < 1.0f){ t += Time.deltaTime / 0.25f; mat.material.SetFloat("_Blend", Mathf.Lerp (0.0f, 1.0f, t)); color.a = Mathf.Lerp(1.0f, 0.0f, t); emptyBar.renderer.material.color = color; yield return new WaitForEndOfFrame(); } // Reset empty bar to blank texture, reset alpha to 1 // emptyBar.renderer.material.mainTexture = weapon.GetComponent<CardScript>().blank; color.a = 1.0f; emptyBar.renderer.material.color = color; // Fade out and ring creation // GameObject ring = (GameObject)Instantiate(weapon.GetComponent<CardScript>().ringEffect, weapon.transform.position, Quaternion.identity); StartCoroutine(FadeOutRing(ring)); t = 0f; mat.material.SetFloat("_Alpha", 0.0f); while (t < 1.0f){ t += Time.deltaTime / 0.1f; mat.material.SetFloat("_Blend", Mathf.Lerp (1.0f, 0.0f, t)); yield return new WaitForEndOfFrame(); } // damage calculation // int damage = Mathf.FloorToInt((caster.strength - defense/2) + weapon.power/3); // before damage is dealt, check damage modification from charge // damage = Mathf.FloorToInt((float)damage * dmgMod); current_health -= damage; damageTaken = damage; if (current_health < 0 && !isDead){ isDead = true; Die(); BattleManager.instance.UpdateOnDeath(currentPosition); current_health = 0; BattleManager.instance.MonsterPostDeath(currentPosition); } // RestoreAttackPosition(); Teleport(weapon.gameObject); attackedByHowMany -= 1; StartCoroutine(ShowDamage(damageTaken, false)); // remove self from queued cards, if the list is not empty, then queue up the next one // queuedCards.RemoveAt(0); if (queuedCards.Count != 0) { StartCoroutine(MoveUp(queuedCards[0], 0.1f)); } }
void Start() { weapon = (WeaponController)this.GetComponent <WeaponController>(); }