Beispiel #1
0
    void HandleShoot()
    {
        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShot; i++)
        {
            Vector3        shotDirection = GetShotDirectionWithinSpread(weaponMuzzle);
            ProjectileBase newProjectile = Instantiate(projectilePrefab, weaponMuzzle.position, Quaternion.LookRotation(shotDirection));
            newProjectile.Shoot(this);
        }

        // muzzle flash
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, weaponMuzzle.position, weaponMuzzle.rotation, weaponMuzzle.transform);
            // Unparent the muzzleFlashInstance
            if (unparentMuzzleFlash)
            {
                muzzleFlashInstance.transform.SetParent(null);
            }

            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        if (shootSFX)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }

        // Trigger attack animation if there is any
        if (weaponAnimator)
        {
            weaponAnimator.SetTrigger(k_AnimAttackParameter);
        }

        // Callback on shoot
        if (onShoot != null)
        {
            onShoot();
        }
    }
Beispiel #2
0
 public override void OnEquipmentAction(Character character, bool isHoldDown)
 {
     if (character.Movement.IsFrozen())
     {
         return;
     }
     if (activeWarpShot == null)
     {
         if (isHoldDown)
         {
             SpawnStillWarpShot(character);
             cantMove = true;
         }
         else
         {
             SpawnMovingWarpShot(character);
         }
     }
     else
     {
         ProjectileBase projectileBase = activeWarpShot.GetComponent <ProjectileBase>();
         if (cantMove && isHoldDown)
         {
             cantMove = false;
             Destroy(projectileBase.gameObject);
             activeWarpShot = null;
         }
         else if (isHoldDown && projectileBase.GetSpeed() > 0)
         {
             originalSpeed = projectileBase.GetSpeed();
             projectileBase.SetSpeed(0);
         }
         else if (isHoldDown && Helper.NearlyEqual(projectileBase.GetSpeed(), 0))
         {
             projectileBase.SetSpeed(originalSpeed);
         }
         else
         {
             WarpToShot();
         }
     }
 }
Beispiel #3
0
    protected override void Shoot(TargetPoint target)
    {
        base.Shoot(target);

        Launch(target);

        ProjectileBase projectile = pool.Get();

        projectile.gameObject.SetActive(true);
        projectile.LaunchCannon(this, target, launchVelocity, explodeRadius);

        EventHandler handler = null;

        handler = (sender, e) =>
        {
            pool.ReturnToPool(projectile);
            projectile.ReturnToPool -= handler;
        };
        projectile.ReturnToPool += handler;
    }
Beispiel #4
0
 //Spawn a projectile
 public void SpawnMapProjectile(
     Entity owner,
     ProjectileBase projectile,
     SpellBase parentSpell,
     ItemBase parentItem,
     Guid mapId,
     byte x,
     byte y,
     byte z,
     byte direction,
     Entity target
     )
 {
     lock (GetMapLock())
     {
         var proj = new Projectile(owner, parentSpell, parentItem, projectile, Id, x, y, z, direction, target);
         MapProjectiles.Add(proj);
         PacketSender.SendEntityDataToProximity(proj);
     }
 }
Beispiel #5
0
        public void FireProjectile()
        {
            if (projectilePrefab == null || Time.time < cooldownTime)
            {
                return;
            }
            cooldownTime = Time.time + cooldownDuration;

            PlayFiringAnimation();

            GameObject instance = Instantiate(projectilePrefab,
                                              projectileOrigin.position,
                                              projectileOrigin.rotation);
            ProjectileBase projectile = instance.GetComponent <ProjectileBase>();

            if (projectile)
            {
                projectile.Setup(myTeamData);
            }
        }
Beispiel #6
0
        public void DespawnProjectilesOf(ProjectileBase projectileBase)
        {
            var projectiles = new List <Projectile>();

            lock (GetMapLock())
            {
                foreach (var entity in mEntities)
                {
                    if (entity.GetType() == typeof(Projectile) && ((Projectile)entity).Base == projectileBase)
                    {
                        projectiles.Add((Projectile)entity);
                    }
                }

                foreach (var en in projectiles)
                {
                    en.Die(0);
                }
            }
        }
 public ProjectileSpawn(
     byte dir,
     byte x,
     byte y,
     byte z,
     Guid mapId,
     ProjectileBase projectileBase,
     Projectile parent
     )
 {
     MapId             = mapId;
     X                 = x;
     Y                 = y;
     Z                 = z;
     Dir               = dir;
     ProjectileBase    = projectileBase;
     Parent            = parent;
     TransmittionTimer = Globals.Timing.Milliseconds +
                         (long)((float)ProjectileBase.Speed / (float)ProjectileBase.Range);
 }
Beispiel #8
0
    void OnInteract(GameObject caller)
    {
        ProjectileBase projectileBase = caller.GetComponent <ProjectileBase>();
        float          damage;

        if (projectileBase != null)
        {
            // if interact from spell
            CharacterStatsController characterStatsController = projectileBase.owner.GetComponent <CharacterStatsController>();
            float spellDamageModifier = projectileBase.spellDamageModifier;
            damage = selfDamageModifier * spellDamageModifier * characterStatsController.ap.GetValue();
        }
        else
        {
            // if interact directly
            CharacterStatsController characterStatsController = caller.GetComponent <CharacterStatsController>();
            damage = selfDamageModifier * characterStatsController.ap.GetValue();
        }
        m_SelfStatsController.TakeDamage(damage);
        // print(string.Format("{0} does {1} damage to {2}", caller.name, damage, gameObject.name));
    }
Beispiel #9
0
    //场景及预加载资源完毕时进行的操作;
    void OnEndLoad()
    {
        if (m_levelAsset != null)
        {
            ioo.resourceManager.ReleaseAsset(m_levelAsset);
            m_levelAsset = null;
        }
        //处理map的无效shader
        GameObject _gameobject = GameObject.Find("map");

        if (_gameobject != null)
        {
            ProjectileBase.excuteShader(_gameobject);
        }
        //资源加载完成之后,所有camera 的初始化和其他变化还是交给lua处理。
        //AudioListener temp = m_bar.gameObject.GetComponent<AudioListener>();
        GameObject.Destroy(m_bar.gameObject);

        //这里才调用lua的对应函数做进度;
        ioo.gameManager.uluaMgr.OnLevelLoaded(m_level);
    }
Beispiel #10
0
    void Update()
    {
        UpdateAmmo();

        UpdateCharge();

        if (Time.deltaTime > 0)
        {
            muzzleWorldVelocity  = (weaponMuzzle.position - m_LastMuzzlePosition) / Time.deltaTime;
            m_LastMuzzlePosition = weaponMuzzle.position;
        }

        if (m_AltShotsToFire > 0 && Time.time - m_LastTimeAltLaunched >= delayBetweenAltLaunching)
        {
            Vector3        shotDirection = GetShotDirectionWithinSpread(weaponMuzzle, false);
            ProjectileBase newProjectile = Instantiate(altProjectilePrefab, m_LastMuzzlePosition, Quaternion.LookRotation(shotDirection));
            newProjectile.Shoot(gameObject);
            m_AltShotsToFire--;
            m_LastTimeAltLaunched = Time.time;
        }
    }
Beispiel #11
0
    public void CreateProjectile(Vector3 position, Quaternion rotation, double createTime, int projectileId)
    {
        m_LastShootTime = Time.realtimeSinceStartup;

        //Every player receives this so we create the prefabs locally instead of calling PhotonNetwork.Instantiate
        //By having its start position, start rotation and time when it was created, we can calculate where the laser is at all times
        //Check out Part 1 Lesson 3 http://youtu.be/ozBmZ9FoN_o for more detailed explanations
        GameObject newProjectileObject = (GameObject)Instantiate(Resources.Load <GameObject>("Laser1"), new Vector3(0, -100, 0), rotation);

        newProjectileObject.name = "ZZZ_" + newProjectileObject.name;

        ProjectileBase newProjectile = newProjectileObject.GetComponent <ProjectileBase>();

        newProjectile.SetCreationTime(createTime);
        newProjectile.SetStartPosition(position);
        newProjectile.SetProjectileId(projectileId);

        newProjectile.Owner = Ship;

        m_Projectiles.Add(newProjectile);
    }
Beispiel #12
0
    private void OnEnable()
    {
        m_ProjectileBase = GetComponent <ProjectileBase>();
        DebugUtility.HandleErrorIfNullGetComponent <ProjectileBase, ProjectileStandard>(m_ProjectileBase, this, gameObject);

        m_ProjectileBase.onShoot += OnShoot;

        Destroy(gameObject, maxLifeTime);

        int stageLayer   = 1 << LayerMask.NameToLayer("Stage");
        int enemiesLayer = 1 << LayerMask.NameToLayer("Enemies");

        hittableLayers = stageLayer | enemiesLayer;

        if (homing)
        {
            FindHomingTarget();
        }

        spawnTime = Time.time;
    }
Beispiel #13
0
    void HandleShoot()
    {
        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShot; i++)
        {
            Vector3 fromPosition = Character.Muzzle.transform.position;
            Vector3 toPosition   = Character.Target;
            Vector3 direction    = toPosition - fromPosition;

            ProjectileBase newProjectile = Instantiate(projectilePrefab, fromPosition, Quaternion.LookRotation(GetShotDirectionWithinSpread(direction)));
            newProjectile.Shoot(this);
        }

        // muzzle flash
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, Character.Muzzle.position, Character.Muzzle.rotation, Character.Muzzle.transform);
            // Unparent the muzzleFlashInstance
            if (unparentMuzzleFlash)
            {
                muzzleFlashInstance.transform.SetParent(null);
            }

            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        if (shootSFX)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }

        // Callback on shoot
        if (onShoot != null)
        {
            onShoot();
        }
    }
Beispiel #14
0
    public void FireWeapon()
    {
        ProjectileBase projectileInstance = PhotonNetwork.Instantiate(projectile.name, muzzle.transform.position, muzzle.transform.rotation).GetComponent <ProjectileBase>();

        projectileInstance.owner = GetComponent <WeaponBase>();

        switch (weaponManager.modifierSelected)
        {
        case ModifierBase.EModifier.CLUSTER:
            projectileInstance.gameObject.AddComponent <ClusterModifier>().m_projectile = projectileInstance;
            break;

        case ModifierBase.EModifier.RICOCHET:
            projectileInstance.gameObject.AddComponent <RicochetModifier>().m_projectile = projectileInstance;
            break;

        case ModifierBase.EModifier.THREEWAY:
            projectileInstance.gameObject.AddComponent <ThreeWayModifier>().m_projectile = projectileInstance;
            break;

        case ModifierBase.EModifier.PIERCE:
            projectileInstance.gameObject.AddComponent <PierceModifier>().m_projectile = projectileInstance;
            break;
        }

        ModifierBase mod = projectileInstance.gameObject.AddComponent <RicochetModifier>();

        mod.m_projectile = projectileInstance;
        switch (weaponType)
        {
        case EWeapon.SHOOT:
            projectileInstance.Fire(fireVelocity, false);
            break;

        default:
            projectileInstance.Fire(fireVelocity, true);
            break;
        }
        Debug.Log("Firing");
    }
 private bool Chain()
 {
     if (chainCount > 0)
     {
         List <Vector2Int> hexes;
         hexes = TerrainGen.GetHexInRange(TerrainGen.GetGridPosition2D(transform.position), (int)chainDistanceMax);
         List <mobBase> mobs = new List <mobBase>();
         foreach (Vector2Int hex in hexes)
         {
             List <mobBase> mobHex = MobLister.GetMobList(hex);
             if (mobHex != null)
             {
                 foreach (mobBase mob in mobHex)
                 {
                     float distance = MyMath.calcDistance(transform.position, mob.transform.position);
                     if (distance > chainDistanceMin && distance < chainDistanceMax && mob != target)
                     {
                         mobs.Add(mob);
                     }
                 }
             }
         }
         chainCount -= 1;
         damage     *= chainDamageLoss;
         if (mobs.Count > 0)
         {
             Debug.Log("Chaining");
             ProjectileBase newProj = CopyProjectile(chainDamageLoss);
             newProj.SetParticleSystems(effect, explosion);
             newProj.transform.position = this.transform.position;
             newProj.target             = mobs[Random.Range(0, mobs.Count - 1)];
             Debug.DrawLine(newProj.transform.position, newProj.target.transform.position, Color.red, 1);
         }
         return(true);
         //
     }
     return(false);
 }
    public void ShootProjectile()
    {
        float   randomAngle    = Random.Range(-shootRandomAngle, shootRandomAngle);
        Vector3 shootDirection = currentShootDirection == ShootDirection.Right ? Vector3.right : Vector3.left;

        shootDirection = Quaternion.Euler(0, 0, randomAngle) * shootDirection;

        //Vector3 shootPosition = (currentShootDirection == ShootDirection.Right ? rightShootPosition : leftShootPosition).position;
        Vector3 shootPosition = charaFlower.GetCurrentShootPosition;

        //Quaternion shootRotation = (currentShootDirection == ShootDirection.Right ? rightShootPosition : leftShootPosition).rotation;
        Quaternion     shootRotation = Quaternion.Euler(0, 0, currentShootDirection == ShootDirection.Right ? 0 : 180);
        ProjectileBase newProjectile = Instantiate(projectilePrefab, shootPosition, shootRotation);

        newProjectile.ShootProjectile(shootDirection, gameObject);

        currentHorizontalSpeed += shootRecoil * (currentShootDirection == ShootDirection.Right ? -1 : 1);

        PlayShootFeedback();

        charaFlower.SetShooting();
        OnPlayerShotProjectile?.Invoke();
    }
Beispiel #17
0
 protected override void Shoot()
 {
     // base.Shoot();
     charging.Stop();
     //GameObject bulletGO = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
     for (int i = 0; i < bullets.Count; i++)
     {
         if (!bullets[i].activeInHierarchy)
         {
             GameObject     _bullet    = bullets[i];
             ProjectileBase projectile = _bullet.GetComponent <ProjectileBase>();
             _bullet.transform.position = firePoint.position;
             _bullet.transform.rotation = firePoint.rotation;
             _bullet.SetActive(true);
             projectile.SetDamage(projectile.GetDamage() * currentChargeLevel);
             Debug.Log(projectile.GetDamage());
             projectile.SetDurability(currentChargeLevel);
             projectile.SetTarget(target);
             shoot.Play();
             break;
         }
     }
 }
Beispiel #18
0
    protected virtual void CreateProjectile()
    {
        //Create basic projectile
        GameObject newBullet;

        if (projectileData.hitscan)
        {
            newBullet = Instantiate(hitscanProjectilePrefab, projectileStartPos.position, Quaternion.identity);
        }
        else
        {
            newBullet = Instantiate(physicalProjectilePrefab, projectileStartPos.position, Quaternion.identity);
        }
        ProjectileBase projectile = newBullet.GetComponent <ProjectileBase>();

        //Set general properties
        projectile.SetDirection(TrigUtilities.DegreesToVector(owner.GetPlayerMovement().GetPlayerAngle() + Random.Range(-accuracyDegreeOffsetRange, accuracyDegreeOffsetRange)));
        projectile.SetDamage(projectileData.damage);
        projectile.SetDamageForce(projectileData.damageForce);
        projectile.SetOwner(owner);
        projectile.SetCanHitOwner(projectileData.canHitOwner);
        projectile.SetColor(owner.GetColor().GetModifiedBrightness(3f));
        projectile.SetBounces(projectileData.bounces);
        projectile.SetCauseExplosion(projectileData.causeExplosion);
        projectile.SetExplosionRadius(projectileData.explosionRadius);
        projectile.SetExplodeEveryBounce(projectileData.explodeEveryBounce);

        //Set properties depending on if it's hitscan or physical
        if (projectileData.hitscan)
        {
            SetHitscanProperties(newBullet);
        }
        else
        {
            SetPhysicalProperties(newBullet);
        }
    }
Beispiel #19
0
        public override void Load(EntityPacket packet)
        {
            if (mLoaded)
            {
                return;
            }

            base.Load(packet);
            var pkt = (ProjectileEntityPacket)packet;

            ProjectileId = pkt.ProjectileId;
            Dir          = pkt.ProjectileDirection;
            TargetId     = pkt.TargetId;
            mOwner       = pkt.OwnerId;
            mMyBase      = ProjectileBase.Get(ProjectileId);
            if (mMyBase != null)
            {
                for (var x = 0; x < ProjectileBase.SPAWN_LOCATIONS_WIDTH; x++)
                {
                    for (var y = 0; y < ProjectileBase.SPAWN_LOCATIONS_WIDTH; y++)
                    {
                        for (var d = 0; d < ProjectileBase.MAX_PROJECTILE_DIRECTIONS; d++)
                        {
                            if (mMyBase.SpawnLocations[x, y].Directions[d] == true)
                            {
                                mTotalSpawns++;
                            }
                        }
                    }
                }

                mTotalSpawns *= mMyBase.Quantity;
            }

            Spawns  = new ProjectileSpawns[mTotalSpawns];
            mLoaded = true;
        }
Beispiel #20
0
        public void Attack()
        {
            OnAttackEvent?.Invoke();
            ProjectileBase arrow = Instantiate(arrowPrefab);

            arrow.Reset();
            arrow.transform.localEulerAngles = projectileRotation[(int)facing];
            Vector2 dir;

            switch (facing)
            {
            case Facing.Front:
                dir = Vector2.down;
                break;

            case Facing.Back:
                dir = Vector2.up;
                break;

            case Facing.Left:
                dir = Vector2.left;
                break;

            case Facing.Right:
                dir = Vector2.right;
                break;

            default:
                dir = Vector2.down;
                break;
            }

            arrow.OnHitEvent += DealDamage;
            arrow.Launch(dir, attackPoint.position);
            audio.Play();
        }
Beispiel #21
0
        //GameObjectPacket
        private static void HandlePacket(GameObjectPacket packet)
        {
            var id      = packet.Id;
            var deleted = packet.Deleted;
            var json    = "";

            if (!packet.Deleted)
            {
                json = packet.Data;
            }

            switch (packet.Type)
            {
            case GameObjectType.Animation:
                if (deleted)
                {
                    var anim = AnimationBase.Get(id);
                    anim.Delete();
                }
                else
                {
                    var anim = new AnimationBase(id);
                    anim.Load(json);
                    try
                    {
                        AnimationBase.Lookup.Set(id, anim);
                    }
                    catch (Exception exception)
                    {
                        Log.Error($"Another mystery NPE. [Lookup={AnimationBase.Lookup}]");
                        if (exception.InnerException != null)
                        {
                            Log.Error(exception.InnerException);
                        }

                        Log.Error(exception);
                        Log.Error($"{nameof(id)}={id},{nameof(anim)}={anim}");

                        throw;
                    }
                }

                break;

            case GameObjectType.Class:
                if (deleted)
                {
                    var cls = ClassBase.Get(id);
                    cls.Delete();
                }
                else
                {
                    var cls = new ClassBase(id);
                    cls.Load(json);
                    ClassBase.Lookup.Set(id, cls);
                }

                break;

            case GameObjectType.Item:
                if (deleted)
                {
                    var itm = ItemBase.Get(id);
                    itm.Delete();
                }
                else
                {
                    var itm = new ItemBase(id);
                    itm.Load(json);
                    ItemBase.Lookup.Set(id, itm);
                }

                break;

            case GameObjectType.Npc:
                if (deleted)
                {
                    var npc = NpcBase.Get(id);
                    npc.Delete();
                }
                else
                {
                    var npc = new NpcBase(id);
                    npc.Load(json);
                    NpcBase.Lookup.Set(id, npc);
                }

                break;

            case GameObjectType.Projectile:
                if (deleted)
                {
                    var proj = ProjectileBase.Get(id);
                    proj.Delete();
                }
                else
                {
                    var proj = new ProjectileBase(id);
                    proj.Load(json);
                    ProjectileBase.Lookup.Set(id, proj);
                }

                break;

            case GameObjectType.Quest:
                if (deleted)
                {
                    var qst = QuestBase.Get(id);
                    qst.Delete();
                }
                else
                {
                    var qst = new QuestBase(id);
                    qst.Load(json);
                    foreach (var tsk in qst.Tasks)
                    {
                        qst.OriginalTaskEventIds.Add(tsk.Id, tsk.CompletionEventId);
                    }

                    QuestBase.Lookup.Set(id, qst);
                }

                break;

            case GameObjectType.Resource:
                if (deleted)
                {
                    var res = ResourceBase.Get(id);
                    res.Delete();
                }
                else
                {
                    var res = new ResourceBase(id);
                    res.Load(json);
                    ResourceBase.Lookup.Set(id, res);
                }

                break;

            case GameObjectType.Shop:
                if (deleted)
                {
                    var shp = ShopBase.Get(id);
                    shp.Delete();
                }
                else
                {
                    var shp = new ShopBase(id);
                    shp.Load(json);
                    ShopBase.Lookup.Set(id, shp);
                }

                break;

            case GameObjectType.Spell:
                if (deleted)
                {
                    var spl = SpellBase.Get(id);
                    spl.Delete();
                }
                else
                {
                    var spl = new SpellBase(id);
                    spl.Load(json);
                    SpellBase.Lookup.Set(id, spl);
                }

                break;

            case GameObjectType.CraftTables:
                if (deleted)
                {
                    var cft = CraftingTableBase.Get(id);
                    cft.Delete();
                }
                else
                {
                    var cft = new CraftingTableBase(id);
                    cft.Load(json);
                    CraftingTableBase.Lookup.Set(id, cft);
                }

                break;

            case GameObjectType.Crafts:
                if (deleted)
                {
                    var cft = CraftBase.Get(id);
                    cft.Delete();
                }
                else
                {
                    var cft = new CraftBase(id);
                    cft.Load(json);
                    CraftBase.Lookup.Set(id, cft);
                }

                break;

            case GameObjectType.Map:
                //Handled in a different packet
                break;

            case GameObjectType.Event:
                var wasCommon = false;
                if (deleted)
                {
                    var evt = EventBase.Get(id);
                    wasCommon = evt.CommonEvent;
                    evt.Delete();
                }
                else
                {
                    var evt = new EventBase(id);
                    evt.Load(json);
                    wasCommon = evt.CommonEvent;
                    EventBase.Lookup.Set(id, evt);
                }

                if (!wasCommon)
                {
                    return;
                }

                break;

            case GameObjectType.PlayerVariable:
                if (deleted)
                {
                    var pvar = PlayerVariableBase.Get(id);
                    pvar.Delete();
                }
                else
                {
                    var pvar = new PlayerVariableBase(id);
                    pvar.Load(json);
                    PlayerVariableBase.Lookup.Set(id, pvar);
                }

                break;

            case GameObjectType.ServerVariable:
                if (deleted)
                {
                    var svar = ServerVariableBase.Get(id);
                    svar.Delete();
                }
                else
                {
                    var svar = new ServerVariableBase(id);
                    svar.Load(json);
                    ServerVariableBase.Lookup.Set(id, svar);
                }

                break;

            case GameObjectType.Tileset:
                var obj = new TilesetBase(id);
                obj.Load(json);
                TilesetBase.Lookup.Set(id, obj);
                if (Globals.HasGameData && !packet.AnotherFollowing)
                {
                    GameContentManager.LoadTilesets();
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            GameObjectUpdatedDelegate?.Invoke(packet.Type);
        }
Beispiel #22
0
	public void OnProjectileHit(ProjectileBase projectile)
	{
		health = health - projectile.damage;
		
		// pulse a red filter in front of camera
	}
Beispiel #23
0
	/// <summary>
	/// Called by the projectile that hits this ship
	/// </summary>
	/// <param name="projectile">The projectile.</param>
	public void OnProjectileHit( ProjectileBase projectile )
	{
		Ship.DealDamage( 10, projectile.Owner );
	}
Beispiel #24
0
 public virtual void OnHit(Entity projectileEntity, ProjectileBase projectile)
 {
     Entity.Delete();
 }
Beispiel #25
0
 public void OnHit(Entity projectileEntity, ProjectileBase projectile)
 {
     _ship.Damage(GridLocation, (int)Math.Floor(projectile.GetDamage(Entity, this)));
 }
Beispiel #26
0
 /// <summary>
 /// Called by the projectile that hits this ship
 /// </summary>
 /// <param name="projectile">The projectile.</param>
 public void OnProjectileHit(ProjectileBase projectile)
 {
     Ship.DealDamage(10, projectile.Owner);
 }
Beispiel #27
0
 public void OnProjectileCollision(ProjectileBase projectileBase)
 {
     decreaseHP (projectileBase.ProjectileProperties.damage);
 }
Beispiel #28
0
 public void OnProjectileHit(ProjectileBase projectile)
 {
     currentHealth = currentHealth - projectile.damage;
     //transform.position = Vector3.Lerp(transform.position, transform.position + (projectile.transform.forward * 5f), 0.1f );
 }
Beispiel #29
0
	public void OnProjectileHit(ProjectileBase projectile)
	{
		currentHealth = currentHealth - projectile.damage;
		//transform.position = Vector3.Lerp(transform.position, transform.position + (projectile.transform.forward * 5f), 0.1f );
	}
Beispiel #30
0
        public static void RegisterProjectiles()
        {
            ProjectileBase.AddType(new ProjectileType()
            {
                Id = ProjectileId.DigSmall, UseTierParticleColor = true, IsSlowBloom = true, InitialParticleBurst = 10, DigBrush = Brush.Size4, MaxAge = 600, Speed = 500, FireSound = Sound.MiningToolFire, TechName = "Mining Tool", UseTierTextures = true
            });
            ProjectileBase.AddType(new ProjectileType()
            {
                Id = ProjectileId.DigMedium, UseTierParticleColor = true, IsSlowBloom = true, InitialParticleBurst = 10, DigBrush = Brush.Size6, MaxAge = 600, Speed = 520, FireSound = Sound.MiningToolFire, TechName = "Mining Tool", UseTierTextures = true
            });
            ProjectileBase.AddType(new ProjectileType()
            {
                Id = ProjectileId.DigLarge, UseTierParticleColor = true, IsSlowBloom = true, InitialParticleBurst = 10, DigBrush = Brush.Size7, MaxAge = 600, Speed = 540, FireSound = Sound.MiningToolFire, TechName = "Mining Tool", UseTierTextures = true,
            });
            ProjectileBase.AddType(new ProjectileType()
            {
                Id = ProjectileId.DigExtraLarge, UseTierParticleColor = true, IsSlowBloom = true, InitialParticleBurst = 10, DigBrush = Brush.Size9, MaxAge = 600, Speed = 560, FireSound = Sound.MiningToolFire, TechName = "Mining Tool", UseTierTextures = true,
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.Blaster,
                BaseDamage           = 5,
                MaxAge               = 600,
                Speed                = 750,
                InitialParticleBurst = 10,
                UseTierParticleColor = true,
                UseTierTextures      = true,
                ParticleStream       = true,
                FireSound            = Sound.BlasterFire,
                HitSound             = Sound.BlasterHit,
                Knockback            = 1000,
            });

            var blasterCharged = ProjectileBase.Get(ProjectileId.Blaster).Clone();

            blasterCharged.Name            = null;
            blasterCharged.Id              = ProjectileId.BlasterCharged;
            blasterCharged.BaseDamage      = 20;
            blasterCharged.Speed           = 1000;
            blasterCharged.Knockback       = 10;
            blasterCharged.UseTierTextures = true;
            blasterCharged.FireSound       = Sound.BlasterChargedFire;
            ProjectileBase.AddType(blasterCharged);

            var slowBlaster = ProjectileBase.Get(ProjectileId.Blaster).Clone();

            slowBlaster.TechName        = slowBlaster.Name;
            slowBlaster.Name            = null;
            slowBlaster.Id              = ProjectileId.SlowBlaster;
            slowBlaster.UseTierTextures = false;
            slowBlaster.BaseDamage      = 8;
            slowBlaster.Speed           = 300;
            slowBlaster.MaxAge          = 6000;
            ProjectileBase.AddType(slowBlaster);

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.LongRangeBlaster,
                BaseDamage           = 4,
                MaxAge               = 4000,
                Speed                = 650,
                Penetrate            = true,
                InitialParticleBurst = 10,
                UseTierParticleColor = true,
                //UseTierTextures = true,
                FireSound = Sound.BlasterFire,
                HitSound  = Sound.BlasterHit,
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.BallLightning,
                BaseDamage           = 20,
                MaxAge               = 6000,
                Speed                = 500,
                Penetrate            = true,
                InitialParticleBurst = 10,
                ParticleColor        = Color.LightBlue,
                HitSound             = Sound.ElectricityHit,
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.Disruptor,
                BaseDamage           = 6,
                MaxAge               = 200,
                Speed                = 750,
                InitialParticleBurst = 5,
                UseTierTextures      = true,
                UseTierParticleColor = true,
                FireSound            = Sound.DisruptorFire,
                HitSound             = Sound.DisruptorHit,
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id         = ProjectileId.LaserRifle,
                BaseDamage = 13,
                MaxAge     = 1000,
                Speed      = 1000,
                //CoolDown = 500,
                InitialParticleBurst = 15,
                UseTierTextures      = true,
                UseTierParticleColor = true,
                FireSound            = Sound.LaserRifleFire,
                HitSound             = Sound.LaserRifleHit,
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.PoisonDart,
                BaseDamage           = 5,
                MaxAge               = 2000,
                Speed                = 700,
                InitialParticleBurst = 10,
                ParticleColor        = Color.Green,
                FireSound            = Sound.Spike,
                HitSound             = Sound.BlasterHit,
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.HomingMissile,
                BaseDamage           = 11,
                MaxAge               = 3000,
                Speed                = 500,
                IsHoming             = true,
                UseTierTextures      = true,
                InitialParticleBurst = 30,
                ParticleColor        = Color.LightGray,
                ParticleStream       = true,
                FireSound            = Sound.HomingMissileFire,
                HitSound             = Sound.HomingMissileHit,
                OnHitParticleBurst   = 75,
            });

            var acidSpit = ProjectileBase.Get(ProjectileId.HomingMissile).Clone();

            acidSpit.Id              = ProjectileId.AcidSpit;
            acidSpit.Name            = "AcidSpit";
            acidSpit.UseTierTextures = false;
            acidSpit.ParticleColor   = Color.FromNonPremultiplied(194, 245, 65, 200);
            acidSpit.FireSound       = Sound.FireBreath;
            acidSpit.HitSound        = Sound.AcidSplat;
            ProjectileBase.AddType(acidSpit);

            //var explosiveAcidSpit = ProjectileBase.Get(ProjectileId.HomingMissile).Clone();
            //explosiveAcidSpit.Id = ProjectileId.ExplosiveAcidSpit;
            //explosiveAcidSpit.Name = "Explosive AcidSpit";
            //explosiveAcidSpit.Penetrate = true;
            //explosiveAcidSpit.IsHoming = false;
            //explosiveAcidSpit.UseTierTextures = false;
            //explosiveAcidSpit.MaxAge = 6000;
            //explosiveAcidSpit.Speed = 400;
            //explosiveAcidSpit.ParticleColor = Color.FromNonPremultiplied(194, 245, 65, 200);
            //explosiveAcidSpit.FireSound = Sound.FireBreath;
            //explosiveAcidSpit.HitSound = Sound.AcidSplat;
            //explosiveAcidSpit.OnProjectileHitTerrain = (projectile, material) => {
            //        projectile.Map.RenderBrush(projectile.Position, Brush.Size4, Material.Acid, 0);
            //    };
            //explosiveAcidSpit.OnProjectileHit = (projectile, target, amount) => {
            //    projectile.Map.RenderBrush(projectile.Position, Brush.Size4, Material.Acid, 0);
            //};
            //ProjectileBase.AddType(explosiveAcidSpit);

            ProjectileBase.AddType(new ProjectileType()
            {
                Id               = ProjectileId.FlameThrower,
                Speed            = 1000,
                ParticleColor    = Color.Red,
                OnProjectileMove = (projectile, material) => {
                    if (material != Material.Fire && MaterialInfo.IsLiquid(material))
                    {
                        projectile.Remove();
                    }
                    else
                    {
                        if (projectile.Age > 150)
                        {
                            projectile.Map.RenderBrush(projectile.Position, Brush.Size4, Material.Fire, 0);
                        }
                    }
                },
                OnProjectileHitTerrain = (projectile, material) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size4, Material.Fire, 0);
                },
                OnProjectileHit = (projectile, target, amount) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size4, Material.Fire, 0);
                }
            });


            ProjectileBase.AddType(new ProjectileType()
            {
                Id                     = ProjectileId.Fireball,
                BaseDamage             = 25,
                Speed                  = 1000,
                MaxAge                 = 2000,
                DigBrush               = Brush.Size10,
                DigStrength            = 7,
                FireSound              = Sound.FireBreath,
                ParticleColor          = Color.FromNonPremultiplied(255, 113, 95, 200),
                ParticleStream         = true,
                InitialParticleBurst   = 20,
                OnProjectileHitTerrain = (projectile, material) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size5, Material.Fire, 0);
                },
                OnProjectileHit = (projectile, target, amount) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size5, Material.Fire, 0);
                }
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.Fireball_2,
                BaseDamage           = 8,
                Speed                = 800,
                MaxAge               = 3000,
                Penetrate            = true,
                FireSound            = Sound.FireBreath,
                ParticleColor        = Color.FromNonPremultiplied(255, 113, 95, 200),
                ParticleStream       = true,
                InitialParticleBurst = 20,
                OnProjectileHit      = (projectile, target, amount) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size10, Material.Fire, 0);
                }
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                     = ProjectileId.Comet,
                BaseDamage             = 10,
                Speed                  = 500,
                ParticleColor          = Color.FromNonPremultiplied(255, 43, 61, 175),
                ParticleStream         = true,
                InitialParticleBurst   = 20,
                MaxAge                 = 2000,
                DigBrush               = Brush.Size10,
                DigStrength            = 7,
                HasGravity             = true,
                FireSound              = Sound.FireBreath,
                OnProjectileHitTerrain = (projectile, material) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size4, Material.Fire, 0);
                },
                OnProjectileHit = (projectile, target, amount) => {
                }
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.Spike,
                BaseDamage           = 10,
                MaxAge               = 2000,
                Speed                = 750,
                InitialParticleBurst = 15,
                ParticleColor        = Color.FromNonPremultiplied(114, 118, 20, 255),
                ParticleStream       = true,
                FireSound            = Sound.Spike,
            });

            var project = ProjectileBase.Get(ProjectileId.Spike).Clone();

            project.TechName   = project.Name;
            project.Name       = null;
            project.Id         = ProjectileId.SproutSpike;
            project.BaseDamage = 7;
            ProjectileBase.AddType(project);

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.BoseEinsteinCondenser,
                BaseDamage           = 5,
                MaxAge               = 1000,
                Speed                = 500,
                FireSound            = Sound.BoseEinsteinCondenserFire,
                InitialParticleBurst = 5,
                ParticleColor        = Color.LightBlue,
                ParticleStream       = true,
                OnProjectileMove     = (projectile, material) => {
                    if (MaterialInfo.IsLiquid(material))
                    {
                        projectile.Map.RenderBrush(projectile.Position, Brush.Size9, Material.Ice, 0);
                        projectile.Remove();
                    }
                },
                OnProjectileHitTerrain = (projectile, material) => {
                    //if (projectile.Age > 150)
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size9, Material.Ice, 0);
                },
                OnProjectileHit = (projectile, target, amount) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size9, Material.Ice, 0);
                }
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                     = ProjectileId.DiggingAndDamaging,
                BaseDamage             = 10,
                DigBrush               = Brush.Size7,
                DigStrength            = 7,
                ParticleColor          = Color.FromNonPremultiplied(248, 113, 241, 100),
                ParticleStream         = true,
                MaxAge                 = 3000,
                Speed                  = 600,
                FireSound              = Sound.SpaceShipBlaster,
                OnProjectileHitTerrain = (projectile, material) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size8, Material.Fire, 1);
                },
            });

            //Final Boss Grenades
            ProjectileBase.AddType(new ProjectileType()
            {
                Id                     = ProjectileId.Grenade,
                BaseDamage             = 5,
                ParticleColor          = Color.FromNonPremultiplied(109, 247, 27, 255),
                ParticleStream         = true,
                Speed                  = 500,
                MaxAge                 = 3000,
                FireSound              = Sound.HomingMissileFire,
                HitSound               = Sound.HomingMissileHit,
                OnProjectileHitTerrain = (projectile, material) => {
                    projectile.Map.Explode(projectile.Position, 250, 9);
                },
                OnProjectileHit = (projectile, target, amount) => {
                    projectile.Map.Explode(projectile.Position, 250, 9);
                }
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id             = ProjectileId.Grenade_2,
                BaseDamage     = 1,
                Speed          = 1000,
                MaxAge         = 6000,
                HasGravity     = true,
                FireSound      = Sound.GrenadeFire,
                ParticleColor  = Color.FromNonPremultiplied(109, 247, 27, 255),
                ParticleStream = true,
                //OnProjectileMove = (projectile, material) =>
                //{
                //    if (projectile.Age > 2800)
                //        projectile.Map.Explode(projectile.Position, 5, 1);
                //},
                OnProjectileHitTerrain = (projectile, material) => {
                    projectile.Map.Explode(projectile.Position, 5, 1);
                },
                OnProjectileHit = (projectile, target, amount) => {
                    projectile.Map.Explode(projectile.Position, 5, 1);
                }
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                   = ProjectileId.MiniFlame,
                BaseDamage           = 5,
                DigBrush             = Brush.Size7,
                DigStrength          = 8,
                ParticleColor        = Color.FromNonPremultiplied(255, 80, 98, 255),
                ParticleStream       = true,
                InitialParticleBurst = 30,
                MaxAge               = 5000,
                Speed                = 300,
                Penetrate            = true
            });

            ProjectileBase.AddType(new ProjectileType()
            {
                Id                     = ProjectileId.MiniFlame_2,
                BaseDamage             = 5,
                ParticleColor          = Color.FromNonPremultiplied(255, 80, 98, 255),
                ParticleStream         = true,
                MaxAge                 = 5000,
                Speed                  = 650,
                FireSound              = Sound.MiniFlame,
                OnProjectileHitTerrain = (projectile, material) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size3, Material.Fire, 0);
                },
                OnProjectileHit = (projectile, target, amount) => {
                    projectile.Map.RenderBrush(projectile.Position, Brush.Size3, Material.Fire, 0);
                }
            });
        }
Beispiel #31
0
 private void cmbProjectile_SelectedIndexChanged(object sender, EventArgs e)
 {
     mEditorItem.Projectile = ProjectileBase.Get(ProjectileBase.IdFromList(cmbProjectile.SelectedIndex - 1));
 }
Beispiel #32
0
        private void UpdateEditor()
        {
            if (mEditorItem != null)
            {
                pnlContainer.Show();

                txtName.Text          = mEditorItem.Name;
                cmbFolder.Text        = mEditorItem.Folder;
                txtDesc.Text          = mEditorItem.Description;
                cmbType.SelectedIndex = (int)mEditorItem.ItemType;
                cmbPic.SelectedIndex  = cmbPic.FindString(TextUtils.NullToNone(mEditorItem.Icon));
                cmbEquipmentAnimation.SelectedIndex = AnimationBase.ListIndex(mEditorItem.EquipmentAnimationId) + 1;
                nudPrice.Value          = mEditorItem.Price;
                cmbRarity.SelectedIndex = mEditorItem.Rarity;

                nudStr.Value = mEditorItem.StatsGiven[0];
                nudMag.Value = mEditorItem.StatsGiven[1];
                nudDef.Value = mEditorItem.StatsGiven[2];
                nudMR.Value  = mEditorItem.StatsGiven[3];
                nudSpd.Value = mEditorItem.StatsGiven[4];

                nudStrPercentage.Value = mEditorItem.PercentageStatsGiven[0];
                nudMagPercentage.Value = mEditorItem.PercentageStatsGiven[1];
                nudDefPercentage.Value = mEditorItem.PercentageStatsGiven[2];
                nudMRPercentage.Value  = mEditorItem.PercentageStatsGiven[3];
                nudSpdPercentage.Value = mEditorItem.PercentageStatsGiven[4];

                nudHealthBonus.Value  = mEditorItem.VitalsGiven[0];
                nudManaBonus.Value    = mEditorItem.VitalsGiven[1];
                nudHPPercentage.Value = mEditorItem.PercentageVitalsGiven[0];
                nudMPPercentage.Value = mEditorItem.PercentageVitalsGiven[1];
                nudHPRegen.Value      = mEditorItem.VitalsRegen[0];
                nudMpRegen.Value      = mEditorItem.VitalsRegen[1];

                nudDamage.Value         = mEditorItem.Damage;
                nudCritChance.Value     = mEditorItem.CritChance;
                nudCritMultiplier.Value = (decimal)mEditorItem.CritMultiplier;
                cmbAttackSpeedModifier.SelectedIndex = mEditorItem.AttackSpeedModifier;
                nudAttackSpeedValue.Value            = mEditorItem.AttackSpeedValue;
                nudScaling.Value                 = mEditorItem.Scaling;
                nudRange.Value                   = mEditorItem.StatGrowth;
                chkBound.Checked                 = Convert.ToBoolean(mEditorItem.Bound);
                chkStackable.Checked             = Convert.ToBoolean(mEditorItem.Stackable);
                cmbToolType.SelectedIndex        = mEditorItem.Tool + 1;
                cmbAttackAnimation.SelectedIndex = AnimationBase.ListIndex(mEditorItem.AttackAnimationId) + 1;
                RefreshExtendedData();
                if (mEditorItem.ItemType == ItemTypes.Equipment)
                {
                    cmbEquipmentBonus.SelectedIndex = (int)mEditorItem.Effect.Type;
                }

                nudEffectPercent.Value         = mEditorItem.Effect.Percentage;
                chk2Hand.Checked               = mEditorItem.TwoHanded;
                cmbMalePaperdoll.SelectedIndex =
                    cmbMalePaperdoll.FindString(TextUtils.NullToNone(mEditorItem.MalePaperdoll));

                cmbFemalePaperdoll.SelectedIndex =
                    cmbFemalePaperdoll.FindString(TextUtils.NullToNone(mEditorItem.FemalePaperdoll));

                if (mEditorItem.ItemType == ItemTypes.Consumable)
                {
                    cmbConsume.SelectedIndex    = (int)mEditorItem.Consumable.Type;
                    nudInterval.Value           = mEditorItem.Consumable.Value;
                    nudIntervalPercentage.Value = mEditorItem.Consumable.Percentage;
                }

                picItem.BackgroundImage?.Dispose();
                picItem.BackgroundImage = null;
                if (cmbPic.SelectedIndex > 0)
                {
                    picItem.BackgroundImage = System.Drawing.Image.FromFile("resources/items/" + cmbPic.Text);
                }

                picMalePaperdoll.BackgroundImage?.Dispose();
                picMalePaperdoll.BackgroundImage = null;
                if (cmbMalePaperdoll.SelectedIndex > 0)
                {
                    picMalePaperdoll.BackgroundImage =
                        System.Drawing.Image.FromFile("resources/paperdolls/" + cmbMalePaperdoll.Text);
                }

                picFemalePaperdoll.BackgroundImage?.Dispose();
                picFemalePaperdoll.BackgroundImage = null;
                if (cmbFemalePaperdoll.SelectedIndex > 0)
                {
                    picFemalePaperdoll.BackgroundImage =
                        System.Drawing.Image.FromFile("resources/paperdolls/" + cmbFemalePaperdoll.Text);
                }

                cmbDamageType.SelectedIndex  = mEditorItem.DamageType;
                cmbScalingStat.SelectedIndex = mEditorItem.ScalingStat;

                //External References
                cmbProjectile.SelectedIndex = ProjectileBase.ListIndex(mEditorItem.ProjectileId) + 1;
                cmbAnimation.SelectedIndex  = AnimationBase.ListIndex(mEditorItem.AnimationId) + 1;

                nudCooldown.Value = mEditorItem.Cooldown;

                if (mChanged.IndexOf(mEditorItem) == -1)
                {
                    mChanged.Add(mEditorItem);
                    mEditorItem.MakeBackup();
                }
            }
            else
            {
                pnlContainer.Hide();
            }

            UpdateToolStripItems();
        }
Beispiel #33
0
 public static void AddProjectile(ProjectileBase newProjectile)
 {
     projectilesList.Add(newProjectile);
 }
Beispiel #34
0
 private void cmbProjectile_SelectedIndexChanged(object sender, EventArgs e)
 {
     mEditorItem.Combat.ProjectileId = ProjectileBase.IdFromList(cmbProjectile.SelectedIndex);
 }