Ejemplo n.º 1
0
        public Character GetValidTarget(Character target, ValidTarget findFlags)
        {
            if (target == null || target is Player && ((Player)target).playerSession.isUpdatesLocked)
            {
                return(null);
            }

            if ((findFlags & ValidTarget.Ally) != 0)
            {
                return(owner.pet);
            }

            // todo: this is beyond retarded
            var oldFlags = this.validTarget;

            this.validTarget = findFlags;
            if (CanTarget(target, false, true))
            {
                this.validTarget = oldFlags;
                return(target);
            }
            this.validTarget = oldFlags;

            return(null);
        }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        ValidTarget tg = other.gameObject.GetComponent <ValidTarget>();

        if (tg != null && tg.canBeTargeted)
        {
            numTargetsInside += 1;
            targetsInside.Add(tg);

            if (numTargetsInside > 0)
            {
                if (hitMaterial == null)
                {
                    this.renderer.material.color = hitColor;
                    hitMaterial            = this.renderer.material;
                    disc.renderer.material = hitMaterial;
                }
                else
                {
                    this.renderer.material = hitMaterial;
                    disc.renderer.material = hitMaterial;
                }
            }
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Call this before <see cref="FindWithinArea"/> <para/>
 /// </summary>
 /// <param name="maxDistance">
 /// <see cref="TargetFindAOEType.Circle"/> - radius of circle <para/>
 /// <see cref="TargetFindAOEType.Cone"/> - height of cone <para/>
 /// <see cref="TargetFindAOEType.Box"/> - width of box / 2 (todo: set box length not just between user and target)
 /// </param>
 /// <param name="param"> param in degrees of cone (todo: probably use radians and forget converting at runtime) </param>
 public void SetAOEType(ValidTarget validTarget, TargetFindAOEType aoeType, TargetFindAOETarget aoeTarget, float maxDistance, float minDistance, float height, float aoeRotate, float coneAngle, float param = 0.0f)
 {
     this.validTarget    = validTarget;
     this.aoeType        = aoeType;
     this.maxDistance    = maxDistance;
     this.minDistance    = minDistance;
     this.param          = param;
     this.height         = height;
     this.aoeRotateAngle = aoeRotate;
     this.coneAngle      = coneAngle;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Call this to prepare Box AOE
        /// </summary>
        /// <param name="validTarget"></param>
        /// <param name="aoeTarget"></param>
        /// <param name="length"></param>
        /// <param name="width"></param>
        public void SetAOEBox(ValidTarget validTarget, TargetFindAOETarget aoeTarget, float length, float width, float aoeRotateAngle)
        {
            this.validTarget    = validTarget;
            this.aoeType        = TargetFindAOEType.Box;
            this.aoeTarget      = aoeTarget;
            this.aoeRotateAngle = aoeRotateAngle;
            float x = owner.positionX - (float)Math.Cos(owner.rotation + (float)(Math.PI / 2)) * (length);
            float z = owner.positionZ + (float)Math.Sin(owner.rotation + (float)(Math.PI / 2)) * (length);

            this.maxDistance = length;
            this.width       = width;
        }
Ejemplo n.º 5
0
    void OnTriggerExit(Collider other)
    {
        ValidTarget tg = other.gameObject.GetComponent <ValidTarget>();

        if (tg != null && tg.canBeTargeted)
        {
            numTargetsInside -= 1;
            targetsInside.Remove(tg);
        }

        if (numTargetsInside == 0)
        {
            this.renderer.material = normalMaterial;
            disc.renderer.material = normalMaterial;
        }
    }
Ejemplo n.º 6
0
 public void Reset()
 {
     this.findType          = TargetFindCharacterType.None;
     this.validTarget       = ValidTarget.Enemy;
     this.aoeType           = TargetFindAOEType.None;
     this.aoeTarget         = TargetFindAOETarget.Target;
     this.aoeTargetPosition = null;
     this.aoeTargetRotation = 0;
     this.maxDistance       = 0.0f;
     this.minDistance       = 0.0f;
     this.width             = 0.0f;
     this.height            = 0.0f;
     this.aoeRotateAngle    = 0.0f;
     this.coneAngle         = 0.0f;
     this.param             = 0.0f;
     this.targets           = new List <Character>();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// <para> Call SetAOEType before calling this </para>
        /// Find targets within area set by <see cref="SetAOEType"/>
        /// </summary>
        public void FindWithinArea(Character target, ValidTarget flags, TargetFindAOETarget aoeTarget)
        {
            targets.Clear();
            validTarget = flags;
            // are we creating aoe circles around target or self
            if (aoeTarget == TargetFindAOETarget.Self)
            {
                this.aoeTargetPosition = owner.GetPosAsVector3();
                this.aoeTargetRotation = owner.rotation + (float)(aoeRotateAngle * Math.PI);
            }
            else
            {
                this.aoeTargetPosition = target.GetPosAsVector3();
                this.aoeTargetRotation = target.rotation + (float)(aoeRotateAngle * Math.PI);
            }

            masterTarget = TryGetMasterTarget(target) ?? target;

            // todo: this is stupid
            bool withPet = (flags & ValidTarget.Ally) != 0 || masterTarget.allegiance != owner.allegiance;

            if (masterTarget != null && CanTarget(masterTarget))
            {
                targets.Add(masterTarget);
            }

            if (aoeType != TargetFindAOEType.None)
            {
                AddAllInRange(target, withPet);
            }

            //if (targets.Count > 8)
            //targets.RemoveRange(8, targets.Count - 8);

            //Curaga starts with lowest health players, so the targets are definitely sorted at least for some abilities
            //Other aoe abilities might be sorted by distance?
            //Protect is random
            targets.Sort(delegate(Character a, Character b) { return(a.GetHP().CompareTo(b.GetHP())); });
        }
Ejemplo n.º 8
0
 public void SetValidTarget (ValidTarget vt) {
 	validTarget = vt;
 }
Ejemplo n.º 9
0
 public virtual bool IsValidTarget(Character target, ValidTarget validTarget)
 {
     return(!target.isStatic);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Find and try to add a single target to target list
 /// </summary>
 public void FindTarget(Character target, ValidTarget flags)
 {
     validTarget = flags;
     // todo: maybe this should only be set if successfully added?
     AddTarget(target, false);
 }
Ejemplo n.º 11
0
 public void SetValidTarget(ValidTarget vt)
 {
     validTarget = vt;
 }