Example #1
0
 void Awake()
 {
     _transform = GetComponent<Transform> ();
     _translation = new Vector3 (speed, 0, 0);
     _anim = GetComponentInChildren<Animator2D> ();
     _gameManager = GameObject.Find("GameManager").GetComponent<HorseGameManager>();
 }
 public override void ChangeDirection(Direction newDirection)
 {
     //IL_0010: Unknown result type (might be due to invalid IL or missing references)
     //IL_0015: Unknown result type (might be due to invalid IL or missing references)
     //IL_001a: Unknown result type (might be due to invalid IL or missing references)
     //IL_0038: Unknown result type (might be due to invalid IL or missing references)
     //IL_0078: Unknown result type (might be due to invalid IL or missing references)
     //IL_00b6: Unknown result type (might be due to invalid IL or missing references)
     //IL_00cc: Unknown result type (might be due to invalid IL or missing references)
     if (newDirection != m_direction)
     {
         Vector2    position   = Vector2Int.op_Implicit(m_cellObject.coords);
         Animator2D animator2D = m_animator2D;
         CharacterAnimationParameters animationParameters    = m_animationParameters;
         CharacterAnimationInfo       characterAnimationInfo = (m_animationParameters.secondDirection == Direction.None) ? new CharacterAnimationInfo(position, animationParameters.animationName, animationParameters.timelineKey, animationParameters.loops, newDirection, m_mapRotation) : new CharacterAnimationInfo(previousDirection: DirectionExtensions.Rotate(angle: m_direction.DirectionAngleTo(newDirection), value: animationParameters.firstDirection), position: position, animationName: animationParameters.animationName, timelineKey: animationParameters.timelineKey, loops: animationParameters.loops, direction: newDirection, mapRotation: m_mapRotation);
         animator2D.get_transform().set_localRotation(characterAnimationInfo.flipX ? Quaternion.Euler(0f, -135f, 0f) : Quaternion.Euler(0f, 45f, 0f));
         direction = newDirection;
         string animationName = characterAnimationInfo.animationName;
         int    currentFrame  = animator2D.get_currentFrame();
         m_animationCallback.ChangeAnimationName(animationName);
         animator2D.SetAnimation(animationName, characterAnimationInfo.loops, false, true);
         animator2D.set_currentFrame(currentFrame);
         m_animationParameters = characterAnimationInfo.parameters;
     }
 }
    void Start()
    {
        m_Animator2D   = GetComponent <Animator2D>();
        m_Controller2D = GetComponent <Controller2D_SL>();

        m_v3DefaultScale = transform.localScale;

        m_fGravity      = -(2.0f * m_fJumpHeight) / (m_fTimeToJumpApex * m_fTimeToJumpApex);
        m_fJumpVelocity = Mathf.Abs(m_fGravity) * m_fTimeToJumpApex;
        print("Gravity: " + m_fGravity + "|| JumpVel: " + m_fJumpVelocity);

        //Give the character states access this script

        m_StationaryState = new StationaryCharacterState();
        m_RunState        = new RunCharacterState();
        m_JumpUpState     = new JumpUpCharacterState();
        m_FallDownState   = new FallDownCharacterState();

        m_StationaryState.PlayerControllerScript = this;
        m_RunState.PlayerControllerScript        = this;
        m_JumpUpState.PlayerControllerScript     = this;
        m_FallDownState.PlayerControllerScript   = this;

        EnterCharacterState(PlayerCharacterState.ECharacterState.Stationary);
        m_eWeaponState                 = PlayerCharacterState.ECharacterWeaponState.BlasterInactive;
        m_tmWeaponStateTimer           = new System.Timers.Timer(333);
        m_tmWeaponStateTimer.AutoReset = false;
        m_tmWeaponStateTimer.Elapsed  +=
            (object sender, System.Timers.ElapsedEventArgs e) =>
        {
            m_bWeaponStateDirty = true;
            m_eWeaponState      = PlayerCharacterState.ECharacterWeaponState.BlasterInactive;
        };
    }
Example #4
0
        protected IEnumerator MoveToDoActionRoutine(Vector2Int[] movementCells, Direction actionDirection)
        {
            int movementCellsCount = movementCells.Length;

            if (movementCellsCount != 0)
            {
                CellObject cellObject = m_cellObject;
                IMap       parentMap  = cellObject.parentMap;
                Vector2Int val        = movementCells[0];
                if (cellObject.coords != val)
                {
                    Log.Warning($"Was not on the start cell of a new movement sequence: {cellObject.coords} instead of {val} ({this.get_gameObject().get_name()}).", 341, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\FightCharacterObject.cs");
                    CellObject cellObject2 = parentMap.GetCellObject(val.get_x(), val.get_y());
                    SetCellObject(cellObject2);
                }
                Animator2D animator = m_animator2D;
                foreach (CharacterAnimationInfo item in CharacterFightMovementSequencer.ComputeMovementToAction(movementCells, actionDirection, m_mapRotation))
                {
                    CharacterAnimationInfo sequenceItem = item;
                    SetPosition(parentMap, sequenceItem.position);
                    StartFightAnimation(sequenceItem);
                    while (!CharacterObjectUtility.HasAnimationEnded(animator, sequenceItem))
                    {
                        yield return(null);
                    }
                }
                Vector2Int val2 = movementCells[movementCellsCount - 1];
                SetPosition(parentMap, Vector2Int.op_Implicit(val2));
                if (m_cellObject.TryGetIsoObject(out IObjectWithActivation _))
                {
                    direction = actionDirection;
                    PlayIdleAnimation();
                }
            }
        }
Example #5
0
        public IEnumerator PlayRangedActionAnimation(Direction directionToAttack)
        {
            if (!m_characterData.hasRangedAttackAnimations)
            {
                yield return(PlayActionAnimation(directionToAttack, waitForAnimationEndOnMissingLabel: true));

                yield break;
            }
            CharacterAnimationInfo rangedAttackAnimationInfo = new CharacterAnimationInfo(Vector2Int.op_Implicit(m_cellObject.coords), "rangedattack", "rangedattack", loops: false, directionToAttack, m_mapRotation);

            StartFightAnimation(rangedAttackAnimationInfo, (Action)((CharacterObject)this).PlayIdleAnimation, (Action)null, restart: true, async: false);
            Animator2D animator = m_animator2D;
            int        num      = default(int);

            if (animator.CurrentAnimationHasLabel("shot", ref num))
            {
                while (!CharacterObjectUtility.HasAnimationReachedLabel(animator, rangedAttackAnimationInfo, "shot"))
                {
                    yield return(null);
                }
            }
            else
            {
                Log.Warning(animator.GetDefinition().get_name() + " is missing the 'shot' label in the animation named '" + rangedAttackAnimationInfo.animationName + "'.", 512, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\FightCharacterObject.cs");
            }
        }
        public static Animator2D CreateAnimatedObjectEffectInstance([NotNull] AnimatedObjectDefinition definition, string animationName, [NotNull] Transform parent)
        {
            //IL_0038: Unknown result type (might be due to invalid IL or missing references)
            //IL_003d: Unknown result type (might be due to invalid IL or missing references)
            if (null == definition)
            {
                throw new NullReferenceException();
            }
            if (null == s_instance)
            {
                Log.Error("CreateAnimatedObjectEffectInstance called while the factory is not ready.", 367, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightObjectFactory.cs");
                return(null);
            }
            Animator2D component = s_animatedObjectEffectPool.Instantiate(parent.get_position(), Quaternion.get_identity(), parent).GetComponent <Animator2D>();

            if (!string.IsNullOrEmpty(animationName))
            {
                component.SetAnimation(animationName, false, false, true);
            }
            else
            {
                component.set_animationLoops(false);
            }
            component.SetDefinition(definition, null, (Graphic[])null);
            return(component);
        }
Example #7
0
        public void MoveTo(int x, int y)
        {
            lock (_runningLock)
            {
                if (!_running)
                {
                    var animator = new Animator2D(FPSLimiterKnownValues.LimitSixty);
                    var currPos  = _playerDrawable.GetPosition();

                    animator.Paths = CreatePath(currPos.X, currPos.Y, x, y);

                    _lastPathEnd = animator.Paths.Last().End;
                    animator.Play(_frameCallbackInvoker, _endCallback);
                    _running = true;
                }
                else
                {
                    var path = CreatePath((int)_lastPathEnd.X, (int)_lastPathEnd.Y, x, y);
                    _lastPathEnd = path.Last().End;

                    foreach (var path2D in path)
                    {
                        _waitingPaths.Add(path2D);
                    }
                }
            }
        }
Example #8
0
 // Use this for initialization
 void Start()
 {
     superAttackGraphic = transform.FindChild("FireLine").gameObject;
     superAttackGraphic.SetActive(false);
     gameManager = GameObject.Find("GameManager").GetComponent <FlightGameManager>();
     animator    = GetComponent <Animator2D>().Child("Plane");
 }
Example #9
0
 void Start()
 {
     walking = false;
     map = GameObject.Find ("MapWorld").GetComponent<MapWorldScript>();
     NodeChoice nodeScript = map.startPosition.GetComponent<NodeChoice>();
     nodeScript.SetGirlOn();
     animator = GetComponent<Animator2D>();
 }
 public static bool HasAnimationEnded([NotNull] Animator2D animator2D, CharacterAnimationInfo animationInfo)
 {
     if (!animator2D.get_reachedEndOfAnimation())
     {
         return(!animationInfo.animationName.Equals(animator2D.get_animationName()));
     }
     return(true);
 }
 public static bool HasAnimationReachedLabel([NotNull] Animator2D animator2D, CharacterAnimationInfo animationInfo, [NotNull] string label)
 {
     if (!animator2D.get_reachedEndOfAnimation() && !label.Equals(animator2D.get_currentLabel(), StringComparison.OrdinalIgnoreCase))
     {
         return(!animationInfo.animationName.Equals(animator2D.get_animationName()));
     }
     return(true);
 }
Example #12
0
    public Landmine()
    {
        m_texture   = Resources.Load <Texture2D>("Textures/LandmineSign");
        m_explosion = Resources.Load <Texture2D>("Textures/BoomSheet");

        m_animator = new Animator2D(m_explosion, textureSize, textureSize, 5, 100);

        Active = true;
    }
        private unsafe void OnAnimatorInitialized(object sender, Animator2DInitialisedEventArgs e)
        {
            //IL_000e: Unknown result type (might be due to invalid IL or missing references)
            //IL_0018: Expected O, but got Unknown
            Animator2D animator2D = m_animator2D;

            animator2D.remove_Initialised(new Animator2DInitialisedEventHandler((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/));
            animator2D.set_paused(false);
            PlayIdleAnimation();
        }
Example #14
0
 private unsafe void OnEnable()
 {
     //IL_0035: Unknown result type (might be due to invalid IL or missing references)
     //IL_003f: Expected O, but got Unknown
     m_animator2D = CreateAnimatorComponent();
     if (m_animatedObjectDefinition != null && m_animatedObjectDefinition != null)
     {
         m_animator2D.add_Initialised(new Animator2DInitialisedEventHandler((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/));
         m_animator2D.SetDefinition(m_animatedObjectDefinition, null, (Graphic[])null);
     }
 }
 public static void DestroyAnimatedObjectEffectInstance([NotNull] Animator2D instance)
 {
     if (null != s_instance)
     {
         s_animatedObjectEffectPool.Release(instance.get_gameObject());
     }
     else
     {
         Object.Destroy(instance.get_gameObject());
     }
 }
        public IEnumerator PlayHitAnimation()
        {
            CharacterAnimationInfo hitAnimationInfo = new CharacterAnimationInfo(Vector2Int.op_Implicit(m_cellObject.coords), "hit", "hit", loops: false, direction, m_mapRotation);

            StartFightAnimation(hitAnimationInfo, (Action)((CharacterObject)this).PlayIdleAnimation, (Action)null, restart: true, async: false);
            Animator2D animator = m_animator2D;

            while (!CharacterObjectUtility.HasAnimationReachedLabel(animator, hitAnimationInfo, "die"))
            {
                yield return(null);
            }
        }
        public IEnumerator PlayLethalHitAnimation()
        {
            Animator2D animator            = m_animator2D;
            string     animationNameBackup = animator.get_animationName();

            yield return(null);

            if (string.Equals(animator.get_animationName(), animationNameBackup))
            {
                CharacterAnimationInfo animationInfo = new CharacterAnimationInfo(Vector2Int.op_Implicit(m_cellObject.coords), "hit", "hit", loops: false, direction, m_mapRotation);
                StartFightAnimation(animationInfo, (Action)((CharacterObject)this).PlayIdleAnimation, (Action)null, restart: true, async: false);
            }
        }
Example #18
0
    // Use this for initialization
    void Awake()
    {
        Vector2 pos = GlobalFlags.GetPlayerPosition();

        transform.position = new Vector3(pos.x, pos.y, transform.position.z);

        P = (EntityData)entityData;
        //if (P.GetNumDragons() == 0)
        //    P.AddDragon("Basic Drakling", -1);

        lookDirection = new Vector2Int(0, 0);
        state         = PlayerState.Exploring;
        rigidbody     = GetComponent <Rigidbody2D>();
        animator      = GetComponent <Animator2D>();
    }
Example #19
0
        public override IEnumerator DestroyWhenFinished(Component instance)
        {
            Animator2D animator2D = instance;

            do
            {
                yield return(null);

                if (null == animator2D)
                {
                    yield break;
                }
            }while (!animator2D.get_reachedEndOfAnimation());
            FightObjectFactory.DestroyAnimatedObjectEffectInstance(animator2D);
        }
        public IEnumerator PlayActivationAnimation()
        {
            Animator2D animator = m_animator2D;

            if (!m_characterData.hasActivationAnimation)
            {
                Log.Warning(animator.GetDefinition().get_name() + " does not have an activation animation.", 204, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\ObjectMechanismObject.cs");
                yield break;
            }
            CharacterAnimationInfo activationAnimationInfo = new CharacterAnimationInfo(Vector2Int.op_Implicit(m_cellObject.coords), "attack", "attack", loops: false, direction, m_mapRotation);

            StartFightAnimation(activationAnimationInfo, (Action)((CharacterObject)this).PlayIdleAnimation, (Action)null, restart: true, async: false);
            while (!CharacterObjectUtility.HasAnimationReachedLabel(animator, activationAnimationInfo, "shot"))
            {
                yield return(null);
            }
            TriggerActivationEffect();
        }
    void Start()
    {
        Animator2D animator = null;

        if (!animator_on_child)
        {
            animator = gameObject.GetComponent <Animator2D>();
        }
        else
        {
            animator = gameObject.GetComponentInChildren <Animator2D>();
        }

        if (animator != null)
        {
            animator.PlayAnimation(animation_to_play, speed, loop);
        }
    }
Example #22
0
 private void OnEnable()
 {
     m_animator2D = this.GetComponent <Animator2D>();
     if (null == m_animator2D)
     {
         this.set_enabled(false);
         return;
     }
     if (null == s_currentCamera)
     {
         s_currentCamera = Camera.get_main();
         if (null == s_currentCamera)
         {
             return;
         }
     }
     CameraHandler.AddMapRotationListener(OnMapRotationChanged);
 }
Example #23
0
        private Animator2D CreateAnimatorComponent()
        {
            //IL_0005: Unknown result type (might be due to invalid IL or missing references)
            //IL_000a: Unknown result type (might be due to invalid IL or missing references)
            //IL_001c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0031: Unknown result type (might be due to invalid IL or missing references)
            //IL_003b: Unknown result type (might be due to invalid IL or missing references)
            //IL_005d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0067: Unknown result type (might be due to invalid IL or missing references)
            GameObject val = new GameObject("Animator2D Hidden");

            val.get_transform().SetParent(this.get_transform(), false);
            val.get_transform().set_localScale(new Vector3(0.01f, 0.01f, 0.01f));
            val.get_transform().set_localRotation(Quaternion.Euler(0f, (float)(m_invertAxis ? 225 : 45), 0f));
            Animator2D result = val.AddComponent <Animator2D>();

            val.AddComponent <CharacterMeshShaderProperties>();
            return(result);
        }
Example #24
0
        private void EndCallback()
        {
            lock (_runningLock)
            {
                if (_waitingPaths.Any())
                {
                    var animator = new Animator2D(FPSLimiterKnownValues.LimitSixty)
                    {
                        Paths = _waitingPaths.ToArray()
                    };
                    _waitingPaths.Clear();

                    animator.Play(_frameCallbackInvoker, _endCallback);
                }
                else
                {
                    _running = false;
                }
            }
        }
        protected unsafe override IEnumerator SetAnimatorDefinition()
        {
            Animator2D animator = m_animator2D;

            animator.add_Initialised(new Animator2DInitialisedEventHandler((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/));
            AnimatedBoardCharacterData animatedBoardCharacterData = (AnimatedBoardCharacterData)GetAnimatedCharacterData();

            animator.SetDefinition(animatedBoardCharacterData.animatedObjectDefinition, null, (Graphic[])null);
            while (true)
            {
                Animator2DInitialisationState initialisationState = animator.GetInitialisationState();
                if ((int)initialisationState == 1 || ((int)initialisationState == 2 && animator.get_isActiveAndEnabled()))
                {
                    yield return(null);

                    continue;
                }
                break;
            }
        }
        protected override IEnumerator PlayDeathAnimation()
        {
            CharacterAnimationInfo deathAnimationInfo = new CharacterAnimationInfo(Vector2Int.op_Implicit(m_cellObject.coords), "hit", "death", loops: false, direction, m_mapRotation);

            StartFightAnimation(deathAnimationInfo, null, null, restart: false);
            Animator2D animator = m_animator2D;
            int        num      = default(int);

            if (animator.CurrentAnimationHasLabel("die", ref num))
            {
                while (!CharacterObjectUtility.HasAnimationReachedLabel(animator, deathAnimationInfo, "die"))
                {
                    yield return(null);
                }
                animator.set_paused(true);
            }
            else
            {
                Log.Warning(animator.GetDefinition().get_name() + " is missing the 'die' label in the animation named '" + deathAnimationInfo.animationName + "'.", 244, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\BoardCharacterObject.cs");
            }
        }
        protected override void OnMapRotationChanged(DirectionAngle previousMapRotation, DirectionAngle newMapRotation)
        {
            //IL_0010: Unknown result type (might be due to invalid IL or missing references)
            //IL_0016: Invalid comparison between Unknown and I4
            //IL_0021: Unknown result type (might be due to invalid IL or missing references)
            //IL_0026: Unknown result type (might be due to invalid IL or missing references)
            //IL_002b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0043: Unknown result type (might be due to invalid IL or missing references)
            //IL_007e: Unknown result type (might be due to invalid IL or missing references)
            //IL_00bc: Unknown result type (might be due to invalid IL or missing references)
            //IL_00d2: Unknown result type (might be due to invalid IL or missing references)
            base.OnMapRotationChanged(previousMapRotation, newMapRotation);
            Animator2D animator2D = m_animator2D;

            if ((int)animator2D.GetInitialisationState() == 3)
            {
                Vector2 position = Vector2Int.op_Implicit(m_cellObject.coords);
                CharacterAnimationParameters animationParameters = m_animationParameters;
                CharacterAnimationInfo       characterAnimationInfo;
                if (m_animationParameters.secondDirection == Direction.None)
                {
                    characterAnimationInfo = new CharacterAnimationInfo(position, animationParameters.animationName, animationParameters.timelineKey, animationParameters.loops, direction, newMapRotation);
                }
                else
                {
                    DirectionAngle angle             = newMapRotation.Substract(previousMapRotation);
                    Direction      previousDirection = animationParameters.firstDirection.Rotate(angle);
                    characterAnimationInfo = new CharacterAnimationInfo(position, animationParameters.animationName, animationParameters.timelineKey, animationParameters.loops, previousDirection, direction, newMapRotation);
                }
                animator2D.get_transform().set_localRotation(characterAnimationInfo.flipX ? Quaternion.Euler(0f, -135f, 0f) : Quaternion.Euler(0f, 45f, 0f));
                string animationName = characterAnimationInfo.animationName;
                int    currentFrame  = animator2D.get_currentFrame();
                m_animationCallback.ChangeAnimationName(animationName);
                animator2D.SetAnimation(animationName, characterAnimationInfo.loops, false, true);
                animator2D.set_currentFrame(currentFrame);
                m_animationParameters = characterAnimationInfo.parameters;
            }
        }
Example #28
0
 // Use this for initialization
 void Start()
 {
     _anim = GetComponent<Animator2D>();
     _anim.PlayAnimation("idle");
 }
Example #29
0
        private IEnumerator MoveToRoutine(List <Vector3> path, Vector3 endLookAt)
        {
            //IL_0015: Unknown result type (might be due to invalid IL or missing references)
            //IL_0016: Unknown result type (might be due to invalid IL or missing references)
            int movementCellsCount = path.Count;

            if (movementCellsCount <= 1)
            {
                yield break;
            }
            Animator2D animator = m_animator2D;

            AnimatedFightCharacterData.IdleToRunTransitionMode idleToRunTransitionMode = m_characterData.idleToRunTransitionMode;
            Vector3 startCell = path[0];

            if (!m_isRunning && idleToRunTransitionMode.HasFlag(AnimatedFightCharacterData.IdleToRunTransitionMode.IdleToRun))
            {
                Direction direction = (movementCellsCount >= 2) ? GetDirection(startCell, path[1]) : this.direction;
                CharacterAnimationInfo transitionAnimationInfo2 = new CharacterAnimationInfo(new Vector2(startCell.x, startCell.z), "idle_run", "idle-to-run", loops: false, direction, m_mapRotation);
                if (!transitionAnimationInfo2.animationName.Equals(m_animator2D.get_animationName()))
                {
                    StartAnimation(transitionAnimationInfo2);
                }
                while (!CharacterObjectUtility.HasAnimationEnded(animator, transitionAnimationInfo2))
                {
                    yield return(null);
                }
            }
            m_isRunning = true;
            Vector3 previousCoords = startCell;
            int     num;

            for (int i = 1; i < movementCellsCount; i = num)
            {
                Vector3   coords     = path[i];
                Vector3   direction2 = coords - previousCoords;
                float     magnitude  = direction2.get_magnitude();
                Direction direction3 = GetDirection(direction2);
                CharacterAnimationInfo animationInfo = new CharacterAnimationInfo(new Vector2(coords.x, coords.z), "run", "run", loops: true, direction3, m_mapRotation);
                StartAnimation(animationInfo, null, null, restart: false);
                float cellTraversalDuration = magnitude * 5f * (1f / m_speedFactor) / (float)animator.get_frameRate();
                float animationTime         = 0f;
                do
                {
                    Vector3 val = Vector3.Lerp(previousCoords, coords, animationTime / cellTraversalDuration);
                    this.get_transform().set_position(val + Vector3.get_up() * m_heightOffest);
                    yield return(null);

                    animationTime += Time.get_deltaTime();
                }while (animationTime < cellTraversalDuration);
                this.get_transform().set_position(coords + Vector3.get_up() * m_heightOffest);
                previousCoords = coords;
                num            = i + 1;
            }
            m_isRunning = false;
            if (idleToRunTransitionMode.HasFlag(AnimatedFightCharacterData.IdleToRunTransitionMode.RunToIdle))
            {
                CharacterAnimationInfo transitionAnimationInfo2 = new CharacterAnimationInfo(new Vector2(previousCoords.x, previousCoords.z), "run_idle", "run-to-idle", loops: false, this.direction, m_mapRotation);
                StartAnimation(transitionAnimationInfo2);
                while (!CharacterObjectUtility.HasAnimationEnded(animator, transitionAnimationInfo2))
                {
                    yield return(null);
                }
            }
            if (endLookAt != Vector3.get_zero())
            {
                m_direction = GetDirection(endLookAt);
            }
            PlayIdleAnimation();
            m_movementCoroutine = null;
        }
Example #30
0
 void Start()
 {
     _anim = GetComponentInChildren<Animator2D>();
     _controller = GetComponent<CharacterController>();
     _manager = GameObject.Find("GameManager").GetComponent<MazeGameManager>();
 }
Example #31
0
    public override void OnInspectorGUI()
    {
        Animator2D myScript = (Animator2D)target;

        if (!Application.isPlaying)
        {
            if (GUILayout.Button("Add Animation"))
            {
                myScript.AddAnimation();
            }
        }

        List <Animation2D> animations = myScript.GetAnimations();

        for (int i = 0; i < animations.Count; ++i)
        {
            Animation2D curr_animation = animations[i];

            string curr_name = curr_animation.GetName();

            string text = curr_name + ": [" + i + "]";

            curr_animation.editor_foolded = EditorGUILayout.Foldout(curr_animation.editor_foolded, text);

            if (curr_animation.editor_foolded)
            {
                if (!Application.isPlaying)
                {
                    string new_name = GUILayout.TextField(curr_name);

                    curr_animation.SetName(new_name);
                }

                List <Sprite> curr_sprites = curr_animation.GetSprites();

                if (!Application.isPlaying)
                {
                    int new_sprites_count = EditorGUILayout.IntField("Frames:", curr_sprites.Count);

                    if (new_sprites_count != curr_sprites.Count)
                    {
                        curr_animation.SetSprites(new_sprites_count);
                    }
                }
                else
                {
                    GUILayout.Label("Frames: " + curr_sprites.Count);
                }

                curr_sprites = curr_animation.GetSprites();

                for (int y = 0; y < curr_sprites.Count; ++y)
                {
                    Sprite curr_sprite = curr_sprites[y];

                    string sprite_name = "Sprite [" + y + "]";

                    if (curr_sprite != null)
                    {
                        sprite_name = curr_sprite.name;
                    }

                    if (!Application.isPlaying)
                    {
                        Sprite new_sprite = (Sprite)EditorGUILayout.ObjectField(sprite_name, curr_sprite, typeof(Sprite), false);

                        curr_animation.AddSprite(y, new_sprite);
                    }
                    else
                    {
                        GUILayout.Label(sprite_name);
                    }
                }
            }
        }

        DrawDefaultInspector();
    }
Example #32
0
	void Awake() {
		gameManager = GameObject.Find ("GameManager").GetComponent<CandyWizardGameManager>();
		candy= GameObject.Find ("Candy").GetComponent<Candy>();
		animator = GetComponentInChildren<Animator2D>();
	}
Example #33
0
 // Use this for initialization
 void Start()
 {
     _anim = GetComponent<Animator2D> ();
     _anim.PlayAnimation ("left");
     _pos = transform.position;
 }
Example #34
0
 void Awake()
 {
     gameManager = GameObject.Find("GameManager").GetComponent <CandyWizardGameManager>();
     candy       = GameObject.Find("Candy").GetComponent <Candy>();
     animator    = GetComponentInChildren <Animator2D>();
 }
Example #35
0
        protected unsafe IEnumerator MoveToRoutine(Vector2Int[] movementCells)
        {
            int movementCellsCount = movementCells.Length;

            if (movementCellsCount == 0)
            {
                yield break;
            }
            CellObject cellObj   = m_cellObject;
            IMap       parentMap = cellObj.parentMap;
            Animator2D animator  = m_animator2D;

            AnimatedFightCharacterData.IdleToRunTransitionMode idleToRunTransitionMode = m_characterData.idleToRunTransitionMode;
            Vector2Int startCell = movementCells[0];
            Vector2Int endCell   = movementCells[movementCellsCount - 1];

            if (cellObj.coords != startCell)
            {
                Log.Warning($"Was not on the start cell of a new movement sequence: {cellObj.coords} instead of {startCell} ({this.get_gameObject().get_name()}).", 232, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\FightCharacterObject.cs");
                CellObject cellObject = parentMap.GetCellObject(startCell.get_x(), startCell.get_y());
                SetCellObject(cellObject);
            }
            if (idleToRunTransitionMode.HasFlag(AnimatedFightCharacterData.IdleToRunTransitionMode.IdleToRun))
            {
                Direction direction = (movementCellsCount >= 2) ? startCell.GetDirectionTo(movementCells[1]) : this.direction;
                CharacterAnimationInfo transitionAnimationInfo2 = new CharacterAnimationInfo(Vector2Int.op_Implicit(startCell), "idle_run", "idle-to-run", loops: false, direction, m_mapRotation);
                StartFightAnimation(transitionAnimationInfo2);
                while (!CharacterObjectUtility.HasAnimationEnded(animator, transitionAnimationInfo2))
                {
                    yield return(null);
                }
            }
            Vector2Int val = startCell;
            float      cellTraversalDuration = ((movementCellsCount <= 2) ? 5f : 4f) / (float)animator.get_frameRate();

            foreach (CharacterAnimationInfo item in CharacterFightMovementSequencer.ComputeMovement(movementCells, m_mapRotation))
            {
                Vector2Int cellCoords   = item.position.RoundToInt();
                CellObject movementCell = parentMap.GetCellObject(cellCoords.get_x(), cellCoords.get_y());
                bool       goingUp      = ((IntPtr)(void *)movementCell.get_transform().get_position()).y >= ((IntPtr)(void *)cellObj.get_transform().get_position()).y;
                Vector2    innerPositionStart;
                Vector2    innerPositionEnd;
                if (goingUp)
                {
                    SetCellObject(movementCell);
                    innerPositionStart = Vector2Int.op_Implicit(val - cellCoords);
                    innerPositionEnd   = Vector2.get_zero();
                }
                else
                {
                    innerPositionStart = Vector2.get_zero();
                    innerPositionEnd   = Vector2Int.op_Implicit(cellCoords - val);
                }
                StartFightAnimation(item, null, null, restart: false);
                float animationTime = 0f;
                do
                {
                    Vector2 cellObjectInnerPosition = Vector2.Lerp(innerPositionStart, innerPositionEnd, animationTime / cellTraversalDuration);
                    SetCellObjectInnerPosition(cellObjectInnerPosition);
                    yield return(null);

                    animationTime += Time.get_deltaTime();
                }while (animationTime < cellTraversalDuration);
                SetCellObjectInnerPosition(innerPositionEnd);
                if (!goingUp)
                {
                    SetCellObject(movementCell);
                }
                val     = cellCoords;
                cellObj = movementCell;
                if (cellCoords != endCell && movementCell.TryGetIsoObject(out IObjectWithActivation isoObject))
                {
                    isoObject.PlayDetectionAnimation();
                }
                cellCoords = default(Vector2Int);
            }
            if (idleToRunTransitionMode.HasFlag(AnimatedFightCharacterData.IdleToRunTransitionMode.RunToIdle))
            {
                CharacterAnimationInfo transitionAnimationInfo2 = new CharacterAnimationInfo(Vector2Int.op_Implicit(val), "run_idle", "run-to-idle", loops: false, this.direction, m_mapRotation);
                StartFightAnimation(transitionAnimationInfo2);
                while (!CharacterObjectUtility.HasAnimationEnded(animator, transitionAnimationInfo2))
                {
                    yield return(null);
                }
            }
        }