void Awake() { core = Core.instance; core.SetPlayer(transform); playerInput = PlayerInput.instance; player = ReInput.players.GetPlayer(playerID); characterController = GetComponent <CharacterController>(); rb = GetComponent <Rigidbody>(); turn = new Turn(this); faceTarget = new FaceTarget(this, inputLibrary.Left_Shoulder); move = new Move(this); strafing = new Strafing(this, inputLibrary.Left_Trigger); customGravity = new CustomGravity(this); groundedCheck = new GroundedCheck(this); edgeCheck = new EdgeCheck(this); jump = new Jump(this, inputLibrary.A); dash = new Dash(this, inputLibrary.Right_Shoulder); attackFast = new Attack(this, inputLibrary.X, playerProfile.attack); attackHeavy = new Attack(this, inputLibrary.Y, playerProfile.attackHeavy); attackFeint = new Attack(this, inputLibrary.B, playerProfile.attackFeint); // AnimationControl should be instantiated last to enable // connections to former components //animationControl = new AnimationControl(this, move); }
public void TriggerDespawnEvent(CameraEdgeController alerted, EdgeCheck edge) { if (UseWarp) { if (true && !alerted.containsPoint(alerted.attachedPlayer.transform.position)) //TODO: If no other camera edge controls this player { CameraPlayerMap[alerted].gameObject.SetActive(false); } } }
public override void SetupBrain(Agent agent) { _agent = agent; _eyes = _agent.GetComponentInChildren <Eyesight>(); _edgeCheck = _agent.GetComponent <EdgeCheck>(); Attack = false; MoveInput = 0; _movingRight = true; _turning = false; _searching = false; DeathManager.Enemies.Add(agent); }
public void TriggerSpawnEvent(CameraEdgeController alerted, EdgeCheck edge) //Gets called when this camera's edge collider detects the player { if (UseWarp) { WarpTo destination = alerted.getWarp(edge.dir); if (!CameraPlayerMap[destination.cam].gameObject.activeInHierarchy) //If no other camera is currently using this player { PlayerMovement Clone = CameraPlayerMap[destination.cam]; PlayerMovement Source = CameraPlayerMap[alerted]; Vector3 offset = edge.transform.position - Source.transform.position; Clone.transform.position = destination.edge.transform.position - offset; Clone.gameObject.SetActive(true); Clone.GetComponent <Rigidbody2D>().velocity = Source.GetComponent <Rigidbody2D>().velocity; //TODO: Keep player variables consistent //Clone.CopyState(Source); } } }
void GenerateColliders() { if (useCustomEdges) { leftEdge.dir = Direction.LEFT; leftCollider = leftEdge.GetComponent <EdgeCollider2D>(); rightEdge.dir = Direction.RIGHT; rightCollider = rightEdge.GetComponent <EdgeCollider2D>(); topEdge.dir = Direction.UP; topCollider = topEdge.GetComponent <EdgeCollider2D>(); bottomEdge.dir = Direction.DOWN; bottomCollider = bottomEdge.GetComponent <EdgeCollider2D>(); } else { leftCollider = Instantiate(EdgePrefab, this.transform, false).GetComponent <EdgeCollider2D>(); leftCollider.name = "Left"; leftEdge = leftCollider.GetComponent <EdgeCheck>(); leftEdge.dir = Direction.LEFT; rightCollider = Instantiate(EdgePrefab, this.transform, false).GetComponent <EdgeCollider2D>(); rightCollider.name = "Right"; rightEdge = rightCollider.GetComponent <EdgeCheck>(); rightEdge.dir = Direction.RIGHT; topCollider = Instantiate(EdgePrefab, this.transform, false).GetComponent <EdgeCollider2D>(); topCollider.name = "Top"; topEdge = topCollider.GetComponent <EdgeCheck>(); topEdge.dir = Direction.UP; bottomCollider = Instantiate(EdgePrefab, this.transform, false).GetComponent <EdgeCollider2D>(); bottomCollider.name = "Bottom"; bottomEdge = bottomCollider.GetComponent <EdgeCheck>(); bottomEdge.dir = Direction.DOWN; } }
public WarpTo(CameraEdgeController newCam, EdgeCheck newEdge) { cam = newCam; edge = newEdge; }