// Use this for initialization
 void Start()
 {
     laserCannons = gameObject.GetComponentsInChildren<LaserCannon>();
     canFireLasers = true;
     ai_controller = gameObject.GetComponent<AI_Controller>();
     target = ai_controller.target;
 }
Exemple #2
0
 private void Awake()
 {
     mRigid         = GetComponent <Rigidbody>();
     mEntity        = GetComponent <AI_Controller>();
     mAnim          = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
     mModelFollower = UT_FindComponent.FindComponent <ObjectFollower>(gameObject);
 }
 private void Awake()
 {
     mCont       = GetComponent <AI_Controller>();
     mGun        = GetComponentInChildren <WP_Gun>();
     mEyeCaster  = GetComponentInChildren <AI_EyeCaster>();
     mFootCaster = GetComponentInChildren <AI_FeetCaster>();
 }
 private void OnEnable()
 {
     if (myController == null)
     {
         myController = gameObject.GetComponent <AI_Controller>();
     }
 }
    private void OnTriggerEnter(Collider other)
    {
        // Also want it destroying the lanky shield if it hits him
        if (hasBeenThrown)
        {
            EnemyForceField forceField = UT_FindComponent.FindComponent <EnemyForceField>(other.gameObject);
            if (forceField != null)
            {
                forceField.TakeDamage(10000f);
                DestroyObject();
                return;
            }
        }

        if ((other.GetComponent <DestroyObjectOnCollision>() != null && other.GetComponent <ThrowableObject>() == null) && hasBeenThrown)
        {
            DestroyObject();
            return;
        }

        AI_Controller npc = UT_FindComponent.FindComponent <AI_Controller>(other.gameObject);

        if (npc != null && hasBeenThrown)
        {
            npc.TakeDamage(properties.damage);
            addScore.Raise(pointsForEnemyKill);
            DestroyObject();
        }
    }
Exemple #6
0
    private void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        if (GameStateManager.Instance.MatchType != MatchTypes.Singleplayer)
        {
            return;
        }
        PlayerAIs = new AI_BaseClass[2];

        for (int i = 0; i < PlayerAIs.Length; i++)
        {
            isPlayerAI[i] = Player.Players[i].Type == PlayerType.AI;
            if (isPlayerAI[i])
            {
                PlayerAIs[i] = new AI_BaseClass(i);
            }
            else
            {
                PlayerAIs[i] = null;
            }
        }
        TurnManager.Instance.NewTurnEvent += OnNewTurn;
    }
    public override void OnInspectorGUI()
    {
        GUILayout.Label("AI PATROL POINTS LIST", EditorStyles.boldLabel);

        DrawDefaultInspector();

        if (presetsData == null)
        {
            presetsData = Resources.Load <AI_PresetsSave>("ScriptObjects/AI_PresetsSave");
        }

        trg = (AI_Controller)target;

        ReloadPreset();

        GUILayout.Space(10);
        GUILayout.Label("SELECT GLOBAL AI PRESET", EditorStyles.boldLabel);
        trg._presetIndex = EditorGUILayout.Popup("", trg._presetIndex, _aiPresets);
        GUILayout.Label("TO CREATE A NEW AI PRESET OPEN 'AI/AI CONTROLLER WINDOW' IN TOP TOOLBAR", EditorStyles.boldLabel);

        GUILayout.Space(10);
        GUILayout.Label("AGENT IS: " + _aiState[trg._agentState], EditorStyles.boldLabel);

        if (trg._pointsList != null)
        {
            GUILayout.Label("AGENT TARGET: " + trg._pointsList._points[trg.pointIndex].name, EditorStyles.boldLabel);
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (_gameOn)
        {
            if (_Enemy == null && _detectionTimer >= _detectionCoolDown)
            {
                if (!_isEscorting && other.gameObject.tag == "Player" && gameObject.tag == "Enemy")
                {
                    _detectionTimer = 2.0f;
                    _Enemy          = other.gameObject;
                    _AIState        = AIStates.Alert;
                }
                else if (!_isEscorting && other.gameObject.tag == "Enemy" && gameObject.tag == "Player")
                {
                    _detectionTimer = 2.0f;
                    _Enemy          = other.gameObject;
                    _AIState        = AIStates.Alert;
                }
            }

            if (_Friend == null && _canEscort && !_isPanicing && !_isRaging && _detectionTimer >= _detectionCoolDown)
            {
                if ((other.gameObject.tag == "Enemy" && gameObject.tag == "Enemy") || (other.gameObject.tag == "Player" && gameObject.tag == "Player"))
                {
                    _detectionTimer = 2.0f;
                    AI_Controller friend = other.gameObject.GetComponent <AI_Controller>();
                    if (friend._EnemyName == _SupporterName)
                    {
                        _Friend = other.gameObject;
                    }
                }
            }
        }
    }
Exemple #9
0
    private Vector3 CalculateRandomError(Vector3 dir)
    {
        AI_Controller owner = UT_FindComponent.FindComponent <AI_Controller>(gameObject);

        if (owner == null)
        {
            return(dir);
        }

        SO_AI_Base bs = owner.GetBase();

        if (!bs.mFireInaccurately)
        {
            return(dir);
        }

        // now find a random spread up to the max spread.
        float spread = Random.Range(0, bs.mInacRange);

        if (Random.value > 0.5f)
        {
            spread *= -1;
        }

        // now apply that spread to the bullets direction.
        Vector3 newDir = Quaternion.AngleAxis(spread, Vector3.up) * dir;

        return(newDir);
    }
 public override void Act(AI_Controller controller)
 {
     if (eventToInvoke != null)
     {
         eventToInvoke.RaiseEvent(changeState);
     }
 }
Exemple #11
0
 private void Awake()
 {
     mRigid         = GetComponent <Rigidbody>();
     mEntity        = GetComponent <AI_Controller>();
     mAnim          = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
     mStunParticles = GetComponentInChildren <StunnedParticles>();
 }
    private void Fire(AI_Controller controller)
    {
        float total = 0f;

        foreach (ProjectileAndChance elem in itemList)
        {
            total += elem.chance;
        }

        float randomPoint = Random.value * total;

        for (int i = 0; i < itemList.Count; i++)
        {
            if (randomPoint <= itemList[i].chance)
            {
                int?laneID = null;
                if (!fireOnAll)
                {
                    laneID = controller.gameObject.GetInstanceID();
                }

                fireProjectileEvent.RaiseEvent(itemList[i].item.gameObject, laneID);
                break;
            }
            else
            {
                randomPoint -= itemList[i].chance;
            }
        }
    }
 public NavMeshAgent Get_NavMeshAgent(Animator animator)
 {
     if (characterController == null)
     {
         characterController = animator.GetComponent <AI_Controller>();
     }
     return(characterController.agent);
 }
 public AI_Controller.State Get_CharacterState(Animator animator)
 {
     if (characterController == null)
     {
         characterController = animator.GetComponent <AI_Controller>();
     }
     return(characterController.state);
 }
 public AI_Controller.Role Get_CharacterRole(Animator animator)
 {
     if (characterController == null)
     {
         characterController = animator.GetComponent <AI_Controller>();
     }
     return(characterController.role);
 }
Exemple #16
0
 /// <summary>
 /// Send References to the  AI script
 /// </summary>
 /// <param name="aiControl"></param>
 /// <param name="rbRef"></param>
 /// <param name="cusPart"></param>
 public void GrabAIReferences(AI_Controller aiControl, Rigidbody2D rbRef, CustomParticles cusPart, AI_WallRay aiRay, TokenController token)
 {
     aiControlRef      = aiControl;
     rb                = rbRef;
     particlControlRef = cusPart;
     aiWallRay         = aiRay;
     tokenControlRef   = token;
 }
Exemple #17
0
 // Here we add ourselves to the list of enemies that want to fire.
 public void ThisEnemyWantsToFire(AI_Controller enemy)
 {
     if (mEnemiesTryingToFire.Contains(enemy))
     {
         return;
     }
     mEnemiesTryingToFire.Add(enemy);
 }
Exemple #18
0
 private void Awake()
 {
     mEntity   = GetComponent <AI_Controller>();
     mOrienter = GetComponent <AI_Orienter>();
     mRigid    = GetComponent <Rigidbody>();
     mAnim     = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
     mMover    = GetComponent <AI_MoveToGoal>();
 }
    private void Start()
    {
        AI_Controller ai = playerTransform.GetComponent <AI_Controller>();

        if (ai)
        {
            GetComponentInChildren <UI_TaskDebugInfo>().ai = ai;
        }
    }
 private bool ChangeToVictory(AI_Controller _controller)
 {
     if (m_playerHealth.value <= 0)
     {
         DebugLogger.Log <AI_Decision_Victory>("Player Health in Decision: " + m_playerHealth.value);
         return(true);
     }
     return(false);
 }
Exemple #21
0
 private bool ChangeToLose(AI_Controller _controller)
 {
     if (m_AIHealth.value <= 0)
     {
         DebugLogger.Log <AI_Decision_Lose>("AI Health in Decision: " + m_AIHealth.value);
         return(true);
     }
     return(false);
 }
Exemple #22
0
    // Use this for initialization
    void Start()
    {
        anim       = GetComponent <Animator>();
        ai         = GetComponent <AI_Movement>();
        controller = GetComponent <AI_Controller>();

        state     = animationState.IDLE;
        prevState = state;
    }
        /// <summary>
        /// Generation of Enemies
        /// </summary>
        private void GenerateEnemy(ENEMIES_SPAWN_STYLE _style, Lane_Mk2 _lane, int _index)
        {
            // Create Enemies
            AI_Controller tempEnemy = Instantiate(m_enemyPrefab, transform.parent, true);

            tempEnemy.transform.localScale = new Vector3(m_scaleMultiplier, m_scaleMultiplier, m_scaleMultiplier);
            // Offset Variables ---- HACK #3 KMS yes
            float m_offsetZ = 0.25f * transform.localScale.z;

            // Based on Style, position the enemies accordingly
            tempEnemy.transform.position = _lane.m_enemySpawnPoint.position;
            switch (_style)
            {
            case ENEMIES_SPAWN_STYLE.W_STYLE:
                switch (m_laneLayout)
                {
                case LANE_LAYOUT.HORIZONTAL:
                    switch (_index % 2)
                    {
                    case 0:
                        break;

                    case 1:
                        // Add a z offset
                        tempEnemy.transform.localPosition -= _lane.m_enemySpawnPoint.forward * m_offsetZ;
                        // Add a x offset
                        tempEnemy.transform.localPosition += _lane.m_enemySpawnPoint.right * m_widthLane * 0.5f;
                        Destroy(tempEnemy.transform.Find("ProjectileSpawner").gameObject);
                        return;
                    }
                    break;

                case LANE_LAYOUT.CIRCULAR:
                    // generate surrounding in a circle
                    break;
                }
                break;

            default:
                break;
            }
            // Add a z offset
            //tempEnemy.transform.localPosition -= _lane.m_enemySpawnPoint.forward * m_offsetZ;

            // Make Enemy look accordingly to lane layout
            switch (m_laneLayout)
            {
            case LANE_LAYOUT.HORIZONTAL:
                tempEnemy.transform.forward = m_laneList[0].transform.forward;
                break;

            case LANE_LAYOUT.CIRCULAR:
                tempEnemy.transform.LookAt(transform);
                break;
            }
        }
 private void Awake()
 {
     mEntity   = GetComponent <AI_Controller>();
     mCons     = GetComponent <AI_Conditions>();
     mOrienter = GetComponent <AI_Orienter>();
     mStrafer  = GetComponent <AI_Strafer>();
     mGun      = GetComponentInChildren <WP_Gun>();
     mRigid    = GetComponent <Rigidbody>();
     mAnim     = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
 }
    public virtual bool AssignWorker(AI_Controller worker)
    {
        if (this.worker != null)
        {
            return(false);
        }

        this.worker = worker;
        return(true);
    }
Exemple #26
0
    public override void Spawn(Hex a_startingTile)
    {
        base.Spawn(a_startingTile);

        healthBar.Show();

        // Get the AI Controller and tell it that this agent was spawned
        ai_Controller = GameObject.FindGameObjectWithTag("AI_Controller").GetComponent <AI_Controller>();
        players       = ai_Controller.AddUnit(this);
    }
    public void Init(float moveSpeed)
    {
        activeArea    = AreaController.instance.active_area;
        speed         = new Stat(moveSpeed, StatType.MoveSpeed);
        curTile       = activeArea.GetTile(transform.position);
        aI_Controller = GetComponent <AI_Controller>();

        // Modify this unit's speed to add randomness to each unit
        speed.AddModifier(Random.Range(-0.5f, 0.5f));
    }
Exemple #28
0
    private void Awake()
    {
        mStoredPath = new List <int>();
        mStoredPath.Clear();

        mEntity      = GetComponent <AI_Controller>();
        mWallChecker = GetComponent <AI_WallCheck>();
        mGrounder    = GetComponentInChildren <Grounded>();
        mFootCaster  = GetComponentInChildren <AI_FeetCaster>();
    }
Exemple #29
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
    public void SetAIStats(int i, AI_Controller t)
    {
        AIStats a = ai_stats[i];

        t.changeStateTolerance = Ran(a.changeStateTolerance_min, a.changeStateTolerance_max);
        t.normalRate           = Ran(a.normalRate_min, a.normalRate_max);
        t.closeRate            = Ran(a.closeRate_min, a.closeRate_max);
        t.blockingRate         = Ran(a.blockingRate_min, a.blockingRate_max);
        t.aiStateLife          = Ran(a.aiStateLife_min, a.aiStateLife_max);
        t.jumpRate             = Ran(a.jumpRate_min, a.jumpRate_max);
    }
    public override void Act(AI_Controller _controller)
    {
        // Set "Attack" Animation to play
        _controller.gameObject.GetComponent <Animator>().SetTrigger("Attack");

        // Send Sound event to play
        if (m_sound != null)
        {
            m_triggerSoundEvent.RaiseEvent(m_sound);
        }
    }
Exemple #32
0
	public int AddEnemy(AI_Controller addMe)
	{
		int ID;
		for (ID = 0; ID < enemies.Count; ID++)
		{
			if (enemies[ID] == addMe)
				break;

		}
		if(ID == enemies.Count)
			enemies.Add(addMe);
		return ID;
	}
    //void OnGUI()
    //{
    //GUILayout.BeginArea(new Rect(Screen.width-150, 10, 150, 150));
    //GUILayout.BeginVertical();
    //GUILayout.Label("Num Enemies: " + enemies.Count);
    //GUILayout.EndVertical();
    //GUILayout.EndArea();
    //}
    public void SpawnEnemy(int numEnemies, Vector3 spawnLoc, AI_Controller.AI_Types _ai_type, Transform _target)
    {
        for (int i = 0; i < numEnemies; i++)
        {
            Vector3 spawnPos = spawnLoc + Random.onUnitSphere * 500;
            GameObject enemyClone = Instantiate(enemy, spawnPos, Quaternion.identity) as GameObject;
            enemyClone.GetComponent<AI_Controller>().ai_type = _ai_type;
            enemyClone.GetComponent<AI_Controller>().target = _target;
            enemyClone.transform.LookAt(_target);
            enemies.Add(enemyClone);
            missionController.missionEnemies.Add(enemyClone);

        }
    }
 void OnDestroy()
 {
     Instance = null;
 }
 void Awake()
 {
     if (Instance == null) {
         Instance = this;
     } else {
         Destroy(gameObject);
     }
 }
 public void GenerateDistressMission(MissionType missionType, Transform _waypoint, Vector3 _victimPos, int _enemiesToKill, AI_Controller.AI_Types _ai_type)
 {
     this.missionType = missionType;
     currentVictim = Instantiate(victimPrefab, _victimPos, Quaternion.identity) as GameObject;
     enemyController.SpawnEnemy(_enemiesToKill, _victimPos, _ai_type, currentVictim.transform);
     missionComplete = false;
     missionFailed = false;
     enemiesLeftToKill = _enemiesToKill;
 }
 public void GenerateExterminateMission(MissionType missionType,Transform _waypoint, Vector3 _enemySpawnPoint, int _enemiesToKill, AI_Controller.AI_Types _ai_type)
 {
     this.missionType = missionType;
     enemyController.SpawnEnemy(_enemiesToKill, _enemySpawnPoint, _ai_type,playerTarget);
     missionComplete = false;
     missionFailed = false;
     enemiesLeftToKill = _enemiesToKill;
 }
 public void GenerateDestroyStructureMission(MissionType missionType, Transform _waypoint, Vector3 _structurePos, int _enemiesToKill, AI_Controller.AI_Types _ai_type)
 {
     this.missionType = missionType;
     currentEnemyStruct = Instantiate(enemyStructPrefab, _structurePos, Quaternion.identity) as GameObject;
     enemyController.SpawnEnemy(_enemiesToKill, _structurePos, _ai_type, playerTarget);
     missionComplete = false;
     missionFailed = false;
     enemiesLeftToKill = _enemiesToKill;
 }