//MAGIC USE METHODS public void UseMagic() { GameObject abilitySystem = GameObject.Find("AbilitySystem"); GameObject fire = abilitySystem.transform.Find("FireAbility").gameObject; FireAbility fireAbility = fire.GetComponent <FireAbility>(); GameObject water = abilitySystem.transform.Find("WaterAbility").gameObject; Water waterAbility = water.GetComponent <Water>(); GameObject air = abilitySystem.transform.Find("AirAbility").gameObject; AirAbility airAbility = air.GetComponent <AirAbility>(); GameObject earth = abilitySystem.transform.Find("EarthAbility").gameObject; EarthAbility earthAbility = earth.GetComponent <EarthAbility>(); if (currManaAmount <= 20f) { if (fireAbility != null) { fireAbility.enabled = false; } if (waterAbility != null) { waterAbility.enabled = false; } if (airAbility != null) { airAbility.enabled = false; } if (earthAbility != null) { earthAbility.enabled = false; } } else if (currManaAmount >= 20f) { if (fireAbility != null) { fireAbility.enabled = true; } if (waterAbility != null) { waterAbility.enabled = true; } if (airAbility != null) { airAbility.enabled = true; } if (earthAbility != null) { earthAbility.enabled = true; } } }
void Start () { playerIndex = (PlayerIndex)playerNum; fireAbility = GetComponent<FireAbility>(); shieldAbility = GetComponent<ShieldAbility>(); tentacleAbility = GetComponent<TentacleAbility>(); animController = GetComponent<Animator> (); body = GetComponent<Rigidbody2D>(); velocity = new Vector3(0,0,0); SetToLevel(level); altarWaitTime = 2.0f; fireAbility.spellAnimationControllers = spellAnimationControllers[playerNum % 4]; gameObject.GetComponent<SpriteRenderer>().material = playerMaterials[playerNum % 4]; footSteps.startColor = playerMaterials [playerNum].color * 0.75f; }
private void Awake() { fireAbility = GetComponent <FireAbility>(); thunderAbility = GetComponent <ThunderAbility>(); iceAbility = GetComponent <IceAbility>(); windAbility = GetComponent <WindAbility>(); debugInfoUI = GameObject.Find("PlayerAbilityDebugInfo").GetComponent <Text>(); if (debugInfoUI == null) { Debug.LogError("没找到PlayerAbilityDebugInfo这个ui物体"); } elementSwitch = GameObject.Find("ElementSwitch").GetComponent <ElementSwitch>(); if (elementSwitch == null) { Debug.LogError("没找到elementSwitch这个ui物体"); } }
void OnEnable() { m_fireAbility = GetComponent<FireAbility> (); }