void Start() { rb = this.gameObject.GetComponent <Rigidbody2D>(); MainCamera = Camera.main; mv = this.gameObject.GetComponent <MovementClass>(); obpool = ObjectPooler.instance; }
public LayerMask whatIsPlayer; // Layermask for the overlap circle private void Start() { player = GameObject.Find("Player"); movement = FindObjectOfType <MovementClass>(); //Used to grab varibles from the player movement script anim = GetComponentInParent <Animator>(); rb2d = GetComponent <Rigidbody2D>(); icicle = this.gameObject; }
void Awake() { rigidBody = this.gameObject.GetComponent <Rigidbody2D>(); if (mv != null) { mv = this.gameObject.AddComponent <MovementClass>(); } mv = this.gameObject.GetComponent <MovementClass>(); // Destroy(gameObject, 2f); }
void Start() { movement = FindObjectOfType <MovementClass>(); //References the movement script onScreen = FindObjectOfType <OnScreen>(); // References the onscreen script swipe = FindObjectOfType <Swipe>(); iceScript = FindObjectOfType <Ice>(); Player = this.gameObject; // Sets the pkayer variable }
private MovementClass movement; // Gets the player movement script void Start() { anim = book.gameObject.GetComponent <Animator>(); book.enabled = false; movement = FindObjectOfType <MovementClass>(); tutorialPage.SetActive(false); elementPage.SetActive(false); tapToExit.SetActive(false); background.enabled = false; }
private void Start() { player = GameObject.Find("Player"); movement = FindObjectOfType <MovementClass>(); anim = player.GetComponent <Animator>(); }
void Start() { steamPushArea = GetComponent <CapsuleCollider2D>(); pushForce = new Vector2(10, 0); movement = FindObjectOfType <MovementClass>(); }
// Get movement invocation public void Movement(object movement) { // Deserialize the Key Stroke Object MovementClass movementClass = JsonConvert.DeserializeObject <MovementClass>(movement.ToString()); if (movementClass.left) { players[Context.ConnectionId].angle += 3; // Turn rate players[Context.ConnectionId].angle %= 360; // Keep the angle within 0 < x < 360 } if (movementClass.right) { players[Context.ConnectionId].angle -= 3; players[Context.ConnectionId].angle %= 360; } if (movementClass.up) { players[Context.ConnectionId].x += (int)(Math.Cos(players[Context.ConnectionId].angle * (Math.PI / 180)) * 3.5); // X advance (based on angle) players[Context.ConnectionId].y -= (int)(Math.Sin(players[Context.ConnectionId].angle * (Math.PI / 180)) * 3.5); // Y advance (based on angle) } if (movementClass.down) { players[Context.ConnectionId].x -= (int)(Math.Cos(players[Context.ConnectionId].angle * (Math.PI / 180)) * 3.5); players[Context.ConnectionId].y += (int)(Math.Sin(players[Context.ConnectionId].angle * (Math.PI / 180)) * 3.5); } if (movementClass.space) // SHOOT! { DateTime nowPress = DateTime.Now; // Get Time Right Now! if (nowPress.Subtract(lastPress[Context.ConnectionId]).TotalMilliseconds > fireRate) // If time between now and last pressed is greater than our chosen fire rate. { // Update our last pressed time lastPress[Context.ConnectionId] = nowPress; // Create a new Bullet and add it to that players List<Bullet> players[Context.ConnectionId].bullets.Add(new Bullet(players[Context.ConnectionId].x, players[Context.ConnectionId].y, players[Context.ConnectionId].angle)); } } // This uses the updated movements to calculate the new coordinates of the ship. // Reference added. float radians = (float)((Math.PI / 180.0) * players[Context.ConnectionId].angle); float cos = (float)Math.Cos(radians); float sin = (float)Math.Sin(radians); int x = players[Context.ConnectionId].x; int y = players[Context.ConnectionId].y; int ax = x + 10; int ay = y; int bx = x - 15; int by = y - 12; int cx = x - 15; int cy = y + 12; players[Context.ConnectionId].ax = (int)((cos * (ax - x)) + (sin * (ay - y)) + x); players[Context.ConnectionId].ay = (int)((cos * (ay - y)) - (sin * (ax - x)) + ay); players[Context.ConnectionId].bx = (int)((cos * (bx - x)) + (sin * (by - y)) + x); players[Context.ConnectionId].by = (int)((cos * (by - y)) - (sin * (bx - x)) + y); players[Context.ConnectionId].cx = (int)((cos * (cx - x)) + (sin * (cy - y)) + x); players[Context.ConnectionId].cy = (int)((cos * (cy - y)) - (sin * (cx - x)) + y); }
//Add Functions: /* * void Add(MovementClass nclass): * Function: Adds in the Mover a new MovementClass. * Usefulness: To insert a MovementClass in the list. * * void Add(float ntime): * Function: Adds in the Mover a "nothing" MovementClass with a particular delay. * Usefulness: To easily insert a wait in the MovementClass. * * void Add(MovType ntype, Vector3 nmovement, float ntime, bool nlocal, bool nincremental): * Function: Adds in the Mover a new MovementClass with all their parameters separated. * Usefulness: To insert a MovementClass in the list with their elements separated. * * void Add(string ntype, Vector3 nmovement, float ntime): * Function: Adds in the Mover a new MovementClass with all their parameters separated. * The string type is identified in the string[] types (nt, tr, rt, sc, sz, atr, art, asc, asz). * It assumes it's always local the movement. * Usefulness: To insert a MovementClass in the list with their elements separated and the string including local and incremental. * */ public void Add(MovementClass nclass) { dict.Add(nclass); }
private void Start() { movement = FindObjectOfType <MovementClass>(); }
private void Start() { onScreen = FindObjectOfType <OnScreen>(); movement = FindObjectOfType <MovementClass>(); box = this.gameObject.GetComponent <BoxCollider2D>(); }