Inheritance: MonoBehaviour
Example #1
0
    /*
     * ===========================================================================================================
     * UNITY'S STUFF
     * ===========================================================================================================
     */
    /// <summary>
    /// When the script is initialized
    /// </summary>
    void Awake()
    {
        if(this.droneType == eDroneType.Patrol){
          patrolDroneScript  = this.gameObject.GetComponent<DronePatrol>();
          //patrolScript = this.gameObject.GetComponent<Patrol>();
        }
        else if(this.droneType == eDroneType.Saboteur) saboteurScript = this.gameObject.GetComponent<Saboteur>();

        // Check if it is a CPU controlled drone (or opponent drones, for that matter)
        if(this.gameObject.layer == MainScript.enemyLayer) {

        // Set a flag to make easier for us
           isThisAnEnemyDrone = true;

            // Check the type and get the component
            // AI hunter drone
            if(this.droneType == eDroneType.Hunter) {

                hunterAIScript = this.gameObject.GetComponent<DroneHunter>();

                captureSpot = GetCaptureSpot();
                captureRaySpot = GetCaptureRaySpot();

                if(!hunterAIScript) {

                    // DEBUG
                    Debug.LogError("DroneHunter component not found in " + this.transform);
                }
            }

          if(this.droneType == eDroneType.Patrol) {

        enemyPatrolScript = this.gameObject.GetComponent<EnemyPatrol>();
        // Set a flag to make easier for us
           //isThisAnEnemyDrone = true;

          }

        }

        sabotageTime = 2.0f;
        // Set the default settings for all the drones
        if(!isThisAnEnemyDrone)
            Selectable = true; // All drones are selectable

        Movable = true; // All drones are movable
        Type = eObjType.Drone;

        AIScript = gameObject.GetComponent<AstarAIFollow>();

        // FSM setup
        eFSMCurrentState = FSMState.STATE_IDLE;

        // Starts the object variables, like the sweet spot and the main mesh object
        GetSweetSpotAndMeshObject();

        // Get info about the collider
        GetColliderInfo();
    }
Example #2
0
    /*
     * ===========================================================================================================
     * UNITY'S STUFF
     * ===========================================================================================================
     */
    /// <summary>
    /// When the script is initialized
    /// </summary>
    void Awake()
    {
        // Set the default settings for all the buildings
        Selectable = true; // All monkeys are selectable
        Movable = true; // All monkeys are movable
        Type = eObjType.Monkey;
        AIScript = gameObject.GetComponent<AstarAIFollow>();

        // FSM setup
        eFSMCurrentState = FSMState.STATE_NULL;

        // Get info about the collider
        GetColliderInfo();

        // Load the icon for this unit
        LoadMinimapIcon();

        // Starts the object variables, like the sweet spot and the main mesh object
        GetSweetSpotAndMeshObject();

        // Get the capture spot
        if(monkeyClass == eMonkeyType.Cientist) {

            captureSpot = GetCaptureSpot();
            captureRaySpot = GetCaptureRaySpot();

        }

        // Get's the spot where we will test for collisions used in the attack
        attackSpot = GetAttackSpot();

        GUIScript = GameObject.Find("HUD-Objects").GetComponent<GUIControl>();
        GUIScript.addMonkey(this);

        fTimeToStartMonkey = Random.value * 10;

        if(meshObject) {

            // Calculates the walk cycle half length
            fDustTimeOfAStep = meshObject.animation[stAnimWalk].clip.length / 2;

            // DEBUG
            //Debug.Log(this.transform + " Length: " + fDustTimeOfAStep);
        }
    }