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; }
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; }