Example #1
0
    private IEnumerator AwaitAnimationFinish(BattleVFX f)
    {
        yield return(new WaitForSeconds(f.DurationSeconds));

        BattleLog.Write($"Finished {f.EffectName} in {f.DurationSeconds} seconds.");
        Message.Publish(new Finished <BattleEffectAnimationRequested>());
    }
    public static BattleVFXAction Create(BattleVFX _vfxObj, string vfxName, GameCharacter target)
    {
        BattleVFXAction action = new BattleVFXAction();

        action.Init(_vfxObj, vfxName);
        action.targetCharacter = target;

        return(action);
    }
Example #3
0
    private void PlayEffect(BattleVFX f, Vector3 target)
    {
        var o = Instantiate(f.gameObject, target, Quaternion.identity, gameObject.transform);

        o.SetActive(true);
        if (f.WaitForCompletion)
        {
            StartCoroutine(AwaitAnimationFinish(f));
        }
        else
        {
            Message.Publish(new Finished <BattleEffectAnimationRequested>());
        }
    }
    public static BattleVFXAction CreateWithPrefab(GameObject vfxPrefab, string vfxName, GameCharacter target)
    {
        Debug.Log("CreateWithPrefab: target.pos=" + target.transform.position);
        Vector3 spawnPos = target.transform.position;

        spawnPos.z = kVFXZPosition;             // upp

        GameObject newObj = GameObject.Instantiate(vfxPrefab, spawnPos, Quaternion.identity);

        newObj.name = "BattleVFX_" + vfxName;
        newObj.transform.position = spawnPos;

        BattleVFX battleComp = newObj.GetComponent <BattleVFX>();


        return(Create(battleComp, vfxName, target));
    }
    public void Init(BattleVFX _vfxObj, string vfxName)
    {
        mIsDone = false;
        Debug.Log("BattleVFXAction: Init called");
        mVFXObject = _vfxObj;
        mVFXName   = vfxName;


        mVFXObject.SetAnimeEventCallback((string eventName) => {
            Debug.Log("BattleVFXAction: animeEvent. name=" + eventName);
            if (eventName == "hit")
            {
                HitTarget();
            }
        });

        mVFXObject.SetAnimeEndCallback(() => {
            MarkAsDone();
        });
    }
Example #6
0
 private void Awake()
 {
     Instance = this;
 }