|
|
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- [CreateAssetMenu(menuName = "Major Project/Pick Ups/Replace Block")]
- [System.Serializable]
- public class Replace : LogicBlock
- {
- public GameObject blockPrefab;
-
- public override Block GetEndBlock(Block startBlock, Transform transform, LayerMask layerMask)
- {
- return startBlock;
- }
-
- protected override IEnumerator BlockLogic(Character player, float animationTime, bool useBlockDirection = false)
- {
- Block oldBlock = player.CurrentBlock;
- Transform parent = oldBlock.transform.parent;
- Vector3 position = oldBlock.position;
-
- Block newBlock = Instantiate(blockPrefab, parent).GetComponent<Block>();
- newBlock.transform.position = position;
-
- yield return player.StartCoroutine(player.MoveToBlock(newBlock, Character.Animation.None, 0.0f));
- Destroy(oldBlock);
- }
-
- public override void CopyToken(BlockToken token)
- {
- base.CopyToken(token);
- blockPrefab= Resources.Load<GameObject>(((ReplaceToken)token).prefabName);
- }
-
- public override BlockToken ToToken(BlockToken token = null)
- {
- if (token == null)
- token = new ReplaceToken(this);
-
- Debug.Log(base.ToToken(token).GetType().Name);
- ReplaceToken retVal = (ReplaceToken)base.ToToken(token);
- retVal.prefabName = blockPrefab.name;
-
- return retVal;
- }
-
- }
-
- [System.Serializable]
- public class ReplaceToken : BlockToken
- {
- public string prefabName;
-
- public ReplaceToken(LogicBlock block) : base(block) { }
- }
-
-
|