private AnimationElement cloneAndPaste(AnimationSequencer destinationSequence) { AnimationElement clonedElement = null; if (currentClipboardObject is AnimationElement) { var cloningElement = currentClipboardObject as AnimationElement; clonedElement = cloningElement.Clone(cloningElement.Target); destinationSequence.InsertElement(clonedElement); } else { var cloningAbility = currentClipboardObject as AnimatedAbility; AnimationSequencer sequencer = cloningAbility.Clone() as AnimationSequencer; AnimatedCharacter target = null; if (destinationSequence is AnimatedAbility) { target = (destinationSequence as AnimatedAbility).Target; } else { target = (destinationSequence as SequenceElement).Target; } SequenceElementImpl sequenceElement = new HeroVirtualTabletop.AnimatedAbility.SequenceElementImpl(sequencer, target); sequenceElement.Type = sequencer.Type; sequenceElement.Name = "Sequence: " + sequenceElement.Type.ToString(); clonedElement = sequenceElement; destinationSequence.InsertElement(sequenceElement); } return(clonedElement); }
private void addMockAbilityToCharacter(AnimatedCharacter character, string name) { var ability = MockAnimatedAbility; ability.Name = name; character.Abilities.InsertAction(ability); }
private void OnValidate() { agent = agent ?? GetComponent <NavMeshAgent>(); anim = anim ?? GetComponent <Animator>(); character = character ?? GetComponent <AnimatedCharacter>(); ghostVFX = ghostVFX ?? GetComponent <GhostVFX>(); }
public AttackComponent(float _damage, float _range, float _cooldownTime, AnimatedCharacter _animation) { Damage = _damage; defaultDamage = _damage; Range = _range; CooldownTime = _cooldownTime; animation = _animation; }
private void addStateToTargetIfPersistent(AnimatedAbility ability, AnimatedCharacter target) { if (ability.Persistent) { AnimatableCharacterState newstate = new AnimatableCharacterStateImpl(ability, target); newstate.AbilityAlreadyPlayed = true; target.AddState(newstate); } }
public BaseBeing(GameObject _go, Vector2 _position) { GameObject = _go; animation = GameObject.GetComponentInChildren <AnimatedCharacter>(); transform = GameObject.transform; transform.localPosition = _position - (Vector2)transform.parent.position; navAgent = GameObject.GetComponent <NavMeshAgent>(); navAgent.destination = Position; }
void OnTriggerEnter(Collider other) { AnimatedCharacter ac = other.transform.GetComponentInChildren<AnimatedCharacter>(); if (ac != null && ac.Owner != null && (ac.Owner as PlayerTroop) != null) { SupplyManager.Instance.TriggerSupplyPickup(supplyDefinition); Destroy(this.gameObject); } }
private void addDefaultMockAbilitiesToCharacter(AnimatedCharacter character) { addMockAbilityToCharacter(character, DefaultAbilities.MISS); addMockAbilityToCharacter(character, DefaultAbilities.HIT); addMockAbilityToCharacter(character, DefaultAbilities.STUNNED); addMockAbilityToCharacter(character, DefaultAbilities.UNCONSCIOUS); addMockAbilityToCharacter(character, DefaultAbilities.DYING); addMockAbilityToCharacter(character, DefaultAbilities.DEAD); addMockAbilityToCharacter(character, DefaultAbilities.UNDERATTACK); }
public void GenerateAndDisplay(AnimatedCharacter character, List <string> attackingCharacterNames, bool showAttackMenu, bool isSequenceView = false, bool isSweepAttackInProgress = false, bool showAttackSpreadMenu = false) { Character = character; AttackingCharacterNames = attackingCharacterNames; ShowAttackMenu = showAttackMenu; IsSequenceViewActive = isSequenceView; IsSweepAttackInProgress = isSweepAttackInProgress; ShowAttackSpreadMenu = showAttackSpreadMenu; GenerateAndDisplay(); ContextCommandFileWatcher.EnableRaisingEvents = true; }
public AnimatedAbility Clone(AnimatedCharacter target) { var clonedSequence = ((AnimationSequencerImpl)Sequencer).Clone(target) as AnimationSequencer; AnimatedAbility clone = new AnimatedAbilityImpl(clonedSequence); clone.Target = target; clone.Name = Name; clone.KeyboardShortcut = KeyboardShortcut; clone.Persistent = Persistent; clone.StopAbility = StopAbility?.Clone(target); return(clone); }
private string GetEffectsStringWithBody(AnimatedCharacter character) { Random rnd = new Random(); List <string> effectsStr = new List <string>(); string efstr = ""; var instructions = this.DefenderAttackInstructions.First(d => d.Defender == character); if (instructions.DefenderHitByAttack) { character.Body = rnd.Next(81, 99); } else { character.Body = 100; } if (instructions.DefenderStunned) { effectsStr.Add("Stunned"); character.Body = rnd.Next(51, 80); } if (instructions.DefenderUnconscious) { effectsStr.Add("Unconscious"); character.Body = rnd.Next(31, 51); } if (instructions.DefenderDying) { effectsStr.Add("Dying"); character.Body = rnd.Next(1, 10); } if (instructions.DefenderDead) { effectsStr.Add("Dead"); character.Body = 0; } if (instructions.DefenderKnockbackDistance > 0 && !(instructions.DefenderDying || instructions.DefenderDead)) { character.Body = rnd.Next(11, 50); } if (effectsStr.Count > 0) { efstr = String.Join(", ", effectsStr); if (efstr.IndexOf(",") != efstr.LastIndexOf(",")) { efstr = efstr.Replace(efstr[efstr.LastIndexOf(", ")].ToString(), " and"); } efstr += "."; } return(efstr); }
public void Play(AnimatedCharacter target) { // If there is an ability with the same name in the target, we should play that ability instead var abilityWithSameName = target.Abilities?.FirstOrDefault(a => a.Name == this.Name && a != this); if (abilityWithSameName != null) { abilityWithSameName.Play(target); } else { Sequencer.Play(target); addStateToTargetIfPersistent(this, target); } }
public void CopyAbilitiesTo(AnimatedCharacter targetCharacter) { foreach (AnimatedAbility ability in this.Abilities) { string abilityName = targetCharacter.GetNewValidAbilityName(ability.Name); AnimatedAbility copiedAbility = new AnimatedAbilityImpl(); ReferenceElement refElement = new ReferenceElementImpl(); ReferenceResource refResource = new ReferenceResourceImpl(); refResource.Ability = ability; refResource.Character = this; refElement.Reference = refResource; refElement.Name = ability.Name; copiedAbility.InsertElement(refElement); copiedAbility.Name = abilityName; if (ability is AnimatedAttack) { AnimatedAttack attack = ability as AnimatedAttack; AnimatedAttack copiedAttack = ability.TransformToAttack(); AnimatedAbility copiedOnHitAbility = new AnimatedAbilityImpl(); ReferenceElement refElementOnHit = new ReferenceElementImpl(); ReferenceResource refResourceOnHit = new ReferenceResourceImpl(); refResource.Ability = attack.OnHitAnimation; refResource.Character = this; refElementOnHit.Reference = refResourceOnHit; refElementOnHit.Name = attack.OnHitAnimation.Name; copiedOnHitAbility.InsertElement(refElementOnHit); copiedAttack.OnHitAnimation = copiedOnHitAbility; if (ability is AreaEffectAttack) { copiedAttack = copiedAttack.TransformToAreaEffectAttack(); } copiedAbility = copiedAttack; } targetCharacter.Abilities.InsertAction(copiedAbility); } }
public AttackStartedEvent(AnimatedCharacter attacker, AttackInstructions instructions) { this.Attacker = attacker; this.AttackInstructions = instructions; }
public void Stop(AnimatedCharacter target) { Sequencer.Stop(target); target.RemoveStateFromActiveStates(Name); }
public AnimatableCharacterStateImpl(AnimatedAbility ability, AnimatedCharacter target) { StateName = ability.Name; Target = target; Ability = ability; }
public void AddToCharacter(AnimatedCharacter character) { character.AddState(this); }
public void RemoveFromCharacter(AnimatedCharacter character) { throw new NotImplementedException(); }
protected override void Awake() { base.Awake(); ac = cb as AnimatedCharacter; }
public void GenerateMenu() { AnimatedCharacter character = Character; string fileCharacterMenu = Path.Combine(GameDirectoryPath, GAME_DATA_FOLDERNAME, GAME_TEXTS_FOLDERNAME, GAME_LANGUAGE_FOLDERNAME, GAME_MENUS_FOLDERNAME, GAME_CHARACTER_MENU_FILENAME); var assembly = Assembly.GetExecutingAssembly(); var resourceName = "HeroVirtualTabletop.Desktop.character.mnu"; List <string> menuFileLines = new List <string>(); using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { string line; while ((line = reader.ReadLine()) != null) { menuFileLines.Add(line); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < menuFileLines.Count - 1; i++) { if (menuFileLines[i].StartsWith("Option \"Abort\"") && !IsSequenceViewActive) { continue; } if (menuFileLines[i].StartsWith("Option \"Execute Sweep\"") && !IsSweepAttackInProgress) { continue; } sb.AppendLine(menuFileLines[i]); } if (character.CharacterActionGroups != null && character.CharacterActionGroups.Count > 0) { foreach (var actionGroup in character.CharacterActionGroups) { sb.AppendLine(string.Format("Menu \"{0}\"", actionGroup.Name)); sb.AppendLine("{"); IEnumerable actionList = null; if (actionGroup is CharacterActionList <Identity> ) { actionList = actionGroup as CharacterActionList <Identity>; } else if (actionGroup is CharacterActionList <AnimatedAbility.AnimatedAbility> ) { actionList = actionGroup as CharacterActionList <AnimatedAbility.AnimatedAbility>; } else if (actionGroup is CharacterActionList <Movement.CharacterMovement> ) { actionList = actionGroup as CharacterActionList <Movement.CharacterMovement>; } else { actionList = actionGroup as CharacterActionList <CharacterAction>; } foreach (var action in actionList) { var act = action as CharacterAction; string whiteSpaceReplacedOptionGroupName = actionGroup.Name.Replace(" ", SPACE_REPLACEMENT_CHARACTER); string whiteSpaceReplacedOptionName = act.Name.Replace(" ", SPACE_REPLACEMENT_CHARACTER); sb.AppendLine(string.Format("Option \"{0}\" \"bind_save_file {1}{2}{3}.txt\"", act.Name, whiteSpaceReplacedOptionGroupName, DEFAULT_DELIMITING_CHARACTER, whiteSpaceReplacedOptionName)); } sb.AppendLine("}"); } } sb.AppendLine(menuFileLines[menuFileLines.Count - 1]); File.WriteAllText( fileCharacterMenu, sb.ToString() ); System.Threading.Thread.Sleep(200); // Delay so that the file write completes before calling the pop menu } }