Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        m_AiManager = transform.parent.GetComponentInParent <AiSpawner>();
        m_animator  = GetComponent <Animator>();

        SetUpNPC();
    }
Example #2
0
    public SpeciesBehavior(string Name, FlockAgent Prefab, int NumberOfAI, AiSpawner lake)
    {
        this.m_aiGroupName = Name;
        this.m_prefab      = Prefab;
        this.m_numberOfAI  = NumberOfAI;

        m_lake = lake;
    }
Example #3
0
    public override void OnInspectorGUI()
    {
        AiSpawner spawner = target as AiSpawner;

        spawner.characterType           = (CharacterType)EditorGUILayout.EnumPopup("Character Type", spawner.characterType);
        spawner.spawnSpecificCharacters = EditorGUILayout.Toggle("Spawn Specific Character", spawner.spawnSpecificCharacters);

        int listCount;

        // enemy list
        if (spawner.characterType == CharacterType.Enemy)
        {
            listCount = Mathf.Max(0, EditorGUILayout.IntField("Enemies Blueprints", spawner.EnemyBlueprints.Count));

            while (listCount < spawner.EnemyBlueprints.Count)
            {
                spawner.EnemyBlueprints.RemoveAt(spawner.EnemyBlueprints.Count - 1);
            }
            while (listCount > spawner.EnemyBlueprints.Count)
            {
                spawner.EnemyBlueprints.Add(null);
            }

            for (int i = 0; i < spawner.EnemyBlueprints.Count; i++)
            {
                spawner.EnemyBlueprints[i] = (EnemyBlueprint)EditorGUILayout.ObjectField(spawner.EnemyBlueprints[i], typeof(EnemyBlueprint), true);
            }
        }
        // npc list
        else
        {
            listCount = Mathf.Max(0, EditorGUILayout.IntField("Passive NPCs Blueprints", spawner.passiveNPCBlueprints.Count));
            while (listCount < spawner.passiveNPCBlueprints.Count)
            {
                spawner.passiveNPCBlueprints.RemoveAt(spawner.passiveNPCBlueprints.Count - 1);
            }
            while (listCount > spawner.passiveNPCBlueprints.Count)
            {
                spawner.passiveNPCBlueprints.Add(null);
            }

            for (int i = 0; i < spawner.passiveNPCBlueprints.Count; i++)
            {
                spawner.passiveNPCBlueprints[i] = (NPCBlueprint)EditorGUILayout.ObjectField(spawner.passiveNPCBlueprints[i], typeof(NPCBlueprint), true);
            }
        }

        if (!spawner.spawnSpecificCharacters)
        {
            spawner.charactersToSpawn = EditorGUILayout.IntSlider(spawner.charactersToSpawn, 1, 20);
        }

        spawner.characterParent = (CharacterParent)EditorGUILayout.EnumPopup("Character Parent", spawner.characterParent);
        if (spawner.characterParent == CharacterParent.Parent)
        {
            spawner.parent = (Transform)EditorGUILayout.ObjectField(spawner.parent, typeof(Transform), true);
        }
    }
Example #4
0
    //Handle death
    void Die()
    {
        Debug.Log("Die");

        GameObject parent = this.gameObject.transform.parent.gameObject;
        AiSpawner  script = parent.GetComponent <AiSpawner>();

        script.HandleDeath(SurvivedTime, XThetas, ZThetas, SpeedThetas, XRotThetas);
        Destroy(this.gameObject);
    }
Example #5
0
    void Start()
    {
        squareMaxSpeed        = maxSpeed * maxSpeed;
        squareNeighborRadius  = neighborRadius * neighborRadius;
        squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier;

        m_targetNumber = m_species.NumberOfAI;

        Debug.Log("Neighbor radius: " + squareNeighborRadius * squareNeighborRadius);
        Debug.Log("Avoidance radius: " + squareAvoidanceRadius * squareAvoidanceRadius);

        m_AIManager = transform.parent.GetComponentInParent <AiSpawner>();
    }
    private void Start()
    {
        player         = GameObject.FindGameObjectWithTag("Player");
        characterStats = player.GetComponent <AllCharacterStats>();

        if (navigationName == "")
        {
            Debug.LogError("ERROR - Ai: Navigation was not assigned!");
        }
        else
        {
            spawner = GameObject.Find(navigationName).GetComponent <AiSpawner>();

            if (spawner.characterType == CharacterType.Enemy)
            {
                for (int i = 0; i < spawner.EnemyBlueprints.Count; i++)
                {
                    if (this.name == spawner.EnemyBlueprints[i].prefabName)
                    {
                        indexInList = i;

                        totalAttackChance = spawner.EnemyBlueprints[i].smallAttackChance +
                                            spawner.EnemyBlueprints[i].bigAttackChance +
                                            spawner.EnemyBlueprints[i].critiaclChance;
                    }
                }
            }
            else
            {
                for (int i = 0; i < spawner.passiveNPCBlueprints.Count; i++)
                {
                    if (this.name == spawner.passiveNPCBlueprints[i].prefabName)
                    {
                        indexInList = i;
                    }
                }
            }

            timer = attackTimer;
        }
    }