protected override void Start() { base.Start(); GetAllCapturePoints(); // Utility AI setup // ****** VALUES ****** UAIV_AgentHealth agentHealth = new UAIV_AgentHealth(this, _AgentController._AgentStats.HealthPoints); UAIV_SoldierFriendlyCount friendlySoldierCount = new UAIV_SoldierFriendlyCount(this, 4); UAIV_SoldierEnemyCount enemySoldierCount = new UAIV_SoldierEnemyCount(this, 3); UAIV_DistanceToEnemy distanceToEnemy = new UAIV_DistanceToEnemy(this, _AgentController._Senses._ViewRange); UAIV_DistanceToFriendlyFlag distanceToFriendlyFlag = new UAIV_DistanceToFriendlyFlag(this, _AgentController._Senses._ViewRange); UAIV_FriendlyFlagsCount friendlyFlagsCount = new UAIV_FriendlyFlagsCount(this, 5); UAIV_AllFriendlySoldiersCount allFriendlySoldiersCount = new UAIV_AllFriendlySoldiersCount(this, _AgentController._PlayerOwner._MaxSoldiers); // ****** SCORERS ****** UtilityScorer scorer_agentHealth = new UtilityScorer(agentHealth, _HealthCurve); UtilityScorer scorer_friendlyCount = new UtilityScorer(friendlySoldierCount, _FriendlyAgentsCurve); UtilityScorer scorer_enemyCount = new UtilityScorer(enemySoldierCount, _EnemyAgentsCurve); UtilityScorer scorer_distanceToEnemy = new UtilityScorer(distanceToEnemy, _AttackDesireCurve); UtilityScorer scorer_distanceToEnemyFlee = new UtilityScorer(distanceToEnemy, _FleeDesireCurve); UtilityScorer scorer_distanceToFriendlyFlag = new UtilityScorer(distanceToFriendlyFlag, _FriendlyFlagDistanceCurve); UtilityScorer scorer_friendlyFlagsCount = new UtilityScorer(friendlyFlagsCount, _FriendlyFlagsForHQAttackCurve); UtilityScorer scorer_allFriendlySoldiersCount = new UtilityScorer(allFriendlySoldiersCount, _AllFriendlyAgentsCountCurve); // ****** ACTIONS ****** CaptureFlags captureFlagsAction = new CaptureFlags(capturePointsInScene, this, 0.5f); AttackEnemy attackEnemyAction = new AttackEnemy(this, 0.0f); attackEnemyAction.AddScorer(scorer_distanceToEnemy); Flee fleeAction = new Flee(this, 0.0f); fleeAction.AddScorer(scorer_agentHealth); fleeAction.AddScorer(scorer_enemyCount); fleeAction.AddScorer(scorer_friendlyCount); //fleeAction.AddScorer(scorer_distanceToEnemyFlee); HealAtFlag healAtFlagAction = new HealAtFlag(this, 0.0f); healAtFlagAction.AddScorer(scorer_agentHealth); healAtFlagAction.AddScorer(scorer_distanceToFriendlyFlag); healAtFlagAction.AddScorer(scorer_distanceToEnemyFlee); AttackHQ attackHQAction = new AttackHQ(_AgentController._PlayerOwner._EnemyPlayer, this, 0.0f); attackHQAction.AddScorer(scorer_friendlyFlagsCount); attackHQAction.AddScorer(scorer_allFriendlySoldiersCount); // ****** REGISTER ACTIONS ****** _AgentActions.Add(captureFlagsAction); _AgentActions.Add(attackEnemyAction); _AgentActions.Add(fleeAction); _AgentActions.Add(healAtFlagAction); _AgentActions.Add(attackHQAction); }
private static void FactoryInitialize() { const int numberToPreAllocate = 20; for (int i = 0; i < numberToPreAllocate; i++) { AttackEnemy instance = new AttackEnemy(mContentManagerName, false); mPool.AddToPool(instance); } }
// Use this for initialization void Start() { this.m_rigidbody = GetComponent <Rigidbody2D> (); m_anim = GetComponent <Animator> (); health = maxHealth; healthSlider.maxValue = maxHealth; healthSlider.value = health; lm = GameObject.FindObjectOfType <LevelManager> (); startPosition = (Vector2)transform.position; canMove = true; a_Tip = GetComponentInChildren <AttackEnemy> (); }
public static AttackEnemy CreateNew(Layer layer) { if (string.IsNullOrEmpty(mContentManagerName)) { throw new System.Exception("You must first initialize the factory to use it."); } AttackEnemy instance = null; instance = new AttackEnemy(mContentManagerName, false); instance.AddToManagers(layer); if (mScreenListReference != null) { mScreenListReference.Add(instance); } if (EntitySpawned != null) { EntitySpawned(instance); } return(instance); }
public override void Start() { base.Start(); //We need to have this to set up the basic info from Basic Enemy currDirection = cuttlefish.transform.position - transform.position; GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); otherAttackers = new List <AttackEnemy>(); for (int i = 0; i < enemies.Length; i++) { if (enemies[i] != gameObject) { AttackEnemy a = enemies[i].GetComponent <AttackEnemy>(); if (a != null) { otherAttackers.Add(a); } } } }
/// <summary> /// Makes the argument objectToMakeUnused marked as unused. This method is generated to be used /// by generated code. Use Destroy instead when writing custom code so that your code will behave /// the same whether your Entity is pooled or not. /// </summary> public static void MakeUnused(AttackEnemy objectToMakeUnused, bool callDestroy) { objectToMakeUnused.Destroy(); }
/// <summary> /// Makes the argument objectToMakeUnused marked as unused. This method is generated to be used /// by generated code. Use Destroy instead when writing custom code so that your code will behave /// the same whether your Entity is pooled or not. /// </summary> public static void MakeUnused(AttackEnemy objectToMakeUnused) { MakeUnused(objectToMakeUnused, true); }