public virtual void DoShoot() { Vector2 shootPosition = shootingOrigin.transform.localPosition; RaycastHit2D[] m_HitBuffer = new RaycastHit2D[1]; Projectile.ProjectData projectData = new Projectile.ProjectData() { direction = m_SpriteForward, gravity = Vector2.zero, shootOrigin = shootingOrigin.position, shootSpeed = launchSpeed, destroyWhenOutOfView = destroyWhenOutOfView }; if (track) { projectData.Track = true; projectData.direction = new Vector2(m_SpriteForward.x * Mathf.Cos(Mathf.Deg2Rad * shootAngle), Mathf.Sin(Mathf.Deg2Rad * shootAngle)); projectData.Target = m_Target; projectData.trackSensitivity = trackSensitivity; projectData.timeBeforeAutodestruct = trackTime; } else { projectData.Track = false; projectData.Target = null; if (locate) { projectData.direction = (Target.transform.position - shootingOrigin.position).normalized; } } ProjectileObject obj = m_ProjectilePool.Pop(projectData); shootingAudio.PlayRandomSound(); }
void SwitchWeapon() //If player switches weapon { if (_playerInput.WeaponSwitch() == 1 || _playerInput.WeaponSwitch() == -1) { if (weapons.Count > 1) //If player has more than one weapon, switch weapon { _currentWeapon = weapons.Count + _playerInput.WeaponSwitch(); if (_currentWeapon == 1) { _currentWeapon = 1; } //If player tries to reach a weapon index above current, select the highest index else if (_currentWeapon > weapons.Count) { _currentWeapon = weapons.Count; } //Update current weapon properties bullet = weapons[_currentWeapon - 1]; _bullletInformation = bullet.GetComponent <ProjectileObject>(); _nextTimeToFire = 0; _hud.UpdateHUD(_bullletInformation.bulletProperties.weaponImage, _bullletInformation.bulletProperties.bulletColor, _bullletInformation.bulletProperties.itemName); } //If player has less than 1, weapon do nothing else { bullet = weapons[0]; } } }
private void Awake() //Find relevant objects { _hud = GameObject.Find("HUD Manager").GetComponent <HUDManager>(); _playerProperties = transform.GetComponent <PMovement>().objectParameters; _playerInput = GetComponent <PlayerInput>(); _bullletInformation = bullet.GetComponent <ProjectileObject>(); AddNewWeapon(bullet); }
public void AddNewWeapon(GameObject _newWeapon) //If player collids with itempickup add to list { weapons.Add(_newWeapon); _currentWeapon = weapons.Count; _bullletInformation = _newWeapon.GetComponent <ProjectileObject>(); _nextTimeToFire = Time.time + _bullletInformation.bulletProperties.fireSpeed; _nextTimeToFire = 0; _hud.UpdateHUD(_bullletInformation.bulletProperties.weaponImage, _bullletInformation.bulletProperties.bulletColor, _bullletInformation.bulletProperties.itemName); }
/// <summary> /// Update user life, pixels and songs /// </summary> /// <param name="projectile">the projectile</param> public override void OnCollision(ProjectileObject projectile) { int damages = Math.Min(Life, projectile.Life); Life -= damages; projectile.Life -= damages; CollisionSounds(); projectile.CollisionSounds(); }
public override AbilityTickable AbilityLogic(Vector2 target) { GameObject proj = Instantiate(ProjectilePrefab); proj.transform.position = Owner.transform.position; proj.transform.eulerAngles = new Vector3(0, -Vector2.SignedAngle(Vector2.up, target - Owner.Position), 0); proj.transform.localScale = Vector3.one * 0.25f; ProjectileObject projectile = proj.AddComponent <ProjectileObject>(); projectile.Init(Owner, (ProjectileRange / ProjectileSpeed), (target - Owner.Position).normalized, ProjectileSpeed, ProjectileDamage); return(projectile); }
public void ProjFire() { if (_currentProjectile) { _currentProjectile.Fire(); _animator.SetTrigger("Fire"); StopChargingSound(); SoundManager.instance.PlaySound(SoundManager.instance.auraProjectileFire, SoundManager.instance.SoundSource, true); // dialogue triggering if (_shouldSpeak) { //_shouldSpeak = false; SoundManager.instance.PlayAuraDialogue(SoundManager.instance.AuraVoiceSource, SoundManager.AuraDialogueEvent.Fire, ref SoundManager.instance.auraProjectileDialogueArrayIndex, false); //StartCoroutine(DialogueCooldown()); } if (_useCoolDown) { if (_coolDownTime < _baseCoolDownTime) { _coolDownTime = _baseCoolDownTime; } // if (_coolDown) // _coolDown.StartCoolDown(_coolDownTime); /** Start the cool down for the projectile */ _onPlayerHUD.StartProjectileCoolDown(_coolDownTime); StopAllCoroutines(); StartCoroutine(CoolDown()); } else { _projSpawned = false; } if (!_CB.IsCrouching) { _animator.SetBool("Crouching", false); } _animator.SetBool("isCharging", false); } SetComponentsActive(true); _currentProjectile = null; }
public override void Use(PlayerObject player) { MouseState mouseState = Mouse.GetState(); float dir = (float)Math.Atan2(mouseState.Y - (player.Position.Y + player.Room.ViewPosition.Y), mouseState.X - (player.Position.X + player.Room.ViewPosition.X)); ProjectileObject proj = new ProjectileObject(player.Room, player.Position, dir, 8, Damage, "obj_enemy", "obj_boss"); proj.TimeToLive = 10; proj.Sprite.Change(SwipeTexture); proj.Sprite.Angle = dir; proj.Sprite.Size = new Vector2(16, 32); proj.Sprite.Origin = proj.Sprite.Size / 2; player.Room.GameObjectList.Add(proj); player.Room.Sounds.PlaySound(SwipeSounds[PlatformerMath.Choose(0, 1, 2)], 1); }
public void Fire(string owner, Vector3 position, Quaternion rotation) { OwnerTag = owner; GameObject go = GameObject.Instantiate(Resources.Load(resourceName), position, rotation) as GameObject; _projectileObject = go.GetComponent <ProjectileObject>(); _projectileObject.projectile = this; Debug.Log(angle); if (angle != Vector3.zero) { _projectileObject.transform.Rotate(angle); } }
public override void Use(PlayerObject player) { MouseState mouseState = Mouse.GetState(); float dir = (float)Math.Atan2(mouseState.Y - (player.Position.Y + player.Room.ViewPosition.Y), mouseState.X - (player.Position.X + player.Room.ViewPosition.X)); ProjectileObject proj = new ProjectileObject(player.Room, player.Position, dir, 6, Damage, "obj_enemy", "obj_boss"); proj.TimeToLive = 150; proj.Sprite.Change(MagicBallTexture); proj.Sprite.Size = new Vector2(32, 32); proj.Sprite.Offset = -proj.Sprite.Size / 2; proj.Sprite.Speed = 0.3f; player.Room.GameObjectList.Add(proj); player.Room.Sounds.PlaySound(MagicSounds[PlatformerMath.Choose(0, 1)], 1); }
private void ProjSpawn() { if (!_projSpawned) { if (_useCoolDown) { _timerCountCoroutine = StartCoroutine(TimeCounter()); } if (!_CB.IsCrouching) { _animator.SetBool("Crouching", true); } _animator.SetBool("isCharging", true); var projectile = (GameObject)Instantiate(_projectilePrefab, _projectileSpawn.position, _projectileSpawn.rotation, _projectileSpawn); _currentProjectile = projectile.GetComponent <ProjectileObject>(); _projSpawned = true; SetComponentsActive(false); _currentProjectile.StartCharge(_projectileSpeed, _maxChargeTime, _baseStunTime, _deltaSize, _enemyTag, _camController, _projectileRayOrigin.position, _ignorePlayer, _projectileImpactEffect != null ? _projectileImpactEffect : null); // play charge sound _charging = true; //SoundManager.instance.SoundSource.volume = 1f; SoundManager.instance.SoundSource.pitch = 1; SoundManager.instance.PlaySound(SoundManager.instance.auraProjectileChargeStart, SoundManager.instance.SoundSource, true); SoundManager.instance.SoundSource.loop = true; StartCoroutine(ProjectileChargeSound(SoundManager.instance.SoundSource.clip.length)); } }
/// <summary> /// An gameObjet can is in collision with a projectile if /// the projectile meet a non transparent pixel of the DrawableObject /// </summary> /// <param name="projectile">projectile</param> /// <returns>Is the projectile in a non transparent pixel of the DrawableObject?</returns> public override bool CanCollision(ProjectileObject projectile) { GameException.RequireNonNull(projectile); if (Team == projectile.Team || !projectile.IsAlive()) { return(false); } Rectangle intersect = Vector2D.Intersect(Coords, ImageDimentions, projectile.Coords, projectile.ImageDimentions); if (intersect.IsEmpty) { return(false); } return(IteratePixels(projectile, (x, y) => 0 < Drawable.Image.GetPixel(x, y).A)); }
/// <summary> /// By default, set transparent the common pixels /// </summary> public override void OnCollision(ProjectileObject projectile) { if (!CanCollision(projectile)) { throw new InvalidOperationException(); } IteratePixels( projectile, (x, y) => { if (0 < Drawable.Image.GetPixel(x, y).A) { RemovePixelsInRange(x, y, 5); } return(false); } ); }
/// <summary> /// Apply the PixelColorFunction in the common pixel /// </summary> /// <param name="projectile">the projectile</param> /// <param name="function">the action(s) to apply to the common pixel</param> /// <returns>True if function(x, t) return true</returns> private bool IteratePixels(ProjectileObject projectile, PixelColorFunction function) { Rectangle intersect = Vector2D.Intersect(Coords, ImageDimentions, projectile.Coords, projectile.ImageDimentions); int startX = (int)(intersect.X - Coords.X); int startY = (int)(intersect.Y - Coords.Y); for (int x = startX; x < startX + intersect.Width; x++) { for (int y = startY; y < startY + intersect.Height; y++) { if (function(x, y)) { return(true); } } } return(false); }
void OnCollisionEnter(Collision collision) { if (collision.collider.gameObject.layer == LayerMask.NameToLayer("Player")) { return; } //get local references of collided objects GeneralObject objThem = collision.collider.GetComponent <GeneralObject>(); ProjectileObject objThis = GetComponent <ProjectileObject>(); //calculate damage inflicted float damage = Random.Range(0, objThis.DamageOutput); //inflict damage to them upon hit if (objThem.GetPopulation() > 0) //if population exists, kill population before damaging object itself { if (objThem.GetPopulation() - damage > 0) { objThem.SetPopulation(objThem.GetPopulation() - (int)damage); //all damage to population if population remains above 0 } else { //kill entire population and inflict remainder damage on object iself damage -= (damage - objThem.GetPopulation()); objThem.SetPopulation(0); objThem.Health -= damage; } } else { objThem.Health -= Random.Range(0, objThis.DamageOutput); } //destroy missile itself objThis.Explode(true); }
public void Launch() { //Vector2 force = m_SpriteForward.x > 0 ? Vector2.right.Rotate(shootAngle) : Vector2.left.Rotate(-shootAngle); //force *= shootForce; Vector2 shootPosition = shootingOrigin.transform.localPosition; //if we are flipped compared to normal, we need to localy flip the shootposition too //if ((spriteFaceLeft && m_SpriteForward.x > 0) || (!spriteFaceLeft && m_SpriteForward.x > 0)) // shootPosition.x *= -1; //BulletObject obj = m_BulletPool.Pop(transform.TransformPoint(shootPosition)); RaycastHit2D[] m_HitBuffer = new RaycastHit2D[1]; Projectile.ProjectData projectData = new Projectile.ProjectData() { direction = m_SpriteForward, gravity = Vector2.zero, shootOrigin = shootingOrigin.position, shootSpeed = launchSpeed }; if ((Physics2D.Raycast(shootingOrigin.position, m_SpriteForward, m_ContactFilter, m_HitBuffer, viewDistance) > 0 || m_Target == null) && LaunchTracked == false) { projectData.Track = false; projectData.Target = null; } else { projectData.Track = true; projectData.direction = new Vector2(m_SpriteForward.x * Mathf.Cos(Mathf.Deg2Rad * launchAngle), Mathf.Sin(Mathf.Deg2Rad * launchAngle)); projectData.Target = m_Target; projectData.trackSensitivity = trackSensitivity; } ProjectileObject obj = m_ProjectilePool.Pop(projectData); LaunchAudio.PlayRandomSound(); //obj.rigidbody2D.velocity = (GetProjectilVelocity(m_TargetShootPosition, shootingOrigin.transform.position)); }
public override void DoShoot() { Vector2 shootPosition = shootingOrigin.transform.localPosition; RaycastHit2D[] m_HitBuffer = new RaycastHit2D[1]; Projectile.ProjectData[] projectData = new Projectile.ProjectData[bulletNum]; Vector2 vector = m_SpriteForward; for (int i = 0; i < projectData.Length; i++) { projectData[i] = new Projectile.ProjectData { direction = projectData.Length > 1 ? vector.Rotate(RangeAngle * 0.5f).Rotate(-i * RangeAngle / (bulletNum - 1)) : m_SpriteForward, gravity = Vector2.zero, shootOrigin = shootingOrigin.transform.position, shootSpeed = launchSpeed }; if (track) { projectData[i].Track = true; projectData[i].Target = m_Target; projectData[i].trackSensitivity = trackSensitivity; } else { projectData[i].Track = false; projectData[i].Target = null; if (locate) { projectData[i].direction = (Target.transform.position - shootingOrigin.position).normalized; } } ProjectileObject obj = m_ProjectilePool.Pop(projectData[i]); } shootingAudio.PlayRandomSound(); }
/// <summary> /// Do nothing /// </summary> public override void OnCollision(ProjectileObject projectile) { }
/// <summary> /// Can't have collision with a projectile /// </summary> /// <param name="gameInstance">gameInstance</param> /// <returns>Can a userlife be in collision ?</returns> public override bool CanCollision(ProjectileObject projectile) { return(false); }
public void Fire(string owner, Vector3 position, Quaternion rotation) { OwnerTag = owner; GameObject go = GameObject.Instantiate(Resources.Load(resourceName), position, rotation) as GameObject; _projectileObject = go.GetComponent<ProjectileObject>(); _projectileObject.projectile = this; Debug.Log (angle); if (angle != Vector3.zero) { _projectileObject.transform.Rotate(angle); } }
private void AddNewObject(MouseUpEvent evt) { objectEditSelectionContainer.Clear(); if (objectSelectionField.value == null) { string typeOfObject = ObjectTypeLayer.value; switch (typeOfObject) { case "SpriteObject": #region ObjectField SpriteSpriteSelection = ve.Q <ObjectField>("SpriteImageObjectSelectionField"); if (SpriteSpriteSelection.value != null) { ScriptableObject so = ScriptableObject.CreateInstance <SpriteObject>(); SpriteObject spriteObject = (SpriteObject)so; Sprite s = (Sprite)SpriteSpriteSelection.value; spriteObject.sprite = (Sprite)SpriteSpriteSelection.value; EditorUtility.SetDirty(spriteObject); spriteObject.x = (int)s.rect.x; EditorUtility.SetDirty(spriteObject); spriteObject.y = (int)s.rect.y; EditorUtility.SetDirty(spriteObject); spriteObject.width = (int)s.rect.width; EditorUtility.SetDirty(spriteObject); spriteObject.height = (int)s.rect.height; EditorUtility.SetDirty(spriteObject); if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(spriteObject, "Assets/Export/Data/SpriteData.asset"); } else { AssetDatabase.CreateAsset(spriteObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); break; #endregion case "EnvironmentObject": #region ObjectField EnvironmentSpriteSelection = ve.Q <ObjectField>("SpriteImageObjectSelectionField"); ObjectField ColliderSelection = ve.Q <ObjectField>("SpriteColliderObjectSelectionField"); if (EnvironmentSpriteSelection.value != null) { ScriptableObject eo = ScriptableObject.CreateInstance <EnvironmentObject>(); EnvironmentObject environmentObject = (EnvironmentObject)eo; environmentObject.sprite = (SpriteObject)EnvironmentSpriteSelection.value; EditorUtility.SetDirty(environmentObject); if (ColliderSelection.value != null) { environmentObject.collider = (ColliderObject)ColliderSelection.value; EditorUtility.SetDirty(environmentObject); } if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(environmentObject, "Assets/Export/Data/EnvironementData.asset"); } else { AssetDatabase.CreateAsset(environmentObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); //ve.Bind(serializedObject); break; #endregion case "StaticObject": #region ObjectField StaticSpriteSelection = ve.Q <ObjectField>("SpriteImageObjectSelectionField"); ObjectField StaticColliderSelection = ve.Q <ObjectField>("SpriteColliderObjectSelectionField"); if (StaticSpriteSelection.value != null && StaticColliderSelection.value != null) { ScriptableObject so = ScriptableObject.CreateInstance <StaticObject>(); StaticObject staticObject = (StaticObject)so; staticObject.sprite = (SpriteObject)StaticSpriteSelection.value; EditorUtility.SetDirty(staticObject); staticObject.collider = (ColliderObject)StaticColliderSelection.value; EditorUtility.SetDirty(staticObject); if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(staticObject, "Assets/Export/Data/StaticObject.asset"); } else { AssetDatabase.CreateAsset(staticObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); break; #endregion case "AnimationObject": #region ScriptableObject animso = ScriptableObject.CreateInstance <AnimationObject>(); AnimationObject animObject = (AnimationObject)animso; if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(animObject, "Assets/Export/Data/AnimationObject.asset"); } else { AssetDatabase.CreateAsset(animObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); break; #endregion case "EnemyObject": #region ObjectField EnemyObjectSpriteSelection = ve.Q <ObjectField>("EnemySpriteObjectSelectionField"); FloatField EnemyHealthField = ve.Q <FloatField>("EnemyObjectHealthField"); FloatField EnemyAttackField = ve.Q <FloatField>("EnemyObjectAttackField"); ObjectField EnemyObjectColliderSelection = ve.Q <ObjectField>("EnemyColliderObjectSelectionField"); if (EnemyObjectSpriteSelection.value != null && EnemyHealthField.value != 0 && EnemyAttackField.value != 0 && EnemyObjectColliderSelection.value != null) { ScriptableObject so = ScriptableObject.CreateInstance <EnemyObject>(); EnemyObject enemyObject = (EnemyObject)so; enemyObject.sprite = (SpriteObject)EnemyObjectSpriteSelection.value; EditorUtility.SetDirty(enemyObject); enemyObject.health = EnemyHealthField.value; EditorUtility.SetDirty(enemyObject); enemyObject.attack = EnemyAttackField.value; EditorUtility.SetDirty(enemyObject); enemyObject.enemyCollider = (CircleColliderObject)EnemyObjectColliderSelection.value; EditorUtility.SetDirty(enemyObject); if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(enemyObject, "Assets/Export/Data/EnemyObject.asset"); } else { AssetDatabase.CreateAsset(enemyObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); break; #endregion case "EnemySpawner": #region ObjectField EnemySpawnerObjectSpriteSelection = ve.Q <ObjectField>("EnemySpawnerSpriteObjectSelectionField"); FloatField EnemySpawnerTimeField = ve.Q <FloatField>("EnemySpawnTimeField"); ObjectField EnemySpawnerenemySelection = ve.Q <ObjectField>("EnemyObjectSelectionField"); ObjectField EnemySpawnerObjectColliderSelection = ve.Q <ObjectField>("SpawnerColliderObjectSelectionField"); if (EnemySpawnerObjectSpriteSelection.value != null && EnemySpawnerTimeField != null && EnemySpawnerenemySelection.value != null && EnemySpawnerObjectColliderSelection.value != null) { ScriptableObject so = ScriptableObject.CreateInstance <EnemySpawnerObject>(); EnemySpawnerObject enemySpawnerObject = (EnemySpawnerObject)so; enemySpawnerObject.sprite = (SpriteObject)EnemySpawnerObjectSpriteSelection.value; EditorUtility.SetDirty(enemySpawnerObject); enemySpawnerObject.spawnTime = EnemySpawnerTimeField.value; EditorUtility.SetDirty(enemySpawnerObject); enemySpawnerObject.enemy = (EnemyObject)EnemySpawnerenemySelection.value; EditorUtility.SetDirty(enemySpawnerObject); enemySpawnerObject.spawnerCollider = (CircleColliderObject)EnemySpawnerObjectColliderSelection.value; EditorUtility.SetDirty(enemySpawnerObject); if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(enemySpawnerObject, "Assets/Export/Data/EnemySpawnerObject.asset"); } else { AssetDatabase.CreateAsset(enemySpawnerObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); break; #endregion //case "Player": // break; case "PolygonCollider": #region FloatField PolyColliderHeightField = ve.Q <FloatField>("PolygonColliderHeightField"); FloatField PolyColliderWidthField = ve.Q <FloatField>("PolygonColliderWidthField"); Toggle PolyColliderIsTriggerToggle = ve.Q <Toggle>("PolygonColliderSetTrigger"); if (PolyColliderHeightField != null && PolyColliderWidthField != null && PolyColliderIsTriggerToggle != null) { ScriptableObject so = ScriptableObject.CreateInstance <PolygonColliderObject>(); PolygonColliderObject polygonColliderObject = (PolygonColliderObject)so; polygonColliderObject.height = PolyColliderHeightField.value; EditorUtility.SetDirty(polygonColliderObject); polygonColliderObject.width = PolyColliderWidthField.value; EditorUtility.SetDirty(polygonColliderObject); polygonColliderObject.isTrigger = PolyColliderIsTriggerToggle.value; EditorUtility.SetDirty(polygonColliderObject); if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(polygonColliderObject, "Assets/Export/Data/PolygonColliderObject.asset"); } else { AssetDatabase.CreateAsset(polygonColliderObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); break; #endregion case "CircleCollider": #region FloatField CircleColliderRadiustField = ve.Q <FloatField>("CircleColliderRadiusField"); Toggle CircleColliderIsTriggerToggle = ve.Q <Toggle>("CircleColliderSetTrigger"); if (CircleColliderRadiustField != null && CircleColliderIsTriggerToggle != null) { ScriptableObject so = ScriptableObject.CreateInstance <CircleColliderObject>(); CircleColliderObject circleColliderObject = (CircleColliderObject)so; circleColliderObject.radius = CircleColliderRadiustField.value; EditorUtility.SetDirty(circleColliderObject); circleColliderObject.isTrigger = CircleColliderIsTriggerToggle.value; EditorUtility.SetDirty(circleColliderObject); if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(circleColliderObject, "Assets/Export/Data/CircleColliderObject.asset"); } else { AssetDatabase.CreateAsset(circleColliderObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } } break; #endregion case "ProjectileObject": #region ObjectField ProjectileObjectSpriteSelection = ve.Q <ObjectField>("ProjectileSpriteObjectSelectionField"); FloatField ProjectileSpeedField = ve.Q <FloatField>("ProjectileSpeedField"); ObjectField ProjectileObjectColliderSelection = ve.Q <ObjectField>("ProjectileColliderObjectSelectionField"); if (ProjectileObjectSpriteSelection.value != null && ProjectileSpeedField != null && ProjectileObjectColliderSelection.value != null) { ScriptableObject so = ScriptableObject.CreateInstance <ProjectileObject>(); ProjectileObject projectileObject = (ProjectileObject)so; projectileObject.sprite = (SpriteObject)ProjectileObjectSpriteSelection.value; EditorUtility.SetDirty(projectileObject); projectileObject.speed = ProjectileSpeedField.value; EditorUtility.SetDirty(projectileObject); projectileObject.projectileCollider = (CircleColliderObject)ProjectileObjectColliderSelection.value; EditorUtility.SetDirty(projectileObject); if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(projectileObject, "Assets/Export/Data/ProjectileObject.asset"); } else { AssetDatabase.CreateAsset(projectileObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); break; #endregion case "PlayerObject": #region ObjectField PlayerObjectSpriteSelection = ve.Q <ObjectField>("PlayerSpriteObjectSelectionField"); FloatField PlayerHealthField = ve.Q <FloatField>("PlayerObjectHealthField"); FloatField PlayerAttackField = ve.Q <FloatField>("PlayerObjectAttackField"); FloatField PlayerSpeedField = ve.Q <FloatField>("PlayerObjectSpeedField"); ObjectField PlayerObjectProjectileSelection = ve.Q <ObjectField>("PlayerProjectileObjectSelectionField"); ObjectField PlayerObjectColliderSelection = ve.Q <ObjectField>("PlayerColliderObjectSelectionField"); if (PlayerObjectSpriteSelection.value != null && PlayerHealthField.value != 0 && PlayerAttackField.value != 0 && PlayerSpeedField.value != 0 && PlayerObjectProjectileSelection.value != null && PlayerObjectColliderSelection.value != null) { ScriptableObject so = ScriptableObject.CreateInstance <PlayerObject>(); PlayerObject playerObject = (PlayerObject)so; playerObject.sprite = (SpriteObject)PlayerObjectSpriteSelection.value; EditorUtility.SetDirty(playerObject); playerObject.health = PlayerHealthField.value; EditorUtility.SetDirty(playerObject); playerObject.attack = PlayerAttackField.value; EditorUtility.SetDirty(playerObject); playerObject.projectile = (ProjectileObject)PlayerObjectProjectileSelection.value; EditorUtility.SetDirty(playerObject); playerObject.playerCollider = (CircleColliderObject)PlayerObjectColliderSelection.value; EditorUtility.SetDirty(playerObject); if (string.IsNullOrEmpty(ObjectNameTextField.value)) { AssetDatabase.CreateAsset(playerObject, "Assets/Export/Data/PlayerObject.asset"); } else { AssetDatabase.CreateAsset(playerObject, "Assets/Export/Data/" + ObjectNameTextField.value + ".asset"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); break; #endregion } } }
/// <summary> /// Update the pixels and destroy the projectile /// </summary> public override void OnCollision(ProjectileObject projectile) { base.OnCollision(projectile); projectile.Destroy(); }
/// <summary> /// Determines if object can have a collision with a projectile /// </summary> /// <returns>Can I be in collision with this projectile ?</returns> public abstract bool CanCollision(ProjectileObject projectile);
/// <summary> /// Container Class for all the properties for organization. /// </summary> /// <param name="c"></param> public TorqueScriptTemplate(ref dnTorque c) { m_ts = c; _mConsoleobject = new ConsoleObject(ref c); _mMathobject = new tMath(ref c); _mUtil = new UtilObject(ref c); _mHTTPObject = new HTTPObjectObject(ref c); _mTCPObject = new TCPObjectObject(ref c); _mDynamicConsoleMethodComponent = new DynamicConsoleMethodComponentObject(ref c); _mSimComponent = new SimComponentObject(ref c); _mArrayObject = new ArrayObjectObject(ref c); _mConsoleLogger = new ConsoleLoggerObject(ref c); _mFieldBrushObject = new FieldBrushObjectObject(ref c); _mPersistenceManager = new PersistenceManagerObject(ref c); _mSimDataBlock = new SimDataBlockObject(ref c); _mSimObject = new SimObjectObject(ref c); _mSimPersistSet = new SimPersistSetObject(ref c); _mSimSet = new SimSetObject(ref c); _mSimXMLDocument = new SimXMLDocumentObject(ref c); _mFileObject = new FileObjectObject(ref c); _mFileStreamObject = new FileStreamObjectObject(ref c); _mStreamObject = new StreamObjectObject(ref c); _mZipObject = new ZipObjectObject(ref c); _mDecalRoad = new DecalRoadObject(ref c); _mMeshRoad = new MeshRoadObject(ref c); _mRiver = new RiverObject(ref c); _mScatterSky = new ScatterSkyObject(ref c); _mSkyBox = new SkyBoxObject(ref c); _mSun = new SunObject(ref c); _mGuiRoadEditorCtrl = new GuiRoadEditorCtrlObject(ref c); _mForest = new ForestObject(ref c); _mForestWindEmitter = new ForestWindEmitterObject(ref c); _mForestBrush = new ForestBrushObject(ref c); _mForestBrushTool = new ForestBrushToolObject(ref c); _mForestEditorCtrl = new ForestEditorCtrlObject(ref c); _mForestSelectionTool = new ForestSelectionToolObject(ref c); _mCubemapData = new CubemapDataObject(ref c); _mDebugDrawer = new DebugDrawerObject(ref c); _mGuiTSCtrl = new GuiTSCtrlObject(ref c); _mGuiBitmapButtonCtrl = new GuiBitmapButtonCtrlObject(ref c); _mGuiButtonBaseCtrl = new GuiButtonBaseCtrlObject(ref c); _mGuiCheckBoxCtrl = new GuiCheckBoxCtrlObject(ref c); _mGuiIconButtonCtrl = new GuiIconButtonCtrlObject(ref c); _mGuiSwatchButtonCtrl = new GuiSwatchButtonCtrlObject(ref c); _mGuiToolboxButtonCtrl = new GuiToolboxButtonCtrlObject(ref c); _mGuiAutoScrollCtrl = new GuiAutoScrollCtrlObject(ref c); _mGuiDynamicCtrlArrayControl = new GuiDynamicCtrlArrayControlObject(ref c); _mGuiFormCtrl = new GuiFormCtrlObject(ref c); _mGuiFrameSetCtrl = new GuiFrameSetCtrlObject(ref c); _mGuiPaneControl = new GuiPaneControlObject(ref c); _mGuiRolloutCtrl = new GuiRolloutCtrlObject(ref c); _mGuiScrollCtrl = new GuiScrollCtrlObject(ref c); _mGuiStackControl = new GuiStackControlObject(ref c); _mGuiTabBookCtrl = new GuiTabBookCtrlObject(ref c); _mGuiBitmapCtrl = new GuiBitmapCtrlObject(ref c); _mGuiColorPickerCtrl = new GuiColorPickerCtrlObject(ref c); _mGuiDirectoryFileListCtrl = new GuiDirectoryFileListCtrlObject(ref c); _mGuiFileTreeCtrl = new GuiFileTreeCtrlObject(ref c); _mGuiGameListMenuCtrl = new GuiGameListMenuCtrlObject(ref c); _mGuiGameListOptionsCtrl = new GuiGameListOptionsCtrlObject(ref c); _mGuiGradientCtrl = new GuiGradientCtrlObject(ref c); _mGuiListBoxCtrl = new GuiListBoxCtrlObject(ref c); _mGuiMaterialCtrl = new GuiMaterialCtrlObject(ref c); _mGuiMLTextCtrl = new GuiMLTextCtrlObject(ref c); _mGuiPopUpMenuCtrl = new GuiPopUpMenuCtrlObject(ref c); _mGuiPopUpMenuCtrlEx = new GuiPopUpMenuCtrlExObject(ref c); _mGuiSliderCtrl = new GuiSliderCtrlObject(ref c); _mGuiTabPageCtrl = new GuiTabPageCtrlObject(ref c); _mGuiTextCtrl = new GuiTextCtrlObject(ref c); _mGuiTextEditCtrl = new GuiTextEditCtrlObject(ref c); _mGuiTextListCtrl = new GuiTextListCtrlObject(ref c); _mGuiTreeViewCtrl = new GuiTreeViewCtrlObject(ref c); _mGuiCanvas = new GuiCanvasObject(ref c); _mGuiControl = new GuiControlObject(ref c); _mGuiControlProfile = new GuiControlProfileObject(ref c); _mDbgFileView = new DbgFileViewObject(ref c); _mGuiEditCtrl = new GuiEditCtrlObject(ref c); _mGuiFilterCtrl = new GuiFilterCtrlObject(ref c); _mGuiGraphCtrl = new GuiGraphCtrlObject(ref c); _mGuiImageList = new GuiImageListObject(ref c); _mGuiInspector = new GuiInspectorObject(ref c); _mGuiInspectorTypeFileName = new GuiInspectorTypeFileNameObject(ref c); _mGuiInspectorTypeBitMask32 = new GuiInspectorTypeBitMask32Object(ref c); _mGuiMenuBar = new GuiMenuBarObject(ref c); _mGuiParticleGraphCtrl = new GuiParticleGraphCtrlObject(ref c); _mGuiShapeEdPreview = new GuiShapeEdPreviewObject(ref c); _mGuiInspectorDynamicField = new GuiInspectorDynamicFieldObject(ref c); _mGuiInspectorDynamicGroup = new GuiInspectorDynamicGroupObject(ref c); _mGuiInspectorField = new GuiInspectorFieldObject(ref c); _mGuiVariableInspector = new GuiVariableInspectorObject(ref c); _mGuiMessageVectorCtrl = new GuiMessageVectorCtrlObject(ref c); _mGuiProgressBitmapCtrl = new GuiProgressBitmapCtrlObject(ref c); _mGuiTickCtrl = new GuiTickCtrlObject(ref c); _mGuiTheoraCtrl = new GuiTheoraCtrlObject(ref c); _mMessageVector = new MessageVectorObject(ref c); _mEditTSCtrl = new EditTSCtrlObject(ref c); _mGuiMissionAreaCtrl = new GuiMissionAreaCtrlObject(ref c); _mMECreateUndoAction = new MECreateUndoActionObject(ref c); _mMEDeleteUndoAction = new MEDeleteUndoActionObject(ref c); _mWorldEditor = new WorldEditorObject(ref c); _mLangTable = new LangTableObject(ref c); _mPathedInterior = new PathedInteriorObject(ref c); _mMaterial = new MaterialObject(ref c); _mSimResponseCurve = new SimResponseCurveObject(ref c); _mMenuBar = new MenuBarObject(ref c); _mPopupMenu = new PopupMenuObject(ref c); _mFileDialog = new FileDialogObject(ref c); _mPostEffect = new PostEffectObject(ref c); _mRenderBinManager = new RenderBinManagerObject(ref c); _mRenderPassManager = new RenderPassManagerObject(ref c); _mRenderPassStateToken = new RenderPassStateTokenObject(ref c); _mSceneObject = new SceneObjectObject(ref c); _mSFXController = new SFXControllerObject(ref c); _mSFXParameter = new SFXParameterObject(ref c); _mSFXProfile = new SFXProfileObject(ref c); _mSFXSource = new SFXSourceObject(ref c); _mActionMap = new ActionMapObject(ref c); _mNetConnection = new NetConnectionObject(ref c); _mNetObject = new NetObjectObject(ref c); _mAIClient = new AIClientObject(ref c); _mAIConnection = new AIConnectionObject(ref c); _mAIPlayer = new AIPlayerObject(ref c); _mCamera = new CameraObject(ref c); _mDebris = new DebrisObject(ref c); _mGroundPlane = new GroundPlaneObject(ref c); _mGuiMaterialPreview = new GuiMaterialPreviewObject(ref c); _mGuiObjectView = new GuiObjectViewObject(ref c); _mItem = new ItemObject(ref c); _mLightBase = new LightBaseObject(ref c); _mLightDescription = new LightDescriptionObject(ref c); _mLightFlareData = new LightFlareDataObject(ref c); _mMissionArea = new MissionAreaObject(ref c); _mSpawnSphere = new SpawnSphereObject(ref c); _mPathCamera = new PathCameraObject(ref c); _mPhysicalZone = new PhysicalZoneObject(ref c); _mPlayer = new PlayerObject(ref c); _mPortal = new PortalObject(ref c); _mProjectile = new ProjectileObject(ref c); _mProximityMine = new ProximityMineObject(ref c); _mShapeBaseData = new ShapeBaseDataObject(ref c); _mShapeBase = new ShapeBaseObject(ref c); _mStaticShape = new StaticShapeObject(ref c); _mTrigger = new TriggerObject(ref c); _mTSStatic = new TSStaticObject(ref c); _mZone = new ZoneObject(ref c); _mRenderMeshExample = new RenderMeshExampleObject(ref c); _mLightning = new LightningObject(ref c); _mParticleData = new ParticleDataObject(ref c); _mParticleEmitterData = new ParticleEmitterDataObject(ref c); _mParticleEmitterNode = new ParticleEmitterNodeObject(ref c); _mPrecipitation = new PrecipitationObject(ref c); _mGameBase = new GameBaseObject(ref c); _mGameConnection = new GameConnectionObject(ref c); _mPhysicsDebrisData = new PhysicsDebrisDataObject(ref c); _mPhysicsForce = new PhysicsForceObject(ref c); _mPhysicsShape = new PhysicsShapeObject(ref c); _mAITurretShape = new AITurretShapeObject(ref c); _mTurretShape = new TurretShapeObject(ref c); _mFlyingVehicle = new FlyingVehicleObject(ref c); _mWheeledVehicle = new WheeledVehicleObject(ref c); _mTerrainBlock = new TerrainBlockObject(ref c); _mSettings = new SettingsObject(ref c); _mCompoundUndoAction = new CompoundUndoActionObject(ref c); _mUndoManager = new UndoManagerObject(ref c); _mUndoAction = new UndoActionObject(ref c); _mEventManager = new EventManagerObject(ref c); _mMessage = new MessageObject(ref c); }
/// <summary> /// An image can be in collision /// </summary> public override void OnCollision(ProjectileObject projectile) { throw new InvalidOperationException(); }
/// <summary> /// Action done when CanCollision return true /// </summary> public abstract void OnCollision(ProjectileObject projectile);