示例#1
0
    public void SpawnInhaler()
    {
        GameObject spawnPrefab         = Resources.Load(DataLoaderShooterArmy.GetData("Mober_10").PrefabName) as GameObject;
        int        randomPositionIndex = Random.Range(0, 3);

        GameObjectUtils.AddChild(posList[randomPositionIndex], spawnPrefab, isPreserveLayer: true);
    }
示例#2
0
    // Note that this function assumes it is okay to be spawning triggers.
    private DegradTrigger PlaceTrigger(DegradData degradData)
    {
        string  triggerID = degradData.TriggerID;
        int     partition = degradData.Partition;
        Vector3 position  = degradData.Position;

        ImmutableDataTrigger triggerData = DataLoaderTriggers.GetTriggerData(triggerID);

        //instantiate all the triggers saved in DataManager
        Transform  parent        = PartitionManager.Instance.GetInteractableParent(partition);
        GameObject triggerPrefab = (GameObject)Resources.Load(triggerData.PrefabName);
        GameObject trigger       = GameObjectUtils.AddChild(parent.gameObject, triggerPrefab);

        trigger.transform.localPosition = position;

        //keep a local reference
        currentSpawnTriggers.Add(trigger);

        // set the trigger's ID
        DegradTrigger scriptTrigger = trigger.GetComponent <DegradTrigger>();

        scriptTrigger.ID = triggerID;

        return(scriptTrigger);
    }
        public void StartTutorial()
        {
            TutorialManager.AnalyticsTutorialStart(id);

            if (setCompleteCondition == SetCompleteCondition.SetCompleteOnStart)               // Set this tutorial completed when trigger?
            {
#if UNITY_EDITOR
                if (!TutorialSettings.current.debugMode)                 // Don't set completed if in debug mode in Editor
#endif
                isCompleted = true;
            }

            if (prefab != null)
            {
                tutorialGO      = GameObjectUtils.AddChild(null, prefab);
                tutorialGO.name = prefab.name;
                TutorialStep.ResetStepNumber();
            }

            // Do pre-load things for each tutorial
            if (validator != null)
            {
                validator.OnTutorialStart();
            }
        }
示例#4
0
    private bool isClickable = true;            // When the card is showing/animating lock the click, internal check of card state

    public void Initialize(ImmutableDataMemoryTrigger triggerData, bool isSprite)
    {
        triggerName = triggerData.Name;

        tweeningCoverParent = coverSprite.transform.parent.gameObject;

        // Set components on start
        if (isSprite)
        {
            triggerSprite.sprite  = SpriteCacheManager.GetSprite(triggerData.SpriteName);
            triggerSprite.name    = triggerData.SpriteName;
            tweeningContentParent = triggerSprite.transform.parent.parent.gameObject;           // Get grandfather
            triggerLabelLocalize.transform.parent.gameObject.SetActive(false);                  // Disable the unused half
        }
        else
        {
            triggerLabelLocalize.key = triggerData.DisplayKey;
            triggerLabelLocalize.Localize();
            tweeningContentParent = triggerLabelLocalize.transform.parent.gameObject;           // Get grandfather
            triggerSprite.transform.parent.parent.gameObject.SetActive(false);                  // Disable the unused half
        }

        // Hide the original card content until its clicked
        tweeningContentParent.SetActive(false);

        // Assign the respective trigger type particle
        GameObject particlePrefab = Resources.Load(triggerData.TypeParticlePrefab) as GameObject;

        triggerTypeParticle = GameObjectUtils.AddChild(gameObject, particlePrefab).GetComponent <ParticleSystem>();
    }
示例#5
0
    public void OnBuyAnimation(Item itemData, GameObject sprite)
    {
        Vector3 origin      = new Vector3(sprite.transform.position.x, sprite.transform.position.y, 0f);
        Vector3 endPosition = origin;

        // depending on what type of item the user bought, the animation has the item going to different places
        switch (itemData.Type)
        {
        case ItemType.Decorations:
            endPosition = DecoInventoryUIManager.Instance.itemFlyToTransform.position;
            break;

        case ItemType.Accessories:
            Debug.LogError("Not implemented yet!");
            break;

        default:                    // Everything else
            endPosition = InventoryUIManager.Instance.itemFlyToTransform.position;
            break;
        }

        GameObject animationSprite = GameObjectUtils.AddChild(sprite.transform.parent.gameObject, boughtItemTweenPrefab);

        animationSprite.transform.position   = origin;
        animationSprite.transform.localScale = new Vector3(90, 90, 1);
        animationSprite.GetComponentInChildren <Image>().sprite = SpriteCacheManager.GetItemSprite(secretItem.ID);
        animationSprite.name = secretItem.ID;

        LeanTween.move(animationSprite, endPosition, 0.666f)
        .setEase(LeanTweenType.easeOutQuad)
        .setOnComplete(OnBuyAnimationDone)
        .setOnCompleteParam(animationSprite);
    }
示例#6
0
    public void SpawnPowerUp()
    {
        int        randPowerUp         = Random.Range(5, 8);
        GameObject spawnPrefab         = Resources.Load(DataLoaderShooterArmy.GetData("Mober_" + randPowerUp.ToString()).PrefabName) as GameObject;
        int        randomPositionIndex = Random.Range(0, 3);

        GameObjectUtils.AddChild(posList[randomPositionIndex], spawnPrefab, isPreserveLayer: true);
    }
示例#7
0
    /// <summary>
    /// Creates the lock. and put it in the parent object
    /// </summary>
    /// <param name="parentObject">Parent object.</param>
    /// <param name="level">Level.</param>
    /// <param name="prefabName">Prefab name.</param>
    public static GameObject CreateLock(GameObject parentObject, int level, string prefabName = "LevelLockUI")
    {
        GameObject goPrefab   = Resources.Load(prefabName) as GameObject;
        GameObject lockObject = GameObjectUtils.AddChild(parentObject, goPrefab);

        lockObject.GetComponent <LevelLockObject>().Init(level);
        return(lockObject);
    }
示例#8
0
    IEnumerator Fire()
    {
        yield return(new WaitForSeconds(0.5f));

        bulletAux = GameObjectUtils.AddChild(null, bulletPrefab);
        bulletAux.transform.position = transform.position;
        LeanTween.moveX(bulletAux, 100.0f, 4.0f);
        StartCoroutine("Move");
    }
示例#9
0
        private bool LoadScreenObject(string name, string parentName)
        {
            m_root = GameSystemManager.Get <ResourceManager>().CheckOutAndInstantiate(name, true);
            GameSystemManager.Get <ResourceManager>().CheckIn(name);

            GameObject uiRoot = GameObject.Find(parentName);

            GameObjectUtils.AddChild(uiRoot, m_root);

            return(m_root != null);
        }
示例#10
0
 // shoots a smog ball at the player
 void ShootSmogBall()
 {
     if (!isDead)
     {
         AudioManager.Instance.PlayClip("shooterEnemySpit");
         bulletAux = GameObjectUtils.AddChild(null, bulletPrefab);
         bulletAux.transform.position = transform.position;
         LeanTween.move(bulletAux, player.transform.position, 2.0f);
         StartCoroutine(WaitASecond());
     }
 }
示例#11
0
    //---------------------------------------------------
    // CreateMission()
    // Given a mission type, this function will add
    // entries to the Wellapad for the mission; the mission
    // reward, and tasks.
    //---------------------------------------------------
    private void CreateMission(string missionType)
    {
        // find the available tasks for the mission and add them
        MutableDataWellapadTask task = WellapadMissionController.Instance.GetTask(missionType);

        GameObject goTask = GameObjectUtils.AddChild(goGrid, prefabTask);

        SetNameForGrid(goTask);

        // init this task UI with the task itself
        goTask.GetComponent <WellapadTaskUI>().Init(task);
    }
示例#12
0
 public void SpawnTutorialSet(int stage)
 {
     for (int i = 1; i < AssemblyLineItem.SPRITE_COUNT; i++)
     {
         GameObject item = GameObjectUtils.AddChild(itemParent, itemPrefab);
         item.transform.position = GetPosition(index: i, indexOffset: -1);            //StartPosition.position + (i - 1) * new Vector3(distanceBetween, 0);
         AssemblyLineItem newItemScript = item.GetComponent <AssemblyLineItem>();
         newItemScript.Init(i - 1, stage, i);
         itemQueue.Enqueue(newItemScript);
         newItemScript.CompareVisible(visibleCount, false);
     }
 }
示例#13
0
    public GameObject SpawnTriggersTutorial(int num)
    {
        GameObject triggerPrefab = (GameObject)Resources.Load("NinjaTrigger" + num.ToString());
        Vector3    triggerLocation;

        switch (num)
        {
        case 1:
            triggerLocation = new Vector3(-4.5f, -2.7f, 0);
            break;

        case 2:
            triggerLocation = new Vector3(-3.3f, -1.4f, 0);
            break;

        case 3:
            triggerLocation = new Vector3(-1.8f, 0.25f, 0);
            break;

        case 4:
            triggerLocation = new Vector3(0.05f, 1.3f, 0);
            break;

        case 5:
            triggerLocation = new Vector3(2f, 2f, 0);
            break;

        case 6:
            triggerLocation = new Vector3(4f, 2.4f, 0);
            break;

        default:
            triggerLocation = new Vector3(0, 2.8f, 0);
            break;
        }

        //instantiate trigger
        GameObject triggerObject = GameObjectUtils.AddChild(spawnParent, triggerPrefab);

        triggerObject.transform.position         = triggerLocation;
        triggerObject.transform.localEulerAngles = triggerPrefab.transform.localEulerAngles;

        Rigidbody triggerObjectRigidbody = triggerObject.GetComponent <Rigidbody>();

        triggerObjectRigidbody.useGravity  = false;
        triggerObjectRigidbody.constraints = RigidbodyConstraints.None;
        triggerObjectRigidbody.constraints = RigidbodyConstraints.FreezePositionX |
                                             RigidbodyConstraints.FreezePositionY |
                                             RigidbodyConstraints.FreezeRotationX |
                                             RigidbodyConstraints.FreezeRotationY;

        return(triggerObject);
    }
示例#14
0
 // shoots a smog ball at the player
 void ShootSmogBall()
 {
     if (!isDead)
     {
         AudioManager.Instance.PlayClip("shooterEnemySpit");
         animator.SetBool("Spit", true);
         animator.SetBool("IsSpitMode", false);
         bulletAux = GameObjectUtils.AddChild(null, bulletPrefab);
         bulletAux.transform.position = transform.position;
         LeanTween.moveX(bulletAux, player.transform.position.x, 2.0f);
         StartCoroutine(WaitASecond());
     }
 }
示例#15
0
    // Event callback from the crystal animation CrystalPop
    public void OnCrystalPopDone()
    {
        InventoryUIManager.Instance.ShowPanel(true);

        AudioManager.Instance.PlayClip("fireGemGet");
        getGemParticle.Play();

        // Spawn a prefab that the user can click on and obtain
        GameObjectUtils.AddChild(shardParent, clickableFireCrystalPrefab);

        currentPercentage         = 0;
        spriteFireFill.fillAmount = 0;
        FireCrystalManager.Instance.ResetShards();
    }
示例#16
0
    //Spawns all enemies in the list waiting 1 sec inbetween
    IEnumerator SpawnEnemies()
    {
        yield return(new WaitForSeconds(1.0f));

        if (ShooterGameEnemyController.Instance.enemiesInWave > 0)
        {
            if (!ShooterGameManager.Instance.IsPaused && !ShooterGameManager.Instance.isGameOver)
            {
                int randomPositionIndex = Random.Range(0, 3);

                //they are spawned in more of a weighted list fashion
                //so while one of the first waves has only one hard enemy in it it can spawn more than one
                int randomSpawnIndex = Random.Range(0, spawningList.Count);
                while (spawningList[randomSpawnIndex].Type == "PowerUp")
                {
                    randomSpawnIndex = Random.Range(0, spawningList.Count);
                }
                if (spawningList[randomSpawnIndex].Id != "Mober_4")
                {
                    GameObject spawnPrefab = Resources.Load(spawningList[randomSpawnIndex].PrefabName) as GameObject;
                    GameObjectUtils.AddChild(posList[randomPositionIndex], spawnPrefab, isPreserveLayer: true);
                }
                else
                {
                    randomPositionIndex = Random.Range(3, 5);
                    GameObject spawnPrefab = Resources.Load("ShooterEnemySeeker") as GameObject;
                    GameObject go          = GameObjectUtils.AddChild(posList[randomPositionIndex], spawnPrefab, isPreserveLayer: true);
                    if (randomPositionIndex == 3)
                    {
                        go.transform.Rotate(new Vector3(0, 0, -45));
                        go.GetComponent <ShooterEnemySeeker>().InitBottom();
                    }
                    else
                    {
                        go.transform.Rotate(new Vector3(0, 0, 45));
                        go.GetComponent <ShooterEnemySeeker>().InitTop();
                    }
                }
                StartCoroutine("SpawnEnemies");
            }
            else
            {
                StartCoroutine("WaitASec");
            }
        }
        else
        {
            StartCoroutine("RunWave");
        }
    }
示例#17
0
    public void ShiftAndAddNewItem()
    {
        MoveUpLine();
        // Add new item
        GameObject item         = GameObjectUtils.AddChild(itemParent, itemPrefab);
        int        newItemIndex = itemQueue.Count;

        item.transform.position = GetPosition(index: newItemIndex);        //StartPosition.position + newItemIndex * new Vector3(distanceBetween, 0);
        AssemblyLineItem newItemScript = item.GetComponent <AssemblyLineItem>();

        newItemScript.Init(newItemIndex);
        itemQueue.Enqueue(newItemScript);
        newItemScript.CompareVisible(visibleCount, true);
    }
示例#18
0
    void Update()
    {
        if (isActive)
        {
            if (Time.time > timeBegin + generatedValue)
            {
                timeBegin      = Time.time;
                generatedValue = Random.Range(minInterval, maxInterval);

                // Do the action here
                GameObject emittedObject = GameObjectUtils.AddChild(gameObject, particleObject);
                ExtendedAction(emittedObject);
            }
        }
    }
示例#19
0
    public void SpawnBoss()
    {
        int rand = Random.Range(0, 2);

        if (rand == 0)
        {
            GameObject spawnPrefab = Resources.Load("ShooterEnemyBoss") as GameObject;
            GameObjectUtils.AddChild(posList[0], spawnPrefab, isPreserveLayer: true);
        }
        else
        {
            GameObject spawnPrefab = Resources.Load("ShooterEnemyBossWaller") as GameObject;
            GameObjectUtils.AddChild(posList[0], spawnPrefab, isPreserveLayer: true);
        }
    }
示例#20
0
    public void PopulateQueue(bool compare = false, int count = -1, int indexOffset = 0)
    {
        UpdateVisibleCount();
        int toSpawn = (count == -1) ? startingCount + 1 : count;

        for (int i = 0; i < toSpawn; i++)
        {
            GameObject item = GameObjectUtils.AddChild(itemParent, itemPrefab);
            item.transform.position = GetPosition(index: i, indexOffset: indexOffset);
            AssemblyLineItem itemScript = item.GetComponent <AssemblyLineItem>();
            itemScript.Init((i + indexOffset));
            itemQueue.Enqueue(itemScript);
            itemScript.CompareVisible(visibleCount, compare);
        }
    }
示例#21
0
    // Called when item bought, creates a sprite for the item and move it to correct inventory
    public void OnBuyAnimation(StoreItemController storeItemScript)
    {
        Vector3 origin      = storeItemScript.GetSpritePosition();
        Vector3 endPosition = InventoryUIManager.Instance.itemFlyToTransform.position;         // TODO change this

        GameObject animationSprite = GameObjectUtils.AddChild(storeSubPanel, boughtItemTweenPrefab);

        animationSprite.GetComponentInChildren <Image>().sprite = SpriteCacheManager.GetItemSprite(storeItemScript.ItemData.ID);
        animationSprite.transform.position = origin;
        animationSprite.name = storeItemScript.ItemData.ID;

        LeanTween.move(animationSprite, endPosition, 0.666f)
        .setEase(LeanTweenType.easeOutQuad)
        .setOnComplete(OnBuyAnimationDone)
        .setOnCompleteParam(animationSprite);
    }
示例#22
0
    public void ShowCategory(AccessoryTypes type)
    {
        baseTween.Hide();
        gridTween.Show();
        int itemCount = 0;

        // Reset accessory list
        accessoryEntryList = new List <AccessoryStoreItemController>();

        // Populate the entries with loaded data
        List <Item> accessoryList = ItemManager.Instance.AccessoryList;

        foreach (AccessoryItem accessoryData in accessoryList)
        {
            if (accessoryData.AccessoryType == type)
            {
                // Change the title of the category
                switch (accessoryData.AccessoryType)
                {
                case AccessoryTypes.Hat:
                    categoryBanner.key = "ACCESSORIES_TYPE_HAT";
                    break;

                case AccessoryTypes.Glasses:
                    categoryBanner.key = "ACCESSORIES_TYPE_GLASSES";
                    break;

                default:
                    Debug.LogError("Invalid accessory type");
                    break;
                }
                categoryBanner.Localize();                    // Force relocalize

                GameObject accessoryEntry = GameObjectUtils.AddChild(gridParent.gameObject, accessoryEntryPrefab);
                AccessoryStoreItemController entryController = accessoryEntry.GetComponent <AccessoryStoreItemController>();
                entryController.Init(accessoryData);
                accessoryEntryList.Add(entryController);
                itemCount++;
            }
        }

        // Adjust the grid height based on the height of the cell and spacing
        float gridHeight = itemCount * (gridParent.cellSize.y + gridParent.spacing.y);

        gridParent.GetComponent <RectTransform>().sizeDelta = new Vector2(gridParent.cellSize.x, gridHeight);
    }
示例#23
0
    //---------------------------------------------------
    // Override with force specified.
    //---------------------------------------------------
    protected void SpawnObject(string strObjectResource, float fX, Vector3 vForce)
    {
        // spawn the object at the proper location
        GameObject prefab = Resources.Load(strObjectResource) as GameObject;
        Vector3    vPos   = Camera.main.ViewportToWorldPoint(new Vector3(fX, SPAWN_Y, SPAWN_Z));
        GameObject go     = GameObjectUtils.AddChild(NinjaGameManager.Instance.spawnParent, prefab);

        go.transform.position         = new Vector3(vPos.x, vPos.y, 0f);
        go.transform.localEulerAngles = prefab.transform.localEulerAngles;

        // add force to the object
        go.GetComponent <Rigidbody>().AddForce(vForce);

        // add some torque to the object as well
        float fTorqueRange = 15f;
        float fTorqueX     = UnityEngine.Random.Range(-fTorqueRange, fTorqueRange);
        float fTorqueY     = UnityEngine.Random.Range(-fTorqueRange, fTorqueRange);
        float fTorqueZ     = UnityEngine.Random.Range(-fTorqueRange, fTorqueRange);

        go.GetComponent <Rigidbody>().AddTorque(new Vector3(fTorqueX, fTorqueY, fTorqueZ));
    }
示例#24
0
    /// <summary>
    /// Starts the flying shards. This will also call fill fire sprite on first tween finish
    /// </summary>
    /// <param name="numberOfShards">Number of shards.</param>
    private IEnumerator StartFlyingShards(int numberOfShards, float delay)
    {
        if (IsOpen)
        {
            // Wait before starting
            yield return(new WaitForSeconds(delay));

            // 100 shards is too much... cap at 15
            float numberOfShardsToShow = numberOfShards > 15 ? 15f : numberOfShards;
            float delayBetweenShards   = totalTimeTween / numberOfShardsToShow;

            for (float i = 0; i < numberOfShardsToShow; i++)
            {
                GameObject shardObject = GameObjectUtils.AddChild(shardParent, shardSpritePrefab);
                // Place the shard object on a random point on a circle around center
                shardObject.transform.localPosition =
                    GameObjectUtils.GetRandomPointOnCircumference(Vector3.zero, UnityEngine.Random.Range(300f, 400f));
                FireShardController shardController = shardObject.GetComponent <FireShardController>();

                float pitchCount = 1f + (i / 8.0f);

                Vector3 endPoint = GameObjectUtils.GetRandomPointOnCircumference(Vector3.zero, UnityEngine.Random.Range(0, 40f));

                if (i == 0)
                {
                    // Move the shard into the center and call start filling sprite, first tween
                    shardController.StartMoving(endPoint, 0.8f, pitchCount, isFirstSprite: true);
                }
                else
                {
                    // Move the shard into the center
                    shardController.StartMoving(endPoint, 0.8f, pitchCount);
                }
                yield return(new WaitForSeconds(delayBetweenShards));
            }
        }
    }
示例#25
0
    private void CreateMiniPet(string miniPetId)
    {
        GameObject goMiniPet = null;

        // Unlock in data manager
        DataManager.Instance.GameData.MiniPets.UnlockMiniPet(miniPetId);
        DataManager.Instance.GameData.MiniPetLocations.UnlockMiniPet(miniPetId);
        ImmutableDataMiniPet data   = DataLoaderMiniPet.GetData(miniPetId);
        GameObject           prefab = Resources.Load(data.PrefabName) as GameObject;

        switch (data.Type)
        {
        case MiniPetTypes.Retention:
            // Check if mp needs new locations
            if (isSpawnNewLocations)
            {
                DataManager.Instance.GameData.Wellapad.ResetMissions();
            }

            // Only spawn the retention pet in the bedroom
            if (SceneManager.GetActiveScene().name == SceneUtils.BEDROOM)
            {
                // Calculate the MP location
                LgTuple <Vector3, string> retentionLocation = PartitionManager.Instance.GetBasePositionInBedroom();
                Vector3 locationPosition = retentionLocation.Item1;
                string  locationId       = retentionLocation.Item2;
                int     partitionNumber  = 0;

                DataManager.Instance.GameData.MiniPets.SetIsHatched(miniPetId, true);
                DataManager.Instance.GameData.MiniPetLocations.SaveLocationId(miniPetId, locationId);   // locationId from tuple
                DataManager.Instance.GameData.MiniPets.SaveHunger(miniPetId, true);                     // Set to always full

                goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partitionNumber).gameObject, prefab);
                goMiniPet.transform.localPosition = locationPosition;                   // vector3 from tuple
                goMiniPet.name = prefab.name;

                MiniPetRetentionPet retentionScript = goMiniPet.GetComponent <MiniPetRetentionPet>();
                retentionScript.Init(data);
                retentionScript.FigureOutMissions();
                if (!DataManager.Instance.GameData.Wellapad.CurrentTasks.ContainsKey("DailyInhaler"))
                {
                    retentionScript.GiveOutMission();
                }

                // Add the pet into the dictionary to keep track
                MiniPetTable.Add(miniPetId, goMiniPet);
            }
            break;

        case MiniPetTypes.GameMaster:
            // Check if mp needs new locations
            ImmutableDataGate latestGate = GatingManager.Instance.GetLatestLockedGate();

//			if(latestGate == null)
//				Debug.Log("-----Spawning GameMaster: " + (latestGate == null) + " gate null");
//			else
//				Debug.Log("-----Spawning GameMaster: " + (latestGate.AbsolutePartition - 1 >= 1) + " || latest gate " + latestGate.AbsolutePartition);

            if (latestGate == null || (latestGate.AbsolutePartition - 1 >= 1))
            {
                // NOTE: Besides spawning new locations, there may not be any data for a minipet when coming back to same PP, do or check
                if (isSpawnNewLocations || GetPartitionNumberForMinipet(miniPetId) == -1)
                {
                    // Calculate the MP location
                    MinigameTypes             type = PartitionManager.Instance.GetRandomUnlockedMinigameType();
                    LgTuple <Vector3, string> gameMasterLocation = PartitionManager.Instance.GetPositionNextToMinigame(type);
                    Vector3 locationPosition = gameMasterLocation.Item1;
                    string  locationId       = gameMasterLocation.Item2;
                    int     partitionNumber  = DataLoaderPartitionLocations.GetAbsolutePartitionNumberFromLocationId(locationId);

                    // Save information for minipet
                    DataManager.Instance.GameData.MiniPetLocations.SaveLocationId(miniPetId, locationId);
                    DataManager.Instance.GameData.MiniPets.SaveHunger(miniPetId, false);

                    // Spawn the minipet if it is in current scene
                    if (PartitionManager.Instance.IsPartitionInCurrentZone(partitionNumber))
                    {
                        goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partitionNumber).gameObject, prefab);
                        goMiniPet.transform.localPosition = locationPosition;
                        goMiniPet.name = prefab.name;

                        MiniPetGameMaster gameMasterScript = goMiniPet.GetComponent <MiniPetGameMaster>();
                        gameMasterScript.minigameType = type;
                        gameMasterScript.Init(data);
                        gameMasterScript.isFinishEating = false;

                        // Add the pet into the dictionary to keep track
                        MiniPetTable.Add(miniPetId, goMiniPet);
                    }
                }
                // Spawn based on its saved location
                else
                {
                    // If the saved minipet location is in the current zone
                    if (PartitionManager.Instance.IsPartitionInCurrentZone(GetPartitionNumberForMinipet(miniPetId)))
                    {
                        string locationId = DataManager.Instance.GameData.MiniPetLocations.GetLocationId(miniPetId);

                        // Get relevant info to populate with given saved location ID
                        int           partition    = DataLoaderPartitionLocations.GetAbsolutePartitionNumberFromLocationId(locationId);
                        Vector3       pos          = DataLoaderPartitionLocations.GetOffsetFromLocationId(locationId);
                        MinigameTypes minigameType = DataLoaderPartitionLocations.GetMinigameTypeFromLocationId(locationId);

                        goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partition).gameObject, prefab);
                        goMiniPet.transform.localPosition = pos;
                        goMiniPet.name = prefab.name;

                        MiniPetGameMaster gameMasterScript = goMiniPet.GetComponent <MiniPetGameMaster>();
                        gameMasterScript.minigameType = minigameType;
                        gameMasterScript.Init(data);

                        // Add the pet into the dictionary to keep track
                        MiniPetTable.Add(miniPetId, goMiniPet);
                    }
                }
            }
            break;

        case MiniPetTypes.Merchant:
            ImmutableDataGate latestGate2 = GatingManager.Instance.GetLatestLockedGate();

//			if(latestGate2 == null)
//				Debug.Log("-----Spawning merchant: " + (latestGate2 == null) + " gate null");
//			else
//				Debug.Log("-----Spawning merchant: " + (latestGate2.AbsolutePartition - 1 >= 2) + " || latest gate " + latestGate2.AbsolutePartition);
            if (DataManager.Instance.GameData.MiniPetLocations.IsMerchantSpawning())
            {
                if (latestGate2 == null || (latestGate2.AbsolutePartition - 1 >= 2))
                {
                    // Check if mp needs new locations
                    // NOTE: Besides spawning new locations, there may not be any data for a minipet when coming back to same PP, do or check
                    if (isSpawnNewLocations || GetPartitionNumberForMinipet(miniPetId) == -1)
                    {
                        // Calculate the MP location
                        LgTuple <Vector3, string> merchantLocation = PartitionManager.Instance.GetRandomUnusedPosition();
                        Vector3 locationPosition = merchantLocation.Item1;
                        string  locationId       = merchantLocation.Item2;
                        int     partitionNumber  = DataLoaderPartitionLocations.GetAbsolutePartitionNumberFromLocationId(locationId);

                        // Save information for minipet
                        DataManager.instance.GameData.MiniPetLocations.SaveLocationId(miniPetId, locationId);
                        DataManager.Instance.GameData.MiniPets.SaveHunger(miniPetId, false);

                        // Set new merchant item here only
                        List <ImmutableDataMerchantItem> merchantItemsList = DataLoaderMerchantItem.GetDataList();
                        int rand = UnityEngine.Random.Range(0, merchantItemsList.Count);
                        DataManager.Instance.GameData.MiniPets.SetItem(miniPetId, rand);
                        DataManager.Instance.GameData.MiniPets.SetItemBoughtInPP(miniPetId, false);

                        // Spawn the minipet if it is in current scene
                        if (PartitionManager.Instance.IsPartitionInCurrentZone(partitionNumber))
                        {
                            goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partitionNumber).gameObject, prefab);
                            goMiniPet.transform.localPosition = locationPosition;
                            goMiniPet.name = prefab.name;

                            MiniPetMerchant merchantScript = goMiniPet.GetComponent <MiniPetMerchant>();
                            merchantScript.Init(data);
                            merchantScript.isFinishEating = false;

                            // Add the pet into the dictionary to keep track
                            MiniPetTable.Add(miniPetId, goMiniPet);
                        }
                    }

                    // Spawn based on its saved location
                    else
                    {
                        // If the saved minipet location is in the current zone
                        if (PartitionManager.Instance.IsPartitionInCurrentZone(GetPartitionNumberForMinipet(miniPetId)))
                        {
                            string locationId = DataManager.Instance.GameData.MiniPetLocations.GetLocationId(miniPetId);

                            // Get relevant info to populate with given saved location ID
                            int     partition = DataLoaderPartitionLocations.GetAbsolutePartitionNumberFromLocationId(locationId);
                            Vector3 pos       = DataLoaderPartitionLocations.GetOffsetFromLocationId(locationId);
                            //MinigameTypes minigameType = DataLoaderPartitionLocations.GetMinigameTypeFromLocationId(locationId);

                            goMiniPet = GameObjectUtils.AddChild(PartitionManager.Instance.GetInteractableParent(partition).gameObject, prefab);
                            goMiniPet.transform.localPosition = pos;
                            goMiniPet.name = prefab.name;

                            MiniPetMerchant merchantScript = goMiniPet.GetComponent <MiniPetMerchant>();
                            merchantScript.Init(data);

                            // Add the pet into the dictionary to keep track
                            MiniPetTable.Add(miniPetId, goMiniPet);
                        }
                    }
                }
            }
            break;

        default:
            Debug.LogError("Bad minipet type specified: " + data.Type.ToString());
            break;
        }
    }
示例#26
0
    // in each case we are going to listen to events that tell us to move along
    public void ProcessStep(int step)
    {
        switch (step)
        {
        case 0:                         // Prompt user to hold device with both hands
            ShooterGameManager.Instance.OnTutorialTap += MoveAlong;
            ShooterGameManager.Instance.tutUIAnimator.Play("ShooterTutorialUIHoldDevice");
            ShooterGameManager.Instance.tutUITextLocalize.key = "SHOOTER_TUT_DEVICE";
            ShooterGameManager.Instance.tutUITextLocalize.Localize();
            break;

        case 1:                     //prompt user to move around, the user simply needs to tap the screen
            ShooterGameManager.Instance.OnTutorialTap       -= MoveAlong;
            PlayerShooterController.Instance.OnTutorialMove += MoveAlong;
            ShooterGameManager.Instance.tutUIAnimator.Play("ShooterTutorialUIMoveClick");
            ShooterGameManager.Instance.tutUITextLocalize.key = "SHOOTER_TUT_MOVE";
            ShooterGameManager.Instance.tutUITextLocalize.Localize();
            break;

        case 2:                     //prompt user to shoot
            PlayerShooterController.Instance.OnTutorialMove -= MoveAlong;
            ShooterGameManager.Instance.OnTutorialTap       += MoveAlong;
            ShooterGameManager.Instance.tutUIAnimator.Play("ShooterTutorialUIShootClick");
            ShooterGameManager.Instance.tutUITextLocalize.key = "SHOOTER_TUT_SHOOT";
            ShooterGameManager.Instance.tutUITextLocalize.Localize();
            break;

        case 3:
            ShooterGameManager.Instance.OnTutorialTap      -= MoveAlong;
            ShooterGameManager.Instance.OnTutorialStepDone += MoveAlong;
            ShooterGameManager.Instance.tutUIAnimator.Play("ShooterTutorialUINone");
            GameObjectUtils.AddChild(GameObject.Find("MidPoint"), LoadTutorialEnemyRef());
            break;

        case 4:
            GameObjectUtils.AddChild(GameObject.Find("Upper"), LoadTutorialEnemyRef());
            break;

        case 5:
            GameObjectUtils.AddChild(GameObject.Find("Lower"), LoadTutorialEnemyRef());
            break;

        // the user must defeat the first wave which is simply a wave of 5 basic enemies
        case 6:
            ShooterGameManager.Instance.OnTutorialStepDone         -= MoveAlong;
            ShooterGameEnemyController.Instance.OnTutorialStepDone += MoveAlong;
            ShooterGameEnemyController.Instance.BuildEnemyList();
            break;

        //the user must click the inhaler button to end the tutorial the scene transition should pause after the sun is off screen
        case 7:
            ShooterGameManager.Instance.ShooterTutInhalerStep       = true;
            ShooterGameEnemyController.Instance.OnTutorialStepDone -= MoveAlong;
            ShooterInhalerManager.Instance.proceed += MoveAlong;
            break;

        // the user must defeat the first wave which is simply a wave of 5 basic enemies
        case 8:
            ShooterGameManager.Instance.ShooterTutInhalerStep       = false;
            ShooterGameManager.Instance.OnTutorialStepDone         -= MoveAlong;
            ShooterGameEnemyController.Instance.OnTutorialStepDone += MoveAlong;
            ShooterGameEnemyController.Instance.BuildEnemyList();
            break;

        //the user must click the inhaler button to end the tutorial the scene transition should pause after the sun is off screen
        case 9:
            ShooterGameManager.Instance.ShooterTutInhalerStep       = true;
            ShooterGameEnemyController.Instance.OnTutorialStepDone -= MoveAlong;
            ShooterInhalerManager.Instance.proceed += MoveAlong;
            break;

        case 10:
            ShooterGameManager.Instance.ShooterTutInhalerStep = false;
            ShooterGameManager.Instance.inTutorial            = false;
            ShooterGameManager.Instance.NewGame();
            break;
        }
    }