public void Start() { menuCharacterBehaviour = GameObject.FindGameObjectWithTag("Player").GetComponent <MenuCharacterBehaviour>(); propsBehaviour = menuCharacterBehaviour.GetComponent <PropsBehaviour>(); mobileLevel = menuCharacterBehaviour.GetComponent <MobileLevel>(); LevelText.text = String.Format("Level: {0}", mobileLevel.CurrentLevel); XpText.text = String.Format("Current Experience: {0} \n( Required xp for next level :{1})", mobileLevel.TotalExperienceGained, mobileLevel.GetRequiredExpAmountForNextLevel()); StrengthValue.text = propsBehaviour.Strength.CurrentValue.ToString(); DexterityValue.text = propsBehaviour.Dexterity.CurrentValue.ToString(); MeleeValue.text = String.Format("{0:0.0}", propsBehaviour.Melee.CurrentValue); RangedValue.text = String.Format("{0:0.0}", propsBehaviour.Ranged.CurrentValue); TotalAttributePointsText.text = propsBehaviour.TotalAvaliableAttributePoints.ToString(); if (propsBehaviour.TotalAvaliableAttributePoints <= 0) { StrPlusButton.SetActive(false); StrMinusButton.SetActive(false); DexPlusButton.SetActive(false); DexMinusButton.SetActive(false); } tempStr = propsBehaviour.Strength.CurrentValue; tempDex = propsBehaviour.Dexterity.CurrentValue; tempTotalAvaliableAttributePoints = propsBehaviour.TotalAvaliableAttributePoints; resetPointsButton = ResetPointsButton.GetComponent <Button>(); resetPointsButton.interactable = false; RecalculateBasicAttributesPanel(); }
public void Start() { var playerObj = GameObject.FindGameObjectWithTag("Player"); playerProps = playerObj.GetComponent <PropsBehaviour>(); playerProps.Ranged.OnSkillChangedEvent += new DTWorld.Engines.SkillSystem.Skills.BaseSkill.OnSkillChangedEventHandler(RangedSkillChanged); playerProps.Melee.OnSkillChangedEvent += new DTWorld.Engines.SkillSystem.Skills.BaseSkill.OnSkillChangedEventHandler(MeleeSkillChanged); playerProps.OnAttributePointsGainedEvent += new PropsBehaviour.OnAttributePointsGainedEventHandler(AddAttributePointsGainedText); playerLevel = playerObj.GetComponent <MobileLevel>(); playerLevel.OnLevelChangedEvent += new MobileLevel.OnLevelChangedEventHandler(OnLevelChanged); playerLevel.OnExperienceGainedEvent += new MobileLevel.OnExperienceGainedEventHandler(OnXPGained); }
public virtual void Start() { this.Rigidbody2D = gameObject.GetComponent <Rigidbody2D>(); audioManager = gameObject.GetComponent <AudioManager>(); var damageTakenEffectTransform = transform.Find("DamageTakenEffect"); if (damageTakenEffectTransform != null) { DamageTakenEffect = damageTakenEffectTransform.gameObject.GetComponent <ParticleSystem>(); } // add weapon object in the handle if (RightHandle != null) { var weaponBehaviour = RightHandle.GetComponentInChildren <BaseWeaponBehaviour>(); if (weaponBehaviour != null) { AddWeapon(weaponBehaviour); } } // add shield object in the handle if (LeftHandle != null) { var shieldBehaviour = LeftHandle.GetComponentInChildren <BaseShieldBehaviour>(); if (shieldBehaviour != null) { AddShield(shieldBehaviour); } } //set animation system var animationRig = gameObject.transform.Find("Rig"); if (animationRig != null) { var animator = animationRig.gameObject.GetComponent <Animator>(); if (animator != null) { if (RightHandle != null && LeftHandle != null) { animationHandler = new SimpleDirectionsAnimationHandler(animator, RightHandle, LeftHandle); } else { animationHandler = new SimpleDirectionsAnimationHandler(animator); } } } HealthBehaviour = gameObject.GetComponent <HealthBehaviour>(); HealthBehaviour.OnDamageTakenEvent += new OnDamageTakenEventHandler(OnDamageTaken); HealthBehaviour.OnHealthBelowZeroEvent += new OnHealthBelowZeroEventHandler(OnDead); if (WeaponBehaviour != null) { ChaseDistance = (WeaponBehaviour.AttackDistance / 4) + ChaseDistance; FleeDistance = WeaponBehaviour.IsRanged ? WeaponBehaviour.AttackDistance / 2 : 0; } propsBehaviour = gameObject.GetComponent <PropsBehaviour>(); }