void Start()
	{
		objectAsReference.transform.position = transform.position;
		
		//set up the resting position gameobject
		if(transform.Find(nameOfRestingPosition) == null )
		{
			restingPosition = new GameObject( nameOfRestingPosition );
			restingPosition.transform.parent = transform;
			restingPosition.transform.position = transform.position;
			
			restingPosition.transform.localRotation = Quaternion.Euler( new Vector3( 90f, 0f, 0f) );
			restingPosition.transform.localPosition -= new Vector3( 0f, 0.4f, 0f );
			
		}
		else
		{
			restingPosition = transform.Find(nameOfRestingPosition).gameObject;
		}
		
		//set up cache correctly
		brain = transform.parent.parent.GetComponent<AIStateManager>();
		weaponController = transform.parent.parent.GetComponent<AIWeaponController>();
		
	}
Example #2
0
    private void Start()
    {
        aiCharacter = GetComponentInParent <AIStateManager>();
        longerVisionConePosition = new Vector3(transform.position.x, transform.position.y, (transform.position.z * 2));
        longerVisionConeScale    = new Vector3(transform.localScale.x, (transform.localScale.y * 2), transform.localScale.z);

        originalVisionConePosition = transform.position;
        originalVisionConeScale    = transform.localScale;
    }
 private void Start()
 {
     soldierIncrease = maxSoldiers + 2;
     AIState         = AIStateManager.Instance;
     playerTownHall  = GameObject.Find("TownHall(Clone)");
     aiTownHall      = GameObject.Find("EnemyTownHall(Clone)");
     mercenary       = GetComponent <Mercenary>();
     animator        = GetComponent <Animator>();
     ConfigureMercenarySettings();
 }
    private void OnGUI()
    {
        AIState = EditorGUILayout.TextField("State's Name", AIState);
        aio     = (AIOwner)EditorGUILayout.EnumPopup("AI's type", aio);

        if (GUILayout.Button("Add new AI state") && AIState != null)
        {
            AIStateManager.AddNewAIState(AIState, aio.ToString());
        }
    }
    private void Start()
    {
        AIStateManager state = new AIStateManager();

        animator  = GetComponent <Animator>();
        enManager = EnemyWorkerManager.Instance;
        setSpawnLocation(this.transform);
        createDictionary();
        InvokeRepeating("checkUnderAttack", 2.0f, 2.0f);
        grid = FindObjectOfType <Grid>();
    }
Example #6
0
 private void SetupStates()
 {
     _stateManager  = GetComponent <AIStateManager>();
     _initialStates = new Dictionary <Type, BaseAIState>
     {
         { typeof(UnawareState), new UnawareState(this) },
         { typeof(AwareState), new AwareState(this) },
         { typeof(PatrolState), new PatrolState(this) },
         { typeof(AgressiveState), new AgressiveState(this) }
     };
     _stateManager.SetStates(_initialStates);
 }
Example #7
0
    public override void Init(SpawnManager spawner, TeamColor team)
    {
        base.Init(spawner, team);
        this.spawner   = spawner;
        this.teamColor = team;

        //Get singleton controllers
        GameManager     gameaManager    = GameManager.Instance;
        GameSettings    gameSettings    = GameManager.Instance.gameSettings;
        SceneController sceneController = gameaManager.sceneController;

        if (enemyState == null)
        {
            enemyState = this.gameObject.AddComponent <AIStateManager>();
        }
        avoidanceSystem = this.GetComponent <AvoidanceSystem>();

        //Initialise audio system
        audioSystem = this.GetComponent <VesselAudioSystem>();
        audioSystem.Init(EntityType.AiComputer);

        //Initialise Stat Handler
        VesselShipStats vesselStats = gameSettings.vesselStats.Where(x => x.type == vesselSelection).First();
        BaseStats       enemyStats  = vesselStats.baseShipStats;

        statHandler = new StatHandler(enemyStats, EntityType.AiComputer, this);

        //Initialises the movement systems
        AIMovementController movementController = this.GetComponent <AIMovementController>();

        movementController.Init(vesselStats);

        // Initialise health system
        AIHealthSystem healthSystem = this.GetComponent <AIHealthSystem>();

        healthSystem.Init(statHandler);

        //Set weapon systems and state
        SetWeaponSystems(vesselStats, sceneController);
        SetState <AIPursuit>();

        //Returns pointer UI
        attachedPointer = GameManager.Instance.sceneController.dynamicHud.pointerManagerUI.CreateNewPointer(gameObject.transform, vesselStats.speed);
    }
    void Awake()
    {
        //iniate audio source and cache variables
        if (GetComponent <AudioSource>() == null)
        {
            c_Audio = gameObject.AddComponent <AudioSource>();
        }
        else
        {
            c_Audio = GetComponent <AudioSource>();
        }

        brain         = GetComponent <AIStateManager>();
        previousState = brain.currentState;
        previousPanic = brain.panic;

        //set the pitch correctly
        c_Audio.pitch = basePitch;
        c_Audio.pitch = c_Audio.pitch + Random.Range(-randomPitch, randomPitch);
    }
	void Awake()
	{
		//iniate audio source and cache variables
		if(GetComponent<AudioSource>() == null)
		{
			c_Audio = gameObject.AddComponent<AudioSource>();
		}
		else
		{
			c_Audio = GetComponent<AudioSource>();
		}
		
		brain = GetComponent<AIStateManager>();
		previousState = brain.currentState;
		previousPanic = brain.panic;
		
		//set the pitch correctly
		c_Audio.pitch = basePitch;
		c_Audio.pitch = c_Audio.pitch + Random.Range( -randomPitch, randomPitch);
		
	}
Example #10
0
    void Start()
    {
        objectAsReference.transform.position = transform.position;

        //set up the resting position gameobject
        if (transform.Find(nameOfRestingPosition) == null)
        {
            restingPosition = new GameObject(nameOfRestingPosition);
            restingPosition.transform.parent   = transform;
            restingPosition.transform.position = transform.position;

            restingPosition.transform.localRotation  = Quaternion.Euler(new Vector3(90f, 0f, 0f));
            restingPosition.transform.localPosition -= new Vector3(0f, 0.4f, 0f);
        }
        else
        {
            restingPosition = transform.Find(nameOfRestingPosition).gameObject;
        }

        //set up cache correctly
        brain            = transform.parent.parent.GetComponent <AIStateManager>();
        weaponController = transform.parent.parent.GetComponent <AIWeaponController>();
    }
Example #11
0
 // Start is called before the first frame update
 void Start()
 {
     // Attach Instance
     aiManager = this;
 }
Example #12
0
 void Start()
 {
     aiState   = AIStateManager.Instance;
     resources = ResourceManager.Instance;
 }
Example #13
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     ai      = animator.GetComponent <AIMercenary>();
     aiState = AIStateManager.Instance;
 }