public override void Initialize() { //获得场景物体引用 movementComponent = GetComponent <MovementPlayer>(); poolManager = GameObject.Find("PoolManager").GetComponent <PoolManager>(); //武器切换UI weaponChangePanel = GameObject.Find("WeaponChangePanel"); weaponChangeUI = weaponChangePanel.GetComponent <WeaponChangeUI>(); weaponChangePanel.SetActive(false); //初始化技能类 waterShieldSpell = new WaterShieldSpell(); waterShieldSpell.Initialize(); iceThunderSpell = new IceThunderSpell(); iceThunderSpell.Initialize(); iceShieldSpell = new IceShieldSpell(); iceShieldSpell.Initialize(); iceSwordSpell = new IceSwordSpell(); iceSwordSpell.Initialize(); iceHealSpell = new IceHealSpell(); iceHealSpell.Initialize(); iceHealSpell.Enable(); iceBlinkSpell = new IceBlinkSpell(); iceBlinkSpell.Initialize(); iceArrowSpell = new IceArrowSpell(); iceArrowSpell.Initialize(); iceHammerSpell = new IceHammerSpell(); iceHammerSpell.Initialize(); iceShotSpell = new IceShotSpell(); iceShotSpell.Initialize(); iceSheildMashSpell = new IceShieldMashSpell(); iceSheildMashSpell.Initialize(); //以下为碰墙检测参数的初始化 filter.useNormalAngle = false; filter.useDepth = false; filter.useOutsideDepth = false; filter.useOutsideNormalAngle = false; filter.useTriggers = false; filter.useLayerMask = true; LayerMask layerMask = 0; layerMask ^= 1 << LayerMask.NameToLayer("Water"); filter.layerMask = layerMask; //判断平台 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("移动端获取摇杆失败!"); } } }
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(); } }