Beispiel #1
0
    // Use this for initialization
    IEnumerator Start()
    {
        layerC          = new CalcLayer(transform.eulerAngles.z);
        ssp             = new SpriteSpeed();
        ssp.sleep       = 0.7f;
        ssp.index_jump  = 1;
        SpriteContainer = (GameObject)Resources.Load("Prefabs/SpriteH");
        hm     = transform.parent.GetComponent <CharacterControl>();
        MaxRow = CharacterAnimations.GetAnimationLenght(action_s);
        int i = 1;

        layers = Layer0.Length + 1;
        foreach (item_type s in Layer0)
        {
            if (s == item_type.shilds)
            {
                AddEmptyOrRemoveSprite(s, (i + 2));
                hair_l = i;
                i     += 2;
            }
            else
            {
                AddEmptyOrRemoveSprite(s, i);
            }
            i++;
        }


        foreach (Body_part part in  ITEMS.main.GetRandomPerson(SpriteGender.male))
        {
            AddBodyPart(part);
        }

        weapon_anim = AnimLoad(ITEMS.main.walk_anim, hair_l + 3);

        enabled = false;
        yield return(new WaitForSeconds(Time.deltaTime));

        enabled = true;
        StartCoroutine(ChangeImage());
    }
Beispiel #2
0
    IEnumerator ChangeImage()
    {
        while (true)
        {
            index_jump = AnimSpeed();
            yield return(new WaitForSeconds(1 / (index_jump.sleep * BasicAnimationSpeed)));

            ImageIndex += index_jump.index_jump;
            if (ImageIndex >= MaxRow)
            {
                if (hm.IsDead)
                {
                    if (action != CharacterAnimation.Hurt)
                    {
                        ImageIndex = 0;
                        action_s   = CharacterAnimation.Hurt;
                        MaxRow     = CharacterAnimations.GetAnimationLenght(action_s);
                        UpdateAnyway();
                        continue;
                    }
                    else
                    {
                        ImageIndex--;
                        UpdateAnyway();
                        continue;
                    }
                }

                if (action_s == CharacterAnimation.Shoot)
                {
                    ImageIndex = 4 + (ImageIndex % (MaxRow - 4));
                }
                else if (action_s == CharacterAnimation.idle)
                {
                    ImageIndex = 0;
                }
                else
                {
                    ImageIndex = ImageIndex - MaxRow;
                }
                if (action_s == CharacterAnimation.SpellCast)
                {
                    hm.Attacks.Add(skill_type.spell);
                    new_anim = CharacterAnimation.idle;
                }
                if (new_anim != action_s)
                {
                    ImageIndex = 0;
                    action_s   = new_anim;
                    MaxRow     = CharacterAnimations.GetAnimationLenght(action_s);
                    if (action_s != CharacterAnimation.Hurt)
                    {
                        new_anim = CharacterAnimation.idle;
                    }
                }
                if (action_s == CharacterAnimation.Slash || action_s == CharacterAnimation.Thrust)
                {
                    if (hm.weapon == weapon_type.wand)
                    {
                        hm.Attacks.Add(skill_type.spell);
                    }
                    else
                    {
                        hm.Attacks.Add(skill_type.attack);
                    }
                }
                else if (action_s == CharacterAnimation.Shoot)
                {
                    hm.Attacks.Add(skill_type.arrow_shot);
                }
            }


            if (action_s != CharacterAnimation.idle)
            {
                SpriteColumn = ((int)action_s * 4) + (int)direction;
                if (SpriteColumn >= CharacterAnimations.MaxColumn - 1)
                {
                    SpriteColumn = CharacterAnimations.MaxColumn - 1;
                }
            }
            else
            {
                SpriteColumn = ((int)CharacterAnimation.Walk * 4) + (int)direction;
            }

            UpdateAnyway();
            //(call change image)
        }
    }