示例#1
0
        public void reset()
        {
            ship = new Ship(shipX, shipY, 10.0d, 0.5 * Math.PI);
            missile = new Missile(50.0d, 150.0d, 0.0d, 0.25 * Math.PI, program);

            missile.setTarget(ship);
        }
示例#2
0
 public override void Damage(Collider hitCollider, Vector3 position, Vector3 direction, Missile missile)
 {
     killPosition = position;
     killDirection = direction;
     killPower = missile.GetPower();
     base.Damage(hitCollider, position, direction, missile);
 }
示例#3
0
 public void setMissle(Missile M)
 {
     m = M;
     ps.Play();
     initialized = true;
     m.trail = this;
     ps.Clear();
 }
示例#4
0
 private void OnDisable()
 {
     if (ps == null)
         ps = GetComponent<ParticleSystem>();
     ps.Stop();
     ps.Clear();
     m = null;
 }
示例#5
0
 public void RemoveMissile(Missile pMissile)
 {
     if (!mMissilePool.ContainsKey(pMissile.vType))
     {
         mMissilePool.Add(pMissile.vType, new Queue<Missile>());
     }
     mMissilePool[pMissile.vType].Enqueue(pMissile);
 }
示例#6
0
 public virtual void Damage(Collider hitCollider, Vector3 position, Vector3 direction, Missile missile)
 {
     if (IsLive)
     {
         ApplyDamage(missile.GetDamage(), missile.GetOwner());
         if (OnDamage != null)
             OnDamage(hitCollider, position, direction, missile.GetPower(), missile.GetDamage(), missile.GetOwner());
     }
 }
示例#7
0
文件: UnitEnemy.cs 项目: Mokbii/TemFa
    public override void OnMissileCollider(Missile pMissile)
    {
        if (!aIsAlive)
            return;

        vHp -= pMissile.vPower;
        if (vHp <= 0)
        {
            GoDie();
        }
    }
示例#8
0
 public override void Damage(Collider hitCollider, Vector3 position, Vector3 direction, Missile missile)
 {
     killPosition = position;
     killDirection = direction;
     killPower = missile.GetPower();
     var damageAmount = missile.GetDamage();
     if (hitCollider == HeadCollider)
     {
         Debug.Log("HEADSHOT!");
         damageAmount *= 10f;
     }
     base.Damage(hitCollider, position, direction, killPower, damageAmount, missile.GetOwner());
 }
 protected void OnEnable()
 {
     m = GetComponent<Missile>();
     td = FindObjectOfType<TimerDisplay>();
     timerReadout = td.wir;
     rigid = GetComponent<Rigidbody2D>();
     timer = 0;
     if (td.control != null)
         td.control.IsVisible = false;
     timerActive = true;
     if(RadarController.RC != null)
         RadarController.RC.radar.target = this.gameObject;
 }
示例#10
0
    private void FireMissile(Enemy enemy)
    {
        // Get the desired start position for the missile.
        var isOnLeft = enemy.transform.position.x < 0;
        var position = isOnLeft ? new Vector3(-10, -8, 0) : new Vector3(10, -8, 0);

        // Set the scale (to flip the missile).
        var scale = isOnLeft ? new Vector3(1, 1, 1) : new Vector3(-1, 1, 1);

        // Create the missile and set the target.
        _missile = Instantiate(MissilePrefab, position, Quaternion.identity) as Missile;
        _missile.transform.localScale = scale;
        _missile.SetEnemyTarget(enemy);
    }
示例#11
0
 public void Trigger(Missile missile)
 {
     //Debug.Log("MISSILE SENSOR TRIGGERED!!!!");
     var missileOwner = missile.GetOwner();
     if (missileOwner != null)
     {
         var missileOwnerActor = missileOwner.GetComponentInParent<ActorAgent>();
         if (missileOwnerActor != null)
         {
             if (missileOwnerActor.Team == opposingTeam)
             {
                 var target = Targeting.FindNearest(opposingTeam, owner.GetVehicle().transform.position, 500f);
                 owner.SetTarget(target);
             }
         }
     }
 }
    public void spawnMissileExplosion(Vector2 position, Missile.MissileType type)
    {
        GameObject explosion;
        switch (type)
        {
            case Missile.MissileType.Ballistic:
                explosion = TrashMan.spawn("FlashRingFlame03", position, new Quaternion(0, 0, 0, 0));
                TrashMan.despawnAfterDelay(explosion, 4f);
                break;
            case Missile.MissileType.AOE:
                explosion = TrashMan.spawn("Flame2", position, new Quaternion(0, 0, 0, 0));
                TrashMan.despawnAfterDelay(explosion, 4f);
                break;
            case Missile.MissileType.DOT:
                explosion = TrashMan.spawn("Explosion07", position, new Quaternion(0, 0, 0, 0));
                TrashMan.despawnAfterDelay(explosion, 4f);
                break;

        }
    }
示例#13
0
    /* Shoot()
     *
     * shoots a bullet towards target
     *
     */
    void Shoot()
    {
        GameObject bulletGO = (GameObject)Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
        // kind of annoying - havce to do this for every GO soooo
        Bullet       bullet     = bulletGO.GetComponent <Bullet>();
        Missile      missile    = bulletGO.GetComponent <Missile>();
        PoisonBullet poisBullet = bulletGO.GetComponent <PoisonBullet>();

        Destroy(bullet, 5f);
        Destroy(missile, 5f);
        Destroy(poisBullet, 5f);
        if (bullet != null)
        {
            bullet.Seek(target);
        }
        if (missile != null)
        {
            missile.Seek(target);
        }
        if (poisBullet != null)
        {
            poisBullet.Seek(target);
        }
    }
示例#14
0
 public void RemoveMissile(Missile missile)
 {
     missiles.Remove(missile);
 }
示例#15
0
    public void AddMissile2()
    {
        Missile missile = new Missile(x, y + 50, _player, 0f, 0f);                  // missle that KEEPS following

        game.AddChild(missile);
    }
示例#16
0
 public override void execute(Missile missile)
 {
     missile.thrust = 0.0d;
     missile.turn = 0.0d;
 }
示例#17
0
    protected virtual void OnTriggerEnter(Collider other)
    {
        const float cos45 = 0.70710678118f;         //sqrt(2)/2 = 0.70710678118

        switch (other.gameObject.layer)
        {
        case GameLayer.Units:
        {
            Unit targetUnit = other.GetComponent <Unit>();
            if (targetUnit != null && targetUnit != owner)
            {
                targetUnit.DamageSide(transform.position, damage, damageType);

                //Vector3 direction = other.transform.position - (transform.position - new Vector3(0, transform.position.y, 0));

                //float COS = Vector3.Dot(direction.normalized, targetUnit.view_direction.normalized);

                //if(COS > cos45)
                //{
                //	targetUnit.DamageBack(damage, damageType);
                //	targetUnit.AddEffect(effect);
                //}
                //else if(COS < -cos45)
                //{
                //	targetUnit.DamageFront(damage, damageType);
                //	targetUnit.AddEffect(effect);
                //}
                //else
                //{
                //	Vector3 right_direction = new Vector3(targetUnit.view_direction.z, targetUnit.view_direction.y, -targetUnit.view_direction.x);
                //	COS = Vector3.Dot(direction.normalized, right_direction.normalized);

                //	if(COS > cos45)
                //	{
                //		targetUnit.DamageLeft(damage, damageType);
                //		targetUnit.AddEffect(effect);
                //	}
                //	else if(COS < -cos45)
                //	{
                //		targetUnit.DamageRight(damage, damageType);
                //		targetUnit.AddEffect(effect);
                //	}
                //}

                Destroy();
            }
            return;
        }


        case GameLayer.Missiles:
        {
            Missile missile2 = other.GetComponent <Missile>();
            if (missile2 != null && missile2.owner != owner)
            {
                Destroy();
                Debug.Log("Missile " + name + " deleted by collision with another missile");
            }
            return;
        }

        case GameLayer.Default:
        {
            //if(enabled == false) { Debug.Log("Disabled missile " + name + " going to be destroyed"); }
            Destroy();
            Debug.Log("Missile " + name + " deleted by collision with " + other.name + " in default layer");
            return;
        }

        case GameLayer.Destructibles:
        {
            Destructible targetDestructible = other.GetComponent <Destructible>();
            if (!targetDestructible)
            {
                return;
            }
            targetDestructible.ReceiveDamage(damage, damageType);
            Destroy();
            return;
        }

        case GameLayer.DamageReceivers:
        {
            DamageReceiver receiver = other.GetComponent <DamageReceiver>();

            if (receiver.owner != owner)
            {
                receiver.ReceiveDamage(damage, damageType);
                Destroy();
            }

            return;
        }
        }

        onHit.Invoke();
    }
示例#18
0
文件: Ship.cs 项目: sean-h/spacegame
 public void RemoveMissileLock(Missile missile)
 {
     _missilesLockedOn.Remove(missile);
 }
示例#19
0
 private void Start()
 {
     player        = GameObject.FindGameObjectWithTag("Player");
     missileScript = player.GetComponent <Missile>();
 }
示例#20
0
 public void Trigger(Missile missile)
 {
     if (onDetect != null)
         onDetect(missile);
 }
 public virtual void OnHit(Transform user, Missile projectile) // when the projectile hits something
 {
 }
    public void SpawnMissile(Missile missile, bool belongsToPlayer)
    {
        var missileTransform = Instantiate(MissilePrefab);
        MissileHandler handler = missileTransform.GetComponent<MissileHandler>();
        handler.SetTarget((Card)missile.Target);

        var area = (belongsToPlayer ? PlayerMissileAreaGUI : OpponentMissileAreaGUI);
        missileTransform.SetParent(area);
    }
示例#23
0
 void Start()
 {
     missile = GetComponentInParent<Missile>();
     sightArea = GetComponent<CircleCollider2D>();
     sightArea.radius = 0.001f;
 }
示例#24
0
 private void AcquireTarget()
 {
     float distance;
     missile = Targetable[0].GetComponent<Missile>();
     for (int i = 0; i < Targetable.Length; i++)
     {
         distance = Vector2.Distance(transform.position, Targetable[i].transform.position);
         if (distance <= Vector2.Distance(transform.position, missile.transform.position))
         {
             missile = Targetable[i].GetComponent<Missile>();
         }
     }
     if (missile.target == controller.hullRef.gameObject || missile.target == controller.gameObject)
     targetChange = true;
 }        
示例#25
0
 private void Update()
 {
     if (doingDamage)
     {
         if(missile!=null)
             missile.HP -= pdsturrets.Count * effectiveDamage * Time.deltaTime;
     }
     Targetable = Physics2D.OverlapCircleAll(transform.position, effectiveRange, 1 << targetLayer);
     if (Targetable.Length == 0)//If missile out of range then it is no longer target
     {
         if (missile == null)
             return;
         missile = null;
         targetChange = true;
     }
     if (Targetable.Length >= 1)//More than 1 missile in range, pick closest
     {
         targetTimer += Time.deltaTime;
         if (targetTimer > .2f)
         {
             AcquireTarget();
             targetTimer = 0;
         }
     } 
     if (targetChange)//Everytime a new target is picked it gives it to the pds turrets and updates their effective damage
     {
         foreach (PDSTurret pds in pdsturrets)
         {
             pds.assignTarget(effectiveDamage, missile);
             targetChange = false;
         }
     }
 }
示例#26
0
    // Update is called once per frame
    void LateUpdate()
    {
        //The Update logic does:
        //
        //	Checks whether or not mecanim told us to check for a hit
        //		Mecanim is great for sending us this info because it can play animations at any speed, rather than calculate the time
        //		we use it to tell us the appropriate hit time
        //
        //	Get UI input from keyboard, and mouse clicks
        //
        //	Tells mecanim what animation we should be playing based on variables such as idling, pain or death
        //
        //	Handle movement and direction
        //
        //
        if (hitCheck)       //hitCheck is a boolean variable, it gets set by mecanim attack states, if mecanim set it...then we need to do hit checks right now
        {
            if (ahc < 1)
            {
                ahc = 1;                //we may have a "double pulse" coming from Mecanim so...
            }
            AbilityCollision abilColl = new AbilityCollision();
            abilColl = abilities[WeaponState].collChecks[abilities[WeaponState].collChecks.Count - ahc];
            if (abilColl.type == 0)
            {
                //ANGLE RANGE which can be used for any angle/range including radial attacks
                for (int i = 0; i < enemies.Length; i++) //loop throught the enemies
                {
                    CheckForHit(enemies[i], abilColl);   //ahc= ability hit counter, which is used for indexing a a one tow three punch combo for example...
                }
                ahc -= 1;                                // some abilities have multiple checks, so when we use an ability, we set ahc to the number of hits in the ability (combo punches for example)
            }
            else if (abilColl.type == 1)
            {
                //Missiles
                //are a special type, my enemies are its enemies, my damage is its damage, it needs to know who I am, and which of my abilities used it this time
                Transform tm = (Transform)Instantiate(abilColl.missile, abilColl.missile.position, abilColl.missile.rotation);
                tm.gameObject.SetActive(true);
                Missile missile = tm.GetComponent <Missile>();
                missile.speed   = abilColl.speed;
                missile.damage  = abilColl.damage;
                missile.enemies = enemies;
                missile.abc     = this;
            }
            if (abilColl.type == 2)
            {
                //Beams/Bullets
                Transform tm = (Transform)Instantiate(abilColl.missile, abilColl.missile.position, abilColl.missile.rotation);
                tm.gameObject.SetActive(true);
                RayShot rayshot = tm.GetComponent <RayShot>();
                rayshot.damage  = abilColl.damage;
                rayshot.enemies = enemies;
                Vector3 tempPos = attackPos;
                tempPos.y = abilColl.missile.position.y;
                Vector3 tempdelta = Vector3.Normalize(tempPos - abilColl.missile.position);                 //this is the actual vector from the source point to the attack point normalized
                rayshot.endPos = tempdelta * abilColl.range;
                rayshot.abc    = this;
            }

            hitCheck = false;            // we are done checking, reset the hitCheck bool
        }

        RaycastHit hit;                                                     // RayCastHits hold very useful info such as hitnormal and location
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition); //get a ray that goes from the camera -> "THROUGH" the mouse pointer - > and out into the scene

        if (!Input.GetKey(KeyCode.LeftAlt))                                 //if we are not using the ALT key(camera control)...
        {
            // floor goal
            if (Input.GetMouseButton(0))                      //is the left mouse button being clicked?
            {
                if (floorPlane.Raycast(ray, out hit, 500.0f)) //check to see if that ray hits our "floor"
                {
                    //Rungy, this is where you need to use a cursor object with a character controller on it
                    //placing the controller on the spot wherre you hit, getting the name of the object...doing another downward trce to it for the actual position

                    movementTarget.transform.position = hit.point;                    //mark it where it hit
                    movementTarget.enabled            = true;
                    lookAtPos    = hit.point;
                    lookAtPos.y  = transform.position.y;
                    wasAttacking = false;                    //we're moving now, not attacking
                }
            }
        }

        switch (Input.inputString)       //get keyboard input, probably not a good idea to use strings here...Garbage collection problems with regards to local string usage are known to happen
        {                                //the garbage collection memory problem arises from local alloction of memory, and not freeing it up efficiently
        case "p":
            animator.SetTrigger("Pain"); //the animator controller will detect the trigger pain and play the pain animation
            break;

        case "a":
            animator.SetInteger("Death", 1);                    //the animator controller will detect death=1 and play DeathA
            break;

        case "b":
            animator.SetInteger("Death", 2);                    //the animator controller will detect death=2 and play DeathB
            break;

        case "c":
            animator.SetInteger("Death", 3);                    //the animator controller will detect death=3 and play DeathC
            break;

        case "n":
            animator.SetBool("NonCombat", true);                    //the animator controller will detect this non combat bool, and go into a non combat state "in" this weaponstate
            break;

        default:
            break;
        }

        animator.SetInteger("WeaponState", WeaponState); // probably would be better to check for change rather than bashing the value in like this

        if (!Input.GetKey(KeyCode.LeftAlt))              // if we're changing camera transforms, do not use "USE"
        {
            if (Input.GetMouseButton(1))                 // are we using the right button?
            {
                if (rightButtonDown != true)             // was it previously down? if so we are already using "USE" bailout (we don't want to repeat attacks 800 times a second...just once per press please
                {
                    attackPlane.enabled = true;
                    if (attackPlane.Raycast(ray, out hit, 500.0f))
                    {
                        movementTarget.transform.position = transform.position; //we are attacking so lock our position to where we are
                        attackPos   = hit.point;                                // establish the point that we hit with the mouse
                        attackPos.y = transform.position.y;                     //use our height for the LOOKAT function, so we stay level and dont lean the character in weird angles
                        Vector3 attackDelta = attackPos - transform.position;   //we need the Vector delta which is an un-normalized direction vector
                        lookAtPos = attackPos;
                        animator.SetTrigger("Use");                             //tell mecanim to do the attack animation(trigger)

                        ahc = abilities[WeaponState].collChecks.Count;          //ahc=ability hit counter, used for animations that have multiple hits like combos
                        animator.SetBool("Idling", true);                       //stop moving
                        rightButtonDown = true;                                 //right button was not down before, mark it as down so we don't attack 800 frames a second
                        wasAttacking    = true;                                 //some mecanims will actually move us past the target, so we want to keep looking in one direction instead of spinning wildly around the target
                    }
                    attackPlane.enabled = false;
                }
            }
        }

        if (Input.GetMouseButtonUp(1))        //ok, we can clear the right mouse button and use it for the next attack
        {
            if (rightButtonDown == true)
            {
                rightButtonDown = false;
            }
        }


        Debug.DrawLine((movementTarget.transform.position + transform.up * 2), movementTarget.transform.position);       //useful for visuals in editor

        //We need to handle elevation for mecanim here...we will be doing our ground check right now
        //GROUND check

        ray.direction = transform.up * -1;
        ray.origin    = transform.position + transform.up;

        //need two casts...one for velocity ahead of us
        //and one for where we are
        //we need the time from the last frame, as well as the distance traveled since that frame

        //RAMPS,Coming down from Jumps and Falling
        if (floorPlane.Raycast(ray, out hit, 1.0f))
        {
            //always hit if we are going up
            if (hit.point.y > (transform.position.y + 0.02f))
            {
                transform.position = hit.point;
                lookAtPos.y        = transform.position.y;
                fallspeed          = 0.0f;
            }
        }
        else if (floorPlane.Raycast(ray, out hit, 1.2f))
        {
            //lower hit check for going down ramps specifically
            if (hit.point.y < (transform.position.y - 0.02f))
            {
                transform.position = hit.point;
                lookAtPos.y        = transform.position.y;
                fallspeed          = 0.0f;
            }
        }
        else
        {        //Falling
            transform.parent = null;
            lookAtPos        = transform.position;
            movementTarget.transform.position = transform.position;
            movementTarget.transform.parent   = null;

            fallspeed += 0.3f;
            Vector3 v = new Vector3(0.0f, fallspeed * Time.deltaTime, 0.0f);
            transform.position -= v;
        }

        Debug.DrawLine((movementTarget.transform.position + transform.up * 2), lookAtPos + transform.up * 2);    //useful for visuals in editor

        if (transform.parent == floorPlane.transform)
        {
            lookAtPos = movementTarget.transform.position;
        }
        lookAtPos.y = transform.position.y;
        Quaternion tempRot = transform.rotation;                //save current rotation

        transform.LookAt(lookAtPos);
        Quaternion hitRot = transform.rotation;                 // store the new rotation

        // now we slerp orientation
        transform.rotation = Quaternion.Slerp(tempRot, hitRot, Time.deltaTime * rotateSpeed);


        if (Vector3.Distance(movementTarget.transform.position, transform.position) > 0.5f)
        {
            animator.SetBool("Idling", false);
        }
        else
        {
            animator.SetBool("Idling", true);
            movementTarget.enabled = false;
        }
    }
示例#27
0
        internal void GenerateDefaultProfiles()
        {
            BuffProfile newProfile = new BuffProfile();

            BotBuffs botBuffs = new BotBuffs();

            newProfile.Commands = botBuffs.Commands;
            newProfile.Buffs    = botBuffs.Buffs;
            SaveBuffProfile(newProfile);

            Banes banes = new Banes();

            newProfile.Commands = banes.Commands;
            newProfile.Buffs    = banes.Buffs;
            SaveBuffProfile(newProfile);

            Finesse finesse = new Finesse();

            newProfile.Commands = finesse.Commands;
            newProfile.Buffs    = finesse.Buffs;
            SaveBuffProfile(newProfile);

            Heavy heavy = new Heavy();

            newProfile.Commands = heavy.Commands;
            newProfile.Buffs    = heavy.Buffs;
            SaveBuffProfile(newProfile);

            Light light = new Light();

            newProfile.Commands = light.Commands;
            newProfile.Buffs    = light.Buffs;
            SaveBuffProfile(newProfile);

            Mage mage = new Mage();

            newProfile.Commands = mage.Commands;
            newProfile.Buffs    = mage.Buffs;
            SaveBuffProfile(newProfile);

            Missile missile = new Missile();

            newProfile.Commands = missile.Commands;
            newProfile.Buffs    = missile.Buffs;
            SaveBuffProfile(newProfile);

            Trades trades = new Trades();

            newProfile.Commands = trades.Commands;
            newProfile.Buffs    = trades.Buffs;
            SaveBuffProfile(newProfile);

            TwoHand twoHand = new TwoHand();

            newProfile.Commands = twoHand.Commands;
            newProfile.Buffs    = twoHand.Buffs;
            SaveBuffProfile(newProfile);

            VoidBuffs voidBuffs = new VoidBuffs();

            newProfile.Commands = voidBuffs.Commands;
            newProfile.Buffs    = voidBuffs.Buffs;
            SaveBuffProfile(newProfile);

            XpChain xpChain = new XpChain();

            newProfile.Commands = xpChain.Commands;
            newProfile.Buffs    = xpChain.Buffs;
            SaveBuffProfile(newProfile);
        }
示例#28
0
 private void OnMissileSelected(object sender, Missile e)
 {
     StartCoroutine("SetSelectedMissile", e);
 }
示例#29
0
 public override void execute(Missile missile)
 {
     missile.turn = missile.maxTurn * (percentageOfTurn / 100);
 }
 public virtual void MessUp(Transform user, Missile projectile) // manipulate how the projectile is created
 {
 }
示例#31
0
 /// <summary>
 /// Only keep this script around if we're the owner.
 /// </summary>
 protected override void OnStart()
 {
     mMissile = firedObject.GetComponent<Missile>();
     if (mMissile == null) Debug.LogWarning("No missile found");
 }
示例#32
0
    public void LaunchMissile(uint t, Vector3 c, Vector3 s, float v, int ext_id = 0, byte byStaticShow = 3)
    {                  //       形状     终点      起点       角度      外部数据id        起点终点显示状态
        Missile mis = GetAMissile(Time.time);

        if (mis != null)
        {
            if (mis.alive)
            {
                if (mis.mrMis != null)
                {
                    mis.mrMis.enabled = false;
                }
                mis.mrQuadSource.enabled = false;
                mis.mrQuadTarget.enabled = false;
                if (mis.bShowCone && mis.mrCone != null)
                {
                    mis.mrCone.enabled = false;
                }
                if (mis.bShowIcon && mis.mrShapeIcon != null)
                {
                    mis.mrShapeIcon.enabled = false;
                }
            }
            mis.bShowCone   = bShowCone;
            mis.bShowIcon   = bShowIcon;
            mis.external_id = ext_id;
            mis.StaticShow  = byStaticShow;
            //        gtw, t, r, n, scale, o
            // function(e, t, c, s, f, v) {
            if (GTW.Instance.systems.ContainsKey((int)t))
            {
                mis.style = t;
            }
            else
            {
                mis.style = 1;
            }

            if (mis.bShowIcon)
            {
                if (mis.goShapeIcon == null)
                {
                    mis.goShapeIcon = new GameObject();
                    mis.goShapeIcon.transform.parent = goMissileRoot.transform;
                    mis.mrShapeIcon      = mis.goShapeIcon.AddComponent <MeshRenderer>();
                    mis.mfShapeIcon      = mis.goShapeIcon.AddComponent <MeshFilter>();
                    mis.goShapeIcon.name = "Missile_" + mis.idx.ToString() + "_ShapeIcon_";
                }

                if (mis.MatsShapIcon == null)
                {
                    mis.MatsShapIcon = new Material[GTW.Instance.systems.Count];
                }
                if (mis.MatsShapIcon[mis.style - 1] == null)
                {
                    mis.MatsShapIcon[mis.style - 1] = new Material(GTW.Instance.bDark ? GTW.Instance.systems[(int)mis.style].DarkShapeIcon : GTW.Instance.systems[(int)mis.style].LightShapeIcon);
                }

                mis.mrShapeIcon.sharedMaterial = mis.MatsShapIcon[mis.style - 1];
                mis.mfShapeIcon.sharedMesh     = meshIcon[(int)t];
            }

            if (mis.goQuadSource == null)
            {
                mis.goQuadSource = new GameObject();
                mis.goQuadSource.transform.parent = goMissileRoot.transform;
                mis.mrQuadSource = mis.goQuadSource.AddComponent <MeshRenderer>();
                MeshFilter mf = mis.goQuadSource.AddComponent <MeshFilter>();
                mf.sharedMesh         = meshQuad;
                mis.goQuadSource.name = "Missile_" + mis.idx.ToString() + "_Quad_Source_";
            }
            if (mis.MatsQuadSource[mis.style - 1] == null)
            {
                mis.MatsQuadSource[mis.style - 1] = new Material(GTW.Instance.bDark ? GTW.Instance.systems[(int)mis.style].DarkQuadSource : GTW.Instance.systems[(int)mis.style].LightQuadSource);
            }

            mis.mrQuadSource.sharedMaterial = mis.MatsQuadSource[mis.style - 1];

            if (mis.goQuadTarget == null)
            {
                mis.goQuadTarget = new GameObject();
                mis.goQuadTarget.transform.parent = goMissileRoot.transform;
                mis.mrQuadTarget = mis.goQuadTarget.AddComponent <MeshRenderer>();
                MeshFilter mf = mis.goQuadTarget.AddComponent <MeshFilter>();
                mf.sharedMesh         = meshQuad;
                mis.goQuadTarget.name = "Missile_" + mis.idx.ToString() + "_Quad_Target_";
            }
            if (mis.MatsQuadTarget[mis.style - 1] == null)
            {
                mis.MatsQuadTarget[mis.style - 1] = new Material(GTW.Instance.bDark ? GTW.Instance.systems[(int)mis.style].DarkQuadTarget : GTW.Instance.systems[(int)mis.style].LightQuadTarget);
            }

            mis.mrQuadTarget.sharedMaterial = mis.MatsQuadTarget[mis.style - 1];

            if (mis.goQuadSourceStatic == null)
            {
                mis.goQuadSourceStatic = new GameObject();
                mis.goQuadSourceStatic.transform.parent = goMissileRoot.transform;
                mis.mrQuadSourceStatic = mis.goQuadSourceStatic.AddComponent <MeshRenderer>();
                MeshFilter mf = mis.goQuadSourceStatic.AddComponent <MeshFilter>();
                mf.sharedMesh = meshQuad;
                mis.goQuadSourceStatic.name = "Missile_" + mis.idx.ToString() + "_Quad_Source_Static_";
            }
            if (mis.MatsQuadSourceStatic[mis.style - 1] == null)
            {
                mis.MatsQuadSourceStatic[mis.style - 1] = new Material(GTW.Instance.bDark ? GTW.Instance.systems[(int)mis.style].DarkQuadSourceStatic : GTW.Instance.systems[(int)mis.style].LightQuadSourceStatic);
            }

            mis.mrQuadSourceStatic.sharedMaterial = mis.MatsQuadSourceStatic[mis.style - 1];
            mis.mrQuadSourceStatic.enabled        = false;

            if (mis.goQuadTargetStatic == null)
            {
                mis.goQuadTargetStatic = new GameObject();
                mis.goQuadTargetStatic.transform.parent = goMissileRoot.transform;
                mis.mrQuadTargetStatic = mis.goQuadTargetStatic.AddComponent <MeshRenderer>();
                MeshFilter mf = mis.goQuadTargetStatic.AddComponent <MeshFilter>();
                mf.sharedMesh = meshQuad;
                mis.goQuadTargetStatic.name = "Missile_" + mis.idx.ToString() + "_Quad_Target_Static_";
            }
            if (mis.MatsQuadTargetStatic[mis.style - 1] == null)
            {
                mis.MatsQuadTargetStatic[mis.style - 1] = new Material(GTW.Instance.bDark ? GTW.Instance.systems[(int)mis.style].DarkQuadTargetStatic : GTW.Instance.systems[(int)mis.style].LightQuadTargetStatic);
            }

            mis.mrQuadTargetStatic.sharedMaterial = mis.MatsQuadTargetStatic[mis.style - 1];
            mis.mrQuadTargetStatic.enabled        = false;

            if (mis.bShowCone)
            {
                if (mis.goCone == null)
                {
                    mis.goCone = new GameObject();
                    mis.goCone.transform.parent = goMissileRoot.transform;
                    mis.mrCone = mis.goCone.AddComponent <MeshRenderer>();
                    MeshFilter mf = mis.goCone.AddComponent <MeshFilter>();
                    mf.sharedMesh   = meshCone;
                    mis.goCone.name = "Missile_" + mis.idx.ToString() + "_Cone_";
                }
                if (mis.MatsCone == null)
                {
                    mis.MatsCone = new Material[GTW.Instance.systems.Count];
                }
                if (mis.MatsCone[mis.style - 1] == null)
                {
                    mis.MatsCone[mis.style - 1] = new Material(GTW.Instance.bDark ? GTW.Instance.systems[(int)mis.style].DarkCone : GTW.Instance.systems[(int)mis.style].LightCone);
                }

                mis.mrCone.sharedMaterial = mis.MatsCone[mis.style - 1];
            }

            if (s != Vector3.zero)
            {
                mis.has_source   = true;
                mis.source_coord = s;
            }
            else
            {
                mis.has_source = false;
            }

            mis.start_time   = Time.time;
            mis.alive        = true;
            mis.target_coord = c;
            // if (this.style = t, this.shape = n.shapes[this.style], this.color = GTW.systems[this.style].color[e.palette].f, this.has_source = !! s, this.start_time = e.time, this.alive = !0, this.has_source && vec3.copy(this.source_coord, s), vec3.copy(this.target_coord, c), this.has_source) {
            if (mis.has_source)
            {
                float p = Vector3.Distance(s, c); // var p = vec2.distance(s, c),
                float m = MLS_height * p;         // m = l.height * p,
                float d = (c[0] - s[0]) / p;      // d = (c[0] - s[0]) / p,
                float _ = (c[1] - s[1]) / p;      // _ = (c[1] - s[1]) / p,
                float b = 200f;                   // b = 200,
                float y = b * -_;                 // y = b * -_,
                float T = b * d;                  // T = b * d;
                // v = v || 0;
                float w = Mathf.Cos(v);
                float E = Mathf.Sin(v);
                //int x = 0;
                Vector3 A = MLS_i;
                Vector3 M = MLS_u;

                if (mis.verts == null)
                {
                    mis.verts = new Vector3[missile_g * 2];
                    mis.texs  = new List <Vector4>(new Vector4[missile_g * 2]);
                }
                Vector2 v2id = Hotspot.StoV2((short)(mis.idx + 1));
                mis.v3Offset = GetOffset(s, c);
                for (int R = 0; R < missile_g; ++R)                // for (var w = Math.cos(v), E = Math.sin(v), x = this.index * h, A = i, M = u, R = 0; g > R; ++R) {
                {
                    float P = (float)R / (float)(missile_g - 1);   // var P = R / (g - 1);
                    M = Vector3.Lerp(s, c, P);                     // vec3.lerp(M, s, c, P);// 直线距离上的点
                    float L = m * Mathf.Sin(P * Mathf.PI) * 0.15f; // var L = m * Math.sin(P * Math.PI) * 0.15;// 距离相关的参数,距离远值就大些
                    // y、T为直线状态下每一段的偏移值d、 _并进行b缩放
                    //M[0] += E * L * y;// M[0] += E * L * y,
                    //M[1] += E * L * T;// M[1] += E * L * T,
                    M[2] += w * L * (Map.projection.dir < 0 ? 0.5f : 1f);// M[2] += w * L,

                    LanLonToV3(ref A, M);


                    // o[x + 0] = A[0],
                    // o[x + 1] = A[1],
                    // o[x + 2] = A[2],
                    // o[x + 3] = -P,
                    // o[x + 4] = A[0],
                    // o[x + 5] = A[1],
                    // o[x + 6] = A[2],
                    // o[x + 7] = P,
                    // x += 8

                    mis.verts[R << 1].Set(A[0], A[1], A[2]);
                    mis.texs[R << 1] = new Vector4(-P, 0f, v2id.x, v2id.y);
                    mis.verts[(R << 1) + 1].Set(A[0], A[1], A[2]);
                    mis.texs[(R << 1) + 1] = new Vector4(P, 0f, v2id.x, v2id.y);
                }// }

                if (mis.idxs == null)
                {
                    mis.idxs = CreateTriangleStripIndex(mis.verts).ToArray();
                }

                if (mis.goMissile == null)
                {
                    mis.goMissile                         = new GameObject("Missiles_" + mis.idx.ToString());
                    mis.goMissile.layer                   = goMissileTraceRoot.layer;
                    mis.goMissile.transform.parent        = goMissileTraceRoot.transform;
                    mis.goMissile.transform.localPosition = Vector3.zero;
                    mis.goMissile.transform.localRotation = Quaternion.identity;
                    mis.goMissile.transform.localScale    = Vector3.one;
                    mis.mrMis = mis.goMissile.AddComponent <MeshRenderer>();
                    MeshFilter mf = mis.goMissile.AddComponent <MeshFilter>();
                    mis.mesh          = new Mesh();
                    mf.mesh           = mis.mesh;
                    mis.mesh.vertices = mis.verts;
                    mis.mesh.SetUVs(0, mis.texs);
                    mis.mesh.SetIndices(mis.idxs, MeshTopology.Triangles, 0);
                    mis.mesh.bounds = new Bounds(Vector3.zero, new Vector3(100f, 100f, 100f));
                }
                else
                {
                    mis.mesh.vertices = mis.verts;
                    mis.mesh.SetUVs(0, mis.texs);
                }
                mis.mrMis.enabled = true;
                if (mis.MatsMis[mis.style - 1] == null)
                {
                    mis.MatsMis[mis.style - 1] = new Material(GTW.Instance.bDark ? GTW.Instance.systems[(int)mis.style].DarkMis : GTW.Instance.systems[(int)mis.style].LightMis);
                }

                mis.mrMis.sharedMaterial = mis.MatsMis[mis.style - 1];
                // var D = 4 * this.index * h;
                // webgl.bindVertexBuffer(a),
                // gl.bufferSubData(gl.ARRAY_BUFFER, D, this.verts)
            }   // }

            // this.has_source ?
            //  (this.source_coord[2] < 0.015 ?
            //      r(this.source_mat, this.source_coord, f, e), this.draw_source_impact = !0
            //      :
            //      this.draw_source_impact = !1)
            //:
            //  (l.ff_impacts && (this.start_time -= 1), r(this.target_mat, this.target_coord, f, e))
            UpdateMissileTransform(mis);
        }
    }
示例#33
0
 public void AddNewMissile(Missile missile)
 {
     missiles.Add(missile);
 }
示例#34
0
 public void SetMissile(Missile missile)
 {
     this.pMissile = missile;
 }
示例#35
0
 public override void bounce(Missile proj)
 {
     base.bounce(proj);
 }
示例#36
0
        internal Missile Move()
        {
            float ProposedX;
            float ProposedY;
            Missile ret = null;
            TankEnviroment env = SetupEnviroment();
            var movements = _controller.Move(env)
                .GroupBy(m => m)
                .Select(m => m.First());
            foreach (var m in movements)
            {
                switch (m)
                {
                    case TankAction.Shoot:
                        if (_cooldown == 0)
                        {
                            var newShot = NewShotLocation();
                            ret = new Missile()
                            {
                                Angle = this.TurretAngle,
                                X = newShot.X,
                                Y = newShot.Y,
                                R = this.R,
                                G = this.G,
                                B = this.B,
                            };
                            _cooldown = Game.MISSLE_COOLDOWN;
                        }
                        break;
                    case TankAction.TankClockwise:
                        this.Angle += Game.TANK_TURN_SPEED;
                        break;
                    case TankAction.TankCounterclockwise:
                        this.Angle -= Game.TANK_TURN_SPEED;
                        break;
                    case TankAction.TurretClockwise:
                        this.TurretAngle += Game.TURRET_TURN_SPEED;
                        break;
                    case TankAction.TurretCounterclockwise:
                        this.TurretAngle -= Game.TURRET_TURN_SPEED;
                        break;
                    case TankAction.MoveBackward:
                        ProposedX = this.X - (float)Math.Sin(this.Angle) * Game.TANK_SPEED;
                        ProposedY = this.Y - (float)Math.Cos(this.Angle) * Game.TANK_SPEED;
                        if (IsTankInbounds((float)ProposedX,(float) ProposedY))
                        {
                            this.X = ProposedX;
                            this.Y = ProposedY;
                        }
                        break;
                    case TankAction.MoveForward:
                        ProposedX = this.X + (float)Math.Sin(this.Angle) * Game.TANK_SPEED;
                        ProposedY = this.Y + (float)Math.Cos(this.Angle) * Game.TANK_SPEED;
                        if (IsTankInbounds((float)ProposedX,(float) ProposedY))
                        {
                            this.X = ProposedX;
                            this.Y = ProposedY;
                        }
                        break;
                }
            }

            if (_cooldown > 0)
                _cooldown--;

            while (Angle > 2 * Math.PI)
            {
                Angle -= 2 * (float)Math.PI;
            }
            while (Angle < 0)
            {
                Angle += 2 * (float)Math.PI;
            }
            while (TurretAngle > 2 * Math.PI)
            {
                TurretAngle -= 2 * (float)Math.PI;
            }
            while (TurretAngle < 0)
            {
                TurretAngle += 2 * (float)Math.PI;
            }

            return ret;
        }
示例#37
0
文件: Ship.cs 项目: sean-h/spacegame
 /// <summary>
 /// Adds the missile lock.
 /// </summary>
 /// <param name='missile'>
 /// Missile.
 /// </param>
 public void AddMissileLock(Missile missile)
 {
     _missilesLockedOn.Add(missile);
 }
示例#38
0
    void Missile(GameObject shooter, int Rarity, int Index, bool isVamp, bool IsReinforce)
    {
        Missile[] bullets = new Missile[5];
        Vector3   scale   = Vector3.one;

        if (GameManager.Inst().Player.GetBossMode())
        {
            scale *= 0.5f;
        }
        if (IsReinforce)
        {
            scale *= 1.5f;
        }
        float rad = GameManager.Inst().UpgManager.BData[(int)Bullet.BulletType.MISSILE].GetDuration();

        switch (Rarity)
        {
        case 0:
            Objs[0] = GameManager.Inst().ObjManager.MakeBullet("Missile", Index);
            Objs[0].transform.position   = SpreadPos[0].transform.position;
            Objs[0].transform.rotation   = SpreadPos[0].transform.rotation;
            Objs[0].transform.localScale = scale;

            bullets[0]        = Objs[0].gameObject.GetComponent <Missile>();
            bullets[0].IsVamp = isVamp;
            bullets[0].Vamp   = shooter;
            bullets[0].ResetTarget();

            bullets[0].SearchArea.GetComponent <SearchArea>().SetArea(rad);
            bullets[0].Shoot(SpreadPos[0].transform.up);
            break;

        case 1:
        case 2:
            for (int i = 0; i < 2; i++)
            {
                Objs[i] = GameManager.Inst().ObjManager.MakeBullet("Missile", Index);
                Objs[i].transform.position   = SpreadPos[i + 1].transform.position;
                Objs[i].transform.rotation   = SpreadPos[i + 1].transform.rotation;
                Objs[0].transform.localScale = scale;

                bullets[i]             = Objs[0].gameObject.GetComponent <Missile>();
                bullets[i].IsVamp      = isVamp;
                bullets[i].Vamp        = shooter;
                bullets[i].IsReinforce = IsReinforce;
                bullets[i].ResetTarget();

                bullets[i].SearchArea.GetComponent <SearchArea>().SetArea(rad);
                bullets[i].Shoot(SpreadPos[0].transform.up);
            }
            break;

        case 3:
        case 4:
            for (int i = 0; i < 3; i++)
            {
                Objs[i] = GameManager.Inst().ObjManager.MakeBullet("Missile", Index);
                Objs[i].transform.position   = SpreadPos[i].transform.position;
                Objs[i].transform.rotation   = SpreadPos[i].transform.rotation;
                Objs[0].transform.localScale = scale;

                bullets[i]             = Objs[i].gameObject.GetComponent <Missile>();
                bullets[i].IsVamp      = isVamp;
                bullets[i].Vamp        = shooter;
                bullets[i].IsReinforce = IsReinforce;
                bullets[i].ResetTarget();

                bullets[i].SearchArea.GetComponent <SearchArea>().SetArea(rad);
                bullets[i].Shoot(SpreadPos[i].transform.up);
            }
            break;
        }

        GameManager.Inst().SodManager.PlayEffect("Wp_Missile");
    }
示例#39
0
    private void Create()
    {
        // Create root gameobject

        GameObject gameObject = new GameObject("NewMissile");

        Selection.activeGameObject = gameObject;

        // Create 3D model

        if (missileModel != null)
        {
            GameObject meshObject = Instantiate(missileModel, gameObject.transform);
            meshObject.name = "Model";
            meshObject.transform.localPosition = Vector3.zero;
            meshObject.transform.localRotation = Quaternion.identity;
        }

        // Create the visual effects

        if (exhaustVisualEffects != null)
        {
            GameObject exhaustVisualEffectsObject = Instantiate(exhaustVisualEffects, gameObject.transform);
            exhaustVisualEffectsObject.name = "ExhaustVisualEffects";
            exhaustVisualEffectsObject.transform.localPosition = Vector3.zero;
            exhaustVisualEffectsObject.transform.localRotation = Quaternion.identity;
        }

        // ************************ AUDIO ***************************

        // Create an object to store the audio under
        GameObject audioObject = new GameObject("Audio");

        audioObject.transform.parent        = gameObject.transform;
        audioObject.transform.localPosition = Vector3.zero;
        audioObject.transform.localRotation = Quaternion.identity;

        // Create the launch audio

        if (launchAudioClip != null)
        {
            GameObject launchAudioObject = new GameObject("LaunchAudio");
            launchAudioObject.transform.parent        = audioObject.transform;
            launchAudioObject.transform.localPosition = Vector3.zero;
            launchAudioObject.transform.localRotation = Quaternion.identity;

            AudioSource launchAudioSource = launchAudioObject.AddComponent <AudioSource>();
            launchAudioSource.clip        = launchAudioClip;
            launchAudioSource.playOnAwake = true;
            launchAudioSource.loop        = false;
        }

        // Create the exhaust audio

        if (exhaustAudioClip != null)
        {
            GameObject exhaustAudioObject = new GameObject("ExhaustAudio");
            exhaustAudioObject.transform.parent        = audioObject.transform;
            exhaustAudioObject.transform.localPosition = Vector3.zero;
            exhaustAudioObject.transform.localRotation = Quaternion.identity;

            AudioSource exhaustAudioSource = exhaustAudioObject.AddComponent <AudioSource>();
            exhaustAudioSource.clip        = exhaustAudioClip;
            exhaustAudioSource.playOnAwake = true;
            exhaustAudioSource.loop        = true;
        }

        // ************************ Main Components ***************************

        // Add a rigidbody

        Rigidbody rBody = gameObject.AddComponent <Rigidbody>();

        rBody.useGravity = false;

        // Add the Missile component

        Missile          missile   = gameObject.AddComponent <Missile>();
        SerializedObject missileSO = new SerializedObject(missile);

        missileSO.Update();

        // Add a Target Locker

        TargetLocker     targetLocker   = gameObject.AddComponent <TargetLocker>();
        SerializedObject targetLockerSO = new SerializedObject(targetLocker);

        targetLockerSO.Update();

        targetLockerSO.FindProperty("lockingEnabled").boolValue = false;
        targetLockerSO.ApplyModifiedProperties();

        // Add a target leader

        TargetLeader     targetLeader   = gameObject.AddComponent <TargetLeader>();
        SerializedObject targetLeaderSO = new SerializedObject(targetLeader);

        targetLeaderSO.Update();

        // Add engines

        VehicleEngines3D engines   = gameObject.AddComponent <VehicleEngines3D>();
        SerializedObject enginesSO = new SerializedObject(engines);

        enginesSO.Update();

        // Add a guidance system

        GuidanceController guidanceController   = gameObject.AddComponent <GuidanceController>();
        SerializedObject   guidanceControllerSO = new SerializedObject(guidanceController);

        guidanceControllerSO.Update();

        // Update the guidance system settings
        guidanceControllerSO.FindProperty("engines").objectReferenceValue = engines;
        guidanceControllerSO.ApplyModifiedProperties();

        // Add a Detonator

        Detonator        detonator   = gameObject.AddComponent <Detonator>();
        SerializedObject detonatorSO = new SerializedObject(detonator);

        detonatorSO.Update();

        if (explosion != null)
        {
            detonatorSO.FindProperty("detonatingDuration").floatValue         = 2;
            detonatorSO.FindProperty("detonatingStateSpawnObjects").arraySize = 1;
            detonatorSO.FindProperty("detonatingStateSpawnObjects").GetArrayElementAtIndex(0).objectReferenceValue = explosion;
            detonatorSO.ApplyModifiedProperties();
        }

        UnityEventTools.AddBoolPersistentListener(detonator.onDetonating, engines.SetRigidbodyKinematic, true);
        UnityEventTools.AddBoolPersistentListener(detonator.onDetonated, gameObject.SetActive, false);
        UnityEventTools.AddBoolPersistentListener(detonator.onReset, engines.SetRigidbodyKinematic, false);

        // Add Health Modifier

        HealthModifier   healthModifier   = gameObject.AddComponent <HealthModifier>();
        SerializedObject healthModifierSO = new SerializedObject(healthModifier);

        healthModifierSO.Update();


        if (areaDamage)
        {
            // Add a damage receiver scanner for the area damage

            GameObject areaDamageScannerObject = new GameObject("AreaDamageScanner");
            areaDamageScannerObject.transform.parent        = gameObject.transform;
            areaDamageScannerObject.transform.localPosition = Vector3.zero;
            areaDamageScannerObject.transform.localRotation = Quaternion.identity;

            // Add a kinematic rigidbody

            Rigidbody areaDamageScannerRigidbody = areaDamageScannerObject.AddComponent <Rigidbody>();
            areaDamageScannerRigidbody.isKinematic = true;

            // Add a sphere trigger collider and set the radius

            SphereCollider areaDamageScannerCollider = areaDamageScannerObject.AddComponent <SphereCollider>();
            areaDamageScannerCollider.isTrigger = true;
            areaDamageScannerCollider.radius    = 20;

            // Add a damage receiver scanner

            DamageReceiverScanner areaDamageScanner   = areaDamageScannerObject.AddComponent <DamageReceiverScanner>();
            SerializedObject      areaDamageScannerSO = new SerializedObject(areaDamageScanner);
            areaDamageScannerSO.FindProperty("scannerTriggerCollider").objectReferenceValue = areaDamageScannerCollider;
            areaDamageScannerSO.ApplyModifiedProperties();

            healthModifierSO.FindProperty("areaDamageReceiverScanner").objectReferenceValue = areaDamageScanner;
            healthModifierSO.ApplyModifiedProperties();
        }

        // Add a collision scanner

        CollisionScanner collisionScanner   = gameObject.AddComponent <CollisionScanner>();
        SerializedObject collisionScannerSO = new SerializedObject(collisionScanner);

        collisionScannerSO.Update();

        // Collision scanner settings
        if (areaDamage)
        {
            UnityEventTools.AddPersistentListener(collisionScanner.onHitDetected, healthModifier.RaycastHitAreaDamage);
        }
        else
        {
            UnityEventTools.AddPersistentListener(collisionScanner.onHitDetected, healthModifier.RaycastHitDamage);
        }

        UnityEventTools.AddPersistentListener(collisionScanner.onHitDetected, detonator.Detonate);


        if (targetProximityDetonation)
        {
            // Add a target proximity trigger to the root transform

            TargetProximityTrigger targetProximityTrigger   = gameObject.AddComponent <TargetProximityTrigger>();
            SerializedObject       targetProximityTriggerSO = new SerializedObject(targetProximityTrigger);
            targetProximityTriggerSO.Update();


            // Create an object for the proximity scanner trigger collider

            GameObject proximityTriggerColliderObject = new GameObject("TargetProximityScanner");
            proximityTriggerColliderObject.transform.parent        = gameObject.transform;
            proximityTriggerColliderObject.transform.localPosition = Vector3.zero;
            proximityTriggerColliderObject.transform.localRotation = Quaternion.identity;

            // Add a kinematic rigidbody

            Rigidbody proximityTriggerColliderRigidbody = proximityTriggerColliderObject.AddComponent <Rigidbody>();
            proximityTriggerColliderRigidbody.isKinematic = true;

            // Add a sphere trigger collider and set the radius

            SphereCollider sphereCollider = proximityTriggerColliderObject.AddComponent <SphereCollider>();
            sphereCollider.isTrigger = true;
            sphereCollider.radius    = 20;

            // Add a damage receiver scanner

            DamageReceiverScanner damageReceiverScanner   = proximityTriggerColliderObject.AddComponent <DamageReceiverScanner>();
            SerializedObject      damageReceiverScannerSO = new SerializedObject(damageReceiverScanner);
            damageReceiverScannerSO.Update();

            // Link the collider to the damage receiver scanner

            damageReceiverScannerSO.FindProperty("scannerTriggerCollider").objectReferenceValue = sphereCollider;
            damageReceiverScannerSO.ApplyModifiedProperties();
            damageReceiverScannerSO.Update();

            // Link the scanner to the proximity trigger

            targetProximityTriggerSO.FindProperty("scanner").objectReferenceValue = damageReceiverScanner;
            targetProximityTriggerSO.ApplyModifiedProperties();
            targetProximityTriggerSO.Update();

            UnityEventTools.AddPersistentListener(targetProximityTrigger.onTriggered, healthModifier.EmitDamage);
            UnityEventTools.AddPersistentListener(targetProximityTrigger.onTriggered, detonator.Detonate);

            UnityEventTools.AddPersistentListener(targetLocker.onLocked, targetProximityTrigger.SetTarget);
        }

        // Update the target locker settings

        UnityEventTools.AddPersistentListener(targetLocker.onLocked, targetLeader.SetTarget);
        UnityEventTools.AddVoidPersistentListener(targetLocker.onNoLock, targetLeader.ClearTarget);
        UnityEventTools.AddFloatPersistentListener(targetLocker.onNoLock, detonator.BeginDelayedDetonation, 4);

        // Update the target leader settings
        UnityEventTools.AddPersistentListener(targetLeader.onLeadTargetPositionUpdated, guidanceController.SetTargetPosition);

        missileSO.FindProperty("targetLocker").objectReferenceValue = targetLocker;
        missileSO.ApplyModifiedProperties();
    }
示例#40
0
 void MissileRelease()
 {
     tempMissile.GoTo(aimTarget.position);
     tempMissile = null;
     busy        = false;
 }
示例#41
0
文件: Map.cs 项目: cynic/HvZ
        internal void PopulateFromSerializedData(string serialized)
        {
            // sorry, spanish people.  Maybe I'll fix this up some year.
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            var dataItems = serialized.Split('|')
                            .Where(x => x.Length > 0)
                            .Select(x => x.Split(':'))
                            .Select(x => new { Key = x[0], Values = x[1].Split(',') });

            // clear everything.
            zombies.Clear();
            humans.Clear();
            walkers.Clear();
            spawners.Clear();
            obstacles.Clear();
            resupply.Clear();
            missiles.Clear();
            // parse-back functions.  Not the most secure in the world, but time is pressing...
            Func <string, string, Position> parsePos = (a, b) => new Position(Double.Parse(a), Double.Parse(b));
            Action <string[]> Z = xs => {
                var id   = UInt32.Parse(xs[0]);
                var x    = Double.Parse(xs[1]);
                var y    = Double.Parse(xs[2]);
                var life = Int32.Parse(xs[3]);
                var head = Double.Parse(xs[4]);
                var name = HvZ.Networking.Internal.fromBase64(xs[5]);
                var z    = new Zombie(id, name, this, x, y, head);
                zombies.Add(id, z);
                walkers.Add(id, z);
            };
            Func <string, SupplyItem[]> parseItems = s => s.Select(x => x == 'f' ? SupplyItem.Food : SupplyItem.Sock).ToArray();
            Action <string[]>           H          = xs => {
                var id    = UInt32.Parse(xs[0]);
                var x     = Double.Parse(xs[1]);
                var y     = Double.Parse(xs[2]);
                var life  = Int32.Parse(xs[3]);
                var head  = Double.Parse(xs[4]);
                var items = parseItems(xs[5]);
                var name  = HvZ.Networking.Internal.fromBase64(xs[6]);
                var h     = new Human(id, name, this, x, y, head);
                foreach (var i in items)
                {
                    h.AddItem(i);
                }
                humans.Add(id, h);
                walkers.Add(id, h);
            };
            Action <string[]> SP = xs => {
                var x = Double.Parse(xs[0]);
                var y = Double.Parse(xs[1]);
                var r = Double.Parse(xs[2]);
                spawners.Add(new SpawnPoint(x, y, r));
            };
            Action <string[]> O = xs => {
                var x = Double.Parse(xs[0]);
                var y = Double.Parse(xs[1]);
                var r = Double.Parse(xs[2]);
                obstacles.Add(new Obstacle(x, y, r));
            };
            Action <string[]> R = xs => {
                var id     = UInt32.Parse(xs[0]);
                var x      = Int32.Parse(xs[1]);
                var y      = Int32.Parse(xs[2]);
                var supply = parseItems(xs[3]);
                var r      = new ResupplyPoint(id, x, y);
                r.stored.AddRange(supply);
                resupply.Add(r);
            };
            Action <string[]> M = xs => {
                var id       = xs[0];
                var lifespan = Int32.Parse(xs[1]);
                var x        = Double.Parse(xs[2]);
                var y        = Double.Parse(xs[3]);
                var h        = Double.Parse(xs[4]);
                var m        = new Missile(id, lifespan, x, y, h);
                missiles.Add(m);
            };
            Action <string[]> WH = xs => {
                Width  = Int32.Parse(xs[0]);
                Height = Int32.Parse(xs[1]);
            };

            // quick loop to process each item
            foreach (var di in dataItems)
            {
                switch (di.Key)
                {
                case "z": Z(di.Values); break;

                case "h": H(di.Values); break;

                case "sp": SP(di.Values); break;

                case "o": O(di.Values); break;

                case "r": R(di.Values); break;

                case "wh": WH(di.Values); break;

                case "m": M(di.Values); break;

                default: throw new Exception(String.Format("Map is corrupt? I don't know what the '{0}' key means.", di.Key));
                }
            }
            if (OnMapChange != null)
            {
                OnMapChange(this, EventArgs.Empty);
            }
        }
示例#42
0
 /// <summary>
 /// 将投掷物加入池
 /// </summary>
 /// <param name="missile">投掷物组件</param>
 public static int MissileBirth(Missile missile)
 {
     return(GameDB.Instance.MissileBirth(missile));
 }
示例#43
0
 /// <summary> Sets some missile variables </summary>
 /// <param name="missile"> Missile </param>
 public void InitializeMissileMovement(Missile missile)
 {
     detectionRange     = missile.detectionRange;
     missileSpeed       = missile.speed;
     sprRenderer.sprite = missile.missileSprite;
 }
示例#44
0
 private void OnMissileFinished(Missile missile)
 {
     TriggerFinished();
 }
示例#45
0
文件: Unit.cs 项目: Mokbii/TemFa
 public virtual void OnMissileCollider(Missile pMissile)
 {
 }
示例#46
0
        public void Do(Unit self, Unit targetUnit, Vector3 target)
        {
            if (srvDoFunc == 27)
            {
                // teleport
                self.InstantMove(target);
            }

            if (srvDoFunc == 1)
            {
                Item           weapon   = self.equip == null ? null : self.equip.GetWeapon();
                int            damage   = 10;
                WeaponHitClass hitClass = WeaponHitClass.HandToHand;
                bool           ranged   = false;
                if (weapon != null)
                {
                    WeaponInfo weaponInfo = weapon.info.weapon;
                    hitClass = weaponInfo.hitClass;
                    if (weaponInfo.twoHanded)
                    {
                        damage = Random.Range(weaponInfo.twoHandedMinDamage, weaponInfo.twoHandedMaxDamage + 1);
                    }
                    else
                    {
                        damage = Random.Range(weaponInfo.minDamage, weaponInfo.maxDamage + 1);
                    }

                    ranged = weapon.info.type.shoots != null;
                }

                if (ranged)
                {
                    var missile = Missile.Create("arrow", target, self);
                    missile.weaponDamage = damage;
                }
                else if (targetUnit != null && IsRangeOk(self, targetUnit, target))
                {
                    AudioManager.instance.Play(hitClass.hitSound, targetUnit.transform.position);
                    targetUnit.Hit(damage, self);
                }
            }
            else if (srvDoFunc == 17)
            {
                // charged bold, bolt sentry
                int boltCount = 7;
                for (int i = 0; i < boltCount; ++i)
                {
                    var offset = new Vector3(Random.Range(-boltCount / 2f, boltCount / 2f), Random.Range(-boltCount / 2f, boltCount / 2f));
                    Missile.Create(clientMissileA, self.iso.pos, target + offset, self);
                }
            }
            else if (srvDoFunc == 22)
            {
                // nova, poison nova, howl
                int missileCount = 64;
                Missile.CreateRadially(clientMissileA, self.iso.pos, self, missileCount);
            }
            else if (srvDoFunc == 31)
            {
                // raise skeleton, raise skeletal mage
                var pos     = Iso.MapToWorld(target);
                var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self);
                monster.overrideMode = summode;
                Missile.Create(clientMissileA, target, target, self);
            }
            else if (srvDoFunc == 45)
            {
                // traps
                var pos     = Iso.MapToWorld(target);
                var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self);
                monster.overrideMode = summode;
                Missile.Create(clientMissileA, target, target, self);
            }
            else if (srvDoFunc == 56 || srvDoFunc == 57)
            {
                // 57 iron golem, 56 other golems
                var pos     = Iso.MapToWorld(target);
                var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self);
                monster.overrideMode = summode;
            }
            else if (srvDoFunc == 114)
            {
                // raven
                var pos     = Iso.MapToWorld(target);
                var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self);
                monster.overrideMode = summode;
            }
            else if (srvDoFunc == 119)
            {
                // summon grizzly, wolves, spirits
                var pos     = Iso.MapToWorld(target);
                var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self);
                monster.overrideMode = summode;
            }
            else if (srvDoFunc == 68)
            {
                // barbarian howls
                int missileCount = 64;
                Missile.CreateRadially(clientMissileA, self.iso.pos, self, missileCount);
            }
            else
            {
                if (clientMissileA != null)
                {
                    Missile.Create(clientMissileA, self.iso.pos, target, self);
                }
            }

            if (clientMissile != null)
            {
                Missile.Create(clientMissile, self.iso.pos, target, self);
            }
        }
示例#47
0
    protected override IEnumerator FindEnemies()
    {
        if (Placed)
        {
            Hit   = Physics2D.OverlapCircleAll(transform.position, Radius + 0.1f);
            Enemy = null;
            Collider2D Target2  = null;
            float      Distance = 0;
            foreach (Collider2D enemy in Hit)
            {
                if (enemy.tag == "Enemy" && Distance <= enemy.GetComponent <BaseEnemy>().DistanceTravelled)
                {
                    if (enemy.GetComponent <BaseEnemy>().isCamo == false)
                    {
                        Enemy    = enemy.GetComponent <BaseEnemy>();
                        Distance = Enemy.DistanceTravelled;
                        GetEnemy();
                    }
                    else if (enemy.GetComponent <BaseEnemy>().isCamo == true && canSeeCamo == true)
                    {
                        Enemy    = enemy.GetComponent <BaseEnemy>();
                        Distance = Enemy.DistanceTravelled;
                        GetEnemy();
                    }
                }
            }
            if (DoubleRockets)
            {
                foreach (Collider2D enemy in Hit)
                {
                    if (enemy.tag == "Enemy" && Distance >= enemy.GetComponent <BaseEnemy>().DistanceTravelled)
                    {
                        if (enemy.GetComponent <BaseEnemy>().isCamo == false)
                        {
                            Distance = enemy.GetComponent <BaseEnemy>().DistanceTravelled;
                            Target2  = enemy;
                        }
                        else if (enemy.GetComponent <BaseEnemy>().isCamo == true && canSeeCamo == true)
                        {
                            Distance = enemy.GetComponent <BaseEnemy>().DistanceTravelled;
                            Target2  = enemy;
                        }
                    }
                }
            }

            if (Enemy != null)
            {
                Missile Missile = Instantiate(missile, firePoint.transform.position, firePoint.transform.rotation).GetComponent <Missile>();
                Missile.damage       = Damage;
                Missile.speed        = MissileSpeed;
                Missile.radius       = MissileRadius;
                Missile.moneyUpgrade = MoneyUpgrade;
                Missile.gameObject.transform.position = new Vector3(firePoint.transform.position.x, firePoint.transform.position.y, 0);
                Missile.sender = this;
                Missile.target = Enemy.gameObject;
            }
            if (DoubleRockets)
            {
                if (Target2 != null)
                {
                    Missile Missile = Instantiate(missile, FirePoint3.transform.position, firePoint.transform.rotation).GetComponent <Missile>();
                    Missile.damage       = Damage;
                    Missile.speed        = MissileSpeed;
                    Missile.radius       = MissileRadius;
                    Missile.moneyUpgrade = MoneyUpgrade;
                    Missile.gameObject.transform.position = new Vector3(firePoint.transform.position.x, firePoint.transform.position.y, 0);
                    Missile.sender = this;
                    Missile.target = Target2.gameObject;
                }
            }
        }
        yield return(new WaitForSeconds(FireRate));

        if (ShootAnim != null)
        {
            ShootAnim.SetActive(false);
        }
        StartCoroutine(FindEnemies());
    }
示例#48
0
文件: Map.cs 项目: cynic/HvZ
 internal void MoveMissile(Missile missile)
 {
     missile = missiles.FirstOrDefault(m => m.Id == missile.Id);
     if (missile == null)
     {
         return; // missile already destroyed, perhaps by collision with another missile.
     }
     missile.Move();
     // hrmmmmm.  There may be an off-by-one in the lifespan calculation because of the lifespan check below...?
     // I wonder if I should care more.
     if (missile.Position.X < 0 || missile.Position.Y < 0 || missile.Position.X > Width || missile.Position.Y > Height || missile.Lifespan == 0)
     {
         missiles.Remove(missile); // out of sight, out of mind.
         if (OnMapChange != null)
         {
             OnMapChange(this, EventArgs.Empty);
         }
         return;
     }
     // double-check against walkers.
     foreach (var kvp in walkers)
     {
         if (kvp.Value.Intersects(missile))
         {
             // kill the missile, in any case.
             missiles.Remove(missile);
             if (IsZombie(kvp.Key))
             {
                 ((Zombie)kvp.Value).Stun(); // stun it.  (I know, I'm stunned too.)
             } // otherwise, if it's a human, leave it unaffected.  No friendly fire.
             if (OnMapChange != null)
             {
                 OnMapChange(this, EventArgs.Empty);
             }
             return;
         }
     }
     // double-check against obstacles.
     foreach (var o in Obstacles)   // capital-O Obstacles.  Includes spawnpoints.
     {
         if (o.Intersects(missile))
         {
             missiles.Remove(missile); // g'bye, missile.
             if (OnMapChange != null)
             {
                 OnMapChange(this, EventArgs.Empty);
             }
             return;
         }
     }
     // and now check if it runs into any other missiles.  If so, destroy them both.
     foreach (var mx in missiles)
     {
         if (mx.Id == missile.Id)
         {
             continue;                      // don't check for intersection against myself...
         }
         if (missile.Intersects(mx))
         {
             missiles.Remove(missile);
             missiles.Remove(mx);
             if (OnMapChange != null)
             {
                 OnMapChange(this, EventArgs.Empty);
             }
             return;
         }
     }
 }
示例#49
0
    public void Fire(Vector3 position, Quaternion rotation, ITarget target, Color color)
    {
        var missile = Missile.Instantiate(missilePrefab, transform);

        missile.Initialize(position, rotation, target, color);
    }
示例#50
0
    public void AddMissile()
    {
        Missile missile = new Missile(x - 300, y, null, _player.x, _player.y, false, true);  // missle that moves to position when spawned

        game.AddChild(missile);
    }
示例#51
0
 public static void AddMissile(Missile misile)
 {
     missiles.AddLast(misile);
 }
示例#52
0
 public void AddMissile(Missile missile)
 {
     missiles.Add(missile);
 }
示例#53
0
        private void FireRightWeapon(Game game, Ship enemy)
        {
            switch (rightWeapon)
            {
                case 0:
                    if (rightBulletAmt > 0 && currTime - lastRightBullet > 100)
                    {
                        rightBulletAmt -= 1;
                        Bullet bullet = new Bullet(game);
                        bullet.direction = Direction;
                        bullet.up = Up;
                        bullet.right = Right;

                        Vector3 offset = new Vector3(200, 400, 0);
                        offset = Vector3.TransformNormal(offset, World);
                        bullet.position = new Vector3(Position.X + offset.X, Position.Y + offset.Y, Position.Z + offset.Z);

                        lastRightBullet = currTime;
                        bullets.Add(bullet);
                        vibrationRight = 0.4f;
                    }
                    break;
                case 1:
                    if (currTime - lastRightMissile > 5000 && rightMissileAmt > 0)
                    {
                        rightMissileAmt -= 1;

                        Missile missile = new Missile(game, enemy);
                        missile.direction = Direction;
                        missile.up = Up;
                        missile.right = Right;

                        Vector3 offset = new Vector3(900, 400, 0);
                        offset = Vector3.TransformNormal(offset, World);
                        missile.position = new Vector3(Position.X + offset.X, Position.Y + offset.Y, Position.Z + offset.Z);

                        lastRightMissile = currTime;
                        missiles.Add(missile);
                        vibrationRight = 0.8f;
                    }
                    break;
            }
        }
示例#54
0
 public static void ReturnMissileToObjectPool(Missile missile)
 {
     missilePool.Add(missile);
 }
示例#55
0
    private void Update()
    {
        if (int.Parse(lifeText.text) != (int)lifePoint)//Update la vie du worm
        {
            lifeText.text = ((int)lifePoint).ToString();
        }

        if (isControledWorms)//S'il est controler (set par le GameManager)
        {
            //Fire
            if (Input.GetButton("Jump"))
            {
                //"Désactive" le rigidbody2D
                if (rb2D.bodyType == RigidbodyType2D.Dynamic)
                {
                    rb2D.bodyType = RigidbodyType2D.Static;
                }

                //Direction donnée par la souris
                dirMouse = Camera.main.ScreenToWorldPoint(Input.mousePosition) - (transform.position + Vector3.up * 0.2f);
                dirMouse.Normalize();
                dirMouse.z = 0.0f;

                //S'il n'est pas créer => créer le missile / récupere son script / Init direction-puissance / active le feedback de direction
                if (!isOnFire)
                {
                    isOnFire   = true;
                    shootForce = 1.0f;
                    GameObject missile = PhotonNetwork.Instantiate("MissilePrefab", transform.position + Vector3.up * 0.2f, Quaternion.identity, 0);
                    missileScript          = missile.GetComponent <Missile>();
                    missileScript.launcher = this;
                    missileScript.SetDirPui(dirMouse, shootForce);

                    feedTarget.SetActive(true);
                }
                else
                {
                    //Update de la direction du missile et du feedback
                    if (missileScript != null)
                    {
                        missileScript.SetDirPui(dirMouse, shootForce);
                    }

                    feedTarget.transform.localPosition = Vector3.up * 20.0f;

                    Quaternion rot = Quaternion.LookRotation(feedTarget.transform.forward, new Vector3(feedTarget.transform.forward.x, feedTarget.transform.forward.y, 0.0f) + dirMouse);
                    feedTarget.transform.rotation = rot;

                    feedTarget.transform.localPosition += dirMouse.normalized * (5.0f * shootForce);
                }

                //Augmente la puissance avec le temps
                if (shootForce < 10.0f)
                {
                    shootForce += Time.deltaTime * 1.5f;
                }
                else
                {
                    shootForce = 10.0f;
                }
            }
            else
            {
                //"Réactive" le rigidbody2D
                if (rb2D.bodyType == RigidbodyType2D.Static)
                {
                    rb2D.bodyType = RigidbodyType2D.Dynamic;
                }

                //Déplacement horizontal
                Vector2 moveX           = Vector2.zero;
                float   InputHorizontal = Input.GetAxis("Horizontal");
                moveX.x = InputHorizontal * scaleDeplacement * Time.deltaTime + rb2D.position.x;

                //Flip du sprite (gauche, droit)
                if (InputHorizontal > 0)
                {
                    isFlip = true;
                }
                else if (InputHorizontal < 0)
                {
                    isFlip = false;
                }

                anim.SetFloat("Speed", Mathf.Abs(InputHorizontal));

                view.RPC("UpdateFlipSprite", PhotonTargets.AllBuffered, isFlip);

                //Physic2D => test si le worm est grounded
                Debug.DrawLine(transform.position, transform.position - transform.up, Color.red, 1.0f);
                RaycastHit2D hit;
                hit = Physics2D.BoxCast(transform.position - (Vector3.up * 0.115f), new Vector2(0.2f, 0.01f), 0.0f, -transform.up, 0.0f);
                if (hit.collider != null)
                {
                    isGrounded = true;
                }
                else
                {
                    isGrounded = false;
                }

                //Jump
                if ((Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.UpArrow)) && isGrounded)
                {
                    velocity.y = 1.0f;
                }
                if (!isGrounded)
                {
                    velocity.y -= rb2D.gravityScale * Time.deltaTime;
                }

                rb2D.velocity = velocity;
                moveX.y       = rb2D.position.y;
                rb2D.position = moveX;

                if (isOnFire)//Lance le missile
                {
                    if (missileScript != null)
                    {
                        shootForce = 1.0f;
                        missileScript.rb2D.bodyType = RigidbodyType2D.Dynamic;
                        missileScript.col2D.enabled = true;
                        missileScript.Launch();
                    }
                    feedTarget.SetActive(false);
                    isOnFire = false;
                }
            }
        }

        //Update life
        if (lifePoint < 1 && isAlive)
        {
            isControledWorms = false;
            isAlive          = false;
            rb2D.velocity    = Vector3.zero;
            anim.SetBool("isDead", true);
            lifeText.gameObject.SetActive(false);
        }
    }
示例#56
0
 private void MoveMissle(Missile missle)
 {
     if (_arena.Boundary.Contains(new System.Drawing.PointF((float)missle.X, (float)missle.Y)))
     {
         missle.X += (float)Math.Sin(missle.Angle) * MISSLE_SPEED;
         missle.Y += (float)Math.Cos(missle.Angle) * MISSLE_SPEED;
     }
     else
     {
         missle.IsActive = false;
     }
 }
示例#57
0
 //public Vector3 Pos { get; set; }
 public World(Missile rock, Vector3 pos)
 {
     //Pos = pos;
     rocket = rock;
     G      = 9.8f;
 }
 public override void OnHit(Transform user, Missile projectile)
 {
 }
示例#59
0
文件: Tank.cs 项目: faloi/tegece
 protected void shoot()
 {
     var flightTimeOfLastMissile = 0f;
     foreach (var missile in missilesShooted) {
         if (flightTimeOfLastMissile == 0f)
             flightTimeOfLastMissile = missile.flightTime;
         else if (flightTimeOfLastMissile < missile.flightTime) {
             flightTimeOfLastMissile = missile.flightTime;
         }
     }
     if (INTERVAL_BETWEEN_MISSILES<=flightTimeOfLastMissile || missilesShooted.Count==0) {
         this.setInitMissileRotation();
         var newMissile = new Missile(realPosition, this.initMissileRotation);
         TgcStaticSound sound = new TgcStaticSound();
         sound.loadSound(Path.ExplosionSound);
         sound.play(false);
         missilesShooted.Add(newMissile);
     }
 }