Esempio n. 1
0
    private void Awake()
    {
        //Load NPC schedule event list into a sorted set
        npcScheduleEventSet = new SortedSet <NPCScheduleEvent>(new NPCScheduleEventSort());

        foreach (NPCScheduleEvent npcScheduleEvent in so_NPCScheduleEventList.npcScheduleEventList)
        {
            npcScheduleEventSet.Add(npcScheduleEvent);
        }

        //Get NPC Path Component
        npcPath = GetComponent <NPCPath>();
    }
Esempio n. 2
0
    private void Awake()
    {
        rigidBody2D    = GetComponent <Rigidbody2D>();
        boxCollider2D  = GetComponent <BoxCollider2D>();
        animator       = GetComponent <Animator>();
        npcPath        = GetComponent <NPCPath>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        animatorOverrideController         = new AnimatorOverrideController(animator.runtimeAnimatorController);
        animator.runtimeAnimatorController = animatorOverrideController;

        // Initialise target world position, target grid position & target scene to current
        npcTargetScene         = npcCurrentScene;
        npcTargetGridPosition  = npcCurrentGridPosition;
        npcTargetWorldPosition = transform.position;
    }
Esempio n. 3
0
    // Build our sorted NPCScheduleEvent set by time and priority from the so_NPCScheduleEventList containing all of the schedules we've added for this NPC
    private void Awake()
    {
        // Load the NPC schedule event list into a sorted set with our new NPCScheduleEventSort() custom sorter.
        // Putting that custom sorter in the SortetSet constructor will make use of the IComparer interface and the Compare method which sorts
        // all of the NPCScheduleEvent's in our SO by the time that they occur, and tie-broken by priorities if the times match
        npcScheduleEventSet = new SortedSet <NPCScheduleEvent>(new NPCScheduleEventSort());

        // Loop through all of the NPCScheduleEvent's in our SO's npcScheduleEventList, adding each one to our sortedSet. This will automatically sort
        // them how we specified in NPCScheduleEventSort.cs as we add them
        foreach (NPCScheduleEvent npcScheduleEvent in so_NPCScheduleEventList.npcScheduleEventList)
        {
            npcScheduleEventSet.Add(npcScheduleEvent);
        }

        // Get the NPC Path component for path building
        npcPath = GetComponent <NPCPath>();
    }
Esempio n. 4
0
    // Populate all of the objects (rigidBocy, boxCollider, animator, spriteRenderer, animatorOverrideController, NPC target grid/world position/scene, and NPC path
    private void Awake()
    {
        // Populate the below objects
        rigidBody2D    = GetComponent <Rigidbody2D>();
        boxCollider2D  = GetComponent <BoxCollider2D>();
        animator       = GetComponent <Animator>();
        npcPath        = GetComponent <NPCPath>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        // Set the animation override controller to swap out the blank animations for new ones
        animatorOverrideController         = new AnimatorOverrideController(animator.runtimeAnimatorController);
        animator.runtimeAnimatorController = animatorOverrideController;

        // Initialize the target grid position, world position, and scene to their current values, to be updated later
        npcTargetScene         = npcCurrentScene;
        npcTargetGridPosition  = npcCurrentGridPosition;
        npcTargetWorldPosition = transform.position;
    }
Esempio n. 5
0
 void Start()
 {
     anim = GetComponentInChildren <Animator>();
     path = GetComponent <NPCPath>();
     dia  = FindObjectOfType <Dialogue>();
 }