void Start() { CircleMovement cm = GetComponent <CircleMovement>(); if (cm.centerObject != null) { target = cm.centerObject; } else { target = null; } lineRenderer = GetComponent <LineRenderer>(); lineRenderer.SetWidth(lineWidth, lineWidth); lineRenderer.positionCount = 2; lineRenderer.SetPosition(0, transform.position); if (target != null) { lineRenderer.SetPosition(1, target.position); } else { lineRenderer.SetPosition(1, cm.localCenter); } }
void disableAllScript() { foreach (GameObject drone in drones) { Wandering wandering = drone.GetComponent <Wandering>(); CircleFormation circleFormation = drone.GetComponent <CircleFormation>(); SphereFormation sphereFormation = drone.GetComponent <SphereFormation>(); Boid boid = drone.GetComponent <Boid>(); CircleMovement circle = drone.GetComponent <CircleMovement>(); if (wandering.enabled) { wandering.enabled = false; } if (circleFormation.enabled) { circleFormation.enabled = false; } if (sphereFormation.enabled) { sphereFormation.enabled = false; } if (boid.enabled) { boid.enabled = false; } if (circle.enabled) { circle.enabled = false; } } }
protected override void Load() { StaticSprite frame1 = new StaticSprite(); StaticSprite frame2 = new StaticSprite(); frame1.Load(Parent.Engine.Content, "Froggy", new Rectangle(0, 0, 34, 29)); frame1.Origin = new Vector2(17, 28); frame2.Load(Parent.Engine.Content, "Froggy", new Rectangle(34, 0, 34, 29)); frame2.Origin = new Vector2(18, 28); frame1.Scale = 2f; frame2.Scale = 2f; _sequence.Scale = 2f; _sequence.AddSprite(frame1, 0.5f); _sequence.AddSprite(frame2, 0.5f); _sequence.RepeatIndefinitely = true; _sequence.Start(); //_mask = new CircleMask(new PointFP(8, 8), 10); _mask = new AABBMask(new PointFP(-16, -32), new PointFP(16, 0)); _mask.Position = _position; Dictionary <PlatformAction, PlatformAction> cmap = new Dictionary <PlatformAction, PlatformAction>(); cmap[PlatformAction.Left] = PlatformAction.Left; cmap[PlatformAction.Right] = PlatformAction.Right; cmap[PlatformAction.Up] = PlatformAction.Up; cmap[PlatformAction.Down] = PlatformAction.Down; cmap[PlatformAction.Jump] = PlatformAction.Jump; cmap[PlatformAction.Action] = PlatformAction.Action; /*PaddleMovement<PaddleAction> behavior = new PaddleMovement<PaddleAction>(this, "player", cmap); * behavior.Origin = new Vector2(400, 200); * behavior.Range = 100; * behavior.Speed = 120; * behavior.Direction = PaddleDirection.Vertical; * AddBehavior(behavior);*/ /*PlayerPlatformMovement<PlatformAction> behavior = new PlayerPlatformMovement<PlatformAction>(this, "player", cmap); * behavior.AccelX = (FPInt)0.5; * behavior.DecelX = (FPInt)0.25; * behavior.MinVelocityX = (FPInt)(-3); * behavior.MaxVelocityX = (FPInt)3; * behavior.AccelY = (FPInt)0.4; * behavior.MinVelocityY = -12; * behavior.MaxVelocityY = 12; * behavior.AccelStateY = PlatformAccelState.Accelerate;*/ //AddBehavior(behavior); CircleMovement circle = new CircleMovement(this, new PointFP(300, 300), 150, 1); AddBehavior(circle); }
void switchBehaviour() { switch (this.behaviour) { case "Wandering": foreach (GameObject drone in drones) { Wandering wandering = drone.GetComponent <Wandering>(); wandering.enabled = !wandering.enabled; } break; case "CircleFormation": foreach (GameObject drone in drones) { CircleFormation circleFormation = drone.GetComponent <CircleFormation>(); circleFormation.enabled = !circleFormation.enabled; } break; case "SphereFormation": foreach (GameObject drone in drones) { SphereFormation sphereFormation = drone.GetComponent <SphereFormation>(); sphereFormation.enabled = !sphereFormation.enabled; } break; case "Boid": foreach (GameObject drone in drones) { Boid boid = drone.GetComponent <Boid>(); boid.enabled = !boid.enabled; } break; case "CircleMovement": foreach (GameObject drone in drones) { CircleMovement circleMvt = drone.GetComponent <CircleMovement>(); circleMvt.enabled = !circleMvt.enabled; } break; } }
// Start is called before the first frame update void Start() { // get the rigidbody of the paddle rBody = gameObject.GetComponent <Rigidbody2D>(); paddleCollider = gameObject.GetComponent <BoxCollider2D>(); // get the circle movement script of the ball ballScript = my_ball.GetComponent <CircleMovement>(); // get the starting position of the paddle paddleStart = gameObject.transform.localPosition; // get the width of the walls float wallWidth = leftWall.GetComponent <BoxCollider2D>().bounds.size.x; // define leftWallXPos and rightWallXPos so that they can be used in observations leftWallXPos = leftWall.transform.localPosition.x + wallWidth / 2; rightWallXPos = rightWall.transform.localPosition.x - wallWidth / 2; // define ceilingYPos and paddleYPos so that they can be used in observations ceilingYPos = ceiling.transform.localPosition.y - ceiling.GetComponent <BoxCollider2D>().bounds.size.y / 2; paddleYPos = gameObject.transform.localPosition.y + paddleCollider.bounds.size.y / 2; // get the radius of the ball circleRadius = my_ball.GetComponent <CircleCollider2D>().radius; // get the textmeshproUGUI components of the lives and scores game objects livesUGUI = myLives.GetComponent <TextMeshProUGUI>(); scoreUGUI = myScore.GetComponent <TextMeshProUGUI>(); // set starting values for the score and lives curScore = 0; if (training) { curLives = 1; } else { curLives = 3; } }
// Start is called before the first frame update void Start() { // define the value for displayUGUI, and secondPromptUGUI objects displayUGUI = display.GetComponent <TextMeshProUGUI>(); secondPromptUGUI = secondPrompt.GetComponent <TextMeshProUGUI>(); // get the prompt from the display prompt = displayUGUI.text; // define the values for the playerBallScript and machineBallScript playerBallScript = playerBall.GetComponent <CircleMovement>(); machineBallScript = machineBall.GetComponent <CircleMovement>(); // get the TMPro UGUI game objects for the player's lives and scores playerLivesUGUI = playerLives.GetComponent <TextMeshProUGUI>(); machineLivesUGUI = machineLives.GetComponent <TextMeshProUGUI>(); playerScoreUGUI = playerScore.GetComponent <TextMeshProUGUI>(); machineScoreUGUI = machineScore.GetComponent <TextMeshProUGUI>(); }
protected override void Load() { StaticSprite frame1 = new StaticSprite(); StaticSprite frame2 = new StaticSprite(); frame1.Load(Parent.Engine.Content, "Froggy", new Rectangle(0, 0, 34, 29)); frame1.Origin = new Vector2(17, 28); frame2.Load(Parent.Engine.Content, "Froggy", new Rectangle(34, 0, 34, 29)); frame2.Origin = new Vector2(18, 28); frame1.Scale = 2f; frame2.Scale = 2f; _sequence.Scale = 2f; _sequence.AddSprite(frame1, 0.5f); _sequence.AddSprite(frame2, 0.5f); _sequence.RepeatIndefinitely = true; _sequence.Start(); //_mask = new CircleMask(new PointFP(8, 8), 10); _mask = new AABBMask(new PointFP(-16, -32), new PointFP(16, 0)); _mask.Position = _position; Dictionary<PlatformAction, PlatformAction> cmap = new Dictionary<PlatformAction, PlatformAction>(); cmap[PlatformAction.Left] = PlatformAction.Left; cmap[PlatformAction.Right] = PlatformAction.Right; cmap[PlatformAction.Up] = PlatformAction.Up; cmap[PlatformAction.Down] = PlatformAction.Down; cmap[PlatformAction.Jump] = PlatformAction.Jump; cmap[PlatformAction.Action] = PlatformAction.Action; /*PaddleMovement<PaddleAction> behavior = new PaddleMovement<PaddleAction>(this, "player", cmap); behavior.Origin = new Vector2(400, 200); behavior.Range = 100; behavior.Speed = 120; behavior.Direction = PaddleDirection.Vertical; AddBehavior(behavior);*/ /*PlayerPlatformMovement<PlatformAction> behavior = new PlayerPlatformMovement<PlatformAction>(this, "player", cmap); behavior.AccelX = (FPInt)0.5; behavior.DecelX = (FPInt)0.25; behavior.MinVelocityX = (FPInt)(-3); behavior.MaxVelocityX = (FPInt)3; behavior.AccelY = (FPInt)0.4; behavior.MinVelocityY = -12; behavior.MaxVelocityY = 12; behavior.AccelStateY = PlatformAccelState.Accelerate;*/ //AddBehavior(behavior); CircleMovement circle = new CircleMovement(this, new PointFP(300, 300), 150, 1); AddBehavior(circle); }
private void OnEnable() { _circleMovement = (CircleMovement)target; SetHelpboxText(); }