Example #1
0
    void UpdateDirection()
    {
        lastDirection = transform.position - lastPosition;
        lastPosition  = transform.position;

        float angle = Mathf.Atan2(lastDirection.x, lastDirection.z);

        if (angle < 0)
        {
            angle += Mathf.PI * 2;
        }
        int index = Mathf.RoundToInt(angle / (Mathf.PI * 2) * 8);

        if (index == 8)
        {
            index = 0;
        }
        //Debug.Log("Angle : " + angle + " | Index = " + index);

        var animName = PerAngleAnimationMap[index];
        var lastName = sprite.CurrentClip == null ? "" : sprite.CurrentClip.name;

        if (lastName != animName)
        {
            sprite.Play(animName);

            if (animName == "walk_rs" || lastName == "walk_rs")
            {
                //Debug.Log("name = " + animName);
                sprite.FlipX();
            }
        }
    }
Example #2
0
 public void SetFace(bool isRigth)
 {
     if (isRigth && ani_sprite.scale.x < 0)
     {
         ani_sprite.FlipX();
     }
     else if (!isRigth && ani_sprite.scale.x > 0)
     {
         ani_sprite.FlipX();
     }
 }
Example #3
0
    void Start()
    {
        //Debug.Log("EnemyPlaneController:Start() - direction = " + direction);

        objCamera = (tk2dCamera)GameObject.FindWithTag("MainCamera").GetComponent <tk2dCamera>();
        objSprite = GetComponent <tk2dAnimatedSprite>();

        trans         = transform;
        health        = maxHealth;
        trailTrans    = transform.root.Find("TrailPosition");
        launcherTrans = transform.root.Find("LauncherPosition");

        parTrail = (GameObject)Instantiate(parVaporTrail, trailTrans.position, Quaternion.identity);

        if (direction == PlaneDirection.RIGHT)
        {
            objSprite.FlipX();
        }
    }
Example #4
0
    void UpdateDirection()
    {
        lastDirection = transform.position - lastPosition;
        lastPosition  = transform.position;

        float angle = Mathf.Atan2(lastDirection.x, lastDirection.z);

        if (angle < 0)
        {
            angle += Mathf.PI * 2;
        }
        int index = Mathf.RoundToInt(angle / (Mathf.PI * 2) * 8);

        if (index == 8)
        {
            index = 0;
        }
        //Debug.Log("Angle : " + angle + " | Index = " + index);

        var animName = PerAngleAnimationMap[index];
        var lastName = sprite.CurrentClip == null ? " " : sprite.CurrentClip.name;

        if (lastName != animName && (lastAnimCheck == null || lastAnimCheck != animName))
        {
            sprite.Play(animName);

            if (Scattering)
            {
                sprite.ClipFps = 19;
            }

            if ((animName.StartsWith("r") && !lastName.StartsWith("r")) || (lastName.StartsWith("r") && !animName.StartsWith("r")))
            {
                sprite.FlipX();
            }

            lastAnimCheck        = lastName;
            sinceLastAnimChanged = 0;
        }
    }
    void Start()
    {
        //Debug.Log("EnemyPlaneController:Start() - direction = " + direction);

        objCamera = (tk2dCamera) GameObject.FindWithTag("MainCamera").GetComponent<tk2dCamera>();
        objSprite = GetComponent<tk2dAnimatedSprite>();

        trans = transform;
        health = maxHealth;
        trailTrans = transform.root.Find("TrailPosition");
        launcherTrans = transform.root.Find("LauncherPosition");

        parTrail = (GameObject)Instantiate(parVaporTrail, trailTrans.position, Quaternion.identity);

        if (direction == PlaneDirection.RIGHT)
        {
            objSprite.FlipX();
        }
    }