Пример #1
0
    private void Awake()
    {
        //初始化元素字典
        elements.Add(0, ElementAbilityManager.Element.Fire);
        elements.Add(1, ElementAbilityManager.Element.Ice);
        elements.Add(2, ElementAbilityManager.Element.Wind);
        elements.Add(3, ElementAbilityManager.Element.Thunder);
        elements.Add(4, ElementAbilityManager.Element.NULL);

        //初始化子选项
        mainDropdown = GameObject.Find("MainDropdown").GetComponent <Dropdown>();
        aDropdown    = GameObject.Find("ADropdown").GetComponent <Dropdown>();
        bDropdown    = GameObject.Find("BDropdown").GetComponent <Dropdown>();

        //初始化提示文本
        elementTip = GameObject.Find("ElementTipText").GetComponent <Text>();
        if (elementTip == null)
        {
            Debug.LogError("在" + gameObject.name + "中,找不到ElementTipText组件");
        }
        //元素重复提示文本消失
        elementTip.gameObject.SetActive(false);

        //初始化技能管理器
        elementAbilityManager = GameObject.Find("Player").GetComponent <ElementAbilityManager>();
    }
Пример #2
0
    public override void Initialize()
    {
        //判断平台
        platformJudge = GameObject.Find("ControllerMode").GetComponent <PlatformJudge>();
        if (platformJudge == null)
        {
            Debug.LogError("找不到ControllerMode");
        }
        platform = platformJudge.GetPlatform();
        if (platform == PlatformJudge.Platfrom.ANDROID || platform == PlatformJudge.Platfrom.IOS || platform == PlatformJudge.Platfrom.WEB_MOBILE)
        {
            joystick = GameObject.Find("Variable Joystick").GetComponent <Joystick>();
            if (joystick == null)
            {
                Debug.LogError("移动端获取摇杆失败!");
            }

            aButton = GameObject.Find("AButton").GetComponent <MainElementButton>();
            bButton = GameObject.Find("BButton").GetComponent <SupportingElementButton>();
            cButton = GameObject.Find("CButton").GetComponent <SupportingElementButton>();

            jumpButton     = GameObject.Find("JumpButton").GetComponent <SimpleButton>();
            interactButton = GameObject.Find("InteractButton").GetComponent <SimpleButton>();
        }

        canFight = GetComponent <CanFight>();
        if (canFight == null)
        {
            Debug.LogError("在" + gameObject.name + "中,找不到CanFight组件!");
        }

        //使用string数组初始化canFight能够检测到的层
        string[] targets = new string[1];
        targets[0] = targetLayerName;
        canFight.Initiailize(targets);


        movementComponent = GetComponent <MovementPlayer>();
        if (movementComponent == null)
        {
            Debug.LogError("在Player中,没有找到MovementPlayer脚本!");
        }
        abilityManager = GetComponent <ElementAbilityManager>();
        //attackComponent = GetComponent<AttackPlayer>();
        //if (attackComponent == null)
        //{
        //    Debug.LogError("在Player中,没有找到AttackPlayer脚本!");
        //}

        defenceComponent = GetComponent <DefencePlayer>();
        if (defenceComponent == null)
        {
            Debug.LogError("在Player中,没有找到DefencePlayer脚本!");
        }
        defenceComponent.Initialize(5);

        interactivePlayer = GetComponent <InteractivePlayer>();

        //初始化心心数
        GameObject HpPanel = GameObject.Find("HP Panel");

        hpArray = new HPItem[defenceComponent.getHpMax()];

        for (int i = 0; i < defenceComponent.getHp(); i++)
        {
            Transform hpItem = HpPanel.transform.GetChild(i);
            hpArray[i] = hpItem.GetComponent <HPItem>();
            hpArray[i].Getting();
        }
    }
 protected override void Awake()
 {
     base.Awake();
     abilityManager = player.GetComponent <ElementAbilityManager>();
 }