コード例 #1
0
    float maxTargetLength = 10.0f; // Maximum amount of time to have a target before searching for a new one

    void Start()
    {
        myInfo            = GetComponent <UnitInfo>();
        weaponsController = GetComponent <WeaponsController>();
        myRigidbody       = GetComponent <Rigidbody>();
        target            = GetEasiestTarget();
        myHealth          = GetComponent <Health> ();

        phase     = 1;
        shieldsOn = true;
        boosted   = false;

        if (!UnitTracker.GetActiveUnits().Contains(this.gameObject))
        {
            UnitTracker.AddUnit(this.gameObject);
        }
        // set target on spawn
        messageTxt = GameObject.Find("MessageText").GetComponent <MessageTextController>();
        messageTxt.DisplayMessage("Their shields are too strong for our weapons. Try to find a weak point.");
    }
コード例 #2
0
    void Initialize()
    {
        if (!hasInitialized)
        {
            hsDisplay     = transform.Find("HealthAndShieldsDisplay").gameObject;
            messageText   = transform.Find("MessageText").gameObject;
            objectiveText = transform.Find("ObjectiveText").gameObject;
            timerText     = transform.Find("TimerText").gameObject;
            throttleText  = transform.Find("ThrottleText").gameObject;
            weaponDisplay = transform.Find("WeaponDisplay").gameObject;

            if (hsDisplay != null)
            {
                hsDisplayController = hsDisplay.GetComponent <HealthAndShieldsDisplayController>();
            }
            if (messageText != null)
            {
                messageTextController = messageText.GetComponent <MessageTextController>();
            }
            if (objectiveText != null)
            {
                objectiveTextController = objectiveText.GetComponent <ObjectiveTextController>();
            }
            if (timerText != null)
            {
                timerTextController = timerText.GetComponent <TimerTextController>();
            }
            if (throttleText != null)
            {
                throttleTextController = throttleText.GetComponent <ThrottleTextController>();
            }
            if (weaponDisplay != null)
            {
                weaponDisplayController = weaponDisplay.GetComponent <WeaponDisplayController>();
            }

            hasInitialized = true;
        }
    }