コード例 #1
0
        public void StartPreview(Power p)
        {
            // don't do this for maintains
            if (p.mode == Power.Mode.Maintain)
            {
                previewPower = null;
                return;
            }

            previewPower    = p as PowerArea;
            previewOnTarget = false;
            // is its not an Area power, check for explosive effects and preview them
            if (previewPower == null)
            {
                previewOnTarget = false;
                foreach (Status s in p.effects)
                {
                    Explosion ex = s as Explosion;
                    if (ex)
                    {
                        previewPower    = ex.explosion;
                        previewOnTarget = true;
                    }
                }
            }
        }
コード例 #2
0
ファイル: PowerBeam.cs プロジェクト: DrMikeCooper/RPG
        void CheckChaining(Character ctarget, float charge)
        {
            // if we're a beam, check for chaining
            if (beamSettings.beamMaterial || beamSettings.beamParticles)
            {
                // chained beams
                if (maxChains > 0)
                {
                    // get all targets except the primary one on the other team
                    List <Character> targets = new List <Character>();
                    Character[]      all     = PowerArea.getAll();
                    for (int i = 0; i < all.Length; i++)
                    {
                        if (all[i] != ctarget && all[i].GetTeam() == ctarget.team)
                        {
                            targets.Add(all[i]);
                        }
                    }

                    for (int i = 0; i < maxChains; i++)
                    {
                        if (ctarget)
                        {
                            ctarget = Arc(ctarget, targets, charge);
                        }
                    }
                }
            }
        }
コード例 #3
0
        // does the animation, FX on caster, sound and uses activation energy
        protected void StartPower(Character caster)
        {
            if (sounds)
            {
                sounds.PlayStart(caster.audioSource);
            }
            caster.PlayAnim(animation.ToString());
            caster.energy -= energyCost;
            if (userFX)
            {
                bool       continuous = (mode == Mode.Charge || mode == Mode.Maintain);
                GameObject fx         = userFX.Begin(caster.GetBodyPart(userBodyPart), tint, !continuous, true);

                // scale up area powers to match the radius
                PowerArea area = this as PowerArea;
                if (area)
                {
                    userFX.ScaleToRadius(fx, area.GetRadius(caster));
                }

                if (continuous)
                {
                    userFXInstance = fx;
                }
            }

            FaceTarget(caster);
        }
コード例 #4
0
 static void MakeAreaPower()
 {
     RPG.Status    s     = Selection.activeObject as RPG.Status;
     RPG.PowerArea power = CreateAsset <RPG.PowerArea>(s.name + "Area");
     power.type       = GetDamageType(s, RPG.RPGSettings.DamageType.Fire);
     power.effects    = new RPG.Status[1];
     power.effects[0] = s;
 }
コード例 #5
0
ファイル: PowerBeam.cs プロジェクト: DrMikeCooper/RPG
        // useable on a single target with no to-hit roll
        public override void OnActivate(Character caster, bool doStatus = true)
        {
            Prop target = GetTarget(caster);

            if (target)
            {
                float     charge  = caster.stats[RPGSettings.StatName.Charge.ToString()].currentValue * 0.01f;
                Character ctarget = target as Character;
                if (ctarget)
                {
                    ctarget.MakeAwareOf(caster);
                }

                // draw the beam to the target
                DrawBeam(caster, target);

                // check for deflection shields on the target
                HitResponse.ReflectionType deflect = target.GetReflection(type);
                if (deflect != HitResponse.ReflectionType.None)
                {
                    // get all targets except the primary one on the other team
                    List <Character> targets = new List <Character>();
                    Character[]      all     = PowerArea.getAll();
                    for (int i = 0; i < all.Length; i++)
                    {
                        // TODO - chaining ally powers
                        if (!all[i].dead && all[i].GetTeam() != ctarget.team)
                        {
                            targets.Add(all[i]);
                        }
                    }

                    Arc(ctarget, targets, charge);
                    return;
                }

                // no deflection, carry on...
                bool hit = Apply(target, charge, caster, doStatus);

                CheckChaining(ctarget, charge);
            }
        }
コード例 #6
0
ファイル: HitResponse.cs プロジェクト: DrMikeCooper/RPG
        // utility function for chained projectiles/beams and deflection code
        public static Vector3 Reflect(Prop prop, Vector3 source, ReflectionType type, int team)
        {
            Vector3 position = prop.transform.position;
            Vector3 newDir;

            // for simple types, just reflect straight back
            if (type == ReflectionType.None || type == ReflectionType.Reflect)
            {
                return((source - position).normalized);
            }

            // for redirection, try finding a target to redirect at
            if (type == ReflectionType.Redirect)
            {
                // find all enemies on the other team within line of sight
                List <Transform> targets = new List <Transform>();
                foreach (Character ch in PowerArea.getAll())
                {
                    if (!ch.dead && ch.team != team)
                    {
                        if (ch.CanSee(prop))
                        {
                            targets.Add(ch.transform);
                        }
                    }
                }
                if (targets.Count > 0)
                {
                    newDir   = (targets[UnityEngine.Random.Range(0, targets.Count)].position - position);
                    newDir.y = 0;
                    return(newDir.normalized);
                }
            }

            // final fallthrough is Deflect (or redirect with no targets), pick a random direction within _+/-60 of the original direction
            Vector3 toSource = source - position;
            Vector3 sideWays = new Vector3(toSource.z, 0, -toSource.x);

            newDir   = (toSource + UnityEngine.Random.Range(-2.0f, 2.0f) * sideWays);
            newDir.y = 0;
            return(newDir.normalized);
        }
コード例 #7
0
        public override void Apply(Prop ch, Character caster = null)
        {
            Character ctarget = ch as Character;

            // doens't work with props right now
            if (ctarget == null)
            {
                return;
            }

            List <Character> targets = new List <Character>();

            Character[] all = PowerArea.getAll();
            for (int i = 0; i < all.Length; i++)
            {
                if (all[i] != ch && (ctarget == null || all[i].GetTeam() == ctarget.team))
                {
                    targets.Add(all[i]);
                }
            }

            beam.Arc(ctarget, targets, 1);
        }
コード例 #8
0
 public void EndPreview()
 {
     previewPower = null;
     GetPreviewObject().SetActive(false);
 }
コード例 #9
0
ファイル: TabTarget.cs プロジェクト: DrMikeCooper/RPG
        // Update is called once per frame
        void Update()
        {
            reticle = user.GetReticle();

            if (user.target && user.target.dead)
            {
                user.target = null;
            }

            if (user.target)
            {
                reticle.transform.position = user.target.transform.position;
            }
            else
            {
                reticle.SetActive(false);
            }

            // no changing targets while a power is active
            if (user.activePower)
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.Tab))
            {
                List <Character> targets = new List <Character>();

                foreach (Character ch in PowerArea.getAll())
                {
                    // left shift-TAB toggles between allies, normal TAB through enemies
                    bool valid = (!ch.dead) && (Input.GetKey(KeyCode.LeftShift) ?
                                                (ch != user && ch.GetTeam() == user.team) // TODO - use GetTeam()?
                        : (ch.team != user.team));
                    if (valid)
                    {
                        Vector3 clipPos = Camera.main.WorldToViewportPoint(ch.transform.position);
                        if (clipPos.z > 0 && clipPos.x >= 0 && clipPos.x <= 1 && clipPos.y >= 0 && clipPos.y <= 1)
                        {
                            targets.Add(ch);
                            ch.xScreen = clipPos.x;
                        }
                    }
                }

                // sort from left to right
                targets.Sort(delegate(Character a, Character b) {
                    return(a.xScreen.CompareTo(b.xScreen));
                });

                int selected = -1;
                for (int i = 0; i < targets.Count; i++)
                {
                    if (targets[i] == user.target)
                    {
                        selected = i;
                    }
                }

                //move to the next one with wraparound
                selected++;
                if (selected >= targets.Count)
                {
                    selected = 0;
                }

                if (selected < targets.Count)
                {
                    user.target = targets[selected];
                    reticle.SetActive(true);
                }
            }

            // left mouse clicks select a character (or none)
            if (Input.GetMouseButtonDown(0))
            {
                if (eventSystem && eventSystem.IsPointerOverGameObject())
                {
                    return;
                }

                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit info;
                if (Physics.Raycast(ray, out info))
                {
                    user.target = info.collider.GetComponent <Prop>();

                    //GameObject go = GameObject.Find(user.target.name);
                    //Prop p = go ? go.GetComponent<Prop>() : null;

                    reticle.SetActive(user.target != null);
                }
            }
        }