public static void LoadCheckPoint()
    {
        CheckPointData c = new CheckPointData();

        LoadCheckpointEvent(typeof(CheckPointManager));

        if (xmlDocument != null)
        {
            c = MemoryManager.Load <CheckPointData>(c, xmlDocument, localStoragePath, checkPointFileName);
        }
        else
        {
            Debug.Log("XML file is null");
        }


        if (c != null)
        {
            for (int i = 0; i < c.positions.Count; i++)
            {
                orderOfStorage[i].transform.position = c.positions[i];
                if (orderOfStorage[i].GetComponent <Enemy>())
                {
                    orderOfStorage[i].GetComponent <Enemy>().ResetAI();
                }
            }
            //orderOfStorage.Clear();
        }

        Debug.Log(checkPointData.types.Count + "inside check point manager");
    }
    public static void RegisterCheckPoint()
    {
        checkPointData = new CheckPointData();

        RegisterCheckPointEvent(typeof(CheckPointManager));

        //Storing the positions of the active characters when the player steps on the checkpoint
        //Change this to effect more information
        Character[] characters = FindObjectsOfType <Character>();
        foreach (Character ch in characters)
        {
            if (ch.gameObject.activeSelf)
            {
                orderOfStorage.Add(ch.gameObject);
                checkPointData.positions.Add(ch.gameObject.transform.position);
            }
        }

        if (xmlDocument != null)
        {
            MemoryManager.Save <CheckPointData>(checkPointData, xmlDocument, localStoragePath, checkPointFileName);
        }
        else
        {
            Debug.Log("XML file is null");
        }
    }
    public CheckPoint CreateCheckPointEntity(CheckPointData data, Vector3 position)
    {
        if (!pointParents.TryGetValue(data.Info.ID, out var parent))
        {
            parent = pointRoot.CreateChild(data.Info.ID);
            pointParents.Add(data.Info.ID, parent);
        }
        CheckPoint checkPoint = parent.gameObject.CreateChild(position.ToString()).AddComponent <CheckPoint>();

        checkPoint.Init(data, position);
        return(checkPoint);
    }
    public CheckPointData CreateCheckPoint(CheckPointInformation info, Action <CheckPointInformation> moveIntoAction, Action <CheckPointInformation> leaveAction = null)
    {
        if (!info || !info.IsValid || info.Scene != ZetanUtility.ActiveScene.name)
        {
            return(null);
        }
        CheckPointData checkPointData = new CheckPointData(info);

        checkPointData.AddListener(moveIntoAction, leaveAction);
        foreach (var position in info.Positions)
        {
            checkPointData.Entities.Add(CreateCheckPointEntity(checkPointData, position));
        }
        return(checkPointData);
    }
Beispiel #5
0
    public void Init(CheckPointData data, Vector3 position)
    {
        Data = data;
        ZetanUtility.SetActive(gameObject, data);
        if (!data)
        {
            return;
        }
        Data               = data;
        gameObject.layer   = Data.Info.Layer;
        transform.position = position;
        if (trigger == null)
        {
            switch (Data.Info.TriggerType)
            {
            case CheckPointTriggerType.Box:
                trigger = gameObject.AddComponent <BoxCollider2D>();
                (trigger as BoxCollider2D).size = Data.Info.Size;
                break;

            case CheckPointTriggerType.Circle:
                trigger = gameObject.AddComponent <CircleCollider2D>();
                (trigger as CircleCollider2D).radius = Data.Info.Radius;
                break;

            case CheckPointTriggerType.Capsule:
                trigger = gameObject.AddComponent <CapsuleCollider2D>();
                (trigger as CapsuleCollider2D).size = new Vector2(Data.Info.Radius * 2, Data.Info.Height);
                break;
            }
            if (trigger)
            {
                (trigger as Collider2D).isTrigger = true;
            }
        }
    }