Example #1
0
 public InteractionResult ShootAt(LaserGun l)
 {
     Destroy(gameObject);
     insectReg.DeregisterInsect(this);
     Spawn();
     return(new InteractionResult(l, true, true));
 }
Example #2
0
    private void addCannon()
    {
        if (playerLaserGuns.Count < playerModifiers.maxCannons)
        {
            for (int i = 0; i < 2; i++)
            {
                LaserGun laserGunInstance = Instantiate(laserGunTemplate);
                laserGunInstance.transform.SetParent(gameObject.transform);
                laserGunInstance.transform.localPosition             = Vector3.zero;
                laserGunInstance.GetComponent <LaserGun>().isMainGun = false;
                spawnCount++;
                newPositionDirection = newPositionDirection * -1;
                laserGunInstance.transform.localPosition = laserGunInstance.transform.localPosition + (new Vector3(constantNewPositionDifference, 0, 0) * newPositionDirection); // direction 1 or -1
                playerLaserGuns.Add(laserGunInstance);

                if (isSpawnCountPair())
                {
                    duplicateCount++;
                    constantNewPositionDifference = playerModifiers.newPositionDifference * duplicateCount;
                    spawnCount = 0;
                }
            }

            upgradesDisplay.addUpgradeIcon();
        }
    }
Example #3
0
    void OnParticleCollision(GameObject collision)
    {
        //int checkStatus;
        int checkStatus;

        Transform laserGun = collision.transform.parent;

        LaserGun gunScript = laserGun.GetComponent <LaserGun>();

        checkStatus = gunScript.status;



        if ((collision.tag == "enemyLaser" || collision.name == "LaserFire1" || collision.name == "LaserFire") && checkStatus == 2)
        {
            tk2dTextMesh dT = damageNumber.GetComponent <tk2dTextMesh>();

            int damage = 1;
            dT.text = damage.ToString();

            takeDamage();

            GameObject.Instantiate(damageNumber, transform.position, Quaternion.identity);

            GameObject  cam = GameObject.Find("tk2dCamera");
            CameraShake cS  = (CameraShake)cam.GetComponent(typeof(CameraShake));
            cS.shakeCam();

            AudioSource.PlayClipAtPoint(playerStruck, transform.position);
        }
    }
Example #4
0
    /// <summary>
    /// Alienin luonnin aliohjelma
    /// </summary>
    private PhysicsObject LuoVihu()
    {
        vihuKoko = RandomGen.NextDouble(130, 300);
        PhysicsObject vihu = new PhysicsObject(vihuKoko, vihuKoko);

        vihuPaikka             = RandomGen.NextDouble(Level.Bottom, Level.Top);
        vihu.Image             = LoadImage("jees");
        vihu.X                 = Level.Right;
        vihu.Y                 = vihuPaikka;
        vihu.IgnoresExplosions = true;
        vihu.IgnoresCollisionWith(vihu);
        vihu.IgnoresGravity       = true;
        vihu.CanRotate            = false;
        vihu.CollisionIgnoreGroup = 1;
        vihu.Velocity             = new Vector(-100, 0);

        laserVihu        = new LaserGun(80, 30);
        laserVihu.Angle += Angle.FromDegrees(180);
        laserVihu.ProjectileCollision = LaserOsuu;

        Timer ajastin = new Timer();

        ajastin.Interval = 1.5;
        ajastin.Timeout += delegate { AmmuVihu(laserVihu); }; // Aliohjelma, jota kutsutaan 1.5 sekunnin välein
        ajastin.Start();
        vihu.Add(laserVihu);

        if (vihu.IsDestroyed == true)
        {
            laserVihu.Destroy();
        }

        Add(vihu);
        return(vihu);
    }
Example #5
0
    // Use this for initialization
    void Start()
    {
        speedOffset = Random.Range(5, 30);



        lG = laser.GetComponent <LaserGun>();
        lG.setStats(5f, 8f, 5f, 0.5f);
        foreach (Transform child in transform)
        {
            // do whatever you want with child transform object here
            if (child.name == "LaserGun")
            {
                laser = child;
            }
        }
        lG.fire();
        //sF = gameObject.GetComponent<SmoothFollow>();
        //sF.enabled = false;
        isTeleported = false;
        isVenting    = false;
        hasExploded  = false;

        /*
         * GameObject.Instantiate(spawnOutline, new Vector3(transform.position.x,
         *                                                                                               transform.position.y,
         *                                                                                               transform.position.z), Quaternion.identity);
         */
    }
Example #6
0
 void Start()
 {
     if (WeaponManager.Instance)
     {
         MachineGun machineGun    = WeaponManager.Instance.GetComponentInChildren <MachineGun>();
         LaserGun   laserGun      = WeaponManager.Instance.GetComponentInChildren <LaserGun>();
         SingleShot singleShotGun = WeaponManager.Instance.GetComponentInChildren <SingleShot>();
         ForkGun    forkGun       = WeaponManager.Instance.GetComponentInChildren <ForkGun>();
         SideShot   sideGun       = WeaponManager.Instance.GetComponentInChildren <SideShot>();
         RadialGun  radialGun     = WeaponManager.Instance.GetComponentInChildren <RadialGun>();
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node24>(laserGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node25>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node26>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node27>(radialGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node28>(sideGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node29>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node30>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node31>(forkGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node32>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node33>(machineGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node34>(laserGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node35>(radialGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node36>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node57>(singleShotGun);
     }
 }
Example #7
0
    void FillWeaponList()
    {
        LaserGun _laserGun = new LaserGun();

        _laserGun.Name = "Awesome Lasergun of the gods";
        WeaponList.Add(_laserGun);
    }
Example #8
0
    // Start is called before the first frame update
    void Start()
    {
        playerModifiers = playerModifiersGameObject.GetComponent <PlayerModifiers>();

        foreach (GameObject LaserGun in laserGuns)
        {
            playerLaserGuns.Add(LaserGun.GetComponent <LaserGun>());
            laserGunTemplate = LaserGun.GetComponent <LaserGun>();
        }

        playerFirestormX    = firestormX.GetComponent <FirestormX>();
        playerRenderer      = GetComponent <SpriteRenderer>();
        energyStatusBar     = EnergyBar.GetComponent <UIStatusBar>();
        firestormXStatusBar = FirestormXBar.GetComponent <UIStatusBar>();
        playerStatus        = playerStatusGameObject.GetComponent <PlayerStatus>();
        upgradesDisplay     = upgradesIcons.GetComponent <UIDisplayUpgrades>();
        deathSound          = deathSoundObject.GetComponent <AudioSource>();

        newPositionDirection          = 1;
        duplicateCount                = 1;
        spawnCount                    = 0;
        constantNewPositionDifference = playerModifiers.newPositionDifference;
        pointsDisplay                 = pointsUI.GetComponent <UIDisplayNumbers>();

        PlayerCollision.onEnemyHit       += substractEnergy;
        PlayerCollision.onEnemyHit       += RemoveUpgrades;
        PlayerCollision.onEnergyCollected = RecoverEnergy;
        PlayerCollision.onRocketCollected = addCannon;
        GameManager.onRoundEnd           += disableUI;
        GameManager.onRoundEnd           += disableCollision;
        GameManager.onRoundEnd           += disableGuns;
    }
Example #9
0
    public override void Begin()
    {
        Level.Size = Screen.Size;

        Level.Background.CreateStars();

        Surfaces borders = Level.CreateBorders();
        Camera.ZoomToLevel();

        PhysicsObject pelaaja = new PhysicsObject(50, 100, Shape.Triangle);
        Weapon ase = new LaserGun(20, 20);
        ase.IsVisible = false;
        ase.Angle = Angle.FromDegrees(90);
        // Opettajalle huom: Laserin osumisen käsittely on Tämän selittäminen ajan kanssa on tärkeää. Kerro tarkasti, mitä min parametri tarkoittaa ja miksi kutsuttava aliohjelmat saa ne parametrit mitkä saavat.
        ase.ProjectileCollision = LaserOsui;
        pelaaja.Add(ase);
        Add(pelaaja);

        LisaaKivi();
        LisaaKivi();
        LisaaKivi();

        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");

        // Opettajalle huom: Näiden selittäminen ajan kanssa on tärkeää. Kerro tarkasti, mitä min parametri tarkoittaa ja miksi kutsuttava aliohjelmat saa ne parametrit mitkä saavat.
        Keyboard.Listen(Key.Space, ButtonState.Pressed, Ammu, "Ammu rakettia", ase);
        Keyboard.Listen(Key.Up, ButtonState.Down, KaytaRakettia, "Käytä rakettia", pelaaja);
        Keyboard.Listen(Key.Left, ButtonState.Down, Kaanny, "Käänny oikealle", pelaaja, 5.0);
        Keyboard.Listen(Key.Left, ButtonState.Released, Kaanny, "", pelaaja, 0.0);
        Keyboard.Listen(Key.Right, ButtonState.Down, Kaanny, "Käytä rakettia", pelaaja, -5.0);
        Keyboard.Listen(Key.Right, ButtonState.Released, Kaanny, "", pelaaja, 0.0);
    }
Example #10
0
        public void AttackMonsterReportsCorrectly()
        {
            LaserGun      w  = new LaserGun("Test Weapon", "Test Weapon", 1);
            Monster       m  = new Monster("Test", 10);
            MonsterHunter mh = new MonsterHunter("First", "Last", w, w);

            string expected = $"{mh.GetFullName()} hits {m.Name} with {w.Name} doing {w.Damage} damage.";

            Assert.AreEqual(mh.Attack(m), expected);
        }
Example #11
0
 public LaserGunXna(PlanesGame game, LaserGun weapon, CoordinatesTransformer coordinatesTransformer)
     : base(game, weapon, coordinatesTransformer)
 {
     m_particlesEmitter = new SymmetricParticlesEmitter(game.GameManager.GameWorldXna)
     {
         PositionDeviationRadius      = 0.4,
         VelocityDeviationRadius      = 3,
         AlphaVelocityDeviationFactor = 0.3
     };
 }
Example #12
0
        public void WeaponWithOneDamageKills1HealthMonster()
        {
            LaserGun      w  = new LaserGun("Test Weapon", "Test Weapon", 1);
            Monster       m  = new Monster("Test", 1);
            MonsterHunter mh = new MonsterHunter("First", "Last", w, w);

            string expected = $"{mh.GetFullName()} hits {m.Name} with {w.Name} and kills it!";

            Assert.AreEqual(mh.Attack(m), expected);
        }
 private void Start()
 {
     if (!isParent)
     {
         animator       = GetComponent <Animator>();
         enemyRenderer  = GetComponent <SpriteRenderer>();
         enemyLaserGun  = LaserGun.GetComponent <LaserGun>();
         explosionSound = ExplosionObject.GetComponent <AudioSource>();
         hurtSound      = hurtObject.GetComponent <AudioSource>();
     }
 }
Example #14
0
    IEnumerator ChangeWeapon()
    {
        hasSpecialGun = true;

        laserGun = specialGuns[Random.Range(0, specialGuns.Length)];

        yield return(new WaitForSeconds(specialWeaponDuration));

        laserGun = defaultGun;

        hasSpecialGun = false;
    }
Example #15
0
    // Update is called once per frame
    void Update()
    {
        energyDrainTimer         += Time.deltaTime;
        firestormXChargeTimer    += Time.deltaTime;
        energyStatusBar.value     = playerStatus.energy;
        firestormXStatusBar.value = playerStatus.firestormXCharge;

        if (Input.GetKey(KeyCode.F))
        {
            foreach (LaserGun LaserGun in playerLaserGuns)
            {
                LaserGun.Shoot();
            }
        }

        if (Input.GetKeyDown(KeyCode.Alpha1)) // DEBUG
        {
            if (playerLaserGuns.Count < playerModifiers.maxCannons)
            {
                addCannon();
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (playerStatus.firestormXCharge >= 100)
            {
                playerStatus.firestormXCharge = 0;
                playerFirestormX.Shoot();
            }
        }

        if (energyDrainTimer >= playerModifiers.energyDrainRate)
        {
            energyDrainTimer = 0;
            playerStatus.energy--;
        }

        if (firestormXChargeTimer >= playerModifiers.firestormXChargeRate)
        {
            playerStatus.firestormXCharge++;
            if (playerStatus.firestormXCharge >= 100)
            {
                playerStatus.firestormXCharge = 100;
            }
            firestormXChargeTimer = 0;
        }

        if (playerStatus.energy <= 0)
        {
            playerDie();
        }
    }
Example #16
0
 public void BuyLaserSpeedLevel()
 {
     if (EnergyTracker.singleton.Count >= LaserGunSpeedPrice && ownLaserGun && LaserGun.LaserSpeedlvl != LaserGun.LaserSpeedMaxlvl)
     {
         EnergyTracker.singleton.spend(LaserGunSpeedPrice);
         LaserGun.increaseSpeedLevel();
         LaserGunSpeedLvlText.text = "LVL " + LaserGun.LaserSpeedlvl.ToString();
     }
     if (LaserGun.LaserSpeedlvl == LaserGun.LaserSpeedMaxlvl)
     {
         LaserGunSpeedPriceText.transform.parent.GetComponent <Button>().interactable = false;
         LaserGunSpeedLvlText.text = "MAX";
     }
 }
    //private LineRenderer lineRenderer;
    // Use this for initialization
    void Start()
    {
        //lineRenderer = GetComponent<LineRenderer> ();
        //lineRenderer.SetVertexCount (laserNumSegments);
        //lineRenderer.SetPosition (0, Vector3.zero);

        GameObject newGun = (GameObject)Instantiate (gun, Vector3.zero, Quaternion.identity);
        newGun.transform.parent = transform;
        newGun.transform.localPosition = Vector3.zero;
        newGun.transform.localRotation = Quaternion.identity;
        laserGun = newGun.GetComponent<LaserGun> ();

        damageTaker = GetComponent<DamageTaker> ();
        cameraTracker = Camera.main.GetComponent<CameraTracker> ();
        gameRules = Camera.main.GetComponent<GameRules> ();
    }
Example #18
0
    void Awake()
    {
        Instance = Instance == null ? this : Instance;

        UI.UpdateInterface(this);

        LaserGun _laserGun = new LaserGun();

        _laserGun.InitliazeSettings("Awesome Lasergun of the gods");
        CurrentWeapon = _laserGun;

        GameObject             = Instantiate(ObjectPrefab);
        GameObject.tag         = "Player";
        VirtualCamera.m_Follow = GameObject.transform;

        AimLine = GameObject.GetComponent <LineRenderer>();
    }
Example #19
0
 public void Initialize()
 {
     player       = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
     GM           = GameObject.FindGameObjectWithTag("Managers").GetComponent <GameManager>();
     laser        = GetComponentInChildren <LaserGun>();
     flameThrower = GetComponentInChildren <FlameThrower>();
     hJump        = GetComponentInChildren <HyperJump>();
     hDash        = GetComponentInChildren <HyperDash>();
     mLauncher    = GetComponentInChildren <MisileLauncher>();
     absorb       = GetComponentInChildren <Absorb>();
     laser.Initialize();
     flameThrower.Initialize();
     hJump.Initialize();
     hDash.Initialize();
     mLauncher.Initialize();
     absorb.Initialize();
 }
Example #20
0
	// Use this for initialization
	void Start () {
		GameObject newGun = (GameObject)Instantiate (gun, Vector3.zero, Quaternion.identity);
		newGun.transform.parent = transform;
		newGun.transform.localPosition = Vector3.zero;
		newGun.transform.localRotation = Quaternion.identity;
		laserGun = newGun.GetComponent<LaserGun> ();
		laserGun.fireRate = 1.0f;
		laserGun.laserSpeed = 40.0f;
		laserGun.laserStartColor = new Color (0.0f, 0.0f, 1.0f);
		laserGun.laserEndColor = new Color (0.0f, 0.0f, 0.5f);
		laserGun.laserDamageAmount = 25.0f;

		// this is lame
		playerTransform = Camera.main.GetComponent<CameraTracker> ().target;

		turretRenderer = GetComponent<Renderer> ();
	}
Example #21
0
 void Power_Down()
 {
     for (int i = 0; i < fm.MovingFriends.Count; i++)
     {
         if (fm.MovingFriends[i].name == "StartFriend" || fm.MovingFriends[i].name == "Frodo(Clone)")
         {
             Gun gun = fm.MovingFriends[i].GetComponentInChildren <Gun>();
             gun.ShotDelay = 2.0f;
         }
         else if (fm.MovingFriends[i].name == "Tube(Clone)")
         {
             Barrier bar = fm.MovingFriends[i].GetComponentInChildren <Barrier>();
             bar.Delay = 2.0f;
         }
         else if (fm.MovingFriends[i].name == "Ryan(Clone)")
         {
             LaserGun lg = fm.MovingFriends[i].GetComponentInChildren <LaserGun>();
             lg.Thickness = 2.0f;
         }
         else if (fm.MovingFriends[i].name == "Neo(Clone)")
         {
             MissileLauncher ml = fm.MovingFriends[i].GetComponentInChildren <MissileLauncher>();
             ml.MissileSpeed = 4.0f;
         }
         else if (fm.MovingFriends[i].name == "Muzi(Clone)")
         {
             BombThrower bt = fm.MovingFriends[i].GetComponentInChildren <BombThrower>();
             bt.AttackDelay = 2.0f;
         }
         else if (fm.MovingFriends[i].name == "JayG(Clone)")
         {
             LightningAttack la = fm.MovingFriends[i].GetComponentInChildren <LightningAttack>();
             la.AttackRange     = 3.0f;
             la.AttackDelayTime = 1.0f;
         }
         else if (fm.MovingFriends[i].name == "Peach(Clone)")
         {
             StarShooter ss = fm.MovingFriends[i].GetComponentInChildren <StarShooter>();
             ss.ShotDelay = 2.0f;
         }
         else // Con
         {
         }
     }
 }
Example #22
0
    void Update()
    {
        if (!MainClass.isGameRunning)
        {
            return;
        }

        Rigidbody2D shipRB   = ship.GetComponent <Rigidbody2D>();
        float       velocity = (int)(shipRB.velocity.magnitude * 100.0f);

        velocityText.text = "" + velocity;

        ShipControll shipControll = ship.GetComponent <ShipControll>();
        LaserGun     laserGun     = ship.GetComponent <LaserGun>();

        setLight(MainEnginesLight, shipControll.engineOn);
        setLight(ControlEnginesLight, shipControll.controlEnginesOn);
        setLight(LaserLight, laserGun.isShoting);
    }
Example #23
0
    /// <summary>
    /// Alienin aseen ampumisen parametrit, mm. nopeus,,ammukset.
    /// </summary>
    private void AmmuVihu(LaserGun laserVihu)
    {
        PhysicsObject ammus = laserVihu.Shoot();

        if (ammus != null)
        {
            ammus.Width  = 35;
            ammus.Height = 4;
            ammus.Image  = LoadImage("laser");
            ammus.CollisionIgnoreGroup = 1;
            if (laserVihu.IsDestroyed == true)
            {
                ammus.Destroy();
                laserVihu.AttackSound = null;
            }
        }
        laserVihu.FireRate           = RandomGen.NextDouble(1, 3);
        laserVihu.Power.DefaultValue = 150;
        laserVihu.InfiniteAmmo       = true;
    }
Example #24
0
    void fireLasers()
    {
        GameObject    sM     = GameObject.Find("ScreenManager");
        ScreenManager script = sM.GetComponent <ScreenManager>();

        if (script.currentScreen == 2)
        {
            int currentWeapon = PlayerPrefs.GetInt("CurrentWeapon");

            if (currentWeapon == 3)               // laser
            {
                LaserGun lG = laser.GetComponent <LaserGun>();
                //lG.setStats((float)PlayerPrefs.GetInt("W1Damage") * 3, (float)PlayerPrefs.GetInt("W1Range"), LaserFireRate - fireRateMod, 0.5f);
                lG.mute = true;
                lG.fire();

                NextFireAt = Time.time + LaserFireRate - fireRateMod;

                //GameObject.Instantiate(laser, transform.position, Quaternion.identity);
                //NextFireAt = Time.time + LaserFireRate -  fireRateMod;
            }

            if (currentWeapon == 1)               // scatter
            {
                GameObject.Instantiate(tripleShot, transform.position, Quaternion.identity);
                NextFireAt = Time.time + TripleFireRate - fireRateMod;
            }

            if (currentWeapon == 2)               // melee
            {
                GameObject.Instantiate(melee, transform.position, Quaternion.identity);
                NextFireAt = Time.time + MeleeFireRate - fireRateMod;
            }

            if (currentWeapon == 4)
            {
                GameObject.Instantiate(mortarShot, transform.position, Quaternion.identity);
                NextFireAt = Time.time - fireRateMod;
            }
        }
    }
Example #25
0
        public void CanAttemptCaptureMonster()
        {
            LaserGun w = new LaserGun("Test Weapon", "Test Weapon", 1);
            Monster  m = new Monster("Test", 10)
            {
                IsElderDragon = false
            };
            MonsterHunter mh = new MonsterHunter("First", "Last", w, "Longsword");

            string expected  = $"{mh.GetFullName()} attempts to capture {m.Name} ...... and caught it!";
            string expected2 = $"{mh.GetFullName()} attempts to capture {m.Name} ...... but it escaped!";
            string actual    = mh.Capture(m);

            Assert.That(actual.Equals(expected));
            Assert.That(actual.Equals(expected2));

            Assert.AreEqual(actual, expected);


            Assert.AreEqual(actual, expected2);
        }
Example #26
0
    void OnTriggerStay(Collider other)
    {
        if (gunType == WeaponType.LaserGun)
        {
            GameScene gameScene = GameApp.GetInstance().GetGameScene();
            Player    player    = gameScene.GetPlayer();
            Weapon    w         = player.GetWeapon();
            if (w.GetWeaponType() == WeaponType.LaserGun)
            {
                LaserGun lg = w as LaserGun;
                if (lg.CouldMakeNextShoot())
                {
                    if (other.gameObject.layer == PhysicsLayer.ENEMY)
                    {
                        Enemy enemy = gameScene.GetEnemyByID(other.gameObject.name);
                        if (enemy != null)
                        {
                            if (enemy.GetState() != Enemy.DEAD_STATE)
                            {
                                Object.Instantiate(laserHitObject, enemy.GetPosition(), Quaternion.identity);
                                DamageProperty dp = new DamageProperty();
                                dp.hitForce = (dir + new Vector3(0f, 0.18f, 0f)) * hitForce;
                                dp.damage   = damage;
                                enemy.OnHit(dp, gunType, false);
                            }
                        }
                    }

                    /*
                     * else if (other.gameObject.layer == PhysicsLayer.WOODBOX)
                     * {
                     *  WoodBoxScript ws = other.gameObject.GetComponent<WoodBoxScript>();
                     *  ws.OnHit(damage);
                     * }*/
                }
            }
        }
    }
Example #27
0
 // Use this for initialization
 void Start()
 {
     BFG    = GetComponent <bigGun>();
     Lazers = GetComponent <LaserGun>();
     Pistol = GetComponent <Shoot>();
 }
Example #28
0
        public XWingPlane(double mass, double angularMass, ReferenceArea referenceArea, Vector initialPosition)
            : base(
                mass,
                angularMass,
                new PolygonGeometry(new[]
        {
            new Vector(0, 6),
            new Vector(0.5, -0.6),
            new Vector(7, -1),
            new Vector(7, -5),
            new Vector(-7, -5),
            new Vector(-7, -1),
            new Vector(-0.5, -0.6)
        }),
                referenceArea,
                1000)
        {
            Position = initialPosition;

            m_leftForwardEngine = new RocketEngine(200000.0)
            {
                Info = "Left primary engine"
            };
            m_rightForwardEngine = new RocketEngine(200000.0)
            {
                Info = "Right primary engine"
            };

            m_leftDeflectingEngine = new IonEngine(50000.0)
            {
                Info = "Left deflector"
            };
            m_rightDeflectingEngine = new IonEngine(50000.0)
            {
                Info = "Right deflector"
            };

            Weapon leftLaserGun = LaserGun.CreateDefault();

            leftLaserGun.Info = "Left laser gun";

            Weapon rightLaserGun = LaserGun.CreateDefault();

            rightLaserGun.Info = "Right laser gun";

            Shield shield = new Shield(10.0, 0.5, 1.0, 0.03)
            {
                Info = "Shield"
            };

            AddEquipmentSuppressEvents(m_leftForwardEngine, new PlaneEquipmentRelativeInfo()
            {
                RelativeToOriginPosition = new Vector(-1.55, -6.6), RelativeRotation = 5
            });
            AddEquipmentSuppressEvents(m_rightForwardEngine, new PlaneEquipmentRelativeInfo()
            {
                RelativeToOriginPosition = new Vector(+1.55, -6.6), RelativeRotation = -5
            });
            AddEquipmentSuppressEvents(m_leftDeflectingEngine, new PlaneEquipmentRelativeInfo()
            {
                RelativeToOriginPosition = new Vector(+0.6, 2.8), RelativeRotation = -80
            });
            AddEquipmentSuppressEvents(m_rightDeflectingEngine, new PlaneEquipmentRelativeInfo()
            {
                RelativeToOriginPosition = new Vector(-0.6, 2.8), RelativeRotation = 80
            });

            AddEquipmentSuppressEvents(leftLaserGun, new PlaneWeaponRelativeInfo()
            {
                WeaponPosition = WeaponPosition.LeftFront, RelativeToOriginPosition = new Vector(-1.5, -0.4), RelativeRotation = 0
            });
            AddEquipmentSuppressEvents(rightLaserGun, new PlaneWeaponRelativeInfo()
            {
                WeaponPosition = WeaponPosition.RightFront, RelativeToOriginPosition = new Vector(1.5, -0.4), RelativeRotation = 0
            });

            AddEquipmentSuppressEvents(shield, new PlaneEquipmentRelativeInfo());
        }
Example #29
0
    // Update is called once per frame
    void Update()
    {
        //mySprite.color.a += .1f;

        // controls
        if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
        {
            if (transform.position.x <= -50)
            {
                transform.position = new Vector3(-50, transform.position.y, transform.position.z);
            }
            if (transform.position.x >= 50)
            {
                transform.position = new Vector3(50, transform.position.y, transform.position.z);
            }
            if (transform.position.y <= -25)
            {
                transform.position = new Vector3(transform.position.x, -25, transform.position.z);
            }
            if (transform.position.y >= 25)
            {
                transform.position = new Vector3(transform.position.x, 25, transform.position.z);
            }


            dir.x = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
            dir.y = Input.GetAxis("Vertical") * speed * Time.deltaTime;
            transform.position += dir;

            thruster.particleSystem.enableEmission = true;             // turn ON thrusters
        }
        else
        {
            thruster.particleSystem.enableEmission = false;             // turn OFF thrusters
        }

        // which direction to spin?
        if (!Input.GetKey(KeyCode.Space))
        {
            if (!Input.GetButton("joystick button 1"))
            {
                //if (!Input.GetButton("joystick button 1")) {
                if (dir.x > 0)
                {
                    lastDir = 0;
                }
                else if (dir.x < 0)
                {
                    lastDir = 1;
                }
            }


            //}
        }

        if (Input.GetKey(KeyCode.Space) || Input.GetButton("joystick button 1"))
        {
            if (restartMode)
            {
                //screenManager.currentScreen = 2;
                levelLogic.killWave();
                //levelLogic.reset();
                isRestarting = false;
                screenManager.resetGame();

                levelLogic.enableTimer();
                //levelLogic.killWave();
                //levelLogic.restartLevel();
                //levelLogic.enableTimer();

                restartMode  = false;
                isRestarting = false;


                if (gameObject != null)
                {
                    Destroy(gameObject);
                }

                levelLogic.killWave();
            }
        }

        if (lastDir == 0)
        {
            endingRotation     = Quaternion.Euler(new Vector3(0, 0, 0));         // rotate right
            transform.rotation = Quaternion.Lerp(transform.rotation, endingRotation, Time.deltaTime * rotationSpeed);
        }
        else if (lastDir == 1)
        {
            endingRotation     = Quaternion.Euler(new Vector3(0, -180, 0));         // rotate left
            transform.rotation = Quaternion.Lerp(transform.rotation, endingRotation, Time.deltaTime * rotationSpeed);
        }


        // weapons
        if ((Input.GetKey(KeyCode.Space) || Input.GetButton("joystick button 1")) && !restartMode && !isDead)
        {
            if (Time.time >= NextFireAt)              // if the cooldown has been reached
            {
                AudioSource.PlayClipAtPoint(playerFireSound, transform.position);

                if (currentWeapon == 3)                   // laser

                {
                    LaserGun lG = laser.GetComponent <LaserGun>();

                    lG.fire();

                    NextFireAt = Time.time + LaserFireRate - fireRateMod;
                }

                if (currentWeapon == 1)                   // scatter
                {
                    GameObject.Instantiate(tripleShot, laserSpawn.transform.position, Quaternion.identity);
                    NextFireAt = Time.time + TripleFireRate - fireRateMod;
                }

                if (currentWeapon == 2)                   // melee
                {
                    GameObject.Instantiate(melee, laserSpawn.transform.position, Quaternion.identity);
                    NextFireAt = Time.time + MeleeFireRate - fireRateMod;
                }
                if (currentWeapon == 4)                   // mortar
                {
                    GameObject.Instantiate(mortarShot, laserSpawn.transform.position, Quaternion.identity);

                    NextFireAt = Time.time + MeleeFireRate - fireRateMod;
                }
            }
        }
        else if ((Input.GetKeyDown(KeyCode.Backspace) || Input.GetButton("joystick button 2")) && restartMode == true)
        {
            stopRestartTimer();

            screenManager.currentScreen = 2;

            isRestarting = false;

            restartMode = false;


            if (gameObject != null)
            {
                Destroy(gameObject);
            }

            levelLogic.killWave();
        }


        // are we dead yet?
        if (isDead)
        {
            transform.renderer.enabled             = false;
            thruster.particleSystem.enableEmission = false;             // turn OFF thrusterss


            restartTimer -= Time.deltaTime;
            isRestarting  = true;
            //pauseRestartTimer();

            //restartMode = true;
            if (restartTimer < 0)
            {
                Debug.Log("timer reached!");
                stopRestartTimer();
                //pauseRestartTimer();
                //pauseRestartTimer();
            }
        }
        else
        {
            transform.renderer.enabled = true;
        }


        // render the health bar
    }
Example #30
0
    // Use this for initialization
    void Start()
    {
        isDead       = false;
        hasExploded  = false;
        isRestarting = false;
        restartMode  = false;
        NextFireAt   = Time.time;    // restart fire timer
        dir          = Vector3.zero; // no direction

        // set player stats from the preferences!
        maxHp     = 1 + PlayerPrefs.GetInt("PHealth");
        currentHp = 1 + PlayerPrefs.GetInt("PHealth");

        maxShield     = PlayerPrefs.GetInt("PShield");
        currentShield = 0;

        rotationSpeed = 9.0f + PlayerPrefs.GetInt("PTurnRate") * 2;
        speed         = speed + PlayerPrefs.GetInt("PThrusters") * 2;


        currentWeapon = PlayerPrefs.GetInt("CurrentWeapon");
        fireRateMod   = PlayerPrefs.GetInt("W1FireRate") / 10.0f;

        // firerates and damage


        // keep track of other stuff
        screenManager  = GameObject.Find("ScreenManager").GetComponent <ScreenManager>();
        levelLogic     = GameObject.Find("Level").GetComponent <LevelLogic>();
        missionControl = GameObject.Find("MissionControl").GetComponent <MissionControl>();
        LaserGun lG = laser.GetComponent <LaserGun>();

        lG.setStats((float)PlayerPrefs.GetInt("W1Damage") * 3, (float)PlayerPrefs.GetInt("W1Range"), LaserFireRate - fireRateMod, 0.5f);

        foreach (Transform child in transform)
        {
            // do whatever you want with child transform object here
            if (child.name == "LaserGun")
            {
                laser = child;
            }
        }



        //instantiate the health bar


        for (int z = 0; z < maxHp; z++)
        {
            Transform tmpB = hpBar;
            tmpB.tag = "hp" + z.ToString();
            Instantiate(tmpB, new Vector3(-46 + z * 1.25f, 25, 0), Quaternion.identity);
            //hpBars.Add(hpBar);

            finalX = -46 + z * 1.25f;
        }

        finalX += 1.25f;
        for (int s = 0; s < currentShield; s++)
        {
            Transform tmpB = shieldBar;
            tmpB.tag = "shield" + s.ToString();

            Instantiate(tmpB, new Vector3(finalX + s * 1.25f, 25, 0), Quaternion.identity);
            //hpBars.Add(hpBar);
        }

        Debug.Log("player born!");
    }
	public void Init(Player _playerRef) {
		rocketRef = _playerRef.rocketRef;
		laserRef = _playerRef.laserRef;
		UiUpdate();
	}
Example #32
0
    //if player colldes with ground set animator bool and script bool to true.
    private void OnCollisionEnter2D(Collision2D c)
    {
        if (c.gameObject.tag == "SwordAttackPowerUp")
        {
            hasSword    = true;
            hasLaserGun = false;
            sword.SetActive(true);
            LaserGun.SetActive(false);
            Destroy(c.gameObject);
            PlayASound(gotPowerUpClip, ChangeVolume.soundVolume);
        }

        if (c.gameObject.tag == "Ground")
        {
            onGround = true;
            anim.SetBool("onGround", true);
        }

        if (c.gameObject.CompareTag("MovingPlatform"))
        {
            Debug.Log("on platform");
            onGround = true;
            anim.SetBool("onGround", true);
            myTransform.parent = c.gameObject.transform;
        }

        if (c.gameObject.tag == "LaserGun")
        {
            Destroy(c.gameObject);
            hasSword    = false;
            hasLaserGun = true;
            LaserGun.SetActive(true);
            sword.SetActive(false);
            SwordWhileSwinging.SetActive(false);
            PlayASound(gotPowerUpClip, ChangeVolume.soundVolume);
            //Instantiate(LaserGun, shotSpawn.position, shotSpawn.rotation);
        }

        if (c.gameObject.tag == "Armour")
        {
            if (ArmourBar.armourAmount <= 3)
            {
                ArmourBar.armourAmount = ArmourBar.armourAmount + 1;
            }
            Destroy(c.gameObject);
            PlayASound(gotPowerUpClip, ChangeVolume.soundVolume);
        }

        if (!isInvinsable && (c.gameObject.CompareTag("Enemy") || c.gameObject.CompareTag("EProjectile")))
        {
            //starts the coroutine that makes the player invinsible
            StartCoroutine(TempInvinsibility());
            //projectiles will be destroyed when they touch the player
            if (c.gameObject.tag == "EProjectile")
            {
                Destroy(c.gameObject);
            }

            if (c.gameObject.CompareTag("Enemy"))
            {
                anim.SetBool("onGround", true);
            }

            if (!hasArmour)
            {
                Health.life--;
            }
            else if (hasArmour)
            {
                ArmourBar.armourAmount--;
            }
        }

        if (c.gameObject.tag == "Blockman")
        {
            startCountdownTillDeath = true;
            rb.velocity             = new Vector3(0, 0, 0);
            myTransform.localScale  = new Vector3(myTransform.localScale.x, 3.5f,
                                                  myTransform.localScale.z);
            anim.enabled = false;
        }

        if (c.gameObject.tag == "CherryPowerUp")
        {
            speed = speed + 2;
            Destroy(c.gameObject);
            PlayASound(gotPowerUpClip, ChangeVolume.soundVolume);
        }

        if (c.gameObject.tag == "Invincible")
        {
            playerSpriteRenderer.color = new Color(1f, 1f, 1f, 0.5f);
            isInvinsable = true;
            PlayASound(gotPowerUpClip, ChangeVolume.soundVolume);
            Destroy(c.gameObject);
            StartCoroutine(waitAndTurnOffInvinsibility());
        }

        if (c.gameObject.tag == "Gem")
        {
            Gem gem = c.gameObject.GetComponent <Gem>();

            if (gem)
            {
                points += gem.Points;
                Destroy(c.gameObject);
                PlayASound(gemPickUpClip, ChangeVolume.soundVolume);
            }
        }
    }
Example #33
0
    //if player colldes with ground set animator bool and script bool to true.
    private void OnCollisionEnter2D(Collision2D c)
    {
        if (c.gameObject.tag == "SwordAttackPowerUp")
        {
            //I am still working on the Swords function.
            //GameObject swordWeapon = Instantiate(sword, shotSpawn.position, Quaternion.identity);
            hasSword    = true;
            hasLaserGun = false;
            sword.SetActive(true);
            LaserGun.SetActive(false);
            Destroy(c.gameObject);
        }

        if (c.gameObject.tag == "LaserGun")
        {
            Destroy(c.gameObject);
            hasSword    = false;
            hasLaserGun = true;
            LaserGun.SetActive(true);
            sword.SetActive(false);
            SwordWhileSwinging.SetActive(false);
            //Instantiate(LaserGun, shotSpawn.position, shotSpawn.rotation);
        }

        if (c.gameObject.tag == "Armour" && ArmourBar.armourAmount < 3)
        {
            ArmourBar.armourAmount = ArmourBar.armourAmount + 1;
            Destroy(c.gameObject);
        }

        if (c.gameObject.tag == "Ground")
        {
            onGround = true;
            anim.SetBool("onGround", true);
        }

        //loads gameOver scene when the player dies.
        if (c.gameObject.tag == "Enemy" || c.gameObject.tag == "EProjectile")
        {
            //EnemyFlyingDrones are listed as a projectile meaning they and other projectiles will be
            //destroyed when they touch the player
            if (c.gameObject.tag == "EProjectile")
            {
                Destroy(c.gameObject);
            }
            //NOTE MUST ADD TEMP INVINCIBILITY
            if (!hasArmour)
            {
                Health.life--;
            }
            else if (hasArmour)
            {
                ArmourBar.armourAmount--;
            }
        }

        if (c.gameObject.tag == "CherryPowerUp")
        {
            speed = speed + 5;
            Destroy(c.gameObject);
        }

        if (c.gameObject.tag == "InvisiblePotion")
        {
            playerSpriteRenderer.color = new Color(1f, 1f, 1f, 0.5f);
            isInvisable = true;
            Destroy(c.gameObject);
            StartCoroutine(waitAndTurnOffInvisibility());
        }

        //sets the firepower attack bool true.
        if (c.gameObject.tag == "StrawBerry")
        {
            firePower = true;
        }

        if (c.gameObject.tag == "Pie")
        {
            Health.life++;
            Destroy(c.gameObject);
        }
    }
    public InteractionResult UpgradeMe(Carryable c)
    {
        if (c is WateringCan)
        {
            WateringCan oldWateringCan = (WateringCan)c;
            int         upgradeLevel   = oldWateringCan.level + 1;
            WateringCan newWateringCan = null;
            foreach (WateringCan w in wateringCans)
            {
                if (w.level == upgradeLevel)
                {
                    newWateringCan = w;
                    break;
                }
            }

            //If there is a better WateringCan and the player can afford it, upgrade.
            if (newWateringCan && player.Pay(newWateringCan.cost))
            {
                Destroy(oldWateringCan.gameObject);
                return(new InteractionResult(Instantiate(newWateringCan, oldWateringCan.oldParent), true, true));
            }
        }
        else if (c is LaserGun)
        {
            LaserGun oldLaserGun  = (LaserGun)c;
            int      upgradeLevel = oldLaserGun.level + 1;
            LaserGun newLaserGun  = null;
            foreach (LaserGun l in laserGuns)
            {
                if (l.level == upgradeLevel)
                {
                    newLaserGun = l;
                    break;
                }
            }

            if (newLaserGun && player.Pay(newLaserGun.cost))
            {
                Destroy(oldLaserGun.gameObject);
                return(new InteractionResult(Instantiate(newLaserGun, oldLaserGun.oldParent), true, true));
            }
        }
        else if (c is FertilizerBox)
        {
            FertilizerBox oldFertilizer = (FertilizerBox)c;
            int           upgradeLevel  = oldFertilizer.level + 1;
            FertilizerBox newFertilizer = null;
            foreach (FertilizerBox f in fertilizers)
            {
                if (f.level == upgradeLevel)
                {
                    newFertilizer = f;
                    break;
                }
            }

            if (newFertilizer && player.Pay(newFertilizer.cost))
            {
                Destroy(oldFertilizer.gameObject);
                return(new InteractionResult(Instantiate(newFertilizer, oldFertilizer.oldParent), true, true));
            }
        }

        return(new InteractionResult(c, false, false));
    }