private void HandleLadder(bool _open, GameObject _object) { ICEWorldEntity _entity = (_object != null ? _object.GetComponent <ICEWorldEntity>() : null); if (_entity == null) { return; } if (_entity.EntityType == EntityClassType.Creature) { ICECreatureControl _creature = _entity as ICECreatureControl; if (_creature == null) { return; } /* * if( _creature.Creature.ActiveTargetVerticalDistance > 0 ) * Debug.Log( "CLIMB UP" ); * else * Debug.Log( "CLIMB DOWN" );*/ } else if (_entity.EntityType == EntityClassType.Player) { ICECreaturePlayer _player = _entity as ICECreaturePlayer; if (_player == null) { return; } } }
public GameObject ActivateSuspendedObject(Vector3 _position, Quaternion _rotation) { GameObject _object = null; if (SuspendedObjects.Count > 0) { _object = SuspendedObjects[0]; if (_object != null) { SuspendedObjects.Remove(_object); _object.transform.position = _position; _object.transform.rotation = _rotation; ICEWorldEntity _entity = _object.GetComponent <ICEWorldEntity>(); if (_entity != null) { _entity.Reset(); } _object.SetActive(true); Register(_object); } } return(_object); }
private GameObject SpawnLocalPlayer() { if (!SpawningLocalPlayerIsAvailable) { return(null); } Vector3 _position = GetSpawnPosition(); Quaternion _rotation = Random.rotation; _rotation.z = 0; _rotation.x = 0; if (WorldManager.LocalPlayer != null && WorldManager.LocalPlayer.activeInHierarchy == false) { SuspendedObjects.Remove(WorldManager.LocalPlayer); WorldManager.LocalPlayer.transform.position = _position; WorldManager.LocalPlayer.transform.rotation = _rotation; } if (WorldManager.LocalPlayer == null) { WorldManager.LocalPlayer = WorldManager.Instantiate(ReferenceGameObject, _position, _rotation); } if (WorldManager.LocalPlayer != null) { //WorldManager.LocalPlayer.name = ReferenceGameObject.name; ICEWorldEntity _entity = WorldManager.LocalPlayer.GetComponent <ICEWorldEntity>(); // if the player is an ICE entity we have to adapt the parent according to it's hierarchy settings if (_entity != null && _entity.UseHierarchyManagement) { WorldManager.LocalPlayer.transform.SetParent(UpdateGroupParent(), true); } if (_entity != null) { _entity.Reset(); _entity.IsLocal = true; } WorldManager.LocalPlayer.SetActive(true); Register(WorldManager.LocalPlayer); m_SpawnCycles++; } return(WorldManager.LocalPlayer); }
public virtual void Hit(GameObject _target, Vector3 _hit_point) { if (Owner == null || Enabled == false) { return; } if (_target != null && ImpactBehaviour.RefusedByLayer(_target.layer)) { return; } ICEWorldEntity.SendDamage(Owner, _target, ImpactType, DamageMethodValue, DamageMethodName, _hit_point, ForceType, UnityEngine.Random.Range(ForceMin, ForceMax), ExplosionRadius); ImpactSound.Play(); ImpactEffect.Start(OwnerComponent); }
public override void Hit(GameObject _target, Vector3 _hit_point) { if (Owner == null || Enabled == false) { return; } if ((_target != null && ImpactBehaviour.RefusedByLayer(_target.layer)) || ImpactBehaviour.RefusedByHitCounter) { return; } ICEWorldEntity.SendDamage(Owner, _target, ImpactType, DamageMethodValue, DamageMethodName, _hit_point, ForceType, UnityEngine.Random.Range(ForceMin, ForceMax), ExplosionRadius); ImpactSound.Play(); ImpactEffect.Start(OwnerComponent); if (ImpactBehaviour.Enabled) { // Handle Projectile Rigidbody Rigidbody _rb = Owner.GetComponent <Rigidbody>(); if (_rb != null) { _rb.useGravity = false; _rb.isKinematic = true; _rb.constraints = RigidbodyConstraints.FreezeAll; } if (ImpactBehaviour.UseAttachOnHit) { WorldManager.AttachToTransform(Owner, _target.transform, false); } if (ImpactBehaviour.UseHideOnHit) { SystemTools.EnableRenderer(Owner.transform, false); } if (ImpactBehaviour.UseDestroyOnHit) { WorldManager.Destroy(Owner, ImpactBehaviour.DestroyDelay); } } }
public GameObject InstantiateNewObject(Vector3 _position, Quaternion _rotation) { if (ReferenceGameObject == null) { return(null); } GameObject _object = WorldManager.Instantiate(ReferenceGameObject, _position, _rotation); if (_object == null) { return(null); } if (UseRandomization) { _object.transform.localScale = _object.transform.localScale + (_object.transform.localScale * (float)Random.Range(RandomSizeMin, RandomSizeMax)); } //_object.name = ReferenceGameObject.name; ICEWorldEntity _entity = _object.GetComponent <ICEWorldEntity>(); // if the object is an ICE entity we have to adapt the parent according to it's hierarchy settings if (_entity != null && _entity.UseHierarchyManagement) { _object.transform.SetParent(UpdateGroupParent(), true); } if (_entity != null) { _entity.Reset(); _entity.IsLocal = true; } _object.SetActive(true); Register(_object); return(_object); }
public virtual void Init(ICEWorldEntity _component) { m_EntityComponent = _component; m_EntityGameObject = (m_EntityComponent != null ? m_EntityComponent.gameObject:null); }
public void Fire(Transform _target) { if (_target != null && DebugLogIsEnabled) { PrintDebugLog(this, "Fire - " + _target.name + " (" + _target.position + ")"); } if (Type == RangedWeaponAmmunitionType.Simulated && _target != null) { ICEWorldEntity.SendDamage(Owner, _target.gameObject, ImpactType, MethodDamage, MethodName, ForceType, UnityEngine.Random.Range(ForceMin, ForceMax), ExplosionRadius); } else if (Type == RangedWeaponAmmunitionType.Projectile || Type == RangedWeaponAmmunitionType.BallisticProjectile) { Vector3 _position = Vector3.zero; Quaternion _rotation = Quaternion.identity; if (Type == RangedWeaponAmmunitionType.Projectile) { if (_target != null) { _position = _target.position; } if (ProjectileSpawnPoint != null) { Debug.DrawRay(ProjectileSpawnPoint.transform.position, ProjectileSpawnPoint.transform.forward * 100); RaycastHit _hit; if (Physics.Raycast(ProjectileSpawnPoint.transform.position, ProjectileSpawnPoint.transform.forward, out _hit, Mathf.Infinity, -1, WorldManager.TriggerInteraction)) { _position = _hit.point; } } GameObject _projectile = WorldManager.Instantiate(Projectile, _position, _rotation); if (_projectile != null) { _projectile.name = Projectile.name; _projectile.transform.localScale = new Vector3(ProjectileScale, ProjectileScale, ProjectileScale); SystemTools.EnableColliders(_projectile.transform, false); Rigidbody _rb = _projectile.GetComponent <Rigidbody>(); if (_rb != null) { _rb.useGravity = false; _rb.isKinematic = true; _rb.constraints = RigidbodyConstraints.FreezeAll; } _projectile.transform.SetParent(_target, true); ICECreatureProjectile _p = _projectile.GetComponent <ICECreatureProjectile>(); if (_p != null) { _p.Hit(_target.gameObject, _position); } } } else if (Type == RangedWeaponAmmunitionType.BallisticProjectile) { if (ProjectileSpawnPoint != null) { _position = ProjectileSpawnPoint.transform.position; _rotation = ProjectileSpawnPoint.transform.rotation; } else { _position = Owner.transform.position; _rotation = Owner.transform.rotation; } GameObject _projectile = WorldManager.Instantiate(Projectile, _position, _rotation); if (_projectile != null) { _projectile.name = Projectile.name; _projectile.transform.localScale = new Vector3(ProjectileScale, ProjectileScale, ProjectileScale); Rigidbody _rb = _projectile.GetComponent <Rigidbody>(); if (_rb != null) { _rb.AddForce(ProjectileSpawnPoint.transform.TransformDirection(new Vector3(0, 0, ProjectileMuzzleVelocity))); } } } } }
public virtual Transform GetTargetTransform() { if (CreatureControl) { TargetObject _target = CreatureControl.Creature.ActiveTarget; if (_target != null && _target.TargetGameObject != null) { Transform _transform = _target.TargetTransform; ICEWorldEntity[] _entities = _target.TargetGameObject.GetComponentsInChildren <ICEWorldEntity>(); if (_entities != null && _entities.Length > 0) { ICEWorldEntity _entity = _entities[UnityEngine.Random.Range(0, _entities.Length)]; if (_entity != null) { _transform = _entity.transform; } } else { Collider[] _colliders = _target.TargetGameObject.GetComponentsInChildren <Collider>(); if (_colliders != null && _colliders.Length > 0) { Collider _collider = _colliders[UnityEngine.Random.Range(0, _colliders.Length)]; if (_collider != null) { _transform = _collider.transform; } } /* * RaycastHit _hit; * if( Physics.Raycast( transform.position, transform.forward, out _hit, Mathf.Infinity, -1, WorldManager.TriggerInteraction ) ) * return ( _hit.collider != null ? _hit.collider.transform : _hit.transform ); */ } //transform.LookAt( _transform, Vector3.up ); return(_transform); } } else if (Player) { RaycastHit _hit; Ray _ray; if (Player.Player.UseMousePositionToAim) { _ray = Camera.main.ScreenPointToRay(Input.mousePosition); } else { _ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); } if (Physics.Raycast(_ray, out _hit)) { return(_hit.collider != null ? _hit.collider.transform : _hit.transform); } } else { RaycastHit _hit; if (Physics.Raycast(transform.position, transform.forward, out _hit, Mathf.Infinity, -1, WorldManager.TriggerInteraction)) { return(_hit.collider != null ? _hit.collider.transform : _hit.transform); } } return(null); }
public void Action(InventoryActionDataObject _action) { if (_action == null || !_action.Enabled) { return; } if (_action.DropItemRequired()) { InventorySlotObject _slot = GetSlotByItemName(_action.ItemName); if (_slot != null && _slot.Amount > 0) { Transform _transform = ICE.World.Utilities.SystemTools.FindChildByName(_action.ParentName, Owner.transform); _transform = (_transform != null ? _transform : Owner.transform); Quaternion _rotation = Quaternion.Euler(0, UnityEngine.Random.Range(0, 360), 0); Vector3 _position = PositionTools.FixTransformPoint(_transform, _action.Offset); GameObject _item = _slot.GiveItem(_position, _rotation); if (_item == null) { _item = CreatureRegister.Spawn(_slot.ItemReferenceObject, _position, _rotation); _slot.Amount--; } } } else if (_action.ParentUpdateRequired()) { InventorySlotObject _slot = GetSlotByItemName(_action.ItemName); if (_slot != null && _slot.Amount > 0) { if (_slot.ItemObject != null) { _slot.MountPointName = _action.ParentName; } } } else if (_action.CollectActiveItemRequired()) { ICECreatureControl _control = OwnerComponent as ICECreatureControl; TargetObject _target = _control.Creature.ActiveTarget; if (_control != null && _target != null && _target.Selectors.TotalCheckIsValid) //&& LastCollectedObjectID != _target.TargetID ) { GameObject _item = _target.TargetGameObject; //LastCollectedObjectID = _target.TargetID; if (_target.EntityComponent != null && _target.EntityComponent.IsChildEntity) { ICEWorldEntity _parent = _target.EntityComponent.RootEntity; if (_parent != null) { if (DebugLogIsEnabled) { PrintDebugLog(this, "CollectActiveItem : take '" + _target.Name + "' from " + _parent.name + " (" + _parent.ObjectInstanceID + ")"); } InventorySlotObject _slot = GetInventorySlot(_parent.gameObject, _target.TargetName); if (_slot != null) { _item = _slot.GiveItem(); } } } if (Insert(_item)) { //Debug.Log( _control.Creature.ActiveTarget.TargetGameObject.name + " - " + _control.Creature.ActiveTarget.TargetGameObject.GetInstanceID() ); //_target.ResetTargetGameObject(); _control.Creature.ResetActiveTarget(); // } } } }