private void OnTriggerEnter(Collider other) { Player player = other.GetComponent <Player>(); //if the player component of the object we collided with isn't null and the nerg is coming out of the ground if ((player != null) && m_IsAttacking) { if (PhotonNetwork.isMasterClient) { //figure out if who ever we collided with is are target if (m_AIReference.Target != player) { //if they weren't are target, they are now m_AIReference.Target = player; } } if (player.photonView.isMine) { //Status[] statuses = { m_AIReference.ElementType, Status.Stun }; Status[] statuses = { Status.Stun }; player.TakeDamage(m_Damage, m_AIReference.transform.position, statuses); } if (PhotonNetwork.isMasterClient) { //set the player to be right at the player they collided with's mid area m_AIReference.transform.position = m_AIReference.Target.transform.position; //increment the current step m_CurrentStep++; m_MoveLocation = MathFunc.CalculateClosestGroundPosition(m_AIReference.transform.position); } } }
public override BehaviourState UpdateNodeBehaviour() { if (m_AttackTimer > m_AttackCooldown) { if (!m_IsInitialized) { SoundManager.GetInstance().photonView.RPC("PlaySFXNetworked", PhotonTargets.All, "NergDig", m_AIReference.transform.position); //get the closest ground position m_MoveLocation = MathFunc.CalculateClosestGroundPosition(m_AIReference.transform.position); //make sure the location to move to is a little bit lower so the nerg goes completely underground m_MoveLocation.y -= m_ExtraDepth; m_IsInitialized = true; } return(RunDigLogic()); } return(BehaviourState.Failed); }
private void SpawnItem(Vector3 positionToSpawn, DroppableItems itemToSpawn) { GameObject itemMesh = ObjectPoolManager.Instance.GetObjectFromNetworkPool(itemToSpawn.ToString()); //chests behave differently then regular pick up items but can still be dropped so they get managed here if (itemToSpawn == DroppableItems.Chest) { ChestItemMesh chest = itemMesh.GetComponent <ChestItemMesh>(); //get the closest position to the ground and place the chest in that location chest.transform.position = MathFunc.CalculateClosestGroundPosition(positionToSpawn); chest.SetActive(true); } //other 3D items that are not chests else { ItemMesh3D item = itemMesh.GetComponent <ItemMesh3D>(); //set the item assembly of the item item.AssemblyName = PickupDetails.GetDroppableItemAssembly(itemToSpawn); if (!m_PickUpItemsInGame.ContainsKey(item.AssemblyName)) { photonView.RPC("RPCCreateAndAddItemToList", PhotonTargets.All, item.AssemblyName); } float speed = UnityEngine.Random.Range(5.0f, 7.5f); Vector3 direction = Vector3.up; direction.x = UnityEngine.Random.Range(-0.25f, 0.25f); direction.z = UnityEngine.Random.Range(-0.25f, 0.25f); item.SetActive(true, positionToSpawn, Quaternion.identity.eulerAngles, direction, speed); object actualItem = GetObjectFromName(item.AssemblyName); item.photonView.RPC("Item3DSetUp", PhotonTargets.All, item.AssemblyName, (actualItem as AbstractItem).ItemType, (actualItem as AbstractItem).SpriteName, false); item.CanPlayerObtainItem = (actualItem as AbstractItem).CanObtainItem; } }
public BehaviourState RunDigLogic() { switch (m_CurrentStep) { //move the nerg underground case CurrentStep.Step1MoveUnderGround: MoveToLocation(); break; //move underneith the player's position case CurrentStep.Step2MoveToPlayerPos: if (m_UnderGroundTimer > m_TimeSpentUnderground) { //increment the step count m_CurrentStep++; //set the location that the entity will need to emerge from m_MoveLocation = m_AIReference.Target.transform.position; m_UnderGroundTimer = 0.0f; //set the entity to be attacking that way while it's emerging it can deal damage m_AIReference.photonView.RPC("SetIsAttacking", PhotonTargets.All, true); } else { m_UnderGroundTimer += Time.deltaTime; } //until if (m_UnderGroundTimer < (m_TimeSpentUnderground - 1)) { Vector3 newLoc = m_AIReference.Target.transform.position; newLoc.y -= m_ExtraDepth; m_AIReference.transform.position = newLoc; } break; //move out of the ground case CurrentStep.Step3EmergFromGround: MoveToLocation(); break; //for a few moments and then re-enter the ground case CurrentStep.Step4ReEnterGround: if (m_WaitTimer > m_WaitTime) { MoveToLocation(); } else { m_WaitTimer += Time.deltaTime; //once the timer has been increased passed the wait time we set the movelocation. We do this here because it's the only logical //place we're we can and have the ability to if (m_WaitTimer > m_WaitTime) { m_MoveLocation = MathFunc.CalculateClosestGroundPosition(m_AIReference.transform.position); m_MoveLocation.y -= m_ExtraDepth; } } break; //pick a random spawn point in the room and move the entity to that location case CurrentStep.Step5MoveToRandomSpawnPoint: Vector3 newPos = m_MoveLocation = m_AIReference.MyIslandRoom.RoomSpawnPoints[UnityEngine.Random.Range(0, m_AIReference.MyIslandRoom.RoomSpawnPoints.Count)].transform.position; newPos.y -= m_ExtraDepth; m_AIReference.transform.position = newPos; m_CurrentStep++; break; //move the entity above the ground case CurrentStep.Step6MoveAboveGroundAndFinish: MoveToLocation(); break; //reset all of the node values because, we're done case CurrentStep.Step7Done: m_AttackTimer = 0.0f; return(BehaviourState.Succeed); } return(BehaviourState.Running); }