Ejemplo n.º 1
0
 public RangeMissile()
 {
     missileType = MissileType.Range;
     targetArea  = new short[, ] {
         { 9, 9 }
     };
 }
 public MissileInfo(long id, Vector3D location, Vector3D direction, MissileType missileType)
 {
     this.id          = id;
     this.location    = location;
     this.direction   = direction;
     this.missileType = missileType;
 }
 public MissileManagementClient(ACPWrapper antennaWrapper, IMyShipController rc, long id, MissileType missileType)
 {
     this.antennaWrapper = antennaWrapper;
     this.rc             = rc;
     this.id             = id;
     this.missileType    = missileType;
 }
 public StandardMissile()
 {
     missileType = MissileType.Standard;
     targetArea  = new short[, ] {
         { 0, 0 }
     };
 }
    //Places any innactive missile of a certain type in position (pos), with rotation (rot) and stores planet owner (owner).
    public void CreateMissileInPos(Vector2 pos, Quaternion rot, MissileType type, Planet owner)
    {
        for (int i = 0; i < missilesPool.Count; i++)
        {
            if (!missilesPool[i].gameObject.activeSelf && missilesPool[i].type == type)
            {
                missilesPool[i].transform.position = pos;
                missilesPool[i].transform.rotation = rot;
                missilesPool[i].owner = owner;
                missilesPool[i].gameObject.SetActive(true);
                controller.sfx.PlaySound("shoot");
                return;
            }
        }

        //All missiles are busy. Creating new one and adding it to the missiles pool.
        Missile mToCreate = Instantiate(GetMissleByType(type).gameObject, missileContainer).GetComponent <Missile>();

        mToCreate.rbody.velocity     = Vector2.zero;
        mToCreate.transform.position = pos;
        mToCreate.transform.rotation = rot;
        mToCreate.owner = owner;
        mToCreate.gameObject.SetActive(true);
        controller.sfx.PlaySound("shoot");
        missilesPool.Add(mToCreate);
    }
Ejemplo n.º 6
0
    public void launchMissile(MissileType type, GameObject T, Controller.Owner O, float d, float omm, bool hacked)
    {
        StopAllCoroutines();
        if (hacked)
            StartCoroutine(enableCollisions());
        switch (O)
        {
            case Controller.Owner.Enemy:
                gameObject.layer = LayerMask.NameToLayer("eMissiles");
                targetLayer = LayerMask.NameToLayer("Player");
                if(PS_Jammer.JammerEnabled)
                    StartCoroutine(checkJammer());
                break;
            case Controller.Owner.Player:
                gameObject.layer = LayerMask.NameToLayer("pMissiles");
                targetLayer = LayerMask.NameToLayer("Enemies");
                break;
        }

        assignedTarget = true;
        target = T;
        missileType = type;
        Modifier = omm;
        HP = 10;
        damage = d;
    }
Ejemplo n.º 7
0
    public void GenerateMissile(Vector2 pos, MissileType type, Vector2 dir = default)
    {
        Missile missilePrefab;

        if (type == MissileType.大型)
        {
            missilePrefab = missileType.missile_Big;
        }
        else if (type == MissileType.中型)
        {
            missilePrefab = missileType.missile_Middle;
        }
        else if (type == MissileType.防御型小)
        {
            missilePrefab = missileType.def_Small;
        }
        else if (type == MissileType.防御型中)
        {
            missilePrefab = missileType.def_Middle;
        }
        else if (type == MissileType.防御型大)
        {
            missilePrefab = missileType.def_Large;
        }
        else if (type == MissileType.引爆型)
        {
            missilePrefab = missileType.bomb;
        }
        else if (type == MissileType.分裂型)
        {
            missilePrefab = missileType.spread;
        }
        else if (type == MissileType.反弹型)
        {
            missilePrefab = missileType.bouncy;
        }
        else if (type == MissileType.跟踪型)
        {
            missilePrefab = missileType.tracer;
        }
        else
        {
            missilePrefab = missileType.missile_Small;
        }

        Missile missile = Instantiate(missilePrefab, pos, Quaternion.identity, Camera.main.transform);

        missileList.Add(missile);
        missile.onDestory = () => {
            missileList.Remove(missile);
        };

        if (dir == default)
        {
            Vector2 targetPoint = cam.transform.position;
            dir = (targetPoint - pos).normalized;
        }
        missile.MoveToward(dir);
    }
Ejemplo n.º 8
0
        public void Generate(Vector3 firingPosition, Vector3 velocity, MissileType type)
        {
            var missile = _missileViewProvider.Get();

            missile.SetType(type);
            missile.SetInitialPosition(firingPosition);
            missile.SetVelocity(velocity);
        }
Ejemplo n.º 9
0
        public static Missile Generate(Sprite parent, MissileType type)
        {
            var missile = CreateMissileFromType(parent, type);

            Missiles.Add(missile);

            return(missile);
        }
 public SpecialMissile()
 {
     missileType = MissileType.Standard;
     targetArea  = new short[, ] {
         { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 }, { 0, 0 }
     };
     //A3
 }
Ejemplo n.º 11
0
 internal void SetType(MissileType type)
 {
     this.type = type;
     if (this.type == MissileType.MISSILE)
     {
         Mesh mesh = GetComponent <MeshFilter>().mesh;
         mesh.uv = mesh.uv2;
     }
 }
Ejemplo n.º 12
0
 static Missile CreateMissileFromType(Sprite parent, MissileType type)
 {
     return(type switch
     {
         MissileType.Basic => new BasicMissile(TextureHelper.MissileTexture, parent),
         MissileType.Fire => new FireMissile(TextureHelper.FireMissileTexture, parent),
         MissileType.Frost => new FrostMissile(TextureHelper.MissileTexture, parent),
         _ => null,
     });
Ejemplo n.º 13
0
 float ShootIntervalFromType(MissileType type)
 {
     return(type switch
     {
         MissileType.Basic => 2f,
         MissileType.Fire => 5f,
         MissileType.Frost => 3f,
         _ => 0f
     });
Ejemplo n.º 14
0
        /// <summary>
        /// Loads a missile type definition from the given XML node.
        /// </summary>
        /// <param name="missileTypeElem">The XML node to load from.</param>
        /// <param name="metadata">The metadata object being constructed.</param>
        private static void LoadMissileType(XElement missileTypeElem, ScenarioMetadata metadata)
        {
            XAttribute nameAttr = missileTypeElem.Attribute(XmlMetadataConstants.TYPE_NAME_ATTR);

            if (nameAttr == null)
            {
                throw new SimulatorException("Missile type name not defined!");
            }

            MissileType missileType = new MissileType(nameAttr.Value, metadata);

            LoadScenarioElementType(missileTypeElem, missileType, metadata);

            XElement launchAnimElem = missileTypeElem.Element(XmlMetadataConstants.LAUNCHANIMATION_ELEM);

            if (launchAnimElem != null)
            {
                XAttribute launchDelayAttr = launchAnimElem.Attribute(XmlMetadataConstants.LAUNCH_DELAY_ATTR);
                if (launchDelayAttr == null)
                {
                    throw new SimulatorException("Launch delay not defined for missile type!");
                }
                int launchDelay = XmlHelper.LoadInt(launchDelayAttr.Value);
                missileType.SetLaunchAnimation(launchAnimElem.Value, launchDelay);
            }

            XElement flyingAnimElem = missileTypeElem.Element(XmlMetadataConstants.FLYINGANIMATION_ELEM);

            if (flyingAnimElem != null)
            {
                missileType.SetFlyingAnimation(flyingAnimElem.Value);
            }

            XElement trailAnimElem = missileTypeElem.Element(XmlMetadataConstants.TRAILANIMATION_ELEM);

            if (trailAnimElem != null)
            {
                XAttribute trailAnimFreqAttr = trailAnimElem.Attribute(XmlMetadataConstants.TRAILANIMATION_FREQUENCY_ATTR);
                if (trailAnimFreqAttr == null)
                {
                    throw new SimulatorException("Trail animation frequency not defined for missile type!");
                }
                int trailAnimFreq = XmlHelper.LoadInt(trailAnimFreqAttr.Value);
                missileType.SetTrailAnimation(trailAnimElem.Value, trailAnimFreq);
            }

            XElement impactAnimElem = missileTypeElem.Element(XmlMetadataConstants.IMPACTANIMATION_ELEM);

            if (impactAnimElem != null)
            {
                missileType.SetImpactAnimation(impactAnimElem.Value);
            }

            metadata.AddMissileType(missileType);
        }
Ejemplo n.º 15
0
        public static bool Prefix(ref int[] ___m_spawn_weapon_count)
        {
            // Setup the primary budget.
            MPPrimaries.Budget.Clear();
            foreach (var weapon in RobotManager.m_multiplayer_spawnable_weapons)
            {
                var weaponType = (WeaponType)weapon.type;
                if (NetworkMatch.IsWeaponAllowed(weaponType))
                {
                    MPPrimaries.Budget.Add(new PrimaryBudget
                    {
                        Type      = weaponType,
                        Budget    = weapon.percent,
                        Remaining = weapon.percent,
                        Active    = 0
                    });
                }

                Debug.Log($"MPPrimaries - Added {weaponType}, budget {weapon.percent}");
            }

            // Spawn in initial primaries.
            var primaries = MPPrimaries.GetMaxPrimaries();

            for (int i = 0; i < primaries; i++)
            {
                MPPrimaries.SpawnPrimary();
            }

            // This is the rest of the PowerupLevelStart code, currently unmodified.
            var num = RobotManager.m_multi_missile_count;

            for (int n = 0; n < num; n++)
            {
                MissileType missileType = NetworkMatch.RandomAllowedMissileSpawn();
                if (missileType != MissileType.NUM)
                {
                    ItemPrefab item2 = ChallengeManager.MissileTypeToPrefab(missileType);
                    // NetworkMatch.SpawnItem(item2, false);
                    AccessTools.Method(typeof(NetworkMatch), "SpawnItem").Invoke(null, new object[] { item2, false });
                }
            }
            NetworkMatch.SetSpawnMissileTimer();
            NetworkMatch.SetSpawnSuperTimer();
            NetworkMatch.SetSpawnBasicTimer();

            // Get rid of weapon counts so they aren't triggered by the original function.
            for (var i = 0; i < 8; i++)
            {
                ___m_spawn_weapon_count[i] = 0;
            }

            // Short circuit the original code.
            return(false);
        }
    //Finds a missile of a specific type.
    public Missile GetMissleByType(MissileType type)
    {
        for (int i = 0; i < missilesPool.Count; i++)
        {
            if (missilesPool[i].type == type)
            {
                return(missilesPool[i]);
            }
        }

        return(null);
    }
Ejemplo n.º 17
0
 public MissileAttack(double latitude, double longitude, DateTime when, PersonelRank rank, MissileType type)
 {
     GRAVITATIONAL_ACCELERATION = 9.8;
     Latitude   = latitude;
     Longitude  = longitude;
     AttackDate = when;
     Rank       = rank;
     if (type == MissileType.Nuclear && rank != PersonelRank.CommanderInChief)
     {
         throw new Exception("Only the president can issue this order");
     }
     MissileType = type;
 }
Ejemplo n.º 18
0
 public void Initialize(Damage damage, Vector3 pos, float speed, Vector2 dir, MissileSource source, MissileType type)
 {
     transform.position = pos;
     this.speed = speed;
     this.direction = dir;
     this.lifetime = 0.0f;
     this.source = source;
     this.type = type;
     this.damage = damage;
     gameObject.SetActive(true);
     spriteRenderer.enabled = true;
     collider.enabled = true;
     audioSource.PlayOneShot(shot_sound);
 }
Ejemplo n.º 19
0
        public void SetType(MissileType type)
        {
            switch (type)
            {
            case MissileType.Player:
                gameObject.layer      = LayerMask.NameToLayer("PlayerMissile");
                _spriteRenderer.color = Color.blue;
                break;

            case MissileType.Invader:
                gameObject.layer      = LayerMask.NameToLayer("InvaderMissile");
                _spriteRenderer.color = Color.red;
                break;
            }
        }
            /*===============| Getters |==============*/
            public MissileInfo GetMissileCloseTo(Vector3D location, MissileType type, bool delete)
            {
                MissileInfo tempInfo = default(MissileInfo);

                foreach (var info in missileList)
                {
                    tempInfo = (Vector3D.DistanceSquared(info.location, location) < Vector3D.DistanceSquared(tempInfo.location, location)) && (type & info.missileType) != 0 ? info : tempInfo;
                }

                if (delete)
                {
                    RemoveMissile(tempInfo);
                }

                return(tempInfo);
            }
Ejemplo n.º 21
0
    private Missile _CreateMissile(MissileType pType, Vector3 pStartPos)
    {
        Missile lResultMissile = _FindMissileFromPool(pType);
        if (lResultMissile == null)
        {
            GameObject lMissilePrefab = null;
            GameObject lMissileObject = null;

            lMissilePrefab = (GameObject)Resources.Load(MissileTypePath[(int)pType]);
            lMissileObject = (GameObject)GameObject.Instantiate(lMissilePrefab, pStartPos, Quaternion.identity);

            lResultMissile = lMissileObject.GetComponent<Missile>();
            lResultMissile.Init(_CreateMissileGuid());
        }
        return lResultMissile;
    }
Ejemplo n.º 22
0
 public void fireMissile(Damage damage, Vector3 pos, float speed, Vector2 direction, MissileSource source, MissileType type)
 {
     for (int i = 0; i < missiles.Count; ++i) {
         if (!goList[i].activeSelf) {
             goList[i].SetActive(true);
             missiles[i].Initialize(damage, pos, speed, direction, source, type);
             return;
         }
     }
     if (isExtendAllowed) { //extend the pool
         goList.Add(GameObject.Instantiate(prefabMissile) as GameObject);
         int idx = goList.Count - 1;
         missiles.Add(goList[idx].GetComponent<Missile>());
         goList[idx].transform.parent = goList[0].transform.parent ;
         goList[idx].SetActive(true);
         missiles[idx].Initialize(damage, pos, speed, direction, source, type);
     }
 }
            public bool ParseMissileEntry(string[] missileEntry)
            {
                if (missileEntry.Length == 5)
                {
                    long Id;
                    if (!Int64.TryParse(missileEntry[1], out Id))
                    {
                        return(false);
                    }

                    Vector3D location;
                    if (!Vector3D.TryParse(missileEntry[2], out location))
                    {
                        return(false);
                    }

                    Vector3D direction;
                    if (!Vector3D.TryParse(missileEntry[3], out direction))
                    {
                        return(false);
                    }


                    int backingNumber;
                    if (!Int32.TryParse(missileEntry[4], out backingNumber))
                    {
                        return(false);
                    }
                    MissileType type = (MissileType)backingNumber;

                    if (AddMissileEntry(Id, location, direction, type))
                    {
                        return(true);
                    }

                    return(false);
                }
                else
                {
                    return(false);
                }
            }
Ejemplo n.º 24
0
 public static int getMissilePriority(MissileType missile)
 {
     if (MPAutoSelection.isInitialised)
     {
         string mis = missile.ToString();
         for (int i = 0; i < 8; i++)
         {
             if (mis.Equals(SecondaryPriorityArray[i]))
             {
                 return(i);
             }
         }
         uConsole.Log("-AUTOSELECT- [WARN]: getMissilePriority:-1, primary wasnt in array");
         return(-1);
     }
     else
     {
         uConsole.Log("-AUTOSELECT- [WARN]: getMissilePriority:-1, priority didnt get initialised");
         return(-1);
     }
 }
Ejemplo n.º 25
0
        public static MissileType returnNextSecondary(Player local, bool prev)
        {
            if (areThereAllowedSecondaries())
            {
                MissileType currentMissile     = local.m_missile_type;
                String      currentMissileName = currentMissile.ToString();

                int index = getMissilePriority(currentMissile);
                if (prev && !currentMissileName.Equals(SecondaryPriorityArray[7]))
                {
                    index++;
                    while (index < 8)
                    {
                        if (isMissileAccessibleAndNotNeverselect(SecondaryPriorityArray[index]) && local.m_missile_ammo[getWeaponIndex(SecondaryPriorityArray[index])] > 0)
                        {
                            return(stringToMissileType(SecondaryPriorityArray[index]));
                        }
                        index++;
                    }
                }
                else if (!prev && !currentMissileName.Equals(SecondaryPriorityArray[0]))
                {
                    index--;
                    while (index >= 0)
                    {
                        if (isMissileAccessibleAndNotNeverselect(SecondaryPriorityArray[index]) && local.m_missile_ammo[getWeaponIndex(SecondaryPriorityArray[index])] > 0)
                        {
                            return(stringToMissileType(SecondaryPriorityArray[index]));
                        }
                        index--;
                    }
                }
                return(MissileType.NUM);
            }
            else
            {
                return(MissileType.NUM);
            }
        }
Ejemplo n.º 26
0
 protected override bool doAction()
 {
     base.CreateNode(NodeType.SkillNode, this.performId);
     this.missileType  = (MissileType)this.data.effectParam1;
     this.colliderType = (ColliderType)this.data.effectParam2;
     this.AddAction(ActionManager.PlayAnim(this.performId, base.unit, true));
     this.mPlayEffectAction = ActionManager.PlayEffect(this.performId, base.unit, null, null, true, string.Empty, this.CasterUnit);
     this.AddAction(this.mPlayEffectAction);
     if (!Singleton <PvpManager> .Instance.IsInPvp && this.useCollider)
     {
         List <Units> list = new List <Units>();
         list.Add(this.targetUnit);
     }
     this.isActive = true;
     if (this.IsInstantHit())
     {
         this.InstantHit();
     }
     else
     {
         base.mCoroutineManager.StartCoroutine(this.Missile_Coroutine(), true);
     }
     if (base.unit == null)
     {
         return(false);
     }
     if (this.skillData == null)
     {
         return(false);
     }
     this.skill = base.unit.getSkillOrAttackById(this.skillData.skillId);
     if (this.skill != null)
     {
         Skill expr_133 = this.skill;
         expr_133.DestroyAction = (Callback <string, int>)Delegate.Combine(expr_133.DestroyAction, new Callback <string, int>(this.ExternDestroy));
     }
     return(true);
 }
Ejemplo n.º 27
0
    public void Spawn(MissileType type, Vector2 currentPlayerPosision)
    {
        // TODO :: 데이터를 빼다가 읽어줘야 됨.
        _spec = new MissileSpec()
        {
            _type     = MissileType.Basic,
            _speed    = 7f,
            _rotate   = 1f,
            _liveTime = 10f
        };

        // TODO :: 스프라이트 렌더러에서 알맞은 미사일을 읽어와야 함.
        _renderer.sprite = _basicMissile;

        var randomUnitVec = new Vector2(UnityEngine.Random.Range(-1, 1), UnityEngine.Random.Range(-1, 1));

        randomUnitVec.Normalize();
        var spawnPosition = _playerPosition + randomUnitVec * _outRange;

        this.transform.position = spawnPosition;

        _isMissileValid  = true;
        _isMissileActive = true;
    }
            public static void Postfix(int amt, MissileType mt, Player __instance)
            {
                if ((GameplayManager.IsChallengeMode || GameplayManager.IsMission) && !GameplayManager.IsMultiplayerActive && MPAutoSelection.secondarySwapFlag && __instance == GameManager.m_local_player)
                {
                    uConsole.Log(mt.ToString() + ", amt:" + amt);
                    int         new_missile     = MPAutoSelection.getMissilePriority(mt);
                    int         current_missile = MPAutoSelection.getMissilePriority(GameManager.m_local_player.m_missile_type);
                    MissileType old_missile     = GameManager.m_local_player.m_missile_type;
                    if (new_missile < current_missile && !MPAutoSelection.SecondaryNeverSelect[new_missile])
                    {
                        sp_next_missileType = mt;
                        delay = 1;
                    }

                    if (GameManager.m_local_player.m_missile_type == MissileType.DEVASTATOR && old_missile != MissileType.DEVASTATOR)
                    {
                        if (MPAutoSelection.zorc)
                        {
                            SFXCueManager.PlayCue2D(SFXCue.enemy_boss1_alert, 1f, 0f, 0f, false);
                            GameplayManager.AlertPopup(Loc.LS("DEVASTATOR SELECTED"), string.Empty, 5f);
                        }
                    }
                }
            }
            public MissileInfo GetMissileCloseToAndInDirection(Vector3D location, Vector3D direction, MissileType type, double range, double dotRange, bool delete)
            {
                MissileInfo tempInfo = default(MissileInfo);

                foreach (var info in missileList)
                {
                    if (((info.direction.Dot(direction) > dotRange) && Vector3D.DistanceSquared(location, info.location) < (range * range)) && (type & info.missileType) != 0)
                    {
                        tempInfo = info;
                    }
                }

                if (delete)
                {
                    RemoveMissile(tempInfo);
                }

                return(tempInfo);
            }
Ejemplo n.º 30
0
 void UseEnemyBullet()
 {
     typeOfProjectileToFire = MissileType.EnemyBullet;
 }
Ejemplo n.º 31
0
    private Missile _FindMissileFromPool(MissileType pType)
    {
        if (!mMissilePool.ContainsKey(pType))
            return null;
        if (mMissilePool[pType].Count <= 0)
            return null;

        Missile lResultMissile = mMissilePool[pType].Dequeue();
        lResultMissile.gameObject.SetActive(true);
        return lResultMissile;
    }
Ejemplo n.º 32
0
 public void AddMissile(Unit pAttackUnit, MissileType pType, Vector3 pStartPos, Vector3 pMissileDirect)
 {
     Missile lMissile = _CreateMissile(pType, pStartPos);
     if (lMissile != null)
         lMissile.GoShot(pAttackUnit, pStartPos, pMissileDirect);
 }
Ejemplo n.º 33
0
 public void ExecuteAttack()
 {
     Console.WriteLine("Shooting {0} weapon at lat:{1} lon:{2} by order from {3}", MissileType.ToString(), Latitude.ToString(), Longitude.ToString(), Rank.ToString());
     //Fire missiles
 }
 private int CountMissilesOfType(MissileType missileType)
 {
     return(missileList.Count(x => (x.missileType & missileType) != 0));
 }
 public void SetInfo(Transform inTarget, MissileType inType, Ship inOwner, bool inlocal, float inThrust, float inTimeAlive, float inBlastRadius)
 {
     owner = inOwner;
     target = inTarget;
     mType = inType;
     local = inlocal;
     thrust = inThrust;
     missileName = owner.name + mType.ToString();
     timeAlive = inTimeAlive;
     blastRadius = inBlastRadius;
     missileHealth = blastRadius/6;
 }
            private bool AddMissileEntry(long id, Vector3D location, Vector3D pointingDirection, MissileType missileType)
            {
                var info = new MissileInfo(id, location, pointingDirection, missileType);

                if (missileList.Add(info))
                {
                    OnMissileAdded?.Invoke(info);
                    return(true);
                }

                return(false);
            }
Ejemplo n.º 37
0
 public IMissile CreateMissile(MissileType missileType)
 {
     return(_missiles(missileType));
 }
Ejemplo n.º 38
0
 void UseSwarmMissile()
 {
     typeOfProjectileToFire = MissileType.SwarmMissile;
 }
Ejemplo n.º 39
0
 void UseSmallMissile()
 {
     typeOfProjectileToFire = MissileType.SmallMissile;
 }
Ejemplo n.º 40
0
 public static void FireMissile(Damage damage, Vector3 pos, float speed, Vector2 direction, MissileSource source, MissileType type)
 {
     int idx = -1;
     instance.poolMap.TryGetValue(type, out idx);
     instance.pools[idx].fireMissile(damage, pos, speed, direction, source, type);
 }
Ejemplo n.º 41
0
 void UseEnemyBomb()
 {
     typeOfProjectileToFire = MissileType.EnemyBomb;
 }
Ejemplo n.º 42
0
 //Sets the enemy missile by specified type.
 public void SetMissleByType(MissileType type)
 {
     missileTypeObj = controller.missile.GetMissleByType(type);
     planet.SetMissileSprite(missileTypeObj.GetComponent <SpriteRenderer>().sprite);
 }
Ejemplo n.º 43
0
 void UseBullet()
 {
     typeOfProjectileToFire = MissileType.Bullet;
 }