예제 #1
0
    public Transform AddUnit(EnumCharacterCamp t, string name, Sprite[] stay, Sprite[] move, Vector2Int tilePos)
    {
        Transform  root = GetUnitTransformRoot(t);
        GameObject unit = new GameObject(name);
        GameObject hp   = new GameObject("hp");

        unit.transform.SetParent(root, false);
        var hp_sp = hp.AddComponent <SpriteRenderer>();

        Utils.GameUtil.DelayFuncEndOfFrame(() => hp_sp.size = new Vector2(HP_WIDTH, HP_HEIGHT));
        hp_sp.drawMode     = SpriteDrawMode.Sliced;
        hp_sp.sortingOrder = 1;
        hp_sp.sprite       = BarSprite;
        hp_sp.color        = ConstTable.CAMP_COLOR(t, 1.0f);
        hp.transform.SetParent(unit.transform, false);
        hp.transform.localPosition = new Vector3(-0.50f, 0.08f, 0);
        hp.transform.localScale    = Vector3.one;
        hp.SetActive(false);
        var sr = unit.AddComponent <SpriteRenderer>();

        sr.sharedMaterial = UnitMaterials[(int)t];
        MultiSpriteAnimator anim = unit.AddComponent <MultiSpriteAnimator>();

        anim.SetAnimatorContent(MultiSpriteAnimator.EAnimateType.Stay, stay);
        anim.SetAnimatorContent(MultiSpriteAnimator.EAnimateType.Move, move);
        anim.SetActiveAnimator(MultiSpriteAnimator.EAnimateType.Stay);
        PositionMath.SetUnitLocalPosition(unit.transform, tilePos);
        keyValue.Add(tilePos, anim);
        return(unit.transform);
    }
예제 #2
0
 public void Show(EnumCharacterCamp camp, int Turn, UnityAction onHide)
 {
     base.Show();
     RegisterHideEvent(onHide);
     text.text  = camp.ToString() + "  Turn " + Turn;
     text.color = ConstTable.CAMP_COLOR(camp);
     AnimatePos(true, MoveOut);
 }