예제 #1
0
    public void add(missionToken mt)
    {
        bool uniqueToken = true;

        if (missionTokens != null)
        {
            for (int i = 0; i < missionTokens.Count; i++)
            {
                if (missionTokens[i].id == mt.id)
                {
                    // duplicate token found, so abort the insert
                    uniqueToken = false;
                    break;
                }
            }
        }

        // insert if unique
        if (uniqueToken)
        {
            missionTokens.Add(mt);
        }
    }
예제 #2
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);
    }
예제 #3
0
    void Dispatch()
    {
        for (int i = 0; i < actions.Count; i++)
        {
            popupResponse resp = actions[i];
            switch (resp.action)
            {
            case (popupAction.LoadLevel1):
            {
                if (gm)
                {
                    gm.ChangeState(gameMgr.eGameState.eGS_Level1);
                    //this.gameObject.SetActive(false);//enabled = false;
                }
                break;
            }

            case (popupAction.LoadLevel2):
            {
                if (gm)
                {
                    gm.ChangeState(gameMgr.eGameState.eGS_Level2);
                    //this.gameObject.SetActive(false);//enabled = false;
                }
                break;
            }

            case (popupAction.LoadLevel3):
            {
                if (gm)
                {
                    gm.ChangeState(gameMgr.eGameState.eGS_Level3);
                    //this.gameObject.SetActive(false);//enabled = false;
                }
                break;
            }

            case (popupAction.LoadLevelMainMenu):
            {
                if (gm)
                {
                    gm.ChangeState(gameMgr.eGameState.eGS_MainMenu);
                }
                break;
            }

            case (popupAction.AwardPoints):
            {
                GameObject player = GameObject.Find("Player1");
                if (player)
                {
                    playerData pd = player.GetComponent <playerData>();
                    if (pd)
                    {
                        pd.AddScore(resp.data.id);
                    }
                }
                break;
            }

            case (popupAction.Instantiate):
            {
                if (gm)
                {
                    GameObject go = (GameObject)Instantiate(resp.data.obj);
                    Vector3    p  = go.transform.position;
                    Quaternion q  = go.transform.rotation;
                    go.transform.position      = Vector3.zero;
                    go.transform.rotation      = Quaternion.identity;
                    go.transform.parent        = GameObject.Find(resp.data.name).transform;
                    go.transform.localPosition = p;
                    go.transform.localRotation = q;
                }
                break;
            }

            case (popupAction.EnableObject):
            {
                resp.data.obj.SetActive(true);
                break;
            }

            case (popupAction.DisableObject):
            {
                resp.data.obj.SetActive(false);
                break;
            }

            case (popupAction.HideGameObject):
            {
                resp.data.obj.SetActive(false);
                break;
            }

            case (popupAction.ShowGameObject):
            {
                resp.data.obj.SetActive(true);
                break;
            }

            case (popupAction.QuitApplication):
            {
                Application.Quit();
                break;
            }

            case (popupAction.CameraLookUp):
            {
                Camera.main.gameObject.GetComponent <GameCam>().LookUp();
                break;
            }

            case (popupAction.CameraLookPlayer):
            {
                Camera.main.gameObject.GetComponent <GameCam>().LookPlayer();
                break;
            }

            case (popupAction.SelfDestruct):
            {
                Destroy(this.transform.parent.gameObject);
                break;
            }

            case (popupAction.MakeNpcDance):
            {
                // loop over all QuizNpcHelpers, and find the one with id same as r.data.id
                Object[] QuizNpcHelperObjects = Object.FindObjectsOfType(typeof(QuizNpcHelper));
                foreach (Object item in QuizNpcHelperObjects)
                {
                    if ((item as QuizNpcHelper).GetQuizNpcId() == resp.data.id)
                    {
                        (item as QuizNpcHelper).doSuccess = true;
                    }
                }
                break;
            }

            case (popupAction.ClearInventory):
            {
                GameObject player = GameObject.Find("Player1");
                if (player == null)
                {
                    player = GameObject.Find("Player");
                }
                if (player)
                {
                    inventoryMgr im = player.GetComponent <inventoryMgr>();
                    if (im)
                    {
                        im.inventoryObjects.Clear();
                    }
                }
                break;
            }

            case (popupAction.ResetScore):
            {
                GameObject go = GameObject.Find("setupLevel3");
                if (go)
                {
                    floatData initialScore = go.GetComponent <floatData>();
                    if (initialScore)
                    {
                        GameObject player = GameObject.Find("Player1");
                        if (player == null)
                        {
                            player = GameObject.Find("Player");
                        }
                        if (player)
                        {
                            player.GetComponent <playerData>().score = (int)initialScore._floatData;
                        }
                    }
                }
                break;
            }

            case (popupAction.AddMissionToken):
            {
                GameObject mm = GameObject.Find("Game");
                if (mm)
                {
                    missionMgr mmgr = mm.GetComponent <missionMgr>();
                    if (mmgr)
                    {
                        missionToken mt = this.GetComponent <missionToken>();
                        if (mt != null)
                        {
                            mmgr.add(mt);
                        }
                    }
                }
                break;
            }
            }
        }
    }
예제 #4
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;
        }
    }