Inheritance: Monster
Example #1
0
    void Update()
    {
        if (start == true)
        {
            count++;
            if (count >= 80)
            {
                count = 0;

                if (DF == null)
                {
                    Debug.LogWarning("DF is NUll!");
                    return;
                }
                tral++;
                UFO d = DF.GetUFO(round);
                if (Manager == null)
                {
                    Debug.LogWarning("Manager is NULL!");
                }
                Manager.PlayUFO(d);
                if (tral == 10)
                {
                    round++;
                    tral = 0;
                }
            }
        }
    }
    public void Balance(List <Vector3> map, bool IgnoreBalanceIsZero = false)
    {
        var Balance = Level1_DB.UFOList.Count - map.Count;        //多(少)幾台

        //extra
        if (Balance > 0)
        {
            UFO.DestroyUFO(Balance);             //Destroy幾台
        }

        //lack
        if (Balance < 0)
        {
            UFO.InstantiateUFOs(Mathf.Abs(Balance));              //實例化UFO
        }

        //重設場上所有UFO座標
        if (!DB.start || !IgnoreBalanceIsZero)
        {
            for (int i = 0; i < map.Count; i++)
            {
                Level1_DB.UFOList [i].moveTo(1f, (Vector3)map [i], true, 0.1f);
            }
        }
    }
Example #3
0
    void OnCollisionEnter(Collision collision)
    {
        Collider collider = collision.collider;

        if (collider.CompareTag("Alien"))
        {
            Alien enemy = collider.gameObject.GetComponent <Alien>();
            enemy.die();
            die();
        }
        else if (collider.CompareTag("UFO"))
        {
            UFO ufo = collider.gameObject.GetComponent <UFO>();
            ufo.die();
            GameObject  g         = GameObject.Find("Environment");
            Environment globalObj = g.GetComponent <Environment>();
            globalObj.score += Random.Range(50, 200);
            die();
        }
        else if (collider.CompareTag("Platform"))
        {
            Platform platform = collider.gameObject.GetComponent <Platform>();
            platform.takeDamage();
            die();
        }
        else
        {
            Debug.Log("Collided with " + collider.tag);
        }
    }
Example #4
0
    void OnCollisionEnter(Collision collision)
    {
        // the Collision contains a lot of info, but it’s the colliding
        // object we’re most interested in.
        Collider collider = collision.collider;

        if (collider.CompareTag("Astroids"))
        {
            Astroid roid = collider.gameObject.GetComponent <Astroid>();
            // let the other object handle its own death throes
            roid.Die();
            // Destroy the Bullet which collided with the Asteroid
            Destroy(gameObject);
        }
        else if (collider.CompareTag("UFO"))
        {
            UFO foe = collider.gameObject.GetComponent <UFO>();
            foe.Die();
            Destroy(gameObject);
        }
        else
        {
            //TODO
            // if we collided with something else, print to console
            // what the other thing was
            Debug.Log("Collided with " + collider.tag);
        }
    }
Example #5
0
        public override void VisitUFO(UFO u)
        {
            ColPair cp = ColPairMan.GetActiveColPair();

            cp.SetCollision(u, this);
            cp.NotifyListeners();
        }
Example #6
0
        public override void Update()
        {
            Life.Text = "Ekstraliv: " + Ekstraliv.ToString();

            if (GameLive)
            {
                #region LEVEL

                m_GameLoops++;
                if (Spawned == 10)
                {
                    Level.Text = "Level 2";
                    SpawnTime  = 150;
                }
                if (Spawned == 30)
                {
                    Level.Text = "Level 3";
                    SpawnTime  = 100;
                }
                if (Spawned == 60)
                {
                    Level.Text = "Level 4";
                    SpawnTime  = 50;
                }
                if (Spawned > 100)
                {
                    Level.Text = "Level 5";
                    SpawnTime  = 20;
                }

                #endregion

                #region SPAWN

                if (m_GameLoops % SpawnTime == 0)
                {
                    Spawned++;
                    BadGuy EnemyUFO = (BadGuy)UFO.Clone();
                    EnemyUFO.Position = new Point(m_Random.Next(-100, 800), -150);
                    Engine_Game.Add(EnemyUFO);
                }

                #endregion

                if (!Music.IsPlaying)
                {
                    Music.Play();
                }

                if (Ekstraliv < 0)
                {
                    GameLive = false;
                }
            }
            else
            {
                GameOver();
            }
        }
Example #7
0
    public void MoveUFO(UFO ufo)
    {
        count++;
        Complete = SSActionEventType.Started;
        CCMoveToAction action = CCMoveToAction.getAction(ufo.speed);

        addAction(ufo.gameObject, action, this);
    }
Example #8
0
    public void PlayUFO(UFO ufo)
    {
        count++;
        Complete = SSActionEventType.Started;
        CCPhysisAction action = CCPhysisAction.getAction(ufo.speed); //实例化为物理运动对象

        addAction(ufo.gameObject, action, this);
    }
Example #9
0
    IEnumerator SpawnUFO()
    {
        yield return(new WaitForSeconds(ufoDelay));

        GameObject ufoGoInstance = Instantiate(ufo, ufoSpawnPoint.transform);

        ufoInstance         = ufoGoInstance.GetComponent <UFO>();
        ufoInstance.health *= WaveSpawner.instance.currentWave / 1.08f;
    }
Example #10
0
    public void AddUFO(UFO ufo)
    {
        activeUFO.Add(ufo);

        if (onUfoCountChange != null)
        {
            onUfoCountChange(activeUFO.Count);
        }
    }
Example #11
0
    public void RemoveActiveUFO(UFO ufo)
    {
        activeUFO.Remove(ufo);

        if (onUfoCountChange != null)
        {
            onUfoCountChange(activeUFO.Count);
        }
    }
Example #12
0
 private void InitializeEntities()
 {
     Player     = new Player();
     UFO        = new UFO();
     Timer      = new System.Windows.Forms.Timer();
     Random     = new Random();
     AliensList = new List <Alien>();
     FuelsList  = new List <Fuel>();
 }
Example #13
0
    void OnTriggerStay2D(Collider2D other)
    {
        if (this.shooter == null)
        {
            return;
        }
        Damageable        damageable         = other.gameObject.GetComponent <Damageable>();
        Rock              rock               = other.gameObject.GetComponent <Rock>();
        UFO               ufo                = other.gameObject.GetComponent <UFO>();
        Nebula            nebula             = other.gameObject.GetComponent <Nebula>();
        ControlledShooter controlled_shooter = this.shooter.gameObject.GetComponent <ControlledShooter>();

        /// The projectile collided with something!
        if (damageable != null)
        {
            damageable.Damage(this.damage);
            if (rock != null)
            {
                if (controlled_shooter != null && controlled_shooter.GetComponent <Scored>() != null)
                {
                    uint value = 0;
                    switch (rock.rock_type)
                    {
                    case Rock.RockType.LARGE:
                        value = controlled_shooter.score_per_large_asteroid_kill;
                        break;

                    case Rock.RockType.MEDIUM:
                        value = controlled_shooter.score_per_medium_asteroid_kill;
                        break;

                    case Rock.RockType.SMALL:
                        value = controlled_shooter.score_per_small_asteroid_kill;
                        break;
                    }
                    controlled_shooter.GetComponent <Scored>().score += value;
                }
            }
            else if (ufo != null && controlled_shooter != null)
            {
                Scored scored = controlled_shooter.GetComponent <Scored>();
                if (scored != null)
                {
                    scored.score += ufo.score_on_hit;
                    if (!ufo.damageable.IsAlive())
                    {
                        controlled_shooter.GetComponent <Scored>().score += ufo.score_on_kill;
                    }
                }
            }
            if (nebula == null)
            {
                Destroy(this.gameObject);
            }
        }
    }
Example #14
0
    void OnCollisionEnter(Collision collision)
    {
        Collider collider = collision.collider;

        // right itself
        if (!collider.CompareTag("Alien"))
        {
            grounded   = true;
            doubleJump = true;
        }

        if (collider.CompareTag("BuilderSpawn"))
        {
            Debug.Log("Now a buidler");
            builder = true;
            gameObject.renderer.material = BuilderMaterial;
            updateClass();
        }
        else if (collider.CompareTag("FighterSpawn"))
        {
            Debug.Log("Now a gfighter");
            gameObject.renderer.material = FighterMaterial;
            builder = false;
            updateClass();
        }
        else if (collider.CompareTag("Alien"))
        {
            // if shielded
            if (shield.activated)
            {
                Alien alien = collider.GetComponent <Alien>();
                alien.die();
            }
            else
            {
                takeDamage();
            }
        }
        else if (collider.CompareTag("UFO"))
        {
            // if shielded
            if (shield.activated)
            {
                GameObject  g         = GameObject.Find("Environment");
                Environment globalObj = g.GetComponent <Environment>();
                globalObj.score += 300;
                UFO ufo = collider.GetComponent <UFO>();
                ufo.die();
            }
            else
            {
                takeDamage();
            }
        }
        // if it's the builderspawn
    }
Example #15
0
    void spawnUFO()
    {
        // generate ufo
        ufo = (Instantiate(Resources.Load("Prefabs/UFOPrefab"),
                           new Vector3(Random.Range(tl.x, br.x), tl.y - 1, alienStart.z),
                           Quaternion.identity) as GameObject).GetComponent <UFO>();
        AudioClip fireSound = (AudioClip)Resources.Load("Audio/ufo_highpitch");

        AudioSource.PlayClipAtPoint(fireSound, gameObject.transform.position);
    }
        public Enemy CreateUFO(Point2D[] points, Point2D creationPoint)
        {
            Enemy enemy = new UFO(Player, points, creationPoint);

            enemy.Destroy += OnDestroy;
            enemy.Rotate(180);
            enemy.Speed = _enemiesSpeed;
            _enemies.Add(enemy);
            CreateGameObject?.Invoke(this, enemy);
            return(enemy);
        }
Example #17
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("UFO") == true)
     {
         int id  = collision.gameObject.GetInstanceID();
         UFO ufo = Factory_UFO.getInstance().getProduct(id);
         if (ufo.canHit)
         {
             Scorer.getInstance().addScore(ufo.Score);
         }
     }
 }
Example #18
0
    void OnCollisionEnter(Collision collision)
    {
        Collider collider = collision.collider;

        if (collider.CompareTag("Penemy1"))
        {
            enemy1cs e1 = collider.gameObject.GetComponent <enemy1cs>();
            e1.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("Penemy2"))
        {
            enemy2cs e2 = collider.gameObject.GetComponent <enemy2cs>();
            e2.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("Penemy3"))
        {
            enemy3cs e3 = collider.gameObject.GetComponent <enemy3cs>();
            e3.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("bunker"))
        {
            bunker eb = collider.gameObject.GetComponent <bunker>();
            eb.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("UFO"))
        {
            UFO uf = collider.gameObject.GetComponent <UFO>();
            uf.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("boss"))
        {
            Global gbs = GameObject.FindGameObjectWithTag("FGlobal").GetComponent <Global>();
            boss   bs  = GameObject.FindGameObjectWithTag("boss").GetComponent <boss>();
            AudioSource.PlayClipAtPoint(hitclipboss, bs.transform.position, 10);
            Instantiate(explosion, bs.transform.position, Quaternion.identity);
            gbs.bosslives--;
        }
        if (collider.CompareTag("Fplayer"))
        {
        }
        else
        {
            Destroy(gameObject);
        }
    }
Example #19
0
    void Start()
    {
        _FSM          = new StateMachine();
        _Ani          = GetComponent <Animator>();
        _ufo          = new UFO();
        _FSM.NowState = _ufo.Idle;
        InitPos       = new Vector3(0, this.transform.position.y, this.transform.position.z);
        HuntFinish    = false;
        TargetID      = UnityEngine.Random.Range(0, m_Targets.Length);
        TargetPos     = new Vector3(m_Targets[TargetID].position.x, this.transform.position.y, this.transform.position.z);
        FoolAround(5);

        AudioManager.SFX_ES.Trigger("UFO");
    }
Example #20
0
    public void game(int Round)
    {
        if (mygui.getstate() != 0)
        {
            return;
        }
        UFO ufo1   = fctory1.Create();
        UFO ufo2   = fctory2.Create();
        UFO ufo3   = fctory3.Create();
        UFO ufo4   = fctory4.Create();
        UFO ufo5   = fctory5.Create();
        int random = 0;

        random = Choose(probArray);

        switch (random)
        {
        case 0:
            //ufo1.Version(Round);
            adapter1.Add_Component_Rigidbody(ufo1, Round);
            grade += 1;
            break;

        case 1:
            grade += 2;
            //ufo2.Version(Round);
            adapter1.Add_Component_Rigidbody(ufo2, Round);
            break;

        case 2:
            grade += 3;
            adapter1.Add_Component_Rigidbody(ufo3, Round);
            //ufo3.Version(Round);
            break;

        case 3:
            grade += 4;
            adapter1.Add_Component_Rigidbody(ufo4, Round);
            //ufo5.Version(Round);
            break;

        default:
            grade += 5;
            adapter1.Add_Component_Rigidbody(ufo5, Round);
            //ufo5.Version(Round);
            break;
        }
    }
    public void Init()
    {
        gameManager  = CoreTools.GetManager <GameManager>();
        pool         = CoreTools.GetManager <RegulatoryPools>();
        timerManager = CoreTools.GetManager <TimerManager>();
        inputManager = CoreTools.GetManager <InputManager>();

        FindCamera();
        DefiningScreenBoundaries();
        AddEventSystem();
        CreatePools();

        state = GameState.Start;

        gameCanvas = GameObject.Instantiate(gameManager.GameCanvasPrefab);
        gameUi     = gameCanvas.GetComponent <GameUI>();
        gameUi.Init();
        gameCanvas.SetActive(false);

        lobbyCanvas = GameObject.Instantiate(gameManager.LobbyCanvasPrefab);
        lobbyMenu   = lobbyCanvas.GetComponent <LobbyMenu>();
        lobbyMenu.Init();
        lobbyCanvas.SetActive(false);

        SetInput(inputManager.CurrentType);
        inputManager.GetInput().SetActive(false);

        gameManager.sceneRightEdge  = sceneRightEdge;
        gameManager.sceneLeftEdge   = sceneLeftEdge;
        gameManager.sceneTopEdge    = sceneTopEdge;
        gameManager.sceneBottomEdge = sceneBottomEdge;
        gameManager.sceneWidth      = sceneWidth;
        gameManager.sceneHeight     = sceneHeight;

        startAsteroidCount = gameManager.StartAsteroidsCount;

        player = GameObject.Instantiate(gameManager.PlayerPrefab);
        ship   = player.GetComponent <Ship>();
        ship.Init();
        player.SetActive(false);

        Ufo = GameObject.Instantiate(gameManager.UfoPrefab);
        ufo = Ufo.GetComponent <UFO>();
        ufo.Init();
        Ufo.SetActive(false);

        EnteringGameMenu();
    }
Example #22
0
 private void CheckIfUFOIsFueled(ProgressBar fuelBar, Button restartButton, Label victoryLabel)
 {
     if (fuelBar.Value == 100)
     {
         UFO.CurrentSprite.Image = Resource1.UFOWithFuel;
         UFO.IsFueled            = true;
         if (UFO.CurrentSprite.Bounds.Contains(Player.CurrentSprite.Location) || Player.InsideUFO)
         {
             Player.InsideUFO        = true;
             UFO.CurrentSprite.Image = Resource1.PlayerInsideUFO;
             UFO.FlyUp();
             Controls.Add(victoryLabel);
             Controls.Add(restartButton);
         }
     }
 }
Example #23
0
        static void Main(string[] args)
        {
            var cessna = new Cessna();
            var ufo    = new UFO();

            var delorean = new DeLorean();
            var ducati   = new Ducati();

            var jetski  = new JetSki();
            var tugboat = new Tugboat();


            // Build a collection of all vehicles that fly
            var flyingStuff = new List <IFly> {
                cessna, ufo
            };

            // With a single `foreach`, have each vehicle Fly()
            foreach (var vehicle in flyingStuff)
            {
                vehicle.Fly();
            }


            // Build a collection of all vehicles that operate on roads
            var roadRunners = new List <IDriver> {
                delorean, ducati
            };

            // With a single `foreach`, have each road vehicle Drive()
            foreach (var roadHog in roadRunners)
            {
                roadHog.Drive();
            }


            // Build a collection of all vehicles that operate on water
            var waveracers = new List <ISwimmer> {
                jetski, tugboat
            };

            // With a single `foreach`, have each water vehicle Drive()
            foreach (var boat in waveracers)
            {
                boat.Drive();
            }
        }
Example #24
0
    private void FixedUpdate()
    {
        if (applyForce)
        {
            Debug.Log("Force Applied");
            Vector3 directionHit = hitObject.gameObject.transform.position - transform.position;
            hitObject.AddForce(directionHit * HitStrength);
            applyForce = false;

            //make it expell all the passengers
            if (hitObject.gameObject.tag == "UFO")
            {
                UFO ufoObject = hitObject.gameObject.GetComponent <UFO>();
                ufoObject.EjectPassengers();
            }
        }
    }
Example #25
0
    void OnCollisionEnter(Collision collision)
    {
        Collider collider = collision.collider;

        if (collider.CompareTag("UFO"))
        {
            UFO ufo = collider.gameObject.GetComponent <UFO>();
            ufo.rigidbody.velocity = new Vector3(0, 0, 0);
            die();
        }
        if (collider.CompareTag("Alien"))
        {
            Alien alien = collider.gameObject.GetComponent <Alien>();
            // alien.rigidbody.velocity = new Vector3(0,0,0);
            die();
        }
    }
Example #26
0
        private void SpawnEnemies()
        {
            switch (activeEvent)
            {
            case Events.None:
                if (random.Next(1, 300) == 1)
                {
                    float spawnPosX = random.Next(25, desiredResolutionWidth - 25);
                    float spawnPosY = -50;
                    UFO.NewUFO(new Vector2(spawnPosX, spawnPosY));
                }
                if (random.Next(1, 380) == 1)
                {
                    float spawnPosX = random.Next(25, desiredResolutionWidth - 25);
                    float spawnPosY = -50;
                    Slicer.NewSlicer(new Vector2(spawnPosX, spawnPosY));
                }
                if (random.Next(1, 720) == 1)
                {
                    float spawnPosX = random.Next(8, desiredResolutionWidth - 8);
                    float spawnPosY = -50;
                    RayEnemy.NewRay(new Vector2(spawnPosX, spawnPosY));
                }
                if (random.Next(1, 720) == 1)
                {
                    float spawnPosX = random.Next(16, desiredResolutionWidth - 16);
                    float spawnPosY = -50;
                    Stasis.NewStasis(new Vector2(spawnPosX, spawnPosY));
                }
                break;

            case Events.AsteroidField:
                if (random.Next(1, 120) == 1)
                {
                    int   asteroidType      = random.Next(0, 4 + 1);
                    float asteroidSpawnPosX = random.Next(24, desiredResolutionWidth - 24);
                    float asteroidSpawnPosY = -50;
                    float asteroidFallSpeed = (float)random.NextDouble() * 0.2f;
                    float asteroidScale     = (float)(random.Next(80, 100 + 1)) / 100f;
                    float asteroidRotation  = (float)(random.Next(10, 100 + 1) / 2000f);
                    Asteroid.NewAsteroid(asteroidType, new Vector2(asteroidSpawnPosX, asteroidSpawnPosY), new Vector2(0f, asteroidFallSpeed / (1.1f - (asteroidScale / 100f))), asteroidRotation, asteroidScale);
                }
                break;
            }
        }
Example #27
0
    //change this up so its more efficient later
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Asteroid") && projectile.isEnemy != true)
        {
            Asteroid asteroid = other.GetComponentInParent <Asteroid>();
            asteroid.DoDamage(projectile.projectileDamage);
            projectile.Destroyed();
        }

        if (other.CompareTag("UFO") && projectile.isEnemy != true)
        {
            UFO ufo = other.GetComponentInParent <UFO>();
            ufo.GetDamaged(projectile.projectileDamage);
            projectile.Destroyed();
        }

        if (other.CompareTag("BossShield") && projectile.isEnemy != true)
        {
            Boss boss = other.GetComponentInParent <Boss>();
            boss.DamageShield(projectile.projectileDamage);
            projectile.Destroyed();
        }

        if (other.CompareTag("BossTurret") && projectile.isEnemy != true)
        {
            Boss boss = other.GetComponentInParent <Boss>();
            boss.DamageCannon(projectile.projectileDamage);
            projectile.Destroyed();
        }

        if (other.CompareTag("Boss") && projectile.isEnemy != true)
        {
            Boss boss = other.GetComponentInParent <Boss>();
            boss.GetDamaged(projectile.projectileDamage);
            projectile.Destroyed();
        }

        if (other.CompareTag("Ship") && projectile.isEnemy == true)
        {
            Debug.Log("Hit");
            Player player = other.GetComponentInParent <Player>();
            player.DoDamage(projectile.projectileDamage);
            projectile.Destroyed();
        }
    }
Example #28
0
    public override IEnumerator LevelManagement(params object[] args)
    {
        var map = (List <Vector3>)args [0];

        CT1.DisplaySliderBar();                          //更新難度條

        var Balance = map.Count;                         //多(少)幾台

        List <UFO> Group = UFO.InstantiateUFOs(Balance); //實例化UFO

        //重設場上所有UFO座標
        for (int i = 0; i < Group.Count; i++)
        {
            Group [i].moveTo(0.7f, map [i], true, 0.1f);
        }

        yield break;
    }
Example #29
0
        public void ResetGameObjects()
        {
            lblScore.Text       = data.Score.ToString();
            lblLevelNumber.Text = data.Level.ToString();


            ResetShieldLabels();
            Shields = logic.InitializeObject_Shields();


            alienGroup = logic.InitializeAliens(data.Level);

            alienGroup = logic.InitializeAliens(data.Level);
            actualUFO  = logic.InitializeUFO(data.Level);

            bullets.Clear();
            alienbullets.Clear();
        }
        /// <summary>
        ///		Gets called when a Scene is unpaused
        /// </summary>
        protected override void OnSceneUnpaused()
        {
            // Make the aliens move again
            AlienCoordinator aliens = GameObjectManager.Active.Find(GameObject.Name.AlienCoordinator, this.AlienCoordinatorId) as AlienCoordinator;

            if (aliens != null)
            {
                aliens.StartMovingAgain();
            }

            // Make the UFO play a sound, if it exists
            UFO ufo = GameObjectManager.Active.Find(GameObject.Name.UFO, this.UfoId) as UFO;

            if (ufo != null)
            {
                ufo.PlayLoopingSound();
            }
        }