Beispiel #1
0
    public NinjaData(string id, Hashtable hashAttr, IXMLNode nodeEntries, string strError)
    {
        // set id
        strID = id;

        // get the weight for this group
        string strWeight = HashUtils.GetHashValue <string>(hashAttr, "Weight", "1");

        nWeight = int.Parse(strWeight);

        // get the scoring categories
        string strScoring = HashUtils.GetHashValue <string>(hashAttr, "Scoring", "Med", strError);

        string[] arrayScoring = strScoring.Split(","[0]);
        for (int i = 0; i < arrayScoring.Length; ++i)
        {
            NinjaScoring eScoring = (NinjaScoring)System.Enum.Parse(typeof(NinjaScoring), arrayScoring[i]);
            listScoring.Add(eScoring);
        }

        // go through the list of entries and add them to our list
        List <IXMLNode> listEntries = XMLUtils.GetChildrenList(nodeEntries);

        for (int i = 0; i < listEntries.Count; ++i)
        {
            Hashtable      hashEntryAttr = XMLUtils.GetAttributes(listEntries[i]);
            NinjaDataEntry entry         = new NinjaDataEntry(hashEntryAttr, strError);
            this.listEntries.Add(entry);
        }
    }
Beispiel #2
0
    void Update()
    {
        if (isTutorialRunning || isGameOver)
        {
            return;
        }

        float deltaTime = Time.deltaTime;

        // update the player's combo
        UpdateComboTimer(deltaTime);

        // if there is a current group of spawn entries in process...
        if (currentTriggerEntries != null && currentTriggerEntries.Count > 0)
        {
            // count up
            timeCount += deltaTime;

            // if our time has surpassed the next entry's time, do it up and remove that entry
            NinjaDataEntry entry     = currentTriggerEntries[0];
            float          timeEntry = entry.GetTime();
            if (timeCount >= timeEntry)
            {
                SpawnGroup(entry);
                currentTriggerEntries.RemoveAt(0);
            }

            // if the list of current entries is empty...null the list and reset our count so we can count down again
            if (currentTriggerEntries.Count == 0)
            {
                currentTriggerEntries = null;
                timeCount             = timeBetweenSpawnGroups;
            }
        }
        else if (timeCount <= 0)
        {
            // otherwise, there is no current group and it is time to start one,
            // so figure out which one to begin
            NinjaScoring scoreKey;
            NinjaData    data = null;
            if (spawning)
            {
                scoreKey = GetScoringKey();
                data     = NinjaDataLoader.GetGroupToSpawn(NinjaModes.Classic, scoreKey);

                // cache the list -- ALMOST FOOLED ME....use new to copy the list
                currentTriggerEntries = new List <NinjaDataEntry>(data.GetEntries());
            }
        }
        else
        {
            timeCount -= deltaTime;             // otherwise, there is no group and we still need to countdown before spawning the next group
        }
    }
Beispiel #3
0
    /// <summary>
    /// Spawns the group.
    /// </summary>
    /// <param name="entry">Entry.</param>
    private void SpawnGroup(NinjaDataEntry entry)
    {
        // create the proper list of objects to spawn
        int           numOfTriggers = entry.GetTriggers();
        int           numOfBombs    = entry.GetBombs();
        int           numOfPowUps   = entry.GetPowUp();
        List <string> listObjects   = new List <string>();

        for (int i = 0; i < numOfTriggers; ++i)
        {
            // NOTE: if want to add variation over time, use GetRandomTrigger(n to choose from)
            string randomTrigger =
                DataLoaderNinjaTriggersAndBombs.GetRandomTrigger(DataLoaderNinjaTriggersAndBombs.numTriggers);
            listObjects.Add(randomTrigger);
        }
        for (int i = 0; i < numOfBombs; ++i)
        {
            // NOTE: if want to add variation over time, use GetRandomBomb(n to choose from)
            string randomBomb =
                DataLoaderNinjaTriggersAndBombs.GetRandomBomb(DataLoaderNinjaTriggersAndBombs.numBombs);
            listObjects.Add(randomBomb);
        }

        for (int i = 0; i < numOfPowUps; ++i)
        {
            // NOTE: if want to add variation over time, use GetRandomBomb(n to choose from)
            string randomPowUps =
                DataLoaderNinjaTriggersAndBombs.GetRandomPowUp(DataLoaderNinjaTriggersAndBombs.numPowUps);
            listObjects.Add(randomPowUps);
        }
        // shuffle the list so everything is nice and mixed up
        listObjects.Shuffle();

        // create the proper object based off the entry's pattern
        NinjaPatterns patternType = entry.GetPattern();

        switch (patternType)
        {
        case NinjaPatterns.Separate:
            new SpawnGroupSeparate(listObjects);
            break;

        case NinjaPatterns.Clustered:
            new SpawnGroupCluster(listObjects);
            break;

        case NinjaPatterns.Meet:
            new SpawnGroupMeet(listObjects);
            break;

        case NinjaPatterns.Cross:
            new SpawnGroupCross(listObjects);
            break;

        case NinjaPatterns.Split:
            new SpawnGroupSplit(listObjects);
            break;

        case NinjaPatterns.Swarms:
            // Random is ambiguous need to specify unity engine
            int rand = UnityEngine.Random.Range(2, 5);
            StartCoroutine(WaitASec(rand, listObjects));
            break;

        default:
            Debug.LogError("Unhandled group type: " + patternType);
            break;
        }
    }