void HandleAttackInput() { bool InputAttack = false; if (touchControl && player.playerId == Common.PlayerId.TouchPlayer) { InputAttack = touchControl.GetButtonDown(attackButtonName); } else if (Input.GetButtonDown(InputMainAttack) || Input.GetButtonDown(attackButtonName)) { InputAttack = true; } if (InputAttack) { int idCurrentAttack = 0; if (currentAttack) { if (!currentAttack.Equals(attackCombo[attackCombo.Length - 1].attack)) { idCurrentAttack = currentAttack.AttackComboOrder + 1; } } currentAttack = attackCombo[idCurrentAttack].attack; currentAttack.attackReaction = attackCombo[idCurrentAttack].attackReaction; currentAttack.attackType = attackCombo[idCurrentAttack].attackType; currentAttack.attackRange = attackRange; currentAttack.attackReactionPower = attackReactionPower; currentAttack.Damage = DamagePower; currentAttack.Fire(); } }
public override void InitPlayer() { if (!isInited) { id++; teamGoally = transform.parent.gameObject.GetComponentInChildren<GoallyPlayer>(); if (teamGoally.transform.position.x < 0) { isRedTeam = false; } else { isRedTeam = true; } AttackPlayer[] list = oponentTeam.GetComponentsInChildren<AttackPlayer>(); foreach (AttackPlayer a in list) { if (a.NameType == GameConsts.ATTACK_PLAYER) { oponentAttacker = a; break; } } rgBody = GetComponent<Rigidbody2D>(); ballScript = FindObjectOfType<BallScript>(); brain = new NeuralNetwork(NeuralNetworkConst.DEFENSE_INPUT_COUNT, NeuralNetworkConst.DEFENSE_OUTPUT_COUNT, NeuralNetworkConst.DEFENSE_HID_LAYER_COUNT, NeuralNetworkConst.DEFENSE_NEURONS_PER_HID_LAY); isInited = true; } }
// Start is called before the first frame update void Start() { sP = GetComponent <StalkPlayer>(); aP = GetComponent <AttackPlayer>(); source = GetComponent <AudioSource>(); source.pitch = Random.Range(0.8f, 3f); }
/// <summary> /// Initializes the Finite state machine. /// </summary> protected virtual void MakeFSM() { // Follow behaviour FollowPlayer follow = new FollowPlayer(attackRange, playerAttackLayer, this); follow.AddTransition(Transition.InPlayerAttackRange, StateID.AttackPlayer); follow.AddTransition(Transition.ReachedDestination, StateID.Idle); // Attack behaviour AttackPlayer attack = new AttackPlayer(attackRange, playerAttackLayer, attackInterval, pushAwayForce, this); attack.AddTransition(Transition.LostPlayerAttackRange, StateID.FollowPlayer); attack.AddTransition(Transition.ReachedDestination, StateID.Idle); // Idle behaviour IdleEnemy idle = new IdleEnemy(); idle.AddTransition(Transition.SawPlayer, StateID.FollowPlayer); fsm = new FSMSystem(); fsm.AddState(follow); fsm.AddState(attack); fsm.AddState(idle); }
public void SpawnEnemy() { GameObject enemyObj = GameObject.Instantiate(enemyPrefabs[_index++], this.transform.position, Quaternion.identity); _spawned.Add(enemyObj); _timeGivenUp.Add(0); AttackPlayer ap = enemyObj.GetComponent <AttackPlayer>(); FollowPlayer fp = enemyObj.GetComponent <FollowPlayer>(); _spawnedFollow.Add(fp); if (Game.Instance.playerShip != null) { if (fp != null) { fp.trackThisObject = Game.Instance.playerShip.gameObject; } if (ap != null) { ap.attackThis = Game.Instance.playerShip.gameObject; } } enemySpawned?.Invoke(this, enemyObj); }
public override void InitPlayer() { if (!isInited) { id++; teamGoally = transform.parent.gameObject.GetComponentInChildren <GoallyPlayer>(); if (teamGoally.transform.position.x < 0) { isRedTeam = false; } else { isRedTeam = true; } AttackPlayer[] list = oponentTeam.GetComponentsInChildren <AttackPlayer>(); foreach (AttackPlayer a in list) { if (a.NameType == GameConsts.ATTACK_PLAYER) { oponentAttacker = a; break; } } rgBody = GetComponent <Rigidbody2D>(); ballScript = FindObjectOfType <BallScript>(); brain = new NeuralNetwork(NeuralNetworkConst.DEFENSE_INPUT_COUNT, NeuralNetworkConst.DEFENSE_OUTPUT_COUNT, NeuralNetworkConst.DEFENSE_HID_LAYER_COUNT, NeuralNetworkConst.DEFENSE_NEURONS_PER_HID_LAY); isInited = true; } }
private AttackPlayer() { if (_instance != null) { return; } _instance = this; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Enemy" || collision.tag == "EnemyMiniBoss") { attackPlayer = collision.GetComponent <AttackPlayer>(); attackPlayer.attackPlayer = true; attackPlayer.playerStats = thePlayerStats; } }
private void OnTriggerEnter2D(Collider2D collision) { Debug.Log("Attack Range collision with " + collision.tag); if (collision.tag == "Enemy" || collision.tag == "EnemyMiniBoss") { attackPlayer = collision.GetComponent <AttackPlayer>(); attackPlayer.EnemyAttackPlayer(attackPlayer.enemyStats.strength, "Player"); attackPlayer.timeUntilNextAttack = attackPlayer.enemyStats.attackSpeed; } }
private static void FactoryInitialize() { const int numberToPreAllocate = 20; for (int i = 0; i < numberToPreAllocate; i++) { AttackPlayer instance = new AttackPlayer(mContentManagerName, false); mPool.AddToPool(instance); } }
void HandleCurrentAttack() { if (currentAttack) { if (!currentAttack.IsFired()) { currentAttack = null; } } }
private void Awake() { m_MoveBehaviour = GetComponent <MovePlayer>(); m_JumpBehaviour = GetComponent <JumpPlayer>(); m_DashBehaviour = GetComponent <DashPlayer>(); m_AttackBehaviour = GetComponent <AttackPlayer>(); //m_PlayerInput = GetComponent<PlayerInput>(); //m_JumpAction = m_PlayerInput.actions["Jump"]; }
private void Awake() { rb = GetComponent <Rigidbody2D>(); Assert.IsNotNull(rb); AttackPlayer attack = GetComponent <AttackPlayer>(); Assert.IsNotNull(attack); attack.AddHitPlayerCallback(HitPlayer); }
private void AddForceToChildObjects(Transform parentObject) { Transform childObject = parentObject.GetChild(1); if (childObject.GetComponent <Rigidbody>() != null) { AttackPlayer currentAttack = attackPrefabs[attackIndex]; childObject.GetComponent <Rigidbody>().AddForce(currentAttack.direction * currentAttack.force, ForceMode.Impulse); Destroy(childObject.gameObject, currentAttack.duration); } }
static bool Prefix(AttackPlayer __instance, int value) { if (Mod.instance.wasAttack) { System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace(); Mod.instance.GetLogger().LogInfo(string.Format("Called with {0}", value)); Mod.instance.GetLogger().LogInfo(t.ToString()); Mod.instance.wasAttack = false; return(false); } return(true); }
// Start is called before the first frame update void Start() { currentLife = maximumLife; generateWeaknessTimer = Random.Range(generateWeaknessDuration, 8); attackPlayerScript = GetComponentInParent <AttackPlayer>(); spawnPoint = GameObject.Find("MasterSpawner").GetComponent <Spawnpoint>(); playerStats = GameObject.Find("GameManager").GetComponent <PlayerStats>(); enemyWeakness = GetComponentInChildren <EnemyWeakness>(); AddWeaknessToEnemy(); }
private void Awake() { Assert.IsTrue(speed > 0); AttackPlayer attackPlayer = GetComponent <AttackPlayer>(); Assert.IsNotNull(attackPlayer); attackPlayer.AddHitEnemyCallback(Flip); attackPlayer.AddHitPlayerCallback(Flip); rb = GetComponent <Rigidbody2D>(); Assert.IsNotNull(rb); }
private void Awake() { source = GetComponentInChildren <AudioSource>(); things = FindObjectsOfType <WaveyThing>(); physicsMat = GetComponentInChildren <Collider2D>().sharedMaterial; col = GetComponent <Collider2D>(); AttackPlayer attackPlayer = GetComponent <AttackPlayer>(); if (attackPlayer) { attackPlayer.enabled = false; } }
private void Awake() { rb = GetComponent <Rigidbody2D>(); player = GameObject.FindGameObjectWithTag("Player"); spriteRend = GetComponentInChildren <SpriteRenderer>(); attack = GetComponent <AttackPlayer>(); nav = GetComponent <NavMeshAgent>(); defaultFlipX = spriteRend.flipX; defaultFlipY = spriteRend.flipY; foundNavMesh = (nav != null); //Debug.Log("'Found navmesh' on " + gameObject.name + " = " + foundNavMesh); }
private void OnSceneGUI() { AttackPlayer attackPlayer = (AttackPlayer)target; Handles.color = Color.red; Handles.DrawWireArc(attackPlayer.transform.position, Vector3.up, Vector3.forward, attackPlayer.AttackAngle, attackPlayer.AttackRadius); Vector3 viewAngleA = attackPlayer.transform.DirectionFromAngle(-attackPlayer.AttackAngle / 2, false); Vector3 viewAngleB = attackPlayer.transform.DirectionFromAngle(attackPlayer.AttackAngle / 2, false); Handles.DrawLine(attackPlayer.transform.position, attackPlayer.transform.position + (viewAngleB - viewAngleA * -1) * attackPlayer.AttackRadius / 2); Handles.DrawLine(attackPlayer.transform.position, attackPlayer.transform.position + viewAngleA * attackPlayer.AttackRadius); Handles.DrawLine(attackPlayer.transform.position, attackPlayer.transform.position + viewAngleB * attackPlayer.AttackRadius); }
public override void Update(AIController owner) { owner.anim.SetFloat("Speed", 10); // Checks if the the npc has reached the target if (!owner.NavAgent.pathPending && owner.NavAgent.remainingDistance < 0.5f) { GotoNextPoint(owner); // Triggers function to set the new waypoint } // Vector3.Distance(((AISuspectController)owner).Player.transform.position, owner.transform.position) <= 20 if (AttackPlayer.IsPlayerVisible((AISuspectController)owner)) { owner.StateMachine.ChangeState(TakeCover.Instance); } }
// Use this for initialization void Start() { facingRight = true; myRigidbody = GetComponent <Rigidbody2D>(); myAnimator = GetComponent <Animator>(); ourHealth = maxHealth; gm = GameObject.FindGameObjectWithTag("gamemaster").GetComponent <Gamemaster>(); soundManager = GameObject.FindGameObjectWithTag("Sounds").GetComponent <SoundManager>(); at = GameObject.FindGameObjectWithTag("attri").GetComponent <AttackPlayer>(); te = GameObject.FindGameObjectWithTag("Enemy").GetComponent <TestEnemy>(); eyybd = GameObject.FindGameObjectWithTag("Enemy1").GetComponent <EnemyyBlood>(); // ob = GameObject.FindGameObjectWithTag("Oc").GetComponent<OcBlood>(); // ns = GameObject.FindGameObjectWithTag("Nhim").GetComponent<NhimScrips>(); dead = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <DeadUI>(); }
private void Awake() { Assert.IsTrue(speed > 0); AttackPlayer attackPlayer = GetComponent <AttackPlayer>(); Assert.IsNotNull(attackPlayer); attackPlayer.AddHitEnemyCallback(Collided); attackPlayer.AddHitPlayerCallback(Collided); rb = GetComponent <Rigidbody2D>(); Assert.IsNotNull(rb); rb.velocity = new Vector3(speed, 0, 0); }
private void FillTeamWithDummyPlayers() { /* DEFENSE PLAYERS */ while (defensePlayers.Count < GameConsts.DEFENSE_PLAYER_COUNT) { var gO = Instantiate(dummyDefensePlayer) as GameObject; gO.transform.parent = transform; gO.transform.position = new Vector2(defenseExample.transform.position.x, defenseExample.transform.position.y); DefensePlayer defPlayer = gO.GetComponent <DefensePlayer>(); defPlayer.oponentTeam = defenseExample.oponentTeam; defPlayer.oponentGoal = defenseExample.oponentGoal; defPlayer.homeGoal = defenseExample.homeGoal; defPlayer.attackerPlayer = attackExample; defPlayer.InitPlayer(); defPlayer.TeamGoally = goallyExample; defPlayer.OponentsAttacker = defenseExample.OponentsAttacker; defensePlayers.Add(defPlayer); } /* ATTACK PLAYERS */ while (attackPlayers.Count < GameConsts.ATTACK_PLAYER_COUNT) { var gO = Instantiate(dummyAttacker) as GameObject; gO.transform.parent = transform; gO.transform.position = new Vector2(attackExample.transform.position.x, attackExample.transform.position.x); AttackPlayer attPlayer = gO.GetComponent <AttackPlayer>(); attPlayer.oponentGoal = attackExample.oponentGoal; attPlayer.oponentTeam = attackExample.oponentTeam; attPlayer.InitPlayer(); attackPlayers.Add(attPlayer); } /* GOALY PLAYERS */ while (goalyPlayers.Count < GameConsts.GOALLY_PLAYER_COUNT) { var gO = Instantiate(dummyGoaly) as GameObject; gO.transform.parent = transform; gO.transform.position = new Vector2(goallyExample.transform.position.x, goallyExample.transform.position.y); GoallyPlayer goaly = gO.GetComponent <GoallyPlayer>(); goaly.oponentGoal = goallyExample.oponentGoal; goaly.oponentTeam = goallyExample.oponentTeam; goaly.goalToSave = goallyExample.goalToSave; goaly.TeamAttacker = goallyExample.TeamAttacker; goaly.InitPlayer(); goalyPlayers.Add(goaly); } }
// Update is called once per frame void Update() { switch (currentState) { case EnemyStates.ATTACK: AttackPlayer?.Invoke(enemy); break; case EnemyStates.CHASE: PlayerDetected?.Invoke(enemy, currentTarget); break; case EnemyStates.IDLE: PlayerUndetected?.Invoke(enemy); break; } }
public static AttackPlayer CreateNew(Layer layer) { if (string.IsNullOrEmpty(mContentManagerName)) { throw new System.Exception("You must first initialize the factory to use it."); } AttackPlayer instance = null; instance = new AttackPlayer(mContentManagerName, false); instance.AddToManagers(layer); if (mScreenListReference != null) { mScreenListReference.Add(instance); } if (EntitySpawned != null) { EntitySpawned(instance); } return(instance); }
public override void InitPlayer() { if (!isInited) { id++; var attackers = transform.parent.gameObject.GetComponentsInChildren <AttackPlayer>(); foreach (AttackPlayer a in attackers) { if (a.NameType == GameConsts.ATTACK_PLAYER) { teamAttacker = a; break; } } rgBody = GetComponent <Rigidbody2D>(); ballScript = FindObjectOfType <BallScript>(); brain = new NeuralNetwork(NeuralNetworkConst.GOLY_INPUT_COUNT, NeuralNetworkConst.GOLY_OUTPUT_COUNT, NeuralNetworkConst.GOLY_HID_LAYER_COUNT, NeuralNetworkConst.GOLY_NEURONS_PER_HID_LAY); curYDiffWithBall = ballScript.transform.position.y - transform.position.y; isInited = true; } }
public override void InitPlayer() { if (!isInited) { id++; var attackers = transform.parent.gameObject.GetComponentsInChildren<AttackPlayer>(); foreach(AttackPlayer a in attackers) { if(a.NameType == GameConsts.ATTACK_PLAYER) { teamAttacker = a; break; } } rgBody = GetComponent<Rigidbody2D>(); ballScript = FindObjectOfType<BallScript>(); brain = new NeuralNetwork(NeuralNetworkConst.GOLY_INPUT_COUNT, NeuralNetworkConst.GOLY_OUTPUT_COUNT, NeuralNetworkConst.GOLY_HID_LAYER_COUNT, NeuralNetworkConst.GOLY_NEURONS_PER_HID_LAY); curYDiffWithBall = ballScript.transform.position.y - transform.position.y; isInited = true; } }
void Start() { if (gameObject.name.StartsWith("Red")) { teamName = "Red"; } else { teamName = "Blue"; } var att = GetComponentsInChildren <AttackPlayer>(); foreach (AttackPlayer a in att) { if (a.NameType == GameConsts.ATTACK_PLAYER) { attackExample = a; break; } } defenseExample = GetComponentInChildren <DefensePlayer>(); goallyExample = GetComponentInChildren <GoallyPlayer>(); try { LoadStats(); } catch (Exception e) { InitMainTeam(); FillTeamWithDummyPlayers(); InitGeneticAlgorithms(); } InitStartingPositionForReset(); WarmUp(); }
public void Setup(LocalBlackboard localBlackboard) { _localBlackboard = localBlackboard; if (TryGetComponent(out AttackPlayer temp)) { _attackPlayer = temp; _attackPlayer.Setup(localBlackboard); } foreach (GameObject atk in attackPrefabs) { attackRoots.Add(atk.GetComponent <AttackRoot>()); } foreach (AttackRoot atkRt in attackRoots) { atkRt.Setup(_localBlackboard); } _localBlackboard.attackCount = attackRoots.Count; SelectAttack(); }
static void DisabledPostfix(AttackPlayer __instance, string _itemName, WeaponType _type) { var herofield = __instance.GetType().GetField("Hero", BindingFlags.NonPublic | BindingFlags.Instance); NetworkHandlerPlayer player = (NetworkHandlerPlayer)herofield.GetValue(__instance); Item item; Weapon weapon; if (_itemName == string.Empty) { item = player.Equipment.CurrWeapon.slotItem; } else { item = ItemDatabase.DB[_itemName]; } weapon = (Weapon)item; Mod.instance.GetLogger().LogInfo(string.Format("Left Attack with item {0} and type {1}.", item.itemName, weapon.weaponType)); Mod.instance.GetLogger().LogInfo(string.Format("Have player {0}.", player.PlayerName)); player.Equipment.SetBattlePosition(weapon.weaponType); __instance.isCombatMode = true; //player.Equipment.ChangeBattlePosition(true, item.itemName, weapon.weaponType); weapon.EquipItem(player); player.Anim.SetTrigger("Attack", true); player.Anim.SetInteger("WeaponLayer", item.itemAnimVar); player.Movement.SetWalkCondition(0); player.Attack.SetAttackCondition(1); // Code above allows us to slide up until the moment we actually shoot. // But it also interrupts attacking if left click isn't spammed. // When put into Postfix, we actually just start casting fireball like a Lvl1 Wizard in D&D. }
void Start() { if (gameObject.name.StartsWith("Red")) { teamName = "Red"; } else { teamName = "Blue"; } var att = GetComponentsInChildren<AttackPlayer>(); foreach (AttackPlayer a in att) { if (a.NameType == GameConsts.ATTACK_PLAYER) { attackExample = a; break; } } defenseExample = GetComponentInChildren<DefensePlayer>(); goallyExample = GetComponentInChildren<GoallyPlayer>(); try { LoadStats(); } catch (Exception e) { InitMainTeam(); FillTeamWithDummyPlayers(); InitGeneticAlgorithms(); } InitStartingPositionForReset(); WarmUp(); }
// Use this for initialization void Start() { ap = GetComponent <AttackPlayer> (); powerOutline.gameObject.SetActive(false); }