Example #1
0
    public void SetSequence(AnimationSequence sequence)
    {
        Sequence = sequence;
        sequence.SetGameObject(this.gameObject);

        sequence.AnimationComplete += AnimComplete;
    }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="key">key name</param>
        /// <param name="assetName">asset name</param>
        /// <param name="resource">animation resource</param>
        public GameResourceAnimation(string key, string assetName, 
                                    AnimationSequence resource) 
            : base(key, assetName)
        {
            this.animationSequence = resource;

            this.resource = (object)this.animationSequence;
        }
Example #3
0
 protected void InitAnimator()
 {
     FrameAnimator a = new FrameAnimator(25, 25);
     AnimationSequence seq = new AnimationSequence("rotating", 0, 8);
     seq.Mode = AnimationSequence.AnimationMode.LOOP;
     a.AddAnimation(seq);
     a.CurrentAnimationName = "rotating";
     this.Animator = a;
 }
Example #4
0
        public override void GetParameterValues()
        {
            //Get the y-rotation value and convert it into a float.
            _rotationAmount = AnimationSequence.GetFloat(0);

            //Get the completion time.
            _duration = AnimationSequence.GetFloat(1);

            //Set the elapsed time to 0.
            _elapsedTime = 0f;
        }
        public override ImportContentData Import(string filename,
                                                 ContentImporterContext context)
        {
            Stream stream = File.OpenRead(Path.Combine("Content", filename));

            XmlTextReader     reader     = new XmlTextReader(stream);
            XmlSerializer     serializer = new XmlSerializer(typeof(AnimationSequence));
            AnimationSequence data       = (AnimationSequence)serializer.Deserialize(reader);

            return(new ImportContentData(data));
        }
Example #6
0
        protected override List <AnimationSequence> EnsureSequences(Scene scene)
        {
            List <AnimationSequence> sequences = new List <AnimationSequence>();
            AnimationSequence        sequence  = new AnimationSequence();
            ImageElement             image     = scene.LoadImage("Images/Race/obstacles/pole.png", false);

            sequence.AddSprite(image, 10, 80);
            sequences.Add(sequence);

            return(sequences);
        }
 // Use this for initialization
 void Start()
 {
     MaxTimeToShootMaxReset = MaxTimeToShoot;
     soundIndex             = 0;
     animSequence           = AnimationSequence.Anim2;
     swarmDirection         = SwarmDirection.left;
     audioSource            = GetComponent <AudioSource> ();
     audioSource.clip       = InvaderMoveSound [0];
     AccumulatedTime        = 0f;
     randTimeToShoot        = Random.Range(MinTimeToShoot, MaxTimeToShoot);
 }
Example #8
0
        public override void GetParameterValues()
        {
            //Get the offset value.
            _offset = AnimationSequence.GetVector3(0);

            //Get the rotation value.
            _rotation = AnimationSequence.GetFloat(1);

            //Get the completion time value.
            _duration = AnimationSequence.GetFloat(2);
        }
        public static AnimationSequenceSave FromAnimationSequence(AnimationSequence animationSequence)
        {
            AnimationSequenceSave sequenceSave = new AnimationSequenceSave();
            sequenceSave.Name = animationSequence.Name;

            foreach (TimedKeyframeList tkl in animationSequence)
            {
                sequenceSave.TimedKeyframeListSaves.Add(TimedKeyframeListSave.FromTimedKeyframeList(tkl));
            }
            return sequenceSave;
        }
        public AnimationSequence ToAnimationSequence(List<InstructionSet> instructionSetList)
        {
            AnimationSequence animationSequence = new AnimationSequence();
            animationSequence.Name = this.Name;
            foreach (TimedKeyframeListSave tkls in TimedKeyframeListSaves)
            {
                animationSequence.Add(tkls.ToTimedKeyframeList(instructionSetList));
            }

            return animationSequence;
        }
Example #11
0
        private void Start()
        {
            var animationDataProvider = ResourceLocator <AnimationDataProvider> .GetResourceProvider();

            _animationSequence = animationDataProvider.GetAnimationSequence(AnimationEntityType.Enemy);

            if (_spawnOne)
            {
                _spawnBatchSize = 1;
            }
        }
Example #12
0
        private void LoadAnimation(string number, string name)
        {
            ShooterLevel      level    = ShooterLevel.Current;
            AnimationSequence sequence = new AnimationSequence();

            sequence.AddSprites(new ImageElement[] {
                level.LoadImage("images/shooter/missile/" + number + "00.png", false),
                level.LoadImage("images/shooter/missile/" + number + "01.png", false),
                level.LoadImage("images/shooter/missile/" + number + "02.png", false)
            }, 30, 30);
            AnimationSequences[name] = sequence;
        }
Example #13
0
        public void OnBeginPlay()
        {
            World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera"));

            SkeletalMesh prototypeMesh = SkeletalMesh.Load("/Game/Tests/Characters/Prototype");

            Actor leftPrototype = new("leftPrototype");
            SkeletalMeshComponent leftSkeletalMeshComponent = new(leftPrototype);

            leftSkeletalMeshComponent.SetSkeletalMesh(prototypeMesh);
            leftSkeletalMeshComponent.SetWorldLocation(new(-700.0f, -70.0f, -100.0f));
            leftSkeletalMeshComponent.SetWorldRotation(Maths.Euler(0.0f, 0.0f, 90.0f));
            leftSkeletalMeshComponent.SetAnimationMode(AnimationMode.Asset);
            leftSkeletalMeshComponent.PlayAnimation(AnimationSequence.Load("/Game/Tests/Characters/Animations/IdleAnimationSequence"), true);

            Assert.IsTrue(leftSkeletalMeshComponent.IsPlaying);
            Assert.IsTrue(leftSkeletalMeshComponent.GetBoneName(0) == "root");

            Bounds leftSkeletalMeshComponentBounds = default;

            leftSkeletalMeshComponent.GetBounds(leftSkeletalMeshComponent.GetTransform(), ref leftSkeletalMeshComponentBounds);

            Assert.IsFalse(leftSkeletalMeshComponentBounds == default(Bounds));

            Actor rightPrototype = new("rightPrototype");
            SkeletalMeshComponent rightSkeletalMeshComponent = new(rightPrototype);

            rightSkeletalMeshComponent.SetSkeletalMesh(prototypeMesh);
            rightSkeletalMeshComponent.SetWorldLocation(new(-700.0f, 70.0f, -100.0f));
            rightSkeletalMeshComponent.SetWorldRotation(Maths.Euler(0.0f, 0.0f, 90.0f));
            rightSkeletalMeshComponent.SetAnimationMode(AnimationMode.Asset);

            MaterialInstanceDynamic prototypeMaterial = rightSkeletalMeshComponent.CreateAndSetMaterialInstanceDynamic(0);

            prototypeMaterial.SetVectorParameterValue("AccentColor", new(0.0f, 0.5f, 1.0f));

            Assert.IsNotNull(prototypeMaterial.GetParent());

            AnimationMontage rightPrototypeAnimationMontage = AnimationMontage.Load("/Game/Tests/Characters/Animations/RunAnimationMontage");

            rightSkeletalMeshComponent.PlayAnimation(rightPrototypeAnimationMontage, true);

            AnimationInstance rightPrototypeAnimationInstance = rightSkeletalMeshComponent.GetAnimationInstance();

            Assert.IsTrue(rightPrototypeAnimationInstance.IsPlaying(rightPrototypeAnimationMontage));
            Assert.IsTrue(rightSkeletalMeshComponent.GetBoneName(0) == "root");

            Bounds rightSkeletalMeshComponentBounds = default;

            rightSkeletalMeshComponent.GetBounds(rightSkeletalMeshComponent.GetTransform(), ref rightSkeletalMeshComponentBounds);

            Assert.IsFalse(rightSkeletalMeshComponentBounds == default(Bounds));
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (animationSequence != null)
                {
                    animationSequence = null;
                }
            }

            base.Dispose(disposing);
        }
Example #15
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (animationSequence != null)
                {
                    animationSequence = null;
                }
            }

            base.Dispose(disposing);
        }
Example #16
0
        private AnimationSequence[] GetSequences()
        {
            int fps = 3;

            AnimationSequence down  = new AnimationSequence(Human.DownSequenceFrames, fps);
            AnimationSequence left  = new AnimationSequence(Human.LeftSequenceFrames, fps);
            AnimationSequence right = new AnimationSequence(Human.RightSequenceFrames, fps);
            AnimationSequence up    = new AnimationSequence(Human.UpSequenceFrames, fps);

            AnimationSequence[] sequences = { down, left, right, up };

            return(sequences);
        }
Example #17
0
        public List <AnimationSequence> ToAnimationSequenceList(List <InstructionSet> instructionSets)
        {
            List <AnimationSequence> animationSequenceList = new List <AnimationSequence>();

            foreach (AnimationSequenceSave sequenceSave in AnimationSequenceSaves)
            {
                AnimationSequence animationSequence = sequenceSave.ToAnimationSequence(instructionSets);

                animationSequenceList.Add(animationSequence);
            }

            return(animationSequenceList);
        }
Example #18
0
 public override void RemoveAction(IAction skyAction)
 {
     AnimationSequence.Remove(skyAction);
     skyAction.ParentAction = null;
     if (PlayTime == skyAction.PlayTime)
     {
         ReComputePlaytime();
         if (ParentAction != null)
         {
             this.ParentAction.ReComputePlaytime();
         }
     }
 }
Example #19
0
    private void ShowWindow(bool show, bool animated)
    {
        if (animated)
        {
            if (show)
            {
                if (showAnim == null)
                {
                    showAnim = new AnimationSequence(initialShowAnimation, applicationEventRelay.RequestStartingCoroutine);
                    startSessionButton.SelectOnShow = true;
                    showAnim.OnFinished(() => ShowButtons(true, false));
                    // showAnim.OnFinished(() => startSessionButton.Select());
                }

                showAnim.Play();

                SetProgressBar(null);
                sessionOverviewPanel.SetActive(true);

                Utility.SetCursor(true, CursorLockMode.None);
            }
            else
            {
                if (hideAnim == null)
                {
                    hideAnim = new AnimationSequence(initialShowAnimation.Reversed(), applicationEventRelay.RequestStartingCoroutine);
                    hideAnim.OnFinished(() => startSessionButton.Deselect());
                    hideAnim.OnFinished(() => ShowButtons(false, false));
                    hideAnim.OnFinished(() => sessionOverviewPanel.SetActive(false));
                }

                hideAnim.Play();

                Utility.SetCursor(false, CursorLockMode.Locked);
            }

            applicationEventRelay.CinemaBar(show, true);
        }
        else
        {
            sessionTitle.SetActive(show);

            ShowButtons(show, false);
        }

        // if (show) {
        //     Utility.SetCursor(true, CursorLockMode.None);
        // } else {
        //     Utility.SetCursor(false, CursorLockMode.Locked);
        // }
    }
Example #20
0
    private void animPrepareToSlam()
    {
        switch (attackAnimationState)
        {
        case AttackAnimationState.NeedsToStart:
            Vector2 launchForce = new Vector2(0f, 300f);

            originalBasketball.localPosition = new Vector2(0.18f, 0.21f);

            GetComponent <BoxCollider2D>().enabled = false;
            rigidbody2D.AddForce(launchForce);
            anim.SetTrigger("Dunking");

            attackAnimationState = AttackAnimationState.InProgress;

            break;

        case AttackAnimationState.InProgress:
            if (rigidbody2D.velocity.magnitude < 0.8)
            {
                anim.SetTrigger("Slamming");
                rigidbody2D.gravityScale = 0;

                originalBasketball.renderer.enabled = false;

                attacksketball.position         = transform.position + new Vector3(0.18f, 0.21f, 0.0f);
                basketballVelocity              = currentAttackTarget.transform.position - attacksketball.position;
                basketballVelocity             *= 2;
                attacksketball.renderer.enabled = true;
                playSound(throwSound);

                attackAnimationState = AttackAnimationState.Complete;
            }
            break;

        case AttackAnimationState.Complete:
            attacksketball.position = attacksketball.position + basketballVelocity * Time.fixedDeltaTime;

            if (attacksketball.position.x > (currentAttackTarget.transform.position.x - 0.1))
            {
                attacksketball.renderer.enabled = false;
                currentAttackTarget.Damage(currentAttack.Power);
                playSound(hitSound);
                currentAnimation     = AnimationSequence.ReturningFromSlamming;
                attackAnimationState = AttackAnimationState.NeedsToStart;
            }

            break;
        }
    }
Example #21
0
 public static AnimationSequence <T> Repeat <T>(this AnimationSequence <T> sequence, int count = -1) where T : Drawable
 {
     sequence.repeatCount    = count;
     sequence.repeatDuration = sequence.duration;
     if (sequence.repeatCount > 0)
     {
         sequence.duration *= count;
     }
     else if (sequence.repeatCount < 0)
     {
         sequence.durationInfinite = true;
     }
     return(sequence);
 }
Example #22
0
        public Missile(Vector2D location)
            : base(location, new SeekMotion(null, 12, new Vector2D(12, 0), 0.25f))
        {
            WeaponsSystem.TotalMissiles++;

            LoadAnimation("00", "8");
            LoadAnimation("01", "9");
            LoadAnimation("02", "10");
            LoadAnimation("03", "11");
            LoadAnimation("04", "12");
            LoadAnimation("05", "13");
            LoadAnimation("06", "14");
            LoadAnimation("07", "15");
            LoadAnimation("08", "0");
            LoadAnimation("09", "1");
            LoadAnimation("10", "2");
            LoadAnimation("11", "3");
            LoadAnimation("12", "4");
            LoadAnimation("13", "5");
            LoadAnimation("14", "6");
            LoadAnimation("15", "7");

            StartAnimation("0");

            ShooterLevel      level    = ShooterLevel.Current;
            AnimationSequence sequence = new AnimationSequence();

            sequence.AddSprites(new ImageElement[] {
                level.LoadImage("images/shooter/explosion/0002.png", false),
                level.LoadImage("images/shooter/explosion/0003.png", false),
                level.LoadImage("images/shooter/explosion/0004.png", false),
                level.LoadImage("images/shooter/explosion/0005.png", false),
                level.LoadImage("images/shooter/explosion/0006.png", false),
                level.LoadImage("images/shooter/explosion/0007.png", false),
                level.LoadImage("images/shooter/explosion/0008.png", false),
                level.LoadImage("images/shooter/explosion/0009.png", false)
            }, 25, 25);
            sequence.Delay = 50;
            sequence.Loop  = false;
            AnimationSequences["Explosion"] = sequence;

            Dino dino = AcquireTarget();

            if (dino != null)
            {
                dino.Locked = true;
            }
            ((SeekMotion)Motion).Target = AcquireTarget();
        }
Example #23
0
        public Bonus(Vector2D location, string bonusType)
            : base()
        {
            Location = new Vector3D(location.X, location.Y, ShooterLevel.BonusZ);

            _motion = new SineMotion(0, location.Y, 0.03f, 20);

            AnimationSequence sequence = new AnimationSequence();

            sequence.AddSprite(ShooterLevel.Current.LoadImage("images/shooter/bonus/" + bonusType + ".png", false), 0, 0);
            AnimationSequences["Default"] = sequence;
            StartAnimation("Default");

            BonusType = bonusType;
        }
Example #24
0
 public override void PlayNext(IAction skyAction)
 {
     if (AnimationSequence.Contains(skyAction))
     {
         int index = AnimationSequence.IndexOf(skyAction);
         if (index < AnimationSequence.Count - 1)
         {
             AnimationSequence [index + 1].Play();
         }
         else
         {
             PlayCallBack.OnCompleteMethod();
         }
     }
 }
Example #25
0
    private void animLameBounce()
    {
        switch (attackAnimationState)
        {
        case AttackAnimationState.NeedsToStart:

            if (timerIsGreaterThan(1.0f))
            {
                initialPosition = transform.position;

                lameBounceVelocity  = (transform.position - Vector3.right / 2) - transform.position;
                lameBounceVelocity *= 3;

                playSound(hitSound);
                target.Damage(1);

                startTimer();
                attackAnimationState = AttackAnimationState.InProgress;
            }

            break;

        case AttackAnimationState.InProgress:
            transform.position = transform.position + lameBounceVelocity * Time.fixedDeltaTime;

            if (timerIsGreaterThan(0.1f))
            {
                attackAnimationState = AttackAnimationState.Complete;
                startTimer();
            }



            break;

        case AttackAnimationState.Complete:
            transform.position = initialPosition;

            if (timerIsGreaterThan(0.5f))
            {
                currentAnimation     = AnimationSequence.None;
                attackAnimationState = AttackAnimationState.Off;
                AnimationInProgress  = false;
            }

            break;
        }
    }
Example #26
0
        public BasicPlasmaBall(Vector2D location, IMotion motion) : base(location, motion)
        {
            ShooterLevel      level    = ShooterLevel.Current;
            AnimationSequence sequence = new AnimationSequence();

            sequence.AddSprites(new ImageElement[] {
                level.LoadImage("images/shooter/plasma/1.png", false),
                level.LoadImage("images/shooter/plasma/2.png", false),
                level.LoadImage("images/shooter/plasma/3.png", false),
                level.LoadImage("images/shooter/plasma/2.png", false)
            }, 6, 6);
            sequence.Loop  = true;
            sequence.Delay = 200;
            AnimationSequences["Default"] = sequence;
            StartAnimation("Default");
        }
    private void ShowMessage(string message)
    {
        trainerMessageText.text = message;

        AnimationOperation scaleOperation = new AnimationOperation(messagePanel, UIAnimationType.Scale, EaseType.SmoothStepSmoother, 0, 1f)
        {
            scaleSettings = new AnimationOperation.ScaleSettings {
                startScale  = Vector3.zero,
                targetScale = Vector3.one
            }
        };

        AnimationOperation fadeOperation = new AnimationOperation(messagePanel, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 1f)
        {
            fadeSettings = new AnimationOperation.FadeSettings {
                startAlpha  = 0,
                targetAlpha = 1
            }
        };

        AnimationOperation flipOperation = new AnimationOperation(messagePanel, UIAnimationType.Rotate, EaseType.SmoothStepSmoother, 0, 0.5f)
        {
            rotateSettings = new AnimationOperation.RotateSettings {
                startEuler  = Vector3.zero,
                targetEuler = new Vector3(90, 0, 0)
            }
        };

        AnimationSequence showMessageAnimation = new AnimationSequence(e => StartCoroutine(e));

        showMessageAnimation.AddOperation(scaleOperation, fadeOperation, new AnimationOperation {
            targetObject = messagePanel, type = UIAnimationType.Activate, activate = true
        });
        showMessageAnimation.AddDelay(2f);
        showMessageAnimation.AddOperation(new AnimationOperation(fadeOperation.Reversed())
        {
            duration = 0.5f
        }, flipOperation, new AnimationOperation {
            targetObject = messagePanel, type = UIAnimationType.Activate, activate = false, delay = 0.5f
        }, new AnimationOperation {
            targetObject = messagePanel, type = UIAnimationType.Rotate, rotateSettings = new AnimationOperation.RotateSettings {
                targetEuler = Vector3.zero
            }, delay = 0.5f
        });

        showMessageAnimation.Play();
    }
Example #28
0
    /// <summary>
    /// Creates a new action of the given type (Walk, Idle, etc.). </summary>
    public BasicAction(BasicActionType type)
    {
        this.type = type;

        // Create an animation sequence for the basic action
        AnimationSequence animationSequence = new AnimationSequence();

        // Add an animation to the animation sequence. By default, make this the same as the type of the basic action
        animationSequence.animations = new string[1] {
            type.ToString()
        };

        // Store the animation sequence inside this action's 'animationSequences' array
        base.animationSequences = new AnimationSequence[1] {
            new AnimationSequence()
        };
    }
    public AnimationSequence(AnimationSequence animationSequence, Action <IEnumerator> delegateForPlay)
    {
        animationOperations = animationSequence.animationOperations;
        playDelegate        = delegateForPlay;

        playFunctions = PlayFunctions();
        doneFunctions = DoneFunctions();

        if (animationSequence.pingPong)
        {
            PingPong();
        }
        if (animationSequence.loop)
        {
            Loop();
        }
    }
Example #30
0
    public override void Attack(PlayerAttack attack, BattleCombatant target)
    {
        currentAttack       = attack;
        currentAttackTarget = target;

        if (attack.Name == "Slam Dunk")
        {
            AnimationInProgress  = true;
            currentAnimation     = AnimationSequence.PreparingToSlam;
            attackAnimationState = AttackAnimationState.NeedsToStart;
        }
        else if (attack.Name == "Gatorade\u2122 Sports Drink")
        {
            playSound(healSound);
            currentAttackTarget.Heal();
        }
    }
    private void SetMultiplier(int combo, bool animated)
    {
        int multiplier = GetScoreMultiplier(combo);

        if (animated)
        {
            if (multiplierAnimation == null && multiplier == 2)
            {
                scaleOperation = new AnimationOperation(multiplierText.gameObject, UIAnimationType.Scale, EaseType.SmoothStepSmoother, 0, 0.5f)
                {
                    scaleSettings = new AnimationOperation.ScaleSettings {
                        startScale  = Vector3.one,
                        targetScale = Vector3.one * 1.25f
                    }
                };
                reversedScaleOperation       = scaleOperation.Reversed();
                reversedScaleOperation.delay = 0.5f;

                multiplierAnimation = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);
                multiplierAnimation.AddOperation(scaleOperation);
                multiplierAnimation.AddOperation(reversedScaleOperation);
                multiplierAnimation.Loop();

                multiplierAnimation.Play();

                Show();
            }

            if (multiplier < currentMultiplier)
            {
                Hide();
            }

            multiplierText.text = $"x {multiplier}";
            currentCombo        = combo;
            currentMultiplier   = multiplier;
        }
        else
        {
            multiplierText.text = $"x {multiplier}";
            currentCombo        = combo;
            currentMultiplier   = multiplier;

            ShowHudElement(multiplier > 1, false);
        }
    }
    private void ShowHudElement(bool show, bool animated)
    {
        if (animated)
        {
            AnimationOperation fadeOperation = new AnimationOperation(panel, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 0.5f)
            {
                fadeSettings = new AnimationOperation.FadeSettings {
                    startAlpha  = 0,
                    targetAlpha = 1
                }
            };
            AnimationOperation anchorPositionOperation = new AnimationOperation(panel, UIAnimationType.AnchoredPosition, EaseType.BackInOut, 0, 0.5f)
            {
                anchoredPositionSettings = new AnimationOperation.AnchoredPositionSettings {
                    startMin  = new Vector2(-0.12f, 0.84f),
                    startMax  = new Vector2(0.08f, 1f),
                    targetMin = new Vector2(0f, 0.84f),
                    targetMax = new Vector2(0.2f, 1f)
                }
            };
            AnimationSequence showAnimation = new AnimationSequence(e => StartCoroutine(e));
            showAnimation.AddOperation(anchorPositionOperation);
            showAnimation.AddOperation(fadeOperation);
            showAnimation.AddOperation(new AnimationOperation {
                targetObject = panel, type = UIAnimationType.Activate, activate = true
            });

            if (show)
            {
                showAnimation.Play();
            }
            else
            {
                AnimationSequence reversedShowAnimation = new AnimationSequence(showAnimation.Reversed(), e => StartCoroutine(e));
                reversedShowAnimation.AddOperation(new AnimationOperation {
                    targetObject = panel, type = UIAnimationType.Activate, activate = false, delay = 0.5f
                });
                reversedShowAnimation.Play();
            }
        }
        else
        {
            panel.SetActive(show);
        }
    }
Example #33
0
    private void animFlyTowardsTarget()
    {
        switch (attackAnimationState)
        {
        case AttackAnimationState.NeedsToStart:
            initialPosition = transform.position;

            GetComponent <JamesGasBehavior>().EnableFlightMode();

            attackAnimationState = AttackAnimationState.InProgress;

            break;

        case AttackAnimationState.InProgress:

            rigidbody2D.AddForce(new Vector2(0, 400) * Time.fixedDeltaTime);


            if (transform.position.y > 0.1f)
            {
                playSound(GasBlastSound);
                attackAnimationState = AttackAnimationState.Complete;
            }


            break;

        case AttackAnimationState.Complete:

            rigidbody2D.AddForce(currentAttackTarget.transform.position - transform.position
                                 * 250 * Time.fixedDeltaTime);

            if (transform.rotation.eulerAngles.z < 170 && transform.rotation.eulerAngles.z > 163)
            {
                currentAttackTarget.Damage(currentAttack.Power);


                currentAnimation     = AnimationSequence.FlyingBack;
                attackAnimationState = AttackAnimationState.NeedsToStart;
            }


            break;
        }
    }
Example #34
0
    public override void AutoAttack(List <BattleCombatant> targetList)
    {
        if (currentChargeCount == chargesRequred)
        {
            targets              = targetList;
            AnimationInProgress  = true;
            currentAnimation     = AnimationSequence.LaserCharge;
            attackAnimationState = AttackAnimationState.NeedsToStart;

            currentChargeCount = 0;
        }
        else
        {
            currentChargeCount++;
        }

        StaffGlow.gravityModifier = Mathf.Lerp(-0.001f, -0.02f, currentChargeCount / (float)chargesRequred);
    }
Example #35
0
	private void animLaserCharge() {
		switch(attackAnimationState) {
		case AttackAnimationState.NeedsToStart:
			LaserCharge.Play();

			attackAnimationState = AttackAnimationState.InProgress;
			playSound(LaserChargeSound);
		
			break;
		case AttackAnimationState.InProgress:
			if(LaserCharge.time >= 2.5) {
				currentAnimation = AnimationSequence.LaserFire;
				attackAnimationState = AttackAnimationState.NeedsToStart;
				LaserFire.Stop();
			}
			
			break;
		}
	}
Example #36
0
        private void AddKeyframeListOk(Window callingWindow)
        {
            string name = ((TextInputWindow)callingWindow).Text;

            if (GuiData.TimeLineWindow.InstructionMode == InstructionMode.All)
            {
                AnimationSequence newSequence = new AnimationSequence();
                newSequence.Name = name;
                EditorData.GlobalInstructionSets.Add(newSequence);
            }
            else
            {

                KeyframeList keyframeList = new KeyframeList();

                EditorData.EditorLogic.CurrentInstructionSet.Add(keyframeList);
                keyframeList.Name = name;

                //GuiData.ListBoxWindow.InstructionSetListBox.HighlightItem(item);
            }
            GuiData.ListBoxWindow.UpdateLists();


        }
Example #37
0
	public override void Attack(PlayerAttack attack, BattleCombatant target) {

		currentAttack = attack;
		currentAttackTarget = target;
		
		if(attack.Name == "Gas Blast") {
			initialPosition = transform.position;

			AnimationInProgress = true;
			currentAnimation = AnimationSequence.FlyingTowardsTarget;
			attackAnimationState = AttackAnimationState.NeedsToStart;

		} else if(attack.Name == "Can of Beans") {
			playSound(HealSound);
			currentAttackTarget.Heal();
			
		}

		
	}
Example #38
0
 protected void OnAnimationComplete(FrameAnimator animator, AnimationSequence.AnimationStatus status)
 {
     if (animator.CurrentAnimationName == STARRING)
     {
         animator.RewindCurrentAnimation();
         animator.CurrentAnimationName = NORMAL;
     }
 }
Example #39
0
        public void PlayAnimation(AnimationSequence anim, bool loop, float frameTime = FrameTime, AnimationSequence end = AnimationSequence.Idle)
        {
            // don't double play animns
            if (anim != PlayingAnimation)
            {
                PlayingAnimation = anim;

                _currentAnimationFrame = 0;
                _loopCurrentAnim = loop;
                _transitionSequence = end;
                _frameTime = frameTime;
            }
        }
Example #40
0
        protected void InitAnimator()
        {
            FrameAnimator animator = new FrameAnimator(55, 55);
            AnimationSequence seq = new AnimationSequence(NORMAL, 1, 1);
            seq.Mode = AnimationSequence.AnimationMode.LOOP;

            AnimationSequence starring = new AnimationSequence(STARRING, 2, 5);
            starring.Mode = AnimationSequence.AnimationMode.STOP_AT_END;

            AnimationSequence electro = new AnimationSequence(ELECTRO, 11, 14);
            electro.Mode = AnimationSequence.AnimationMode.LOOP;

            AnimationSequence killed = new AnimationSequence(KILLED, 15, 20);
            killed.Mode = AnimationSequence.AnimationMode.LOOP;

            animator.AddAnimation(seq);
            animator.AddAnimation(starring);
            animator.AddAnimation(electro);
            animator.AddAnimation(killed);

            animator.CurrentAnimationName = "starring";

            this.Animator = animator;
            this.AnimationNotifier = OnAnimationComplete;
        }
Example #41
0
	public override void Attack(PlayerAttack attack, BattleCombatant target) {

		currentAttack = attack;
		currentAttackTarget = target;
		
		if(attack.Name == "Slam Dunk") {
			AnimationInProgress = true;
			currentAnimation = AnimationSequence.PreparingToSlam;
			attackAnimationState = AttackAnimationState.NeedsToStart;

		} else if(attack.Name == "Gatorade\u2122 Sports Drink") {
			playSound(healSound);
			currentAttackTarget.Heal();
		}

		
	}
Example #42
0
	public override void AutoAttack (List<BattleCombatant> targetList) {

		if(currentChargeCount == chargesRequred) {
			targets = targetList;
			AnimationInProgress = true;
			currentAnimation = AnimationSequence.LaserCharge;
			attackAnimationState = AttackAnimationState.NeedsToStart;

			currentChargeCount = 0;
		} else {
			currentChargeCount++;
		}

		StaffGlow.gravityModifier = Mathf.Lerp (-0.001f, -0.02f, currentChargeCount / (float)chargesRequred);


	}
Example #43
0
	private void animJumpBackward() {
		switch(attackAnimationState) {
		case AttackAnimationState.NeedsToStart:
			Vector2 launchVelocity = new Vector2(-7f, 0f);

			setDragEnabled(false);
			
			//calculate the needed initial vertical speed to reach the initial position
			float dist = initialPosition.x - transform.position.x;
			float time = dist / launchVelocity.x;
			launchVelocity.y = Mathf.Abs(Physics2D.gravity.y) / 2 * time;
			
			
			rigidbody2D.velocity = launchVelocity;
			
			attackAnimationState = AttackAnimationState.InProgress;
			GetComponent<Animator>().SetBool("IsAttacking", false);
			
			break;
		case AttackAnimationState.InProgress:
			if(transform.position.x < initialPosition.x + 0.2f) {
				rigidbody2D.velocity = Vector2.zero;
				currentAnimation = AnimationSequence.None;
				attackAnimationState = AttackAnimationState.Off;
				AnimationInProgress = false;

				// reset X position to inital value
				transform.position = new Vector3(initialPosition.x, transform.position.y, initialPosition.z);
				
				// reset drag to initial value
				setDragEnabled(true);
			}
			break;
		}
	}
Example #44
0
	private void animLaserFire() {
		switch(attackAnimationState) {
		case AttackAnimationState.NeedsToStart:

			LaserFire.enableEmission = true;

			playSound(LaserFireSound);
			attackAnimationState = AttackAnimationState.InProgress;

			startTimer();
			
			break;
		case AttackAnimationState.InProgress:

			if(timerIsGreaterThan(2.5f)) {

				LaserFire.enableEmission = false;
				currentAnimation = AnimationSequence.None;
				attackAnimationState = AttackAnimationState.Off;

				targets.ForEach(t => t.Damage(t.MaxHitPoints - 1));

				AnimationInProgress = false;
			}

			break;
		}
	}
Example #45
0
	public override void Attack(PlayerAttack attack, BattleCombatant target) {
		currentAttack = attack;
		currentAttackTarget = target;

		if(attack.Name == "Fried Chicken Smoothie") {
			anim.Play("Jumping");
			playSound(healSound);
			currentAttackTarget.Heal();
		} else if(attack.Name == "All-Purpose Slice") {
			initialPosition = transform.position;
			AnimationInProgress = true;
			currentAnimation = AnimationSequence.JumpForward;
			attackAnimationState = AttackAnimationState.NeedsToStart;
		} else if(attack.Name == "Sales Pitch") {
			initialPosition = transform.position;
			AnimationInProgress = true;
			currentAnimation = AnimationSequence.SalesPitch;
			attackAnimationState = AttackAnimationState.NeedsToStart;
		}

	}
Example #46
0
	public override void AutoAttack (List<BattleCombatant> targetList) {

		if(currentChargeCount == chargesRequred) {
			// do crazy attack

			targets = targetList;
			AnimationInProgress = true;
			currentAnimation = AnimationSequence.LaserCharge;
			attackAnimationState = AttackAnimationState.NeedsToStart;

			currentChargeCount = 0;
		} else {
			currentChargeCount++;

			// do a simple attack
			target = getWeakestTarget(targetList);

			AnimationInProgress = true;
			currentAnimation = AnimationSequence.LameBounce;
			attackAnimationState = AttackAnimationState.NeedsToStart;
			startTimer();


		}


	}
Example #47
0
	private void animLameBounce() {
		switch(attackAnimationState) {
		case AttackAnimationState.NeedsToStart:

			if(timerIsGreaterThan(1.0f)) {

				initialPosition = transform.position;

				lameBounceVelocity = (transform.position - Vector3.right/2) - transform.position;
				lameBounceVelocity *= 3;

				playSound(hitSound);
				target.Damage(1);

				startTimer();
				attackAnimationState = AttackAnimationState.InProgress;
			}

			break;
		case AttackAnimationState.InProgress:
			transform.position = transform.position + lameBounceVelocity * Time.fixedDeltaTime;
			
			if(timerIsGreaterThan(0.1f)) {
				attackAnimationState = AttackAnimationState.Complete;
				startTimer();
			}


			
			break;
		case AttackAnimationState.Complete:
			transform.position = initialPosition;

			if(timerIsGreaterThan(0.5f)) {
				currentAnimation = AnimationSequence.None;
				attackAnimationState = AttackAnimationState.Off;
				AnimationInProgress = false;
			}

			break;
		}
	}
Example #48
0
	private void animPrepareToSlam () {
		switch (attackAnimationState) {
		case AttackAnimationState.NeedsToStart:
			Vector2 launchForce = new Vector2 (0f, 300f);

			originalBasketball.localPosition = new Vector2(0.18f, 0.21f);

			GetComponent<BoxCollider2D>().enabled = false;
			rigidbody2D.AddForce(launchForce);
			anim.SetTrigger ("Dunking");

			attackAnimationState = AttackAnimationState.InProgress;

			break;
		case AttackAnimationState.InProgress:
			if (rigidbody2D.velocity.magnitude < 0.8) {
				anim.SetTrigger ("Slamming");
				rigidbody2D.gravityScale = 0;

				originalBasketball.renderer.enabled = false;

				attacksketball.position = transform.position + new Vector3(0.18f, 0.21f, 0.0f);
				basketballVelocity = currentAttackTarget.transform.position - attacksketball.position;
				basketballVelocity *= 2;
				attacksketball.renderer.enabled = true;
				playSound(throwSound);

				attackAnimationState = AttackAnimationState.Complete;
			}
			break;
		case AttackAnimationState.Complete:
			attacksketball.position = attacksketball.position + basketballVelocity * Time.fixedDeltaTime;

			if(attacksketball.position.x > (currentAttackTarget.transform.position.x - 0.1) ) {
				attacksketball.renderer.enabled = false;
				currentAttackTarget.Damage(currentAttack.Power);
				playSound(hitSound);
				currentAnimation = AnimationSequence.ReturningFromSlamming;
				attackAnimationState = AttackAnimationState.NeedsToStart;
			}

			break;
		}
	}
Example #49
0
        /// <summary>
        /// adds an animation to the list.
        /// </summary>
        /// <param name="animation">animation structure</param>
        /// <returns>index of the added animation</returns>
        public int AddAnimation(AnimationSequence animation)
        {
            if (animation == null)
            {
                throw new ArgumentNullException("animation");
            }

             animationList.Add(animation);

            return animationList.IndexOf(animation);
        }
Example #50
0
	private void animSalesPitch() {
		switch(attackAnimationState) {
		case AttackAnimationState.NeedsToStart:
			
			GetComponent<Animator>().SetFloat("Speed", 10);
			
			GetComponent<ConstantVelocity>().enabled = true;
			GetComponent<ConstantVelocity>().velocity =  Vector2.right * 3;
			
			attackAnimationState = AttackAnimationState.InProgress;
			break;
			
		case AttackAnimationState.InProgress:
			if(transform.position.x > currentAttackTarget.transform.position.x - 0.5f) {
				GetComponent<ConstantVelocity>().enabled = false;
				GetComponent<Animator>().SetFloat("Speed", 0);

				attackAnimationState = AttackAnimationState.Complete;
				salesPitchParticles.transform.position = transform.position;
				salesPitchParticles.time = 0;
				salesPitchParticles.Play();
				startTimer();
			}
			break;
		case AttackAnimationState.Complete:
			if (timerIsGreaterThan(1.0f)) {
				currentAnimation = AnimationSequence.JumpBackward;
				attackAnimationState = AttackAnimationState.NeedsToStart;

				currentAttackTarget.PutToSleep (currentAttack.Power);
			}
			
			break;
		}
	}
Example #51
0
	private void animLaserFire() {
		switch(attackAnimationState) {
		case AttackAnimationState.NeedsToStart:
			LaserFire.Play();
			playSound(LaserFireSound);
			attackAnimationState = AttackAnimationState.InProgress;
			
			break;
		case AttackAnimationState.InProgress:
			LaserFire.transform.Rotate (new Vector3(0, 0, 10) * Time.deltaTime);

			if(LaserFire.transform.rotation.eulerAngles.z > 9 &&
			   LaserFire.transform.rotation.eulerAngles.z < 10) {


				LaserFire.Stop();
				LaserFire.Clear();

				LaserFire.transform.localRotation = initialLaserRot;
				currentAnimation = AnimationSequence.None;
				attackAnimationState = AttackAnimationState.Off;

				//EVERYONE DIES HAHAHAHAHAHAH
				targets.ForEach(t => t.Damage(AttackPower));

				AnimationInProgress = false;
			}

			break;
		}
	}
Example #52
0
        private Rectangle SourceRectForAnimFrame(GameTime time)
        {
            if (_currentFrameTime >= _frameTime)
            {
                //check for frame reset
                if (_currentAnimationFrame >= _framesPerSequence[PlayingAnimation] - 1)
                {
                    if (!_loopCurrentAnim)
                    {
                        _loopCurrentAnim = true;
                        PlayingAnimation = _transitionSequence;
                        _frameTime = FrameTime;
                    }
                    _currentAnimationFrame = 0;
                }
                else
                {
                    _currentAnimationFrame++;
                }
                _currentFrameTime = 0;
            }
            else
            {
                _currentFrameTime += (float)time.ElapsedGameTime.TotalSeconds;
            }

            return new Rectangle(_currentAnimationFrame * _frameWidth, _frameHeight * (int)PlayingAnimation, _frameWidth, _frameHeight);
        }
Example #53
0
	private void animFlyTowardsTarget () {
		switch (attackAnimationState) {
		case AttackAnimationState.NeedsToStart:
			initialPosition = transform.position;

			GetComponent<JamesGasBehavior>().EnableFlightMode();

			attackAnimationState = AttackAnimationState.InProgress;

			break;
		case AttackAnimationState.InProgress:

			rigidbody2D.AddForce(new Vector2(0, 400) * Time.fixedDeltaTime);

			
			if(transform.position.y > 0.1f) {
				playSound(GasBlastSound);
				attackAnimationState = AttackAnimationState.Complete;
			}


			break;
		case AttackAnimationState.Complete:

			rigidbody2D.AddForce(currentAttackTarget.transform.position - transform.position
			                     * 250 * Time.fixedDeltaTime);

			if(transform.rotation.eulerAngles.z < 170 && transform.rotation.eulerAngles.z > 163) {
				currentAttackTarget.Damage(currentAttack.Power);


				currentAnimation = AnimationSequence.FlyingBack;
				attackAnimationState = AttackAnimationState.NeedsToStart;
			}


			break;
		}
	}
Example #54
0
    public void SetCharacter(Character c)
    {
        TheCharacter = c;
        NeedRebuild = true;

        Anims = TheCharacter.Anims;
        Anims.SetGameObject(Billboard);

        c.LayersChanged += new GameState.EventCallback(Character_LayersChanged);
    }
Example #55
0
	private void animJumpForward () {
		switch (attackAnimationState) {
		case AttackAnimationState.NeedsToStart:
			Vector2 launchVelocity = new Vector2 (7f, 0f);

			setDragEnabled(false);

			//calculate the needed initial vertical speed to reach the target
			float dist = currentAttackTarget.transform.position.x - transform.position.x - 0.3f;
			float time = dist / launchVelocity.x;
			launchVelocity.y = Mathf.Abs (Physics2D.gravity.y) / 2 * time;

			// cheap hack to hit floating bosses
			if(currentAttackTarget.transform.position.y > transform.position.y + 0.2) {
				launchVelocity.y += 4f;
			}

			rigidbody2D.velocity = launchVelocity;
			attackAnimationState = AttackAnimationState.InProgress;
			GetComponent<Animator> ().SetBool ("IsAttacking", true);
			break;
		case AttackAnimationState.InProgress:
			if (transform.position.x > currentAttackTarget.transform.position.x - 1f) {
				playSound (knifeSlash);
				currentAttackTarget.Damage (currentAttack.Power);
				attackAnimationState = AttackAnimationState.Complete;
			}
			break;
		case AttackAnimationState.Complete:
			if (rigidbody2D.velocity == Vector2.zero) {
				currentAnimation = AnimationSequence.JumpBackward;
				attackAnimationState = AttackAnimationState.NeedsToStart;
			}
			break;
		}
	}
Example #56
0
	private void animReturningFromSlamming () {
		switch (attackAnimationState) {
		case AttackAnimationState.NeedsToStart:
			rigidbody2D.gravityScale = 1;
			GetComponent<BoxCollider2D>().enabled = true;

			attackAnimationState = AttackAnimationState.InProgress;
			
			break;
		case AttackAnimationState.InProgress:

			if(rigidbody2D.velocity.magnitude < 0.01f) {
				anim.SetTrigger("Finished");
				originalBasketball.transform.localPosition = originalBasketballLocalPos;
				originalBasketball.renderer.enabled = true;
				attackAnimationState = AttackAnimationState.Complete;
			}

			break;
		case AttackAnimationState.Complete:
			currentAnimation = AnimationSequence.None;
			attackAnimationState = AttackAnimationState.Off;
			AnimationInProgress = false;
			break;
		}
	}
 /// <summary>
 /// The update num frames.
 /// </summary>
 private void UpdateNumFrames()
 {
     if (this.internalAnimation != null && this.internalAnimation.Animations.Count > 0 && this.internalAnimation.Animations.ContainsKey(this.CurrentAnimation))
     {
         this.currentAnimationSequence = this.internalAnimation.Animations[this.CurrentAnimation];
         this.numFrames = this.currentAnimationSequence.Frames.Count;
     }
 }
Example #58
0
	private void animFlyingBack () {
		switch (attackAnimationState) {
		case AttackAnimationState.NeedsToStart:

			rigidbody2D.AddForce(new Vector2(-400, 100) * Time.deltaTime);

			if(transform.position.x < initialPosition.x + 0.1f) {
				attackAnimationState = AttackAnimationState.InProgress;
			}
			
			break;
		case AttackAnimationState.InProgress:

			GetComponent<JamesGasBehavior>().DisableFlightMode();
			rigidbody2D.velocity = Vector2.zero;

			attackAnimationState = AttackAnimationState.Complete;


			break;
		case AttackAnimationState.Complete:

			if(transform.position.y < initialPosition.y + 0.2) {
				currentAnimation = AnimationSequence.None;
				attackAnimationState = AttackAnimationState.Off;
				AnimationInProgress = false;
				transform.position = new Vector3(initialPosition.x, transform.position.y, transform.position.z);
			}

			break;
		}
	}