Пример #1
0
    /// <summary>
    /// Returns the exact time in seconds specified by this starting time. The parameter is a CastingTime instance,
    /// which specifies a time in several different ways. This method returns the time in seconds represented by this
    /// instance.
    /// </summary>
    public float GetStartTime(CastingTime startTime)
    {
        // Determines the time at which the force starts
        switch (startTime.type)
        {
        case DurationType.Frame:
            // The start time is specified by the n-th frame of the character's current animation
            return(startTime.nFrames / CharacterAnimator.FRAME_RATE);

        case DurationType.WaitForAnimationComplete:
            // The force will start when 'animationToWaitFor' is complete
            return(character.CharacterAnimator.GetEndTime(startTime.animationToWaitFor));

        case DurationType.Seconds:
            // The start time is specified in seconds
            return(startTime.seconds);

        default:
            Debug.LogError("Incorrect start time specified: " + startTime.type.ToString());
            break;
        }

        // If this statement is reached, the force does not specify the time at which it should start. Return a default of zero.
        return(0);
    }
Пример #2
0
    /// <summary>
    /// Returns the amount of time (in seconds) that this CastingTime instance represents. The startTime for the event must be
    /// given to determine the duration, and not the end time of the event
    /// </summary>
    public float GetDuration(CastingTime duration, float startTime)
    {
        // Determines the time at which the force starts
        switch (duration.type)
        {
        case DurationType.Frame:
            // The duration is specified by the amount of time elapsed from n frames of the character's current animation
            return(duration.nFrames / CharacterAnimator.FRAME_RATE);

        case DurationType.WaitForAnimationComplete:
            // The force will end when 'animationToWaitFor' is complete
            return(character.CharacterAnimator.GetEndTime(duration.animationToWaitFor) - startTime);

        case DurationType.UsePhysicsData:
            // Use the character's walking physics values when applying a force. The force will last as long as it
            // takes for his walking speed to get him there
            break;

        case DurationType.Seconds:
            // The duration is specified in seconds
            return(duration.seconds);
        }

        // If this statement is reached, the force object does not directly specify its duration. If this duration
        // is used for a force, the duration is not directly specified in seconds. Instead, the force moves the
        // character using his physics values. Therefore, the force will last as long as it takes for his physics
        // values to reach its target. Thus, return 0 since the CastingTime instance has no specified duration
        return(0.0f);
    }
Пример #3
0
    /** Displays the CONTENTS of a 'startTime' foldout. A starting time is used to specify when a certain force or effect
     * begins. It is an instance of CastingTime */
    public static void StartTimeFoldout(CastingTime startTime)
    {
        EditorGUI.indentLevel++;

        // Specify the starting time of this force
        EditorGUILayout.BeginHorizontal();
        {
            startTime.type = (DurationType)EditorGUILayout.EnumPopup("Start at:", startTime.type);
            switch (startTime.type)
            {
            case DurationType.WaitForAnimationComplete:
                startTime.animationToWaitFor = EditorGUILayout.IntField("", startTime.animationToWaitFor, GUILayout.Width(80));
                break;

            case DurationType.Frame:
                startTime.nFrames = EditorGUILayout.IntField("", startTime.nFrames, GUILayout.Width(80));
                break;

            case DurationType.Seconds:
                startTime.seconds = EditorGUILayout.FloatField("Start at:", startTime.seconds);
                break;
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUI.indentLevel--;
    }
Пример #4
0
        public void TakeAction(CastingTime castingTime)
        {
            var         intCastingTime = (int)castingTime;
            RoundAction asRound;

            if (intCastingTime > (int)RoundAction.FullRound)
            {
                asRound = RoundAction.FullRound;
            }
            else
            {
                asRound = (RoundAction)intCastingTime;
            }
            TakeAction(asRound);
        }
Пример #5
0
        private string GetCastingTimeString(CastingTime castingTime)
        {
            switch (castingTime)
            {
            case DataTypes.CastingTime.FullRound: return("Full-round action");

            case DataTypes.CastingTime.Minute: return("1 minute");

            case DataTypes.CastingTime.Standard: return("1 standard action");

            case DataTypes.CastingTime.Swift: return("1 swift action");

            default: return(null);
            }
        }
Пример #6
0
        /// <summary>
        /// Saves a spell definition
        /// </summary>
        /// <param name="writer">XmlWriter</param>
        /// <returns></returns>
        public bool Save(XmlWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            writer.WriteStartElement("spell");
            writer.WriteAttributeString("name", Name);

            writer.WriteElementString("description", Description);



            writer.WriteStartElement("duration");
            writer.WriteAttributeString("value", Duration.ToString());
            writer.WriteEndElement();



            writer.WriteStartElement("castingtime");
            writer.WriteAttributeString("value", CastingTime.ToString());
            writer.WriteEndElement();


            writer.WriteStartElement("class");
            writer.WriteAttributeString("value", Class.ToString());
            writer.WriteEndElement();


            writer.WriteStartElement("range");
            writer.WriteAttributeString("value", Range.ToString());
            writer.WriteEndElement();



            writer.WriteStartElement("level");
            writer.WriteAttributeString("value", Level.ToString());
            writer.WriteEndElement();


            Script.Save("script", writer);


            writer.WriteEndElement();

            return(true);
        }
Пример #7
0
    /// <summary>
    /// Creates a new force instance given a template.
    /// </summary>
    /// <param name="createOnCompleteEvent">If set to <c>true</c> create an onComplete event. This is set to true
    /// by default. This parameter is set to false when the Force is created inside a ForceEvent instance. In this
    /// case, creating an 'onComplete' Event would cause infinite recursion. This is because each ForceEvent holds
    /// an instance of a Force, which creates a new 'Brawler.Event'. Then, the Brawler.Event creates a new ForceEvent,
    /// which then creates a new Force, and the recursion never stops. Therefore, if this Force is a member variable
    /// inside a ForceEvent instance, the onComplete event should not be created.
    /// </param>
    public Force(Force template, bool createOnCompleteEvent)
    {
        if (createOnCompleteEvent)
        {
            // Create a deep copy of the event
            onCompleteEvent = new Brawler.Event(template.onCompleteEvent);
        }

        // Copy the templates values into this new instance
        forceType = template.forceType;
        velocity  = template.velocity;
        relativeToFacingDirection = template.relativeToFacingDirection;
        target = template.target;
        customTargetPosition = template.customTargetPosition;
        faceTarget           = template.faceTarget;
        startTime            = template.startTime;
        duration             = template.duration;
    }
Пример #8
0
        // Creates an Event with the same properties as the given event
        public Event(Event other)
        {
            type                 = other.type;
            actionToPerform      = other.actionToPerform;
            basicActionToPerform = other.basicActionToPerform;
            soundEffect          = other.soundEffect;

            cameraMovement = new CameraMovement(other.cameraMovement);
            slowMotion     = other.slowMotion;
            particleEvent  = other.particleEvent;
            forceEvent     = new Force(other.forceEvent, false);
            colorFlash     = other.colorFlash;
            ghostEffect    = other.ghostEffect;
            screenShake    = other.screenShake;
            tweenEvent     = other.tweenEvent;

            startTime = other.startTime;
            duration  = other.duration;
        }
Пример #9
0
        public override int GetHashCode()
        {
            int hash = Level.GetHashCode();

            if (Description != null)
            {
                hash ^= Description.GetHashCode();
            }
            if (Name != null)
            {
                hash ^= Name.GetHashCode();
            }
            if (Icon != null)
            {
                hash ^= Icon.GetHashCode();
            }
            hash ^= IsHidden.GetHashCode();
            hash ^= IsPassive.GetHashCode();
            hash ^= Cooldown.GetHashCode();
            hash ^= CastingTime.GetHashCode();
            hash ^= ChannelingTime.GetHashCode();
            hash ^= ForceCost.GetHashCode();
            hash ^= EnergyCost.GetHashCode();
            hash ^= ApCost.GetHashCode();
            hash ^= ApType.GetHashCode();
            hash ^= MinRange.GetHashCode();
            hash ^= MaxRange.GetHashCode();
            hash ^= GCD.GetHashCode();
            hash ^= GcdOverride.GetHashCode();
            if (AbilityTokens != null)
            {
                hash ^= AbilityTokens.GetHashCode();
            }
            hash ^= TargetArc.GetHashCode();
            hash ^= TargetArcOffset.GetHashCode();
            hash ^= TargetRule.GetHashCode();
            hash ^= LineOfSightCheck.GetHashCode();
            hash ^= Pushback.GetHashCode();
            hash ^= IgnoreAlacrity.GetHashCode();
            return(hash);
        }
Пример #10
0
        private Spell MapValues(Spell spell, string userId)
        {
            CastingTime time = _ctx.CastingTimes.FirstOrDefault(c => c.Amount == spell.CastingTime.Amount && c.Unit == spell.CastingTime.Unit && c.ReactionCondition == spell.CastingTime.ReactionCondition && c.Type == (int)spell.CastingTime.Type);

            if (time != null)
            {
                spell.CastingTime   = time;
                spell.CastingTimeID = time.ID;
            }

            SpellComponents components = _ctx.SpellComponents.FirstOrDefault(c => c.Somatic == spell.SpellComponents.Somatic && c.Verbal == spell.SpellComponents.Verbal && spell.SpellComponents.Material == c.Material);

            if (components != null)
            {
                spell.SpellComponents   = components;
                spell.SpellComponentsID = components.ID;
            }

            SpellDuration duration = _ctx.SpellDurations.FirstOrDefault(d => d.Amount == spell.SpellDuration.Amount && d.Concentration == spell.SpellDuration.Concentration && d.Type == spell.SpellDuration.Type && d.Unit == spell.SpellDuration.Unit && d.UpTo == spell.SpellDuration.UpTo);

            if (duration != null)
            {
                spell.SpellDuration   = duration;
                spell.SpellDurationID = duration.ID;
            }

            SpellRange range = _ctx.SpellRanges.FirstOrDefault(r => r.Amount == spell.SpellRange.Amount && r.Type == spell.SpellRange.Type && r.Shape == spell.SpellRange.Shape && r.Unit == spell.SpellRange.Unit);

            if (range != null)
            {
                spell.SpellRange   = range;
                spell.SpellRangeID = range.ID;
            }

            spell.Campaign   = _ctx.Campaigns.Where(c => c.ID == spell.CampaignID && c.AppUserId == userId).Single();
            spell.CampaignID = spell.Campaign.ID;

            return(spell);
        }
Пример #11
0
    /** Displays the CONTENTS of a 'duration' foldout. A starting time is used to specify how long a certain force or effect
     * lasts. It is an instance of CastingTime */
    public static void DurationFoldout(CastingTime duration)
    {
        EditorGUI.indentLevel++;

        //Define the duration of the force
        duration.type = (DurationType)EditorGUILayout.EnumPopup("Duration type:", duration.type);

        switch (duration.type)
        {
        case DurationType.WaitForAnimationComplete:
            duration.animationToWaitFor = EditorGUILayout.IntField("Stop at animation:", duration.animationToWaitFor);
            break;

        case DurationType.Frame:
            duration.nFrames = EditorGUILayout.IntField("Number of frames:", duration.nFrames);
            break;

        case DurationType.Seconds:
            duration.seconds = EditorGUILayout.FloatField("Number of seconds:", duration.seconds);
            break;
        }

        EditorGUI.indentLevel--;
    }
Пример #12
0
        public Spell(string name, Dictionary <string, int> level, string description, School school, Subschool subschool, IEnumerable <string> components, CastingTime castingTime, Range range, Duration duration, SavingThrow save, bool spellResistance)
        {
            Name            = name;
            Level           = level;
            Description     = description;
            School          = school;
            SchoolString    = school.ToString();
            Subschool       = subschool;
            SubschoolString = subschool.ToString();
            Components      = components;
            CastingTime     = GetCastingTimeString(castingTime);
            Range           = GetRangeString(range);
            Duration        = GetDurationString(duration);
            SavingThrow     = GetSavingThrowString(save);
            SpellResistance = spellResistance;
            SrString        = GetSrString(spellResistance);

            Link = "https://aonprd.com/SpellDisplay.aspx?ItemName=" + Name;
        }