Game Development Reference
In-Depth Information
3. This script also caches a copy of monument so that it can interface with the
monumentMgr class defined previously.
4. In the update loop, this script will take an object from the inventory of index
objectIndex , remove it from the inventory, and set it to active so that it will
render again as shown in the following code:
GameObject go =
inventoryMgr.inventoryObjects[objectIndex].item;
go.SetActive (true);
5. If there is a cached monument object in the scene, it will then call at-
tachObjToMountPoint and attach this inventoryObject to the flag
mount using the following code:
_monument.GetComponent<MonumentMgr>().attachObjToMountPoint
(go, objectIndex);
Congratulations! You now have written the system that will be used to move the flags
from the inventory to the monument at the end of the mission. This script will be at-
tached to a Prefab that we will instance once the second mission is complete.
Creating the MissionMgrHelper script
This script searches through the mission manager and finds a mission by name.
Once it finds it, it updates the visible and enabled flags on the mission. This is used
to activate the second half of level one's objectives once the first half of the object-
ives are completed. This script can be created as shown in the following code:
using UnityEngine;
using System.Collections;
public class missionMgrHelper : MonoBehaviour
{
public string MissionName;
public bool setActivated;
public bool setVisible;
Search WWH ::




Custom Search