private bool m_Jump; // the world-relative desired move direction, calculated from the camForward and user input. private void Start() { // get the transform of the main camera if (Camera.main != null) { m_Cam = Camera.main.transform; } else { Debug.LogWarning( "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject); // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them! } // get the third person character ( this should never be null due to require component ) m_Character = GetComponent <ThirdPersonCharacter>(); }
protected void InitProp() { statusDirty = true; for (int i = 0; i < RPGSettings.BasicDamageTypesCount; i++) { stats[RPGSettings.GetResistanceStat((RPGSettings.DamageType)(1 << i))] = new Stat(); stats[RPGSettings.GetDefenceStat((RPGSettings.DamageType)(1 << i))] = new Stat(); } stats[RPGSettings.StatName.Health.ToString()] = new Stat(maxHealth, false); healthStat = stats[RPGSettings.StatName.Health.ToString()]; ThirdPersonCharacter tpc = GetComponent <ThirdPersonCharacter>(); if (tpc) { tpc.onGrounded.AddListener(EndKnockback); } }
// Use this for initialization void Start() { animator = GetComponent <Animator>(); brain = GetComponent <AIBrain>(); audioSource = GetComponent <AudioSource>(); if (audioSource == null) { audioSource = gameObject.AddComponent <AudioSource>(); } InitProp(); fadeTime = 10.0f; for (int i = 0; i < RPGSettings.BasicDamageTypesCount; i++) { stats[RPGSettings.GetDamageStat((RPGSettings.DamageType)(1 << i))] = new Stat(); } // healing damage boost does make sense stats[RPGSettings.GetDamageStat(RPGSettings.DamageType.Healing)] = new Stat(); // special starting values and non-buffs go here stats[RPGSettings.StatName.Energy.ToString()] = new Stat(maxEnergy, false); stats[RPGSettings.StatName.Charge.ToString()] = new Stat(0, false); // all others are normal buffable stats RPGSettings.StatName numStats = (RPGSettings.StatName)System.Enum.GetNames(typeof(RPGSettings.StatName)).Length; for (RPGSettings.StatName i = RPGSettings.StatName.EnergyRegen; i <= numStats; i++) { if (!stats.ContainsKey(i.ToString())) { stats[i.ToString()] = new Stat(); } } energyStat = stats[RPGSettings.StatName.Energy.ToString()]; RPGSettings.instance.SetupCharacter(this); tpc = GetComponent <ThirdPersonCharacter>(); if (tpc) { baseJumpPower = tpc.m_JumpPower; } Transform beamChild = transform.Find("Beam"); if (beamChild == null) { GameObject go = ObjectFactory.GetObject(RPGSettings.instance.beam); beamChild = go.transform; beamChild.parent = transform; beamChild.localPosition = Vector3.zero; } if (beamChild) { beam = beamChild.GetComponent <BeamRenderer>(); } ApplyPassives(); //create a tragetting reticle and disable it reticle = ObjectFactory.GetObject(RPGSettings.instance.reticle); reticle.transform.parent = transform; reticle.transform.localPosition = Vector3.zero; reticle.name = "reticle"; reticle.SetActive(false); bodyParts[BodyPart.Root] = transform; bodyParts[BodyPart.Head] = head; bodyParts[BodyPart.Chest] = chest; bodyParts[BodyPart.LeftHand] = leftHand; bodyParts[BodyPart.RightHand] = rightHand; bodyParts[BodyPart.LeftFoot] = leftFoot; bodyParts[BodyPart.RightFoot] = rightFoot; bodyParts[BodyPart.LeftForeArm] = leftForeArm; bodyParts[BodyPart.RightForeArm] = rightForeArm; bodyParts[BodyPart.LeftBicep] = leftBicep; bodyParts[BodyPart.RightBicep] = rightBicep; bodyParts[BodyPart.LeftThigh] = leftThigh; bodyParts[BodyPart.LightThigh] = rightThigh; bodyParts[BodyPart.LeftCalf] = leftCalf; bodyParts[BodyPart.RightCalf] = rightCalf; bodyParts[BodyPart.Waist] = waist; bodyParts[BodyPart.Weapon1] = weapon1; bodyParts[BodyPart.Weapon2] = weapon2; }