public PetIdleState(PetObject obj) : base(obj) { m_OwnerTarget = pet.owner.GetComponent <PlayerTarget>(); m_OwnerDamagable = pet.owner.GetComponent <DamagableObject>(); m_PetWeapon = pet.GetComponent <PetWeapon>(); m_PetTarget = pet.GetComponent <PlayerTarget>(); }
private void UpdateTargetedPlayer() { RaycastHit hit; // Find nearest visible player. targetedPlayer = null; float targetedPlayerDistance2 = float.PositiveInfinity; foreach (PlayerTarget player in PlayerTarget.Players) { Vector3 relativePlayerPosition = player.transform.position - transform.position; float playerDistance2 = relativePlayerPosition.sqrMagnitude; if (playerDistance2 >= targetedPlayerDistance2) { continue; } if (Physics.Raycast(transform.position, relativePlayerPosition, out hit, Mathf.Sqrt(playerDistance2), SensorLevelLayers)) { continue; } targetedPlayer = player; targetedPlayerDistance2 = playerDistance2; Rigidbody rbody = player.GetComponent <Rigidbody>(); foreach (AITargetObserver observer in observers) { observer.Target = rbody; } } }
private void ChangePlayerTarget() { if (Board.Player == null) { return; } switch (_playerTarget) { case PlayerTarget.Top: _playerTarget = PlayerTarget.Right; break; case PlayerTarget.Right: _playerTarget = PlayerTarget.Bottom; break; case PlayerTarget.Bottom: _playerTarget = PlayerTarget.Left; break; case PlayerTarget.Left: _playerTarget = PlayerTarget.Top; break; default: break; } }
public void UpdatePlayerTargetPosition(GameObject targetObject) { ClearTargetPosition(); Target = new PlayerTarget(targetObject); ToggleEnemyTargetVisibility(true); UpdateAnimationParameters(); }
public LootState(Stack <IBotState> botStates, Player player, KeyBindSender keyBindSender) { _botStates = botStates; _player = player; _keyBindSender = keyBindSender; _target = player.Target; }
public void Attack() { PlayerTarget target = player.transform.GetComponent <PlayerTarget>(); if (target != null) { target.PlayerDamage(10); } }
private void OnTriggerEnter2D(Collider2D collision) { PlayerTarget player = collision.gameObject.GetComponent <PlayerTarget>(); if (player != null) { CheckOpen(player); } }
public override void Start() { if (!m_StartCalled) { m_StartCalled = true; base.Start(); m_Character = GetComponent<PlayerCharacterObject>(); m_Player = GetComponent<MmoActor>(); m_PlayerTarget = GetComponent<PlayerTarget>(); m_Bonuses = GetComponent<PlayerBonuses>(); } }
// Update is called once per frame void Update() { PlayerTarget playerTarget = player.GetComponent <PlayerTarget>(); if (playerTarget.IsDead == true) { playerTarget.IsDead = false; player.transform.position = SpawnPoint.position; player.SetActive(true); } }
void Shoot() { StartCoroutine(TBB(currentWeaponTbb)); particles[currentWeapon].Play(); audioSource.clip = ShotSounds[currentWeapon]; audioSource.Play(); if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range)) { target = hit.transform.GetComponent <Target>(); playerTarget = hit.transform.GetComponent <PlayerTarget>(); if (target != null) { target.TakeDmg(damage); DealDmgObj(); Debug.Log("takes dmg"); } if (playerTarget != null) { playerTarget.TakeDmg(damage); DealDmgPlayer(); Debug.Log("player hit"); } if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * impactForce); KnockBack(); Debug.Log("adds knockback"); } } Debug.Log("shoots"); GameObject impactObj = Instantiate(impactParticle, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(impactObj, 2f); NetworkServer.Spawn(impactObj); if (t < 0) { NetworkServer.Destroy(impactObj); t = 2f; } else { t -= Time.deltaTime; } weapons[currentWeapon].GetComponent <Animation>().Play(); }
private void OnTriggerEnter2D(Collider2D collision) { if (!collision.CompareTag("Enemy") && !collision.CompareTag("Projectile") && !collision.CompareTag("Powerup")) { PlayerTarget target = collision.transform.GetComponent <PlayerTarget>(); if (target != null) { target.TakeDamage(damage); } Destroy(this.gameObject); } }
private void damageAndPushPlayer(Collider2D collider) { if (collider.CompareTag("Player")) { PlayerTarget target = collider.transform.GetComponent <PlayerTarget>(); if (target != null) { target.TakeDamage(impactDamage); // pushing the player away from the enemy collider.transform.GetComponent <Rigidbody2D>().AddForce(calculateNormalizedCollisionVector(collider.transform) * impactForce); } } }
public override void Start() { base.Start(); mWeapon = RequireComponent <BaseWeapon>(); mMessage = RequireComponent <MmoMessageComponent>(); mCharacter = RequireComponent <CharacterObject>(); mTarget = RequireComponent <PlayerTarget>(); mMovable = GetComponent <MovableObject>(); m_Skills = GetComponent <PlayerSkills>(); m_Bonuses = GetComponent <PlayerBonuses>(); mChestLiveDuration = nebulaObject.world.Resource().ServerInputs.GetValue <float>("chest_life"); //log.InfoFormat("chest life = {0}", mChestLiveDuration); mShotTimer = m_ShotCooldown; mDead = false; combatAIType = aiType as CombatAIType; if (combatAIType == null) { log.Error("CombatBasseAI must have CombatAIType, but not simple AIType"); } mShipWeapon = GetComponent <ShipWeapon>(); if (Rand.Int() % 2 == 0) { mMovNearTargetType = MovingNearTarget.Circle; } else { mMovNearTargetType = MovingNearTarget.LIne; } mStartPosition = nebulaObject.transform.position; #if USE_SKILLS //--------------------------TESTING------------------------------------ var ship = GetComponent <BaseShip>(); if (ship) { string sSkill = skills[Rand.Int(skills.Count - 1)]; ship.shipModel.Slot(ShipModelSlotType.CB).Module.SetSkill(SkillExecutor.SkilIDFromHexString(sSkill)); mSkills = GetComponent <PlayerSkills>(); mSkills.UpdateSkills(ship.shipModel); } //-------------------------------------------------------------------- #endif mBotObject = GetComponent <BotObject>(); SetupSkills(); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { PlayerTarget target = collision.transform.GetComponent <PlayerTarget>(); if (target != null) { target.TakeHealing(healing); } Debug.Log("Health collided with something!"); Destroy(this.gameObject); } }
public override void Start() { base.Start(); m_Pet = GetComponent <PetObject>(); m_Target = GetComponent <PlayerTarget>(); m_Message = GetComponent <MmoMessageComponent>(); m_Race = GetComponent <RaceableObject>(); if (m_Pet) { if (m_Pet.info != null) { m_Timer = m_Pet.info.Cooldown(nebulaObject.resource.petParameters.cooldown); } } }
private void CmdExplode() { GameObject expl = Instantiate(explosion, transform.position, transform.rotation); NetworkServer.Spawn(expl); Collider[] collidersToDestroy = Physics.OverlapSphere(transform.position, raduis); foreach (Collider nearObj in collidersToDestroy) { Target target = nearObj.GetComponent <Target>(); PlayerTarget playerTarget = nearObj.GetComponent <PlayerTarget>(); if (target != null) { target.TakeDmg(damage); } if (playerTarget != null) { playerTarget.TakeDmg(damage); } } foreach (Collider nearTerrain in collidersToDestroy) { Terrain terrain = nearTerrain.GetComponent <Terrain>(); if (terrain != null) { terrainD.DestroyTerrain(); } else { NetworkServer.Destroy(gameObject); Destroy(gameObject); } } Collider[] collidersToMove = Physics.OverlapSphere(transform.position, raduis); foreach (Collider nearObj in collidersToMove) { Rigidbody rb = nearObj.GetComponent <Rigidbody>(); if (rb != null) { rb.AddExplosionForce(force, transform.position, raduis); } } }
private void LoadFromXML(XElement xEntity) { LifeCount = (int)xEntity.Attribute("Life"); _stepSize = (int)xEntity.Attribute("StepSize"); _movePattern = xEntity.Attribute("MovePattern") != null ? (MovePattern)Enum.Parse(typeof(MovePattern), xEntity.Attribute("MovePattern").Value) : _movePattern; int centerRow = xEntity.Attribute("CenterRow") != null? int.Parse(xEntity.Attribute("CenterRow").Value) : -1; int centerCol = xEntity.Attribute("CenterCol") != null? int.Parse(xEntity.Attribute("CenterCol").Value) : -1; if (centerRow != -1 && centerCol != -1) { _circleCenter = new Position(centerRow, centerCol); } _isClockwise = xEntity.Attribute("_isClockwise") != null? bool.Parse(xEntity.Attribute("_isClockwise").Value) : _isClockwise; _movePace = xEntity.Attribute("MovePace") != null ? (MovePace)Enum.Parse(typeof(MovePace), xEntity.Attribute("MovePace").Value) : _movePace; StepInterval = xEntity.Attribute("StepInterval") != null? int.Parse(xEntity.Attribute("StepInterval").Value) : StepInterval; _playerTarget = xEntity.Attribute("PlayerTarget") != null ? (PlayerTarget)Enum.Parse(typeof(PlayerTarget), xEntity.Attribute("PlayerTarget").Value) : _playerTarget; _stepQuantum = xEntity.Attribute("StepQuantum") != null? int.Parse(xEntity.Attribute("StepQuantum").Value) : _stepQuantum; _stepQuantumCounter = xEntity.Attribute("StepQuantumCounter") != null? int.Parse(xEntity.Attribute("StepQuantumCounter").Value) : _stepQuantumCounter; XElement xDirection = xEntity.Element("MoveDirection"); if (xDirection != null) { _moveDirection.Up = (bool)xDirection.Attribute("Up"); _moveDirection.Down = (bool)xDirection.Attribute("Down"); _moveDirection.Left = (bool)xDirection.Attribute("Left"); _moveDirection.Right = (bool)xDirection.Attribute("Right"); } if (xEntity.Attribute("ImageURI") != null) { Image.Source = new BitmapImage(new Uri(xEntity.Attribute("ImageURI").Value)); } }
public void Process(byte[] buffer, IConnection connection) { var pData = Authentication.Players[connection.Index]; var msg = new ByteBuffer(buffer); var target = msg.ReadInt32(); var targetType = msg.ReadInt32(); if (Enum.IsDefined(typeof(TargetType), targetType)) { var changeTarget = new PlayerTarget() { Player = Authentication.Players[connection.Index] }; changeTarget.ChangeTarget(target, (TargetType)targetType); } }
// Use this for initialization void Start() { UpdateTarget(); updatingTarget = false; playerTarget = GameObject.FindWithTag("PlayerTarget").GetComponent <PlayerTarget>(); damageOverTime = DAMAGE_OVER_TIME; fireRate = FIRE_RATE; laserSound = true; am = GameObject.FindGameObjectWithTag("gamemanager").GetComponent <AudioManager>(); slowReduction = slowReduction / (damageMultiplier * 1.25f); if (moneyTurret) { StartCoroutine(GivePlayerMoney()); } nodeIsPressed = false; currentFirePoint = 0; }
void CheckOpen(PlayerTarget player) { if (redDoor && player.redTarget) { doorBlock.SetActive(false); player.redTarget = false; AudioManager.GetInstance().Play("Door"); } else if (blueDoor && player.blueTarget) { doorBlock.SetActive(false); player.blueTarget = false; AudioManager.GetInstance().Play("Door"); } else if (yellowDoor && player.yellowTarget) { doorBlock.SetActive(false); player.yellowTarget = false; AudioManager.GetInstance().Play("Door"); } }
public Enemy(int id, Board board, Position position = null, XElement xEntity = null) : base(id, board, EntityType.Enemy, position) { InitTimer(); if (xEntity != null) { LoadFromXML(xEntity); } else { InitMovePattern(); InitMovePace(); InitMoveDirection(); _stepSize = DEFAULT_STEP_SIZE; _playerTarget = PlayerTarget.Top; LifeCount = DEFAULT_LIFE_COUNT; CurrentStepInterval = StepInterval = BEGINNER_STEP_INTERVAL; } }
public override void Start() { if (!m_StartCalled) { m_StartCalled = true; mShip = RequireComponent <PlayerShip>(); mTarget = RequireComponent <PlayerTarget>(); mCharacter = RequireComponent <PlayerCharacterObject>(); mAI = RequireComponent <AIState>(); mRace = RequireComponent <RaceableObject>(); mMessage = RequireComponent <MmoMessageComponent>(); mDamagable = RequireComponent <ShipBasedDamagableObject>(); mWeapon = RequireComponent <ShipWeapon>(); mSkills = RequireComponent <PlayerSkills>(); mBonuses = RequireComponent <PlayerBonuses>(); mPassiveBonuses = GetComponent <PassiveBonusesComponent>(); mCharacter.SetCharacterId((string)nebulaObject.Tag((byte)PlayerTags.CharacterId)); mCharacter.SetCharacterName((string)nebulaObject.Tag((byte)PlayerTags.Name)); printPropertiesTimer = printPropertiesInterval; if (application.serverActors.ContainsKey(nebulaObject.Id)) { MmoActor old; if (application.serverActors.TryRemove(nebulaObject.Id, out old)) { log.Info("successfully remove actor before replacing with new [red]"); } } if (application.serverActors.TryAdd(nebulaObject.Id, this)) { log.Info("successfully added actor to server actors [red]"); } //create chest on killing when player die mDamagable.SetCreateChestOnKilling(true); mDamagable.SetIgnoreDamageInterval(30); mDamagable.SetIgnoreDamageAtStart(true); } }
public PlayerTarget GetClosestPlayerToDistance(Vector3 argInMyPosition, float argInDistance) { PlayerTarget bestTargetNonInv = null; PlayerTarget bestTargetInv = null; float closestDistanceSqr = Mathf.Infinity; //Vector3 currentPosition = argInMyPosition; foreach (PlayerTarget potentialTarget in playerTargets) { if (potentialTarget.isInvulnerable == false) { float distance = Vector3.Distance(((Component)potentialTarget).gameObject.transform.position, argInMyPosition); float dist = Mathf.Abs(distance - argInDistance); if (dist < closestDistanceSqr) { closestDistanceSqr = dist; bestTargetNonInv = potentialTarget; } } else { float distance = Vector3.Distance(((Component)potentialTarget).gameObject.transform.position, argInMyPosition); float dist = Mathf.Abs(distance - argInDistance); if (dist < closestDistanceSqr) { closestDistanceSqr = dist; bestTargetInv = potentialTarget; } } } if (bestTargetNonInv != null) { return(bestTargetNonInv); } return(bestTargetInv); }
public PlayerTarget GetPlayerClosestToItsObjective(PlayerTarget argInCaller) { PlayerTarget bestTargetNonInv = null; PlayerTarget bestTargetInv = null; float closestDistanceSqr = Mathf.Infinity; foreach (PlayerTarget potentialTarget in playerTargets) { if (potentialTarget != argInCaller) { if (potentialTarget.isInvulnerable == false) { float dist = Vector3.Distance(((Component)potentialTarget).gameObject.transform.position, potentialTarget.globalObjective); if (dist < closestDistanceSqr) { closestDistanceSqr = dist; bestTargetNonInv = potentialTarget; } } else { float dist = Vector3.Distance(((Component)potentialTarget).gameObject.transform.position, potentialTarget.globalObjective); if (dist < closestDistanceSqr) { closestDistanceSqr = dist; bestTargetInv = potentialTarget; } } } } if (bestTargetNonInv != null) { return(bestTargetNonInv); } return(bestTargetInv); }
void OnCollisionEnter(Collision col) { if (col.gameObject.tag == "Player") { playerInfo = col.gameObject.GetComponent<PlayerTarget>(); if (playerInfo.teamNumber != thrownByTeam) { playerInfo.health -= 1; } } if (col.gameObject.tag == "ForceField") { GameObject Sparked = (GameObject) Instantiate(Sparks, transform.position, Quaternion.identity); Destroy(Sparked, 3f); } else if (col.gameObject.tag != "Player" || col.gameObject.tag != "ForceField") { int SelectSoundFile = Random.Range(0, 4); PlaySound(SelectSoundFile); } }
public PlayerTarget GetClosestPlayerTarget(Vector3 argInMyPosition) { PlayerTarget bestTargetNonInv = null; PlayerTarget bestTargetInv = null; float closestDistanceSqr = Mathf.Infinity; Vector3 currentPosition = argInMyPosition; foreach (PlayerTarget potentialTarget in playerTargets) { if (potentialTarget.isInvulnerable == false) { Vector3 directionToTarget = ((Component)potentialTarget).gameObject.transform.position - currentPosition; float dSqrToTarget = directionToTarget.sqrMagnitude; if (dSqrToTarget < closestDistanceSqr) { closestDistanceSqr = dSqrToTarget; bestTargetNonInv = potentialTarget; } } else { Vector3 directionToTarget = ((Component)potentialTarget).gameObject.transform.position - currentPosition; float dSqrToTarget = directionToTarget.sqrMagnitude; if (dSqrToTarget < closestDistanceSqr) { closestDistanceSqr = dSqrToTarget; bestTargetInv = potentialTarget; } } } if (bestTargetNonInv != null) { return(bestTargetNonInv); } return(bestTargetInv); }
void Shoot() { Debug.Log("Fire!"); _anim.SetBool("Fire", true); if (_nextTimeToFire <= Time.time) { FindObjectOfType <AudioManager>().Play("Rifle"); _nextTimeToFire = Time.time + 1 / fireRate; RaycastHit hit; if (Physics.Raycast(gunTip.position, gunTip.forward, out hit, Mathf.Infinity)) { PlayerTarget playerTarget = hit.transform.gameObject.GetComponent <PlayerTarget>(); AITarget aiTarget = hit.transform.gameObject.GetComponent <AITarget>(); if (playerTarget != null) { playerTarget.Hurt(damage, this.gameObject.transform); } if (aiTarget != null) { SphereCollider aiHead = hit.transform.gameObject.GetComponent <SphereCollider>(); CapsuleCollider aiBody = hit.transform.gameObject.GetComponent <CapsuleCollider>(); if (aiHead != null && hit.collider == aiHead) { aiTarget.HeadShot(); GameObject electricHit = Instantiate(aiTarget.electricHitPrefab, hit.point, Quaternion.identity); } else if (aiBody != null && hit.collider == aiBody) { aiTarget.TakeDamage(damage); } } } } }
private void UpdateTargetedPlayer() { RaycastHit hit; // Find nearest visible player. targetedPlayer = null; float targetedPlayerDistance2 = float.PositiveInfinity; foreach (PlayerTarget player in PlayerTarget.Players) { Vector3 relativePlayerPosition = player.transform.position - transform.position; float playerDistance2 = relativePlayerPosition.sqrMagnitude; if (playerDistance2 >= targetedPlayerDistance2) continue; if (Physics.Raycast(transform.position, relativePlayerPosition, out hit, Mathf.Sqrt(playerDistance2), TrackingLevelLayers)) continue; targetedPlayer = player; targetedPlayerDistance2 = playerDistance2; tracking.TrackedTarget = player.GetComponent<Rigidbody>(); } }
public void AddPlayerTarget(PlayerTarget argInPlayerTarget) { playerTargets.Add(argInPlayerTarget); }
public void AddPlayerTarget(PlayerTarget pt) { playerTargets.Add(pt); }
public Effect(PlayerTarget argInPlayer, EffectHandler argInEffectHandler) { MyEffectHandler = argInEffectHandler; player = argInPlayer; }
public void RemovePlayerTarget(PlayerTarget argInPlayerTarget) { playerTargets.RemoveAll(x => x == argInPlayerTarget); }