コード例 #1
0
        void FindPlayer()
        {
            if (nextTimeToSearch <= Time.time)
            {
                if (_hero == 0)
                {
                    searchResult = GameObject.FindGameObjectWithTag("Ionian");
                }
                else if (_hero == 1)
                {
                    searchResult = GameObject.FindGameObjectWithTag("Athenian");
                }
                else if (_hero == 2)
                {
                    searchResult = GameObject.FindGameObjectWithTag("Spartan");
                }
                else if (_hero == 3)
                {
                    searchResult = GameObject.FindGameObjectWithTag("Achilles");
                }

                if (searchResult != null)
                {
                    target = searchResult;
                    motorToWatch = target.GetComponent<PlatformerMotor2D>();
                    A = target.GetComponent<AchillesHealth>();

                }
                nextTimeToSearch = Time.time + 0.5f;
            }
        }
コード例 #2
0
    void Awake()
    {
        EH = GetComponent<EnemyHealth>();
        stopDist = 1.5f;
        _canAttack = true;

        _motor = GetComponent<PlatformerMotor2D>();
        _anim = GetComponent<EnemyAIAnimator>();
        _hero = PlayerPrefs.GetInt("Hero");

        AI = this.gameObject;

        //Determine which hero to look for and go after;
        switch (_hero)
        {
            case 0:
                Debug.Log("I am from Ionia");
                target = GameObject.FindGameObjectWithTag("Ionian");
                targetT = target.transform;
                IS = target.GetComponent<IonianStatistics>();
                IH = target.GetComponent<IonianHealth>();
                IXP = target.GetComponent<IonianEXP>();
                _pMaster = target.GetComponent<PlayerMaster>();
                break;
            case 1:
                Debug.Log("I am from Athens");
                target = GameObject.FindGameObjectWithTag("Athenian");
                targetT = target.transform;
                ATS = target.GetComponent<AthenianStatistics>();
                ATH = target.GetComponent<AthenianHealth>();
                ATXP = target.GetComponent<AthenianEXP>();
                _pMaster = target.GetComponent<PlayerMaster>();
                break;
            case 2:
                Debug.Log("I am from Sparta");
                target = GameObject.FindGameObjectWithTag("Spartan");
                targetT = target.transform;
                SS = target.GetComponent<SpartanStatistics>();
                SH = target.GetComponent<SpartanHealth>();
                SXP = target.GetComponent<SpartanEXP>();
                _pMaster = target.GetComponent<PlayerMaster>();
                break;
            case 3:
                Debug.Log("I am Greek");
                target = GameObject.FindGameObjectWithTag("Achilles");
                targetT = target.transform;
                AS = target.GetComponent<AchillesStatistics>();
                AH = target.GetComponent<AchillesHealth>();
                AXP = target.GetComponent<AchillesEXP>();
                _pMaster = target.GetComponent<PlayerMaster>();
                break;
        }
    }
コード例 #3
0
        // Use this for initialization
        void Start()
        {
            target = GameObject.FindGameObjectWithTag("Achilles");
            motorToWatch = target.GetComponent<PlatformerMotor2D>();

            A = target.GetComponent<AchillesHealth>();
            motorToWatch.onLanded += OnFallFinished;
            fallText.color = Color.white;

            _hero = PlayerPrefs.GetInt("Hero");
        }