protected void AddBeamBetween(Character source, Character dest, Character.BodyPart sourceBodyPart, PowerBeam.BeamSettings settings) { GameObject beamObj = RPGSettings.instance.beamPool.GetObject(); if (beamObj) { BeamRenderer beam = beamObj.GetComponent <BeamRenderer>(); beam.Activate(source.GetBodyPart(sourceBodyPart), dest.GetBodyPart(targetBodyPart), settings, tint.GetColor()); } else { Debug.Log("Running out of beams! Increase the pool size in RPGSettings"); } }
// Update is called once per frame public void UpdateParticles(BeamRenderer br) { Transform target = br.target.transform; float timer = br.timer; // update particles - position the at the parent transform particles.transform.localPosition = Vector3.zero; //point them at the target particles.transform.forward = target.transform.position - particles.transform.position; float dist = Vector3.Distance(target.transform.position, particles.transform.position); switch (scalingType) { case ScalingType.ScaleLength: //beamParticles.transform.localScale = new Vector3(1,1,Vector3.Distance(target.transform.position, source.position)); ParticleSystem.ShapeModule shape = particles.GetComponent <ParticleSystem>().shape; shape.length = dist; // scale emwission rate to increase over time ParticleSystem.EmissionModule emission = particles.emission; ParticleSystem.MinMaxCurve eCurve = emission.rateOverTime; eCurve.constant = baseEmissionRate * dist; emission.rateOverTime = eCurve; break; case ScalingType.ScaleLifeTime: ParticleSystem.MainModule main = particles.main; ParticleSystem.MinMaxCurve sCurve = main.startLifetime; sCurve.constant = dist / main.startSpeed.constant; main.startLifetime = sCurve; break; } if (timer < 1.01f) { Stop(); } }
// 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; }