private void ModifyWeapon(MeleeName attackName) { MeleeAttack melee = attackPool.GetAttack(attackName); currentMelee = melee; meleeAmmo = melee.durabitlity; }
void Start() { gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight); // print ("Gravity: " + gravity + " Jump Velocity: " + maxJumpVelocity); isFacingRight = transform.localScale.x > 0; Health = maxHealth; numberOfJumpLeft = numberOfJumpMax; rangeAttack = GetComponent <RangeAttack> (); meleeAttack = GetComponent <MeleeAttack> (); soundFx = gameObject.AddComponent <AudioSource> (); soundFx.loop = true; soundFx.playOnAwake = false; soundFx.clip = wallSlideSound; soundFx.volume = wallSlideSoundVolume; isPlaying = true; if (Assist.Instance != null) { Assist.Instance.ReadParam(out maxHealth, out _foodAddHealth, out _runTime); //创建文件 Debug.Log("MaxHealth=" + maxHealth.ToString() + " FoodHealth=" + _foodAddHealth.ToString()); Assist.Instance.ChangeBlockSpriteWrap(); } }
private void Start() { player = GameObject.FindGameObjectWithTag("Player"); mA = GetComponent <MeleeAttack>(); enemyStats = GetComponent <EnemyStats>(); ps = GetComponent <PlaySound>(); }
public void DealAttackDamage(MeleeAttack number) { int damage; DamageEffect damageEffect; switch (number) { case MeleeAttack.First: damage = playerStats.firstAttackDamage; damageEffect = DamageEffect.Hurt; break; case MeleeAttack.Second: damage = playerStats.secondAttackDamage; damageEffect = DamageEffect.Hurt; break; case MeleeAttack.Third: damage = playerStats.thirdAttackDamage; damageEffect = DamageEffect.Knockback; ComboEnds(); break; default: damage = playerStats.firstAttackDamage; damageEffect = DamageEffect.Hit; break; } DealCombatDamage(damage, damageEffect); }
static void Postfix(CombatHUDWeaponSlot __instance, Weapon ___displayedWeapon, CombatHUD ___HUD) { if (__instance == null || ___displayedWeapon == null || ___HUD.SelectedActor == null || !Mod.Config.Melee.FilterCanUseInMeleeWeaponsByAttack) { return; } MeleeAttack selectedAttack = ModState.GetSelectedAttack(___HUD.SelectedActor); if (selectedAttack != null) { Mod.UILog.Debug?.Write($"Checking ranged weapons attacker: {___HUD.SelectedActor.DistinctId()} using selectedAttack: {selectedAttack.Label}"); // Check if the weapon can fire according to the select melee type bool isAllowed = selectedAttack.IsRangedWeaponAllowed(___displayedWeapon); Mod.UILog.Debug?.Write($"Ranged weapon '{___displayedWeapon.UIName}' can fire in melee by type? {isAllowed}"); if (!isAllowed) { Mod.UILog.Debug?.Write($"Disabling weapon from selection"); __instance.ToggleButton.isChecked = false; Traverse showDisabledHexT = Traverse.Create(__instance).Method("ShowDisabledHex"); showDisabledHexT.GetValue(); } } //else //{ // // No selected attack, so revert the weapon to the state it should have // __instance.ToggleButton.isChecked = ___displayedWeapon.IsEnabled && !___displayedWeapon.IsDisabled; //} }
// Use this for initialization void Start() { if (!_meleeAttack.enabled) { _meleeAttack = _meleeAttack.gameObject.GetComponents <MeleeAttack>().First(c => c.enabled); } }
private void Awake() { agent = GetComponent <NavMeshAgent>(); meleeAttack = GetComponent <MeleeAttack>(); damageable = GetComponent <Damageable>(); }
private void Awake() { player = GameObject.FindGameObjectWithTag("Player"); meleeAttack = player.GetComponent <MeleeAttack>(); book = GetComponentInParent <Book>(); rb = GetComponentInParent <Rigidbody2D>(); }
protected override void Awake() { base.Awake(); var search = new SearchForTarget(this, "Player"); var moveToTarget = new MoveToTarget(this, moveSpeed, nextWaypointDistance , myRigidbody, spriteContainer); var idle = new Idle(); var meleeAttack = new MeleeAttack(this, enemyAnimator, enemyRGB, attackCounter, attackPower, jumpBack, jumpBackTime); var death = new Death(this, enemyAnimator); AddTransition(search, moveToTarget, TargetFound()); AddTransition(search, idle, TargetMissing()); //AddTransition(moveToTarget, search, IsStuck()); AddTransition(moveToTarget, search, TargetMissing()); AddTransition(idle, search, ShouldAttack()); AddTransition(moveToTarget, meleeAttack, InRangeToAttack()); AddTransition(meleeAttack, search, TargetOutofRange()); AddAnyTransition(idle, () => !shouldAttackPlayer); AddAnyTransition(death, ReadyToDie()); StateMachine.SetState(search); Func <bool> TargetMissing() => () => Target == null; Func <bool> IsStuck() => () => moveToTarget.TimeStuck > timeTillSearchWhenStuck; Func <bool> TargetFound() => () => Target != null; Func <bool> ShouldAttack() => () => shouldAttackPlayer; Func <bool> InRangeToAttack() => () => Target != null && Mathf.Abs(Vector3.Distance(Target.transform.position, transform.position)) <= attackDistance; Func <bool> TargetOutofRange() => () => Target != null && Mathf.Abs(Vector3.Distance(Target.transform.position, transform.position)) > attackDistance; Func <bool> ReadyToDie() => () => enemyHealth.GetCurrentHealth() <= 0; InvokeRepeating(nameof(UpdatePath), 0f, .5f); }
void Attack(int attackDirection, int orientatnion) { playerAnimator.SetBool("isAttacking", true); playerAnimator.SetFloat("meleeAttackSpeed", player.GetAttackSpeed()); if (orientatnion > 0) { Vector3 attackDir = new Vector3(transform.position.x + attackDirection * player.GetAttackRange(), transform.position.y, -5); if (attackDirection > 0) { meleeAttack = Instantiate(prefabMeleeAttack, attackDir, Quaternion.Euler(0f, 0f, -24.053f)).GetComponent <MeleeAttack>(); } else { meleeAttack = Instantiate(prefabMeleeAttack, attackDir, Quaternion.Euler(0f, 180f, -24.053f)).GetComponent <MeleeAttack>(); } } else { Vector3 attackDir = new Vector3(transform.position.x, transform.position.y + attackDirection * player.GetAttackRange(), -5); if (attackDirection > 0) { meleeAttack = Instantiate(prefabMeleeAttack, attackDir, Quaternion.Euler(0f, 0f, 90f - 24.053f)).GetComponent <MeleeAttack>(); } else { meleeAttack = Instantiate(prefabMeleeAttack, attackDir, Quaternion.Euler(0f, 0f, -90f - 24.053f)).GetComponent <MeleeAttack>(); } } Debug.Log("Im Attacking"); StartCoroutine(AttackSpeedCheck()); }
void Start() { health_stamina_bars = GameObject.FindGameObjectWithTag("Health_Stamina"); health_stamina = health_stamina_bars.GetComponent <Health_Stamina>(); playerGameObject = GameObject.FindGameObjectWithTag("Player"); meleeAttack = playerGameObject.GetComponent <MeleeAttack>(); }
private static void Obj_AI_Base_OnProcessAutoAttack(Obj_AI_Base sender, Obj_AI_BaseMissileClientDataEventArgs e) { //Ignore auto attacks happening too far away if (sender == null || !sender.IsValidTarget(4000, true) || sender is Obj_AI_Hero) { return; } //Only process for minion targets var targetM = e.Target as Obj_AI_Minion; if (targetM == null) { return; } AutoAttack attack; if (sender.IsMelee) { attack = new MeleeAttack(sender, targetM, 0); } else { attack = new RangedAttack(sender, targetM, 0); } Attacks.AddAttack(attack); }
// This patch needs to run to correctly fix the melee attack to the target selected by CleverGirl/AI. // During AI eval multiple targets are evaluated, and this ensures we use the attack for the one that was picked. static void Postfix(AbstractActor unit, ref BehaviorTreeResults __result) { if (__result != null && __result.nodeState == BehaviorNodeState.Success && __result.orderInfo is AttackOrderInfo attackOrderInfo) { if (attackOrderInfo.IsMelee) { Mod.Log.Debug?.Write($"Setting melee weapon for attack from attacker: {unit?.DistinctId()} versus target: {attackOrderInfo.TargetUnit?.DistinctId()}"); // Create melee options MeleeState meleeState = ModState.AddorUpdateMeleeState(unit, attackOrderInfo.AttackFromLocation, attackOrderInfo.TargetUnit); if (meleeState != null) { MeleeAttack meleeAttack = meleeState.GetHighestDamageAttackForUI(); ModState.AddOrUpdateSelectedAttack(unit, meleeAttack); } } else if (attackOrderInfo.IsDeathFromAbove) { // Create melee options MeleeState meleeState = ModState.AddorUpdateMeleeState(unit, attackOrderInfo.AttackFromLocation, attackOrderInfo.TargetUnit); if (meleeState != null) { MeleeAttack meleeAttack = meleeState.DFA; ModState.AddOrUpdateSelectedAttack(unit, meleeAttack); } } } else { Mod.Log.Trace?.Write($"BehaviorTree result is not failed: {__result?.nodeState} or is not an attackOrderInfo, skipping."); } }
/// <summary> /// Sets up the references to different scene elements based on the player number passed by the GameManager /// </summary> /// <param name="i"> player number (0 == Player1)</param> public void SetPlayerNum(int i) { isPlayer1 = i == 0; damageImage = GameObject.Find("P" + (i + 1) + "_" + "DamageImage").GetComponent <Image>(); GameObject healthUI = GameObject.Find("P" + (i + 1) + "_" + "HealthUI"); healthSlider = healthUI.GetComponentInChildren <Slider>(); GameObject blueUI = GameObject.Find("P" + (i + 1) + "_" + "BlueFeUI"); blueSlider = blueUI.GetComponentInChildren <Slider>(); blueSlider.value = 0; GameObject greenUI = GameObject.Find("P" + (i + 1) + "_" + "GreenFeUI"); greenSlider = greenUI.GetComponentInChildren <Slider>(); greenSlider.value = 0; GameObject redUI = GameObject.Find("P" + (i + 1) + "_" + "RedFeUI"); redSlider = redUI.GetComponentInChildren <Slider>(); redSlider.value = 0; MeleeAttack meleeAttack = GetComponentInChildren <MeleeAttack>(); meleeAttack.setPlayerNum(i); }
private void Awake() { if (meleeAttack == null) { meleeAttack = GetComponent <MeleeAttack>(); } if (hpSystem == null) { hpSystem = GetComponent <HealthSystem>(); } if (tag == "Player") { if (characterClass == CharacterClass.Warrior) { hpSystem.maxHealth = 200 + armorHealth; attackPower = 15; } else if (characterClass == CharacterClass.Archer) { hpSystem.maxHealth = 150 + armorHealth; attackPower = 20; } else if (characterClass == CharacterClass.Wizard) { hpSystem.maxHealth = 100 + armorHealth; attackPower = 25; } } }
// Update is called once per frame void Update() { ActionsLeftForThisFrame = MaxActionsToPop; if (Path != null) { if (ProgressPath < Path.corners.Length && Vector3.Distance(Path.corners [ProgressPath], this.transform.position) < 0.5f) { ProgressPath++; } if (ProgressPath < Path.corners.Length) { Move act = new Move(Path.corners [ProgressPath] - this.transform.position); DeclaredActions.Add(act); } if (Path.corners.Length == 0) { Move act = new Move(PlayerPosition.position - this.transform.position); DeclaredActions.Add(act); } } if (Vector3.Distance(transform.position, PlayerPosition.position) < EnemyRadius + 1.2f) { MeleeAttack act = new MeleeAttack(0.2f, 0, "AlliedCharacters"); DeclaredActions.Add(act); } }
private void Start() { rightFingerId = -1; sceneController = GameObject.FindGameObjectWithTag("SceneController").GetComponent <SceneControll>(); shootingButtonPressed = false; meleeScript = GetComponentInChildren <MeleeAttack>(); ammoHealthScript = GetComponent <PlayerHealthAmmo>(); camDistance = mainCamera.transform.localPosition.z; cameraCam = mainCamera.GetComponent <Camera>(); startCamPos = mainCamera.transform.localPosition; startFOV = cameraCam.fieldOfView; crossImage = cross.GetComponent <Image>(); aiming = false; nonAimingButton.SetActive(false); shootingButton.SetActive(false); controller = GetComponent <CharacterController>(); animator = player.GetComponent <Animator>(); startCrossColor = crossImage.color; reloadImgItself = reloadImg.GetComponent <Image>(); reloadImg.SetActive(false); meleeObject.SetActive(false); shootingAudioSource = shootPoint.GetComponent <AudioSource>(); tanyaSoundSource = GetComponent <AudioSource>(); startStepPos = transform.position; shootlight = shootPoint.GetComponent <Light>(); shootlight.enabled = false; startIntensity = shootlight.intensity; //flashlight = shootPoint.transform.GetChild(0).gameObject.GetComponent<Light>(); //flashlight.cookie = lightCookie; }
void Start() { gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight); // print ("Gravity: " + gravity + " Jump Velocity: " + maxJumpVelocity); isFacingRight = transform.localScale.x > 0; Health = maxHealth; numberOfJumpLeft = numberOfJumpMax; rangeAttack = GetComponent <RangeAttack> (); meleeAttack = GetComponent <MeleeAttack> (); soundFx = gameObject.AddComponent <AudioSource> (); soundFx.loop = true; soundFx.playOnAwake = false; soundFx.clip = wallSlideSound; soundFx.volume = wallSlideSoundVolume; isPlaying = true; isFacingRight = false; Flip(); }
public override bool TryAttackOnce(Camera camera) { if (Time.time < m_NextUseTime) { return(false); } var raycastData = Player.RaycastData.Get(); // Send the melee specific attack message. if (raycastData) { bool objectIsClose = raycastData.HitInfo.distance < m_MaxReach; MeleeAttack.Send(objectIsClose); } else { MeleeAttack.Send(false); } // Send the regular attack message. Attack.Send(); m_NextUseTime = Time.time + m_TimeBetweenAttacks; return(true); }
public void Update() { if (GameScript.turn == "EnemyTurn") { GameObject[] friendlyList = GameObject.FindGameObjectsWithTag("FriendlyTroop"); foreach (GameObject entry in friendlyList) { if (Vector3.Distance(entry.transform.position, gameObject.transform.position) <= attackRange) { if (hasAttacked == false) { Debug.Log("Enemy Melee Unit: attacking!"); troop = entry.GetComponent <MasterTroopScript> (); MeleeAttack atk = new MeleeAttack(1, 1, 0); troop.dmg(atk.getDamage()); hasAttacked = true; } } } } if (GameScript.turn == "PlayerTurn") { hasAttacked = false; } }
void Start() { if (!m_MeleeAbility.enabled) { m_MeleeAbility = m_MeleeAbility.gameObject.GetComponents <MeleeAttack>().First(c => c.enabled); } }
static void Postfix(ToHit __instance, ref string __result, AbstractActor attacker, Weapon weapon, ICombatant target, Vector3 attackPosition, Vector3 targetPosition, LineOfFireLevel lofLevel, bool isCalledShot) { Mod.Log.Trace?.Write("TH:GAMD entered"); if (attacker.HasMovedThisRound && attacker.JumpedLastRound || (SharedState.CombatHUD?.SelectionHandler?.ActiveState != null && SharedState.CombatHUD?.SelectionHandler?.ActiveState is SelectionStateJump)) { string localText = new Text(Mod.LocalizedText.Labels[ModText.LT_Label_Attacker_Jumped]).ToString(); __result = string.Format("{0}{1} {2:+#;-#}; ", __result, localText, Mod.Config.ToHitSelfJumped); } // Check melee patches MeleeAttack selectedAttack = ModState.GetSelectedAttack(attacker); if (selectedAttack != null && weapon.Type == WeaponType.Melee) { foreach (KeyValuePair <string, int> kvp in selectedAttack.AttackModifiers) { string localText = new Text(Mod.LocalizedText.Labels[kvp.Key]).ToString(); Mod.Log.Info?.Write($" - Found attack modifier for desc: {localText} = {kvp.Value}"); __result = string.Format("{0}{1} {2:+#;-#}; ", __result, localText, kvp.Value); } } }
static void Postfix(ToHit __instance, ref float __result, Mech attacker, ICombatant target, Vector3 targetPosition, MeleeAttackType meleeAttackType) { Mod.Log.Trace?.Write("TH:GAMM entered"); if (__instance == null) { return; } MeleeAttack selectedAttack = ModState.GetSelectedAttack(attacker); if (selectedAttack == null) { return; } Mod.Log.Debug?.Write("Adding CBTBE modifiers to ToHit"); int sumMod = 0; foreach (KeyValuePair <string, int> kvp in selectedAttack.AttackModifiers) { string localText = new Text(Mod.LocalizedText.Labels[kvp.Key]).ToString(); Mod.Log.Debug?.Write($" - Found attack modifier: {localText} = {kvp.Value}, adding to sum modifier"); sumMod += kvp.Value; } __result += (float)sumMod; }
private void Start() { animator = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); meleeAttack = GetComponent <MeleeAttack>(); standingOnGround = true; }
public static MeleeAttack Instance() { if (MeleeAttack.singleton == null) { MeleeAttack.singleton = new MeleeAttack(); } return(MeleeAttack.singleton); }
void Awake() { weaponManager = GetComponent <WeaponManager>(); meleeAttack = GetComponent <MeleeAttack>(); rangedAttack = GetComponent <RangedAttack>(); animator = GetComponent <Animator>(); block = GetComponent <Block>(); }
void Start() { sprite = GetComponent <SpriteRenderer>(); animator = GetComponent <Animator>(); patrol = GetComponent <Patrol>(); takeDamage = GetComponent <TakeDamage>(); meleeAttack = GetComponent <MeleeAttack>(); }
public override void IssueMeleeAttack(Vector2 loc) { if (MeleeAttack != null) { ArealAttack atk = MeleeAttack.GetInstance(loc); stage.InflictAttack(atk); } }
void Start() { heroTransform = GameObject.FindWithTag("Player").GetComponent <Transform>(); timerPatrollingSide = timePatrollingSide; direction = 1; meleeAtack = GetComponent <MeleeAttack>(); audioSource = GetComponent <AudioSource>(); }
public void Awake() { motor = GetComponent <CharacterMotor>(); weapon = GetComponent <Weapon>(); melee = GetComponent <MeleeAttack>(); holdingPickup = GetComponent <HoldingPickup>(); playerDirection = transform.GetComponent <Direction>(); ani = transform.GetComponent <DwarfAni>(); }
// ================================================================ // public override void initialize() { // Shoot. this.changeBulletShooter(SHOT_TYPE.NEGI); // 근접공격. this.melee_attack = this.gameObject.AddComponent<MeleeAttack>(); this.melee_attack.behavior = this; this.skin_color_control = new SkinColorControl(); this.skin_color_control.create(this); }
void Start() { baseMeleeAttack = new BaseMelee(); hardPunch = new HardPunch(); hardPunch.SetMeleeAttack(baseMeleeAttack); kiPunch = new KiPunch(kiParticles); kiPunch.SetMeleeAttack(baseMeleeAttack); // Set up the Super Ki Punch HardPunch hpDeco = new HardPunch(); hpDeco.SetMeleeAttack(baseMeleeAttack); superKiPunch = hpDeco; KiPunch kpDeco = new KiPunch(kiParticles); kpDeco.SetMeleeAttack(superKiPunch); superKiPunch = kpDeco; }
void Start() { if(!m_MeleeAbility.enabled) m_MeleeAbility = m_MeleeAbility.gameObject.GetComponents<MeleeAttack>().First(c => c.enabled); }