Beispiel #1
0
    /* Takes in a tic tac's path route and instance ID, and updates the correct path. Will move tic tacs forward from queues
     * depending on where the removed tic tac was previously on the path. */
    public void TicTacRemoved(SE.PathRoute removedPathRoute, SE.PathDistance removedPathDistance, int removedInstanceID)
    {
        Path   removedPath   = (removedPathRoute == SE.PathRoute.Melee) ? meleePath : rangedPath;
        TicTac removedScript = removedPath.scriptDict[removedInstanceID];

        if (removedPathDistance == SE.PathDistance.Close && removedPath.scriptDict.Count > pathLimits[0])
        {
            TicTac firstMidScript = removedPath.GetFirstScript(SE.PathDistance.Mid);    // Move first mid script up to close distance
            firstMidScript.CurrPathDistance = SE.PathDistance.Close;
            firstMidScript.StartAdvanceCoroutine((Random.insideUnitSphere * removedPath.radii[0]) + removedPath.centers[0], 0.0f);

            if (removedPath.scriptDict.Count > pathLimits[1])
            {
                TicTac firstFarScript = removedPath.GetFirstScript(SE.PathDistance.Far);    // Move first far script up to mid distance
                firstFarScript.CurrPathDistance = SE.PathDistance.Mid;
                firstFarScript.StartAdvanceCoroutine((Random.insideUnitSphere * removedPath.radii[1]) + removedPath.centers[1], 0.0f);
            }
        }
        else if (removedPathDistance == SE.PathDistance.Mid && removedPath.scriptDict.Count > pathLimits[1]) // Removed tic tac was far
        {
            TicTac firstFarScript = removedPath.GetFirstScript(SE.PathDistance.Far);                         // Move first far script up to mid distance
            firstFarScript.CurrPathDistance = SE.PathDistance.Mid;
            firstFarScript.StartAdvanceCoroutine((Random.insideUnitSphere * removedPath.radii[1]) + removedPath.centers[1], 0.0f);
        }

        removedPath.scriptDict.Remove(removedInstanceID);
    }
Beispiel #2
0
    private Dictionary <SE.Flavor, GameObject> ticTacPrefabDict; // Dictionary of tic tac prefabs, with their types as keys


    /* Takes in an tic tac flavor and a spawn amount, and spawns that many tic tacs of that flavor. Will only spawn up to the
     * far path limit. */
    public void SpawnEnemies(SE.Flavor flavor, int spawnAmount)
    {
        if (!ticTacPrefabDict.ContainsKey(flavor))
        {
            Debug.LogWarning("Tic Tac with flavor " + flavor + " doesn't exist."); return;
        }

        SE.PathRoute pathRoute = ticTacPrefabDict[flavor].GetComponent <TicTac>().PathRoute;
        Path         path      = (pathRoute == SE.PathRoute.Melee) ? meleePath : rangedPath;

        for (int i = 0; i < spawnAmount && pathLimits[2] - path.scriptDict.Count > 0; i++)
        {
            Vector3 spawnPosition = spawnPositions.Dequeue();                                 // Get spawn position
            float   heightOffset  = ticTacPrefabDict[flavor].transform.GetChild(0).localScale.y +
                                    (transform.position.y - (transform.localScale.y / 2.0f)); // Used to spawn object above field
            spawnPosition = V3E.SetY(spawnPosition, heightOffset);
            spawnPositions.Enqueue(spawnPosition);

            GameObject ticTac       = Instantiate(ticTacPrefabDict[flavor], spawnPosition, Quaternion.identity); // Instantiate
            TicTac     ticTacScript = ticTac.GetComponent <TicTac>();
            ticTacScript.InitializeVariables(gameObject, collector);

            float delayTime = delayTimes.Dequeue();  // Get delay time
            delayTimes.Enqueue(delayTime);

            if (path.scriptDict.Count < pathLimits[0])   // Set path distance and start moving towards a new path position
            {
                ticTacScript.CurrPathDistance = SE.PathDistance.Close;
                ticTacScript.StartAdvanceCoroutine(((Random.insideUnitSphere * path.radii[0]) + path.centers[0]), delayTime);
                path.scriptDict.Add(ticTac.GetInstanceID(), ticTacScript);
            }
            else if (path.scriptDict.Count < pathLimits[1])
            {
                ticTacScript.CurrPathDistance = SE.PathDistance.Mid;
                ticTacScript.StartAdvanceCoroutine(((Random.insideUnitSphere * path.radii[1]) + path.centers[1]), delayTime);
                path.scriptDict.Add(ticTac.GetInstanceID(), ticTacScript);
            }
            else                // farPathLimit
            {
                ticTacScript.CurrPathDistance = SE.PathDistance.Far;
                ticTacScript.StartAdvanceCoroutine(((Random.insideUnitSphere * path.radii[2]) + path.centers[2]), delayTime);
                path.scriptDict.Add(ticTac.GetInstanceID(), ticTacScript);
            }
        }
    }
    public Vector3[] GetCenters(SE.PathLetter pathLetter, SE.PathRoute pathRoute)
    {
        Dictionary <SE.PathLetter, Vector3[]> centersDictionary = (pathRoute == SE.PathRoute.Melee) ? meleeCentersDictionary : rangedCentersDictionary;

        return(centersDictionary[pathLetter]);
    }
    public float[] GetRadii(SE.PathLetter pathLetter, SE.PathRoute pathRoute)
    {
        Dictionary <SE.PathLetter, float[]> radiiDictionary = (pathRoute == SE.PathRoute.Melee) ? meleeRadiiDictionary : rangedRadiiDictionary;

        return(radiiDictionary[pathLetter]);
    }