void Start() { inputControls = GameObject.FindWithTag("Player").GetComponent <InputControls>(); playerHook = GameObject.FindWithTag("Player").GetComponent <PlayerHook>(); mat = GetComponent <Renderer>().material; }
//*******************************// // MonoBehaviour Functions // //*******************************// private void Start() { m_normalTimeScale = Time.timeScale; m_ph = GetComponent <PlayerHook>(); m_pa = GetComponent <PlayerAnim>(); m_input = GetComponent <PlayerInput>(); m_pm = GetComponent <PlayerMovement>(); }
// Start is called before the first frame update void Start() { crosshair = transform.GetChild(1); crosshairSprite = crosshair.GetComponent <SpriteRenderer>(); playerMovement = gameObject.GetComponent <PlayerMovement>(); playerHook = gameObject.GetComponent <PlayerHook>(); distance = playerHook.ropeMaxCastDistance; }
public void Awake() { playerHook = GetComponent <PlayerHook>(); playerWeaponHook = GetComponentInChildren <PlayerWeaponHook>(); statAugments = GetComponentsInChildren <StatAugment>().OrderBy(sa => sa.priority).ToList(); playerLevel = GetComponent <PlayerLevel>(); playerUpgrades = GetComponent <PlayerUpgrades>(); }
void Start() { TowSprite = GetComponent <SpriteRenderer>(); phook = GameObject.Find("Player").GetComponent <PlayerHook>(); if (TowSprite == null) { Debug.Log("Cannot find tow sprite Sprite on Player"); } }
//This is for initializing values in the editor only. ApplyAugments will be triggered during build by a GameEventListener listening for any type of stat changes public void Recalculate() { myStatSystem.Awake(); PlayerHook playerHook = myStatSystem.GetComponent <PlayerHook>(); playerHook.Awake(); PlayerWeaponHook playerWeaponHook = myStatSystem.GetComponentInChildren <PlayerWeaponHook>(); playerWeaponHook.Awake(); StatAugment[] statAugments = myStatSystem.GetComponentsInChildren <StatAugment>(); foreach (StatAugment augment in statAugments) { augment.Awake(); } myStatSystem.ApplyAugments(); }
public override void UpdateEffects(Player player) { PlayerHook modPlayer = player.GetModPlayer <PlayerHook>(mod); modPlayer.copterBrake = false; float tilt = player.fullRotation; if (player.wet || player.honeyWet || player.lavaWet) { player.mount.Dismount(player); return; } //Only keep flying, when the player is holding up if (player.controlUp || player.controlJump) { player.mount._abilityCharging = true; player.mount._flyTime = 0; player.mount._fatigue = -verticalSpeed; } else { player.mount._abilityCharging = false; } //Slow down the helicopter, if it's on the ground if (modPlayer.onGround) { if (player.controlUp || player.controlJump) { player.position.Y -= mountData.acceleration; } else { modPlayer.copterBrake = true; } } //tilt the helicopter tilt = player.velocity.X * (MathHelper.PiOver2 * 0.125f); tilt = (float)Math.Sin(tilt) * maxTilt; player.fullRotation = tilt; player.fullRotationOrigin = new Vector2(10f, 14f); //If you change this, also change the x and y values below. //Scan for enemies and fire at them if (player.mount._abilityCooldown == 0) { //Don't change these values, unless you want to adjust the nozzle position. float x = 20f * player.direction; float y = 12f; float sin = (float)Math.Sin(tilt); float cos = (float)Math.Cos(tilt); Vector2 muzzle = new Vector2(x * cos - y * sin, x * sin + y * cos); muzzle = muzzle + player.fullRotationOrigin + player.position; //Readjust the scanning cone to the current position. float direction; if (player.direction == 1) { direction = FOVHelper.POS_X_DIR + tilt; } else { direction = FOVHelper.NEG_X_DIR - tilt; } helper.adjustCone(muzzle, fov, direction); //Look for the nearest, unobscured enemy inside the cone NPC nearest = null; float distNearest = rangeSquare; for (int i = 0; i < 200; i++) { NPC npc = Main.npc[i]; Vector2 npcCenter = npc.Center; if (npc.CanBeChasedBy() && helper.isInCone(npcCenter)) //first param of canBeChasedBy has no effect { float distCurrent = Vector2.DistanceSquared(muzzle, npcCenter); if (distCurrent < distNearest && Collision.CanHitLine(muzzle, 0, 0, npc.position, npc.width, npc.height)) { nearest = npc; distNearest = distCurrent; } } } //Shoot 'em dead if (nearest != null) { if (player.whoAmI == Main.myPlayer) { Vector2 aim = nearest.Center - muzzle; aim.Normalize(); aim *= velocity; float vX = aim.X; float vY = aim.Y; //This precisely mimics the Gatligators spread Random rand = Main.rand; vX += rand.Next(-50, 51) * 0.03f; vY += rand.Next(-50, 51) * 0.03f; vX += rand.Next(-40, 41) * 0.05f; vY += rand.Next(-40, 41) * 0.05f; if (rand.Next(3) == 0) { vX += Main.rand.Next(-30, 31) * 0.02f; vY += Main.rand.Next(-30, 31) * 0.02f; } Projectile.NewProjectile(muzzle.X, muzzle.Y, vX, vY, mod.ProjectileType("CandyCopterBullet"), (int)(damage * player.minionDamage), knockback * player.minionKB, player.whoAmI); //CandyCopterBullet } Point point = player.Center.ToTileCoordinates(); Lighting.AddLight(point.X, point.Y, lightColor.X, lightColor.Y, lightColor.Z); modPlayer.copterFiring = true; modPlayer.copterFireFrame = 0; player.mount._abilityCooldown = cooldown - 1; } else { modPlayer.copterFiring = false; } return; } else if (player.mount._abilityCooldown > cooldown) { player.mount._abilityCooldown = cooldown; } }
public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity) { PlayerHook modPlayer = mountedPlayer.GetModPlayer <PlayerHook>(mod); Mount mount = mountedPlayer.mount; //Part of vanilla code, mount will glitch out // if this is not executed. if (mount._frameState != state) { mount._frameState = state; } //End of required vanilla code //Adjust animation speed after landing/takeoff if (state == 0) { if (mount._idleTime > 0) { mount._idleTime--; } } else { if (mount._idleTime < revUpFrames) { mount._idleTime += 4; } } float throttle = 1; if (mount._idleTime < revUpFrames) { throttle = (mount._idleTime) / (float)revUpFrames; } //Choose next frame mount._frameCounter += throttle; if ((int)mount._frameCounter >= mountData.inAirFrameDelay) { mount._frameCounter -= mountData.inAirFrameDelay; mount._frameExtra++; if (mount._frameExtra >= mountData.inAirFrameCount) { mount._frameExtra = 0; } } mount._frame = mount._frameExtra; if (modPlayer.copterFireFrame >= muzzleFrames) { mount._frame = mount._frameExtra; } else if (modPlayer.copterFireFrame >= muzzleFrames >> 1) { mount._frame = mount._frameExtra + mountData.inAirFrameCount; } else { mount._frame = mount._frameExtra + 2 * mountData.inAirFrameCount; } return(false); }