Пример #1
0
    void insert(interactiveObj iObj)
    {
        // slot into first available spot
        objectInteraction oi = iObj.OnCloseEnough;

        inventoryItem ii = new inventoryItem();

        ii.item           = iObj.gameObject;
        ii.quantity       = 1;
        ii.displayTexture = oi._tex;
        ii.item.SetActive(false);
        inventoryObjects.Add(ii);

        // add token from this object to missionMgr to track, it this obj has a token
        missionToken mt = ii.item.GetComponent <missionToken>();

        if (mt != null)
        {
            _missionMgr.add(mt);
        }

        // if there is a popupInfo, instantiate it on pickup
        Instantiate(ii.item.GetComponent <customGameObject>().popUpInfo, Vector3.zero, Quaternion.identity);
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        RaceStarterObj.SetActive(true);
        if (camScript)
        {
            camScript.height = 0.5f;
        }

        //
        //	Instantiate npcs
        //
        spawnPointsBackup = new List <GameObject>();
        quizPrefabsBackup = new List <GameObject>();
        quizNpcInstances  = new List <GameObject> ();

        // store spawnpoints for later reset
        for (int i = 0; i < spawnPoints.Count; i++)
        {
            spawnPointsBackup.Add(spawnPoints[i]);
        }

        //	store flag prefabs for later reset
        for (int i = 0; i < quizPrefabs.Count; i++)
        {
            quizPrefabsBackup.Add(quizPrefabs[i]);
        }

        //	pick 5 random spawn points
        //	remove from spawn points list
        //	put into spawnpoint list, so we can place random flag instances there
        activeSpawnPoints = new List <GameObject>();
        for (int k = 0; k < kNumFlagMounts; k++)
        {
            int        index          = Random.Range(0, spawnPoints.Count);
            GameObject quizSpawnPoint = spawnPoints[index];
            spawnPoints.RemoveAt(index);
            activeSpawnPoints.Add(quizSpawnPoint);
        }

        missionMgr mm = GameObject.Find("Game").GetComponent <missionMgr>();

        playerData pd = null;

        if (player == null)
        {
            player = GameObject.Find("Player");
            if (player == null)
            {
                player = GameObject.Find("Player1");
            }
        }
        pd = player.GetComponent <playerData>();

        // pick 5 random quizCards
        // remove from flagPrefabs
        // instantiate
        // place at random locator
        //quizInstances = new List<GameObject>();
        for (int k = 0; k < kNumFlagMounts; k++)
        {
            int index = Random.Range(0, quizPrefabs.Count);

            // if we have flagChoices, use them instead of the random index;
            if (pd != null)
            {
                index = pd.flagChoices[k];
            }

            GameObject quizPrefab = quizPrefabs[index];
            quizPrefabs.RemoveAt(index);

            Vector3 quizPos = activeSpawnPoints[k].transform.position;
            quizPos.y += 2.0f;
            GameObject QuizNpcInstance = (GameObject)Instantiate(QuizNpc, quizPos, new Quaternion(0.0f, 0.0f, 0.0f, 1.0f));
            QuizNpcInstance.GetComponent <QuizNpcHelper>().SetPrefabReference(CorrectPopups[k]);
            QuizNpcInstance.SetActive(true);
            QuizNpcInstance.GetComponent <QuizNpcHelper>().SetQuizNpcId(k);
            QuizNpcInstance.transform.parent = GameObject.Find("_level2").transform;

            // attach quizcard to this npc's interaction
            objectInteraction oo = QuizNpc.GetComponent <objectInteraction>();
            if (oo)
            {
                oo.prefab = quizPrefab;
            }

            // add flag instance to mission
            mm.missions[missionId].tokens.Add(CorrectPopups[k].GetComponent <missionToken>());
        }

        // activate mission for the second level
        if (mm)
        {
            mm.missionTokens.Clear();
            mm.missions[missionId].status = mission.missionStatus.MS_Acquired;
        }
    }
Пример #3
0
    // based on the type of interaction component that the interactive object
    // has, the inventoryMgr will handle the add in a specific way
    public void Add(interactiveObj iObj)
    {
        objectInteraction oi = iObj.OnCloseEnough;

        switch (oi.interactionType)
        {
        case (objectInteraction.InteractionType.Unique):
        {
            // slot into first available spot
            insert(iObj);
        }
        break;

        case (objectInteraction.InteractionType.Accumulate):
        {
            bool inserted = false;

            // find object of same type, and increase
            customGameObject cgo = iObj.gameObject.GetComponent <customGameObject>();
            customGameObject.CustomObjectType ot = customGameObject.CustomObjectType.Invalid;
            if (cgo != null)
            {
                ot = cgo.objectType;
            }

            for (int i = 0; i < inventoryObjects.Count; i++)
            {
                //todo
                customGameObject cgoi = inventoryObjects[i].item.GetComponent <customGameObject>();
                customGameObject.CustomObjectType io = customGameObject.CustomObjectType.Invalid;
                if (cgoi != null)
                {
                    io = cgoi.objectType;
                }

                if (ot == io)
                {
                    inventoryObjects[i].quantity++;
                    // add token from this object to missionMgr to track, it this obj has a token
                    missionToken mt = iObj.gameObject.GetComponent <missionToken>();
                    if (mt != null)
                    {
                        _missionMgr.add(mt);
                    }

                    iObj.gameObject.SetActive(false);
                    inserted = true;
                    break;
                }
            }

            //
            //	if we get this far, it means no duplicate found in the inventory, so let's insert it
            //
            if (!inserted)
            {
                insert(iObj);
            }
        }
        break;
        }
    }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     obj = GetComponent <objectInteraction>();
     hintText.SetActive(false);
     StartCoroutine(checkForInteraction());
 }