public EnemyShipController PrefabInstantiate(PlanetController planet, Vector2 orbit, Vector2 position, bool immobile) { EnemyShipController ship = ((GameObject)Object.Instantiate(gameObject)).GetComponent <EnemyShipController>(); FlyController fly = ship.GetComponent <FlyController>(); PointGravityController pgrav = ship.GetComponent <PointGravityController>(); HullController hull = ship.GetComponent <HullController>(); Animator anim = ship.GetComponent <Animator>(); ship.PrefabName = name; if (immobile) { ship.state = Modes.Appearing; ship.GetComponent <Rigidbody2D>().isKinematic = hull.InitialShieldPower > 0; ship.transform.position = orbit; fly.enabled = false; pgrav.enabled = false; GetComponent <Collider2D>().enabled = false; anim.SetTrigger("Appear"); } else { ship.state = Modes.Flying; fly.PrepareFly(orbit, planet); ship.transform.position = position; } ship.Planet = planet; return(ship); }
private void OnTriggerEnter2D(Collider2D collision) { // If collided object is on "Water" layer if (collision.gameObject.layer == 10) { OnDestroyProjectile?.Invoke(this); return; } if (collision.GetComponent <Projectile>()) { return; } if (collision.gameObject != this) { Bubble collidedBubble = collision.GetComponent <Bubble>(); BubbleBehaviour collidedBehaviour; if (collidedBubble) { collidedBehaviour = collidedBubble.type.bubbleBehaviour; collidedBehaviour?.OnShot(collision.gameObject, gameObject); LevelManager.AddToScore(collidedBubble.type.shootScore); LevelManager.currentBubblesPopped++; } FlyController flyController = collision.GetComponent <FlyController>(); } // Makes projectile system remove this from it's projectile list & destroys this OnDestroyProjectile?.Invoke(this); }
private void OnCollisionEnter2D(Collision2D collision) { Collider2D[] currentCollisions = new Collider2D[2]; ContactFilter2D filter2D = new ContactFilter2D(); LayerMask handsMask = LayerMask.GetMask("Hands"); filter2D.SetLayerMask(handsMask); collider.OverlapCollider(filter2D, currentCollisions); if (currentCollisions[0] != null && currentCollisions[1] != null) { if (currentCollisions[0].bounds.Intersects(currentCollisions[1].bounds)) { // is colliding with both hands and hands are touching eachother FlyController flyController = GetComponent <FlyController>(); if (flyController != null) { flyController.DamageFly(); return; } KidFlyController kidFly = GetComponent <KidFlyController>(); if (kidFly != null) { kidFly.DamageFly(); return; } } } }
public void OnPlayerEnterWorld(IConnection connection, Player player) { string uidHex = BitConverter.GetBytes(player.UID).ToHex() + BitConverter.GetBytes(ObjectFamily.Player.GetHashCode()).ToHex(); new SendPacket("8FCD00000000").Send(connection); //1725 EU new SendPacket("0D9600000000").Send(connection); //1725 EU //new SpFriendList(pState.Player.Friends).Send(connection); //new SpFriendUpdate(pState.Player.Friends).Send(connection); new SendPacket("A7F20000000000000000").Send(connection); //1725 EU new SendPacket("03E70000000000000000").Send(connection); //1725 EU new SpCharacterPosition(player).Send(connection); FlyController flyController = player.Controller as FlyController; if (flyController != null) { flyController.EndFly(player.Position.MapId); } new SendPacket("E1EB" + uidHex + "7CC4000001FFFFFF7F").Send(connection); //1725 EU new SpCharacterStats(player).Send(connection); new SpCharacterGatherstats(player.PlayerCraftStats).Send(connection); CraftService.UpdateCraftRecipes(player); player.LastOnlineUtc = Funcs.GetRoundedUtc(); }
void Awake() { hull = GetComponent <HullController>(); flyController = GetComponent <FlyController>(); flyController.OnFlyingComplete += OnFlyComplete; camController = Camera.main.GetComponent <CameraController>(); animator = GetComponent <Animator>(); }
public void Launch(FlyController flyController) { controller = flyController; Vector2 forceDirection = (transform.up * (launchSpeed + flyController.body.velocity.magnitude)); // I've heard rumors that setting velocity directly is not good, I don't care, maybe you should body.velocity = forceDirection; }
public override void OnShot(GameObject thisGO, GameObject shotByGO) { FlyController controller = shotByGO.GetComponent <Projectile>().controller; Bubble bubble = thisGO.GetComponent <Bubble>(); controller?.OnIncreaseScore(controller.playerIndex, bubble.type.shootScore); controller?.OnHitBubble(thisGO.transform.position, bubble.type.shootScore); bubble.BeginDestroy(); }
public AsteroidController PrefabInstantiate(PlanetController planet, Vector2 orbit, Vector2 position) { AsteroidController a = ((GameObject)GameObject.Instantiate(gameObject)).GetComponent <AsteroidController>(); FlyController fly = a.GetComponent <FlyController>(); a.transform.position = position; a.planet = planet; fly.PrepareFly(orbit, planet); return(a); }
public void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Fly") { // kill the fly and stick it to the tongue FlyController fc = other.gameObject.GetComponent <FlyController>(); fc.Die(); fc.transform.SetParent(this.transform); } }
private void SubscribeToFlyKilledEvent(GameObject fly) { FlyController flyController = fly.GetComponent <FlyController>(); if (!flyController) { return; } flyController.FlyKilledEvent += UpdateScore; }
public override void OnCollided(GameObject thisGO, GameObject collidedWithGO) { FlyController controller = collidedWithGO.GetComponent <FlyController>(); if (controller) { controller?.OnDecreaseScore(controller.playerIndex, deductPoints); controller.flightSpeedVariable = slowDownVariable; controller.StartCoroutine(ResetSpeed(controller)); controller?.OnHitBubble(thisGO.transform.position, -deductPoints); } }
public override void OnCollided(GameObject thisGO, GameObject shotByGO) { // Increase speed FlyController controller = shotByGO.GetComponent <FlyController>(); Bubble bubble = thisGO.GetComponent <Bubble>(); controller?.OnIncreaseScore(controller.playerIndex, bubble.type.collideScore); controller?.OnHitBubble(thisGO.transform.position, bubble.type.collideScore); Debug.Log("collided with gas bub"); bubble.BeginDestroy(); }
public void SpawnProjectile(FlyController flyController) { GameObject newProjectileGO = Instantiate(projectilePrefab, flyController.transform.position, flyController.transform.rotation); Projectile newProjectile = newProjectileGO.GetComponent <Projectile>(); if (newProjectile) { projectiles.Add(newProjectile); newProjectile.Launch(flyController); newProjectile.OnDestroyProjectile += RemoveProjectile; } }
public void processDragGesture(Vector2 beginPos, Vector2 endPos) { float distance = Vector3.Distance(beginPos, endPos); // // Cut Flies // RaycastHit2D[] rch2ds = Physics2D.RaycastAll(beginPos, (endPos - beginPos), distance); foreach (RaycastHit2D rch2d in rch2ds) { FlyController fc = rch2d.collider.gameObject.GetComponent <FlyController>(); if (fc) { fc.splat(); } } // // Display the slash //2017-11-20: copied from Stonicorn.TeleportStreakUpdater.position() // //Instantiate the effect GameObject cutGO = GameObject.Instantiate(cutPrefab); //Set the size Vector3 size = cutGO.GetComponent <SpriteRenderer>().bounds.size; float baseWidth = size.x; float baseHeight = size.y; //Set the position cutGO.transform.position = new Vector3(beginPos.x, beginPos.y, 1); float newSize = distance; Vector3 newV = new Vector3(newSize / baseWidth, 1.5f * baseHeight / baseHeight); cutGO.transform.localScale = newV; //Set the angle float angle = AngleSigned(endPos - beginPos, Vector3.left, Vector3.back); cutGO.transform.rotation = Quaternion.Euler(0, 0, angle); }
public void OnCollided(GameObject thisGO, GameObject collidedWithGO) { GasBubbleBehaviour poopBubbleBehaviour = collidedWithGO.GetComponent <GasBubbleBehaviour>(); if (poopBubbleBehaviour) { flightSpeedVariable = speedUpVariable; StartCoroutine(ResetSpeed(speedUpDuration)); return; } FlyController controller = collidedWithGO.GetComponent <FlyController>(); if (controller) { flightSpeedVariable = slowDownVariable; StartCoroutine(ResetSpeed(slowDownDuration)); } }
// Update is called once per frame void Update() { timeRemaining -= Time.deltaTime; timeRemainingText.text = "Time Remaining: " + Mathf.RoundToInt(timeRemaining); fliesRemainingText.text = "Flies Remaining: " + FlyController.flies.Count; if (Input.GetMouseButtonDown(0)) { bool hit = false; FlyController toRemove = null; foreach (FlyController fly in FlyController.flies) { if (fly.IsBeingClicked()) { toRemove = fly; hit = true; } } if (hit) { FlyController.flies.Remove(toRemove); toRemove.Splat(); hitText.text = "Yeah!"; Invoke("ClearHitText", 1.0f); } else { hitText.text = "Miss!"; Invoke("ClearHitText", 1.0f); } } if (FlyController.flies.Count == 0) { Win(); } else if (timeRemaining <= 0) { Lose(); } }
/// <summary> /// Processes the tap gesture with the given position in World Space /// </summary> /// <param name="tapPos"></param> public void processTapGesture(Vector2 tapPos) { int splats = 0; foreach (CircleCollider2D cc2d in FindObjectsOfType <CircleCollider2D>()) { if (cc2d.OverlapPoint(tapPos)) { FlyController fc = cc2d.gameObject.GetComponent <FlyController>(); if (fc) { splats++; fc.splat(); if (splats == splatsPerTap) { break; } } } } }
public void Initialize(PlayerInput input) { /* Debug.Log(input);*/ this.input = input; controller = GetComponent <FlyController>(); }
IEnumerator ResetSpeed(FlyController controller) { yield return(new WaitForSeconds(slowDownDuration)); controller.flightSpeedVariable = defaultFlySpeed; }
public void PlayFlyShootSound(FlyController flyController) { spitAudioSource.clip = spitSounds[Random.Range(0, spitSounds.Count)]; spitAudioSource.Play(); }