Beispiel #1
0
    public AnimFrameSpriteComponent GetFrame(BattleStepData data, Vector3 origin)
    {
        var frame = Pool.GetInstance().GetComponent <AnimFrameSpriteComponent>();

        frame.Populate(data, origin);
        return(frame);
    }
Beispiel #2
0
    public static Sprite SpriteForStep(BattleStepData data)
    {
        var spriteName = data.sprite;

        if (spriteName.StartsWith("battle_anim/"))
        {
            spriteName = spriteName.Substring("battle_anim/".Length);
        }
        if (spriteName.EndsWith(".png"))
        {
            spriteName = spriteName.Substring(0, spriteName.IndexOf(".png"));
        }
        return(Resources.Load <Sprite>(BattleAnimDirectory + spriteName));
    }
Beispiel #3
0
    public List <AnimFrameSpriteComponent> ShowBattleAnimationFrame(BattleStepData data, List <Unit> targets)
    {
        var groupIndices = new HashSet <int>();

        foreach (var target in targets)
        {
            groupIndices.Add(Battle.Enemy.GroupIndexForUnit(target));
        }

        var frames = new List <AnimFrameSpriteComponent>();

        foreach (var index in groupIndices)
        {
            var targetCell = battlerList.GetCell(index);
            var frame      = framePool.GetFrame(data, dollArea.OffsetForEnemy(Battle.Enemy.Groups[index]));
            frames.Add(frame);
        }
        return(frames);
    }
Beispiel #4
0
    public void Populate(BattleStepData data, Vector3 origin)
    {
        renderer.sprite = SpriteForStep(data);

        var transform = renderer.transform;

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

        var transform2 = renderer.transform;

        if (data.rotation == RotationType.ROTATION_ENABLED)
        {
            transform.localEulerAngles = new Vector3(0, 0, Random.Range(0, 4) * 90);
        }
        else
        {
            transform.localEulerAngles = new Vector3(0, 0, 0);
        }
        ApplyOffset(new Vector3(data.x, data.y, 0));
    }
Beispiel #5
0
    protected IEnumerator RenderStepRoutine(BattleStepData data, BattleView view, List <Unit> targets, Vector2 offset, bool autohide = true)
    {
        float elapsed = 0.0f;
        List <AnimFrameSpriteComponent> frames = null;

        while (elapsed < data.start + data.duration)
        {
            elapsed += Time.deltaTime;
            if (elapsed >= data.start && frames == null)
            {
                frames = view.ShowBattleAnimationFrame(data, targets);
                foreach (var frame in frames)
                {
                    frame.ApplyOffset(offset);
                }
            }
            yield return(null);
        }
        if (frames != null && autohide)
        {
            view.HideBattleAnimationFrames(frames);
        }
    }