Example #1
0
    public void DropChainers()
    {
        FileLoader fl = new FileLoader("JSONData" + Path.DirectorySeparatorChar + "Bestiary", "chainers");
        string     actualenemyjson = fl.Read();
        Dictionary <string, System.Object> actualenemydict = Json.Deserialize(actualenemyjson) as Dictionary <string, System.Object>;
        string filename = "chainers";
        int    track    = SpawnIndexToZoneID(spawnIdx);
        int    trackpos = 0;

        GameObject enemyobj = GameObject.Instantiate(Resources.Load("Prefabs/MainCanvas/Enemy")) as GameObject;

        GameObject.Destroy(enemyobj.GetComponent <Enemy>());
        Chainer c = enemyobj.AddComponent <Chainer>() as Chainer;

        enemyobj.transform.SetParent(Dial.spawnLayer, false);
        float chaindelay = (float)(double)actualenemydict["delay"];

        c.delay = chaindelay;

        c.SetSrcFileName(filename);
        c.SetTrackID(track);
        c.SetTrackLane(trackpos);
        //calculate and set position
        float degrees = (track - 1) * 60;        //clockwise of y-axis

        degrees += 15 * trackpos;                //negative trackpos is left side, positive is right side, 0 is middle
        degrees  = ((360 - degrees) + 90) % 360; //convert to counterclockwise of x axis
        degrees *= Mathf.Deg2Rad;
        ((RectTransform)enemyobj.transform).anchoredPosition = new Vector2(Dial.ENEMY_SPAWN_LENGTH * Mathf.Cos(degrees),
                                                                           Dial.ENEMY_SPAWN_LENGTH * Mathf.Sin(degrees));
        c.spawnedByBoss = true;
        c.StartMoving();
    }
Example #2
0
    public void SpawnFollower()
    {
        GameObject enemyspawn = GameObject.Instantiate(Resources.Load("Prefabs/MainCanvas/Enemy")) as GameObject;

        Destroy(enemyspawn.GetComponent <Enemy>());
        Chainer newchainer = enemyspawn.AddComponent <Chainer>() as Chainer;

        enemyspawn.transform.SetParent(Dial.spawnLayer, false);
        followers.Add(newchainer);
        newchainer.FillFollowers(followers);
        newchainer.delay             = delay;
        newchainer.groupAddedToBonus = groupAddedToBonus;
        newchainer.spawnedByBoss     = spawnedByBoss;


        newchainer.SetSrcFileName(srcFileName);
        newchainer.SetTrackID(trackID);
        newchainer.SetTrackLane(trackLane);
        //calculate and set position
        float degrees = (trackID - 1) * 60;      //clockwise of y-axis

        degrees += 15 * trackLane;               //negative trackpos is left side, positive is right side, 0 is middle
        degrees  = ((360 - degrees) + 90) % 360; //convert to counterclockwise of x axis
        degrees *= Mathf.Deg2Rad;
        enemyspawn.GetComponent <RectTransform>().anchoredPosition = new Vector2(Dial.ENEMY_SPAWN_LENGTH * Mathf.Cos(degrees), Dial.ENEMY_SPAWN_LENGTH * Mathf.Sin(degrees));

        newchainer.StartMoving();
    }