Exemplo n.º 1
0
    public void StartMoving()
    {
        //Tougher Enemies risk
        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_tougherEnemies)))
        {
            Debug.Log("calling applyriskstatchanges");
            ApplyRiskStatChanges();
        }
        //Debug.Log ("start moving called on " + this.ToString());
        ConfigureEnemy();
        steering       = gameObject.AddComponent <Steering>() as Steering;
        steering.enemy = this;
        float speedMult = 1f / (impactTime / NORMAL_IMPACT_TIME);

        steering.maxSpeed          = speedMult * NORMAL_SPEED;
        steering.referenceMaxSpeed = steering.maxSpeed;
        steering.maxAccel          = steering.maxSpeed / FRAMES_FROM_ZERO_TO_MAX;
        steering.referenceMaxAccel = steering.maxAccel;
        path = AIPath.CreatePathFromJSONFilename(moverType);
        path.SetDialDimensions(Dial.spawnLayer.anchoredPosition, Dial.FULL_LENGTH);
        path.SetAngle(GetStartingTrackAngle() + (-trackLane * 15f) + moverLaneOverride);
        steering.StartFollowingPath(path);
        steering.SpeedBoost((1f + riskSpeedBoost), 99999999f); //apply Tougher Enemies risk speed bonus

        /*List<Vector2> pathlist = path.GetPathAsListOfVectors();
         * foreach(Vector2 node in pathlist){ //path visualization
         *      GameObject dot = new GameObject();
         *      Image dimg = dot.AddComponent<Image>() as Image;
         *      dot.transform.SetParent(Dial.unmaskedLayer,false);
         *      dot.GetComponent<RectTransform>().sizeDelta = new Vector2(5f,5f);
         *      dot.GetComponent<RectTransform>().anchoredPosition = node;
         * }*/
        //some scaling- could maybe be done through transform.scale, but I don't trust Unity to handle the collider
        ScaleEnemy();
        spawned = true;
        moving  = true;

        //float angle = Mathf.Atan2(rt.anchoredPosition.y , rt.anchoredPosition.x);
        //ySpeed = Mathf.Sin (angle) * speed;
        //xSpeed = Mathf.Cos (angle) * speed;
    }
Exemplo n.º 2
0
    public void ShowPath(float angle)
    {
        string json = Json.Serialize(GetPathDict());
        AIPath p    = new AIPath(json);

        p.SetAngle(angle);
        p.SetCenter(center.GetComponent <RectTransform>().anchoredPosition);
        p.SetTrackRadius(onscreenRadius);
        List <Vector2> pathpoints = p.GetPathAsListOfVectors();

        for (int i = 0; i < pathpoints.Count; i++)
        {
            Vector2 pointA = pathpoints[i];

            GameObject newpreview = new GameObject();
            newpreview.transform.SetParent(previewParent.transform, false);
            Image         img = newpreview.AddComponent <Image>() as Image;
            RectTransform prt = newpreview.GetComponent <RectTransform>();
            prt.sizeDelta        = new Vector2(12f, 12f);
            img.color            = new Color(1f, .7f, .8f);
            prt.anchoredPosition = pointA;
        }
    }
Exemplo n.º 3
0
    public void StartMoving()
    {
        //Debug.Log ("start moving called on " + this.ToString());
        ConfigureEnemy ();
        steering = gameObject.AddComponent<Steering>() as Steering;
        steering.enemy = this;
        float speedMult = 1f/(impactTime/NORMAL_IMPACT_TIME);
        steering.maxSpeed = speedMult * NORMAL_SPEED;
        steering.referenceMaxSpeed = steering.maxSpeed;
        steering.maxAccel = steering.maxSpeed/FRAMES_FROM_ZERO_TO_MAX;
        steering.referenceMaxAccel = steering.maxAccel;
        path = AIPath.CreatePathFromJSONFilename(moverType);
        path.SetDialDimensions(Dial.spawnLayer.anchoredPosition,Dial.FULL_LENGTH);
        path.SetAngle(GetStartingTrackAngle() + (-trackLane*15f) + moverLaneOverride);
        steering.StartFollowingPath(path);
        /*List<Vector2> pathlist = path.GetPathAsListOfVectors();
        foreach(Vector2 node in pathlist){ //path visualization
            GameObject dot = new GameObject();
            Image dimg = dot.AddComponent<Image>() as Image;
            dot.transform.SetParent(Dial.unmaskedLayer,false);
            dot.GetComponent<RectTransform>().sizeDelta = new Vector2(5f,5f);
            dot.GetComponent<RectTransform>().anchoredPosition = node;
        }*/
        //some scaling- could maybe be done through transform.scale, but I don't trust Unity to handle the collider
        ScaleEnemy();
        spawned = true;
        moving = true;

        //float angle = Mathf.Atan2(rt.anchoredPosition.y , rt.anchoredPosition.x);
        //ySpeed = Mathf.Sin (angle) * speed;
        //xSpeed = Mathf.Cos (angle) * speed;
    }
Exemplo n.º 4
0
    public void ShowPath(float angle)
    {
        string json = Json.Serialize(GetPathDict ());
        AIPath p = new AIPath(json);
        p.SetAngle(angle);
        p.SetCenter(center.GetComponent<RectTransform>().anchoredPosition);
        p.SetTrackRadius(onscreenRadius);
        List<Vector2> pathpoints = p.GetPathAsListOfVectors();
        for(int i = 0; i < pathpoints.Count;i++){
            Vector2 pointA = pathpoints[i];

            GameObject newpreview = new GameObject();
            newpreview.transform.SetParent(previewParent.transform,false);
            Image img = newpreview.AddComponent<Image>() as Image;
            RectTransform prt = newpreview.GetComponent<RectTransform>();
            prt.sizeDelta = new Vector2(12f,12f);
            img.color = new Color(1f,.7f,.8f);
            prt.anchoredPosition = pointA;
        }
    }