// Use this for initialization
    void Start()
    {
        data  = GetComponent <TankData>();
        motor = GetComponent <TankMotor>();
        GameManager.instance.aiUnits.Add(this.data);

        // Can use this script to randomly and dynamically select a personality for your AIs

        personality = (personalities)Random.Range(0, System.Enum.GetNames(typeof(personalities)).Length);
        // Debug purposes only: Uncomment the AI type you want to test and comment out the rest including the random above. Default should be random
        // When finished testing make sure you uncomment the
        //personality = personalities.agressive;
        //personality = personalities.guard;
        //personality = personalities.skittish;
        //personality = personalities.stalker;
        switch (personality)
        {
        case personalities.agressive:
            gameObject.AddComponent <Controller_AI_Agressive>();
            distanceToMaintain             = distanceToMaintainAgressive;
            topColor.materials[0].color    = Color.red;
            leftColor.materials[0].color   = Color.red;
            rightColor.materials[0].color  = Color.red;
            bottomColor.materials[0].color = Color.red;
            break;

        case personalities.skittish:
            gameObject.AddComponent <Controller_AI_Skittish>();
            distanceToMaintain             = distanceToMaintainGuard;
            topColor.materials[0].color    = Color.white;
            leftColor.materials[0].color   = Color.white;
            rightColor.materials[0].color  = Color.white;
            bottomColor.materials[0].color = Color.white;
            break;

        case personalities.stalker:
            gameObject.AddComponent <Controller_AI_Stalker>();
            distanceToMaintain             = distanceToMaintainStalker;
            topColor.materials[0].color    = Color.yellow;
            leftColor.materials[0].color   = Color.yellow;
            rightColor.materials[0].color  = Color.yellow;
            bottomColor.materials[0].color = Color.yellow;
            break;

        case personalities.guard:
            gameObject.AddComponent <Controller_AI_Guard>();
            distanceToMaintain             = distanceToMaintainGuard;
            topColor.materials[0].color    = Color.black;
            leftColor.materials[0].color   = Color.black;
            rightColor.materials[0].color  = Color.black;
            bottomColor.materials[0].color = Color.black;
            break;
        }
    }
    // Use this for initialization
    //When the game starts its gets the Data,Motor and Game Manager of the AI.
    void Start()
    {
        data  = GetComponent <TankData>();
        motor = GetComponent <TankMotor>();
        GameManager.instance.aiUnits.Add(this.data);

        //On start it will randomly chose a personality to spawn the AI.

        personality = (personalities)Random.Range(0, System.Enum.GetNames(typeof(personalities)).Length);

        //Defines the differnt AI and changes the color of the tank depending on on the personality it is.
        switch (personality)
        {
        case personalities.aggro:
            gameObject.AddComponent <Aggro_AI>();
            distanceToMaintain             = distanceToMaintainAggro;
            topColor.materials[0].color    = Color.blue;
            leftColor.materials[0].color   = Color.blue;
            rightColor.materials[0].color  = Color.blue;
            bottomColor.materials[0].color = Color.blue;
            break;

        case personalities.scared:
            gameObject.AddComponent <Scared_AI>();
            distanceToMaintain             = distanceToMaintainScared;
            topColor.materials[0].color    = Color.yellow;
            leftColor.materials[0].color   = Color.yellow;
            rightColor.materials[0].color  = Color.yellow;
            bottomColor.materials[0].color = Color.yellow;
            break;

        case personalities.creeper:
            gameObject.AddComponent <Creeper_AI>();
            distanceToMaintain             = distanceToMaintainCreeper;
            topColor.materials[0].color    = Color.magenta;
            leftColor.materials[0].color   = Color.magenta;
            rightColor.materials[0].color  = Color.magenta;
            bottomColor.materials[0].color = Color.magenta;
            break;

        case personalities.holdGround:
            gameObject.AddComponent <HoldsGround_AI>();
            distanceToMaintain             = distanceToMaintainHG;
            topColor.materials[0].color    = Color.gray;
            leftColor.materials[0].color   = Color.grey;
            rightColor.materials[0].color  = Color.grey;
            bottomColor.materials[0].color = Color.grey;
            break;
        }
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        data  = GetComponent <TankData>();
        motor = GetComponent <TankMotor>();
        GameManager.instance.aiUnits.Add(this.data);

        //randomly select a personality

        personality = (personalities)Random.Range(0, System.Enum.GetNames(typeof(personalities)).Length);

        switch (personality)
        {
        case personalities.aggro:
            gameObject.AddComponent <Aggro_AI>();
            distanceToMaintain             = distanceToMaintainAggro;
            topColor.materials[0].color    = Color.blue;
            leftColor.materials[0].color   = Color.blue;
            rightColor.materials[0].color  = Color.blue;
            bottomColor.materials[0].color = Color.blue;
            break;

        case personalities.scared:
            gameObject.AddComponent <Scared_AI>();
            distanceToMaintain             = distanceToMaintainScared;
            topColor.materials[0].color    = Color.yellow;
            leftColor.materials[0].color   = Color.yellow;
            rightColor.materials[0].color  = Color.yellow;
            bottomColor.materials[0].color = Color.yellow;
            break;

        case personalities.creeper:
            gameObject.AddComponent <Creeper_AI>();
            distanceToMaintain             = distanceToMaintainCreeper;
            topColor.materials[0].color    = Color.magenta;
            leftColor.materials[0].color   = Color.magenta;
            rightColor.materials[0].color  = Color.magenta;
            bottomColor.materials[0].color = Color.magenta;
            break;

        case personalities.holdGround:
            gameObject.AddComponent <HoldsGround_AI>();
            distanceToMaintain             = distanceToMaintainHG;
            topColor.materials[0].color    = Color.gray;
            leftColor.materials[0].color   = Color.grey;
            rightColor.materials[0].color  = Color.grey;
            bottomColor.materials[0].color = Color.grey;
            break;
        }
    }