예제 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Rock"))
        {
            RockController rc = other.GetComponent <RockController>();

            if (isBullet)
            {
                rc.OnBulletDestroy();
                Destroy(GO);
            }
            else
            {
                rc.OnLaserDestroy();
            }
        }

        if (other.CompareTag("UFO"))
        {
            UFOController uc = other.GetComponent <UFOController>();

            if (isBullet)
            {
                uc.OnBulletDestroy();
                Destroy(GO);
            }
            else
            {
                uc.OnBulletDestroy();
            }
        }
    }
예제 #2
0
 internal void setUFOController(UFOController ufoCtrl)
 {
     if (myUFOCtrl == null)
     {
         myUFOCtrl = ufoCtrl;
     }
 }
예제 #3
0
    void OnTriggerEnter(Collider other)
    {
        Asteroid ast;

        //Check layer 8 'Asteroid'
        if (other.CompareTag("Asteroid") && ownedObject.CompareTag("Player"))
        {
            ast = other.GetComponent <Asteroid>();
            ownedObject.GetComponent <Player>().AddToScore(ast.scoreValue);
            ast.Destroyed();
            gameObject.SetActive(false);
        }

        else if (other.CompareTag("UFO") && ownedObject.CompareTag("Player"))
        {
            UFOController ufo = other.GetComponent <UFOController>();
            ownedObject.GetComponent <Player>().AddToScore(ufo.ScoreValue);
            gameObject.SetActive(false);
            other.gameObject.SetActive(false);
        }

        //Aka this is an enemy bullet
        else if (ownedObject.CompareTag("UFO") && other.CompareTag("Player"))
        {
            gameObject.SetActive(false);
            other.GetComponent <Player>().LoseLife();
        }
    }
예제 #4
0
 private void CantPlay(UFOController ufo, UFOController target)
 {
     if (target is PlayerController)
     {
         foreach (var player in players)
         {
             player.CanPlay = false;
             player.sucker.gameObject.SetActive(false);
         }
         // target.CanPlay = false;
         // target.gameObject.SetActive(false);
     }
     else
     {
         target.CanPlay = false;
         target.gameObject.SetActive(false);
         var playingPlayers = players.Where((x) => x.CanPlay);
         if (playingPlayers.Count() == 1)
         {
             var player = playingPlayers.First();
             player.CanPlay = false;
             player.sucker.gameObject.SetActive(false);
             OnWin(player);
         }
     }
 }
예제 #5
0
    public override void StateDoing(GameObject Obj)
    {
        uFOController = Obj.GetComponent <UFOController>();
        uFOController.Beam.SetActive(false);
        Vector3 pos;

        if (uFOController.startHunt)
        {
            pos = Vector3.MoveTowards(Obj.transform.position, uFOController.TargetPos, uFOController.MoveSpeed * Time.deltaTime);
        }
        else
        {
            pos = Vector3.MoveTowards(Obj.transform.position, uFOController.InitPos, uFOController.MoveSpeed * Time.deltaTime);
        }

        Obj.transform.position = pos;

        if (Math.Abs(Obj.transform.position.x - uFOController.TargetPos.x) < 0.01f && !UFOController.HuntFinish)
        {
            uFOController.startHunt = false;
            uFOController._Ani.SetTrigger("IsHuntting");
            uFOController._FSM.NowState = uFOController._ufo.Hunt;
            AudioManager.SFX_ES.Trigger("Beam");
            ObserverSystem.share.Notify(uFOController.m_Targets[uFOController.TargetID].name, AnimalState.Help);
        }
    }
예제 #6
0
 public void recycle(UFOController UFOCtrl)
 {
     // 回收一个UFO,将其加入空闲队列
     UFOCtrl.disappear();
     usingList.Remove(UFOCtrl);
     freeQueue.Enqueue(UFOCtrl);
 }
예제 #7
0
 public void UFOIsShot(UFOController UFOCtrl)
 {
     // 响应UFO被击中的事件
     scorer.record(difficultyManager.getDifficulty());
     actionManager.removeActionOf(UFOCtrl.getObj());
     UFOfactory.recycle(UFOCtrl);
     explosionFactory.explodeAt(UFOCtrl.getObj().transform.position);
 }
예제 #8
0
    public UFOController[] produceUFOs(UFOAttributes attr, int n)
    {
        // 一次性产生n个UFO

        UFOController[] arr = new UFOController[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = produceUFO(attr);
        }
        return(arr);
    }
예제 #9
0
 private void GameOver(UFOController ufo, UFOController target)
 {
     if (target is PlayerController)
     {
         ShowFinalPanel();
     }
     else if (ufo is PlayerController)
     {
         Destroy(Instantiate(killTextPrefab, lvlupContainer), 1f);
     }
     StatsUpdate();
 }
예제 #10
0
    // 在這個class被實例化後,被下達Start()時執行
    protected override void OnStart()
    {
        m_startGameUI = GetPage <StartGameUIPage>() as StartGameUIPage;
        m_gamingUI    = GetPage <GamingUIPage>() as GamingUIPage;

        UFOController _player = GameObjectPoolManager.GetUseableObject <UFOController>("UFO"); // 創建玩家

        BumpManager.Instance.SpawnBump();                                                      // 創建第一個團塊
        ScoreManager.Instance.ResetScroe();                                                    // 重設分數
        m_startGameUI.EnablePage(this, false);                                                 // 關閉開始頁面UI
        m_gamingUI.EnablePage(this, true);                                                     // 開啟遊戲UI
        m_gameTimer = 0f;                                                                      // 重設計時器
    }
예제 #11
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        DropletController dropletController = collision.GetComponent <DropletController>();

        if (dropletController != null)
        {
            SuckUpDroplet(dropletController);
        }

        BirdController birdController = collision.GetComponent <BirdController>();

        if (birdController != null)
        {
            if (isAcid)
            {
                birdController.AcidDeath();
            }
            else
            {
                EnemyHit();
            }
        }

        UFOController ufoController = collision.GetComponent <UFOController>();

        if (ufoController != null)
        {
            if (isAcid)
            {
                ufoController.AcidDeath();
            }
            else
            {
                EnemyHit();
            }
        }

        LightningController lightningController = collision.GetComponent <LightningController>();

        if (lightningController != null)
        {
            EnemyHit();
        }

        AcidDropletController acidDropletController = collision.GetComponent <AcidDropletController>();

        if (acidDropletController != null)
        {
            SuckUpAcidDroplet(acidDropletController);
        }
    }
예제 #12
0
    public override void StateDoing(GameObject Obj)
    {
        UFOController uFOController = Obj.GetComponent <UFOController>();

        uFOController.Beam.SetActive(true);
        uFOController._Ani.SetTrigger("IsRest");
        if (UFOController.HuntFinish)
        {
            Debug.Log("Finish huntting");
            uFOController._FSM.NowState = uFOController._ufo.Idle;
            UFOController.HuntFinish    = false;
            uFOController.FoolAround(3);
        }
    }
예제 #13
0
 private void AddXp(UFOController ufo, int xp, bool up)
 {
     if (ufo is PlayerController)
     {
         var t = Instantiate(xpTextPrefab, ((PlayerController)ufo).xpContainer);
         t.GetComponent <Text>().text = "+" + xp;
         Destroy(t, 1f);
         if (up)
         {
             Destroy(Instantiate(lvlupTextPrefab, lvlupContainer), 1f);
         }
     }
     StatsUpdate();
 }
예제 #14
0
        public void Init(UFOController ufo, GameManager gameManager)
        {
            _ufo         = ufo;
            _gameManager = gameManager;
            InUfo        = true;

            foreach (var alienBallController in Weapons)
            {
                alienBallController.Init(_gameManager);
            }

            _gameManager.Player.OnEnterCar += OnPlayerEnterCar;
            _currentTerrain = _gameManager.Terrain1;
        }
예제 #15
0
    //BeamCharge theBC;

    // Start is called before the first frame update
    void Start()
    {
        //mousePos = Input.mousePosition;
        //currentRotation = transform.rotation;
        ufoTurret        = transform.position;
        beamPower        = 100;
        beamSlider.value = beamPower;

        beam.SetActive(false);

        //theBC = FindObjectOfType<BeamCharge>();
        theUfo = FindObjectOfType <UFOController>();

        transform.position = ufo.position;
    }
예제 #16
0
    public void SetTopPlayer()
    {
        if (TOP_PLAYER != this)
        {
            if (TOP_PLAYER != null)
            {
                TOP_PLAYER.topIdicator.SetActive(false);
                // var col1 = TOP_PLAYER.head.material.color;
                // TOP_PLAYER.head.material.color = new Color(col1.r, col1.g, col1.b, 1f);
            }
            topIdicator.SetActive(true);
            // var col2 = head.material.color;
            // head.material.color = new Color(col2.r, col2.g, col2.b, 0.3f);

            TOP_PLAYER = this;
        }
    }
예제 #17
0
    public UFOController produceUFO(UFOAttributes attr)
    {
        UFOController newUFO;

        if (freeQueue.Count == 0)       // 如果没有UFO空闲,则克隆一个对象
        {
            // print("Instantiate");
            GameObject newObj = GameObject.Instantiate(originalUFO);
            newUFO = new UFOController(newObj);
            newObj.transform.position += Vector3.forward * Random.value * 5;
            count++;
        }
        else                            // 如果有UFO空闲,则取出这个UFO
        {
            newUFO = freeQueue.Dequeue();
        }
        newUFO.setAttr(attr);           // 将UFO的颜色速度大小设置成参数指定的样子
        usingList.Add(newUFO);          // 将UFO加入使用中的队列
        newUFO.appear();
        return(newUFO);
    }
예제 #18
0
    void Update()
    {
        if (Input.GetButton("Fire1"))   // Fire1按键是鼠标左键或左Ctrl键
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            // layerMask参数使这个射线只能打中指定layer的物体
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
            {
                if (hit.transform.gameObject.layer == 8)
                {                                       // 通过hit获取到了击中物体所在的层
                    UFOController UFOCtrl = hit.transform.GetComponent <UFOScript>().ctrl;
                    sceneController.UFOIsShot(UFOCtrl); // 通知sceneController
                }
                else if (hit.transform.gameObject.layer == 9)
                {
                    sceneController.GroundIsShot(hit.point);
                }
            }
            if (muzzleFlashEnable == false) // 显示枪口火焰
            {
                muzzleFlashEnable = true;
                muzzleFlash.SetActive(true);
            }
        }


        if (muzzleFlashEnable)      // 计时,枪口火焰显示0.1秒后消失
        {
            muzzleFlashTimer += Time.deltaTime;
            if (muzzleFlashTimer >= muzzleFlashMaxTime)
            {
                muzzleFlashEnable = false;
                muzzleFlash.SetActive(false);
                muzzleFlashTimer = 0;
            }
        }
    }
예제 #19
0
 // Start is called before the first frame update
 void Start()
 {
     myUFO = GetComponent <UFOController>();
 }
예제 #20
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Asteroid      asteroid = hitInfo.GetComponent <Asteroid>();
        UFOController ufo      = hitInfo.GetComponent <UFOController>();

        if (asteroid != null)
        {
            FindObjectOfType <Game>().PlayExplosion(asteroid.size);

            int asteroidSizePoints = asteroid.size == 3 ? 20 : asteroid.size == 2 ? 50 : 100;

            Canvas canvas        = FindObjectOfType <Canvas>();
            Text   textComponent = canvas.transform.GetChild(0).gameObject.GetComponent <Text>();
            Text   lives         = canvas.transform.GetChild(1).gameObject.GetComponent <Text>();

            if (textComponent != null)
            {
                Game game = FindObjectOfType <Game>();

                int score = game.score + asteroidSizePoints;
                game.score += asteroidSizePoints;

                textComponent.text = "Score: " + score;

                if (game.score > game.interval)
                {
                    game.interval += game.inter;
                    Control ship = FindObjectOfType <Control>();
                    ship.lives++;
                    lives.text = "Lives: " + ship.lives;
                }
            }

            asteroid.SplitAsteroid(asteroid);

            Destroy(gameObject);
        }

        if (ufo != null)
        {
            FindObjectOfType <Game>().PlayExplosion(2);
            Canvas canvas        = FindObjectOfType <Canvas>();
            Text   textComponent = canvas.transform.GetChild(0).gameObject.GetComponent <Text>();
            Text   lives         = canvas.transform.GetChild(1).gameObject.GetComponent <Text>();

            if (textComponent != null)
            {
                Game game = FindObjectOfType <Game>();
                game.score += 500;
                int score = game.score;

                textComponent.text = "Score: " + score;

                if (game.score > game.interval)
                {
                    game.interval += game.inter;
                    Control ship = FindObjectOfType <Control>();
                    ship.lives++;
                    lives.text = "Lives: " + ship.lives;
                }
            }

            Destroy(gameObject);
            Destroy(ufo.gameObject);
        }
    }
예제 #21
0
 private void Start()
 {
     theUFO = FindObjectOfType <UFOController>();
 }
예제 #22
0
 /// <summary>
 /// Start is called on the frame when a script is enabled just before
 /// any of the Update methods is called the first time.
 /// </summary>
 void Awake()
 {
     ufo = this.GetComponentInParent <UFOController>();
 }
예제 #23
0
 private void Win(UFOController winner)
 {
     ShowFinalPanel();
     Crown.SetActive(true);
 }
 // Use this for initialization
 void Start()
 {
     ownController = GetComponent <UFOController>();
     ownHealth     = GetComponent <UFOHealth>();
 }
예제 #25
0
 private void Start()
 {
     _theUFO   = UFOToInform.GetComponent <UFOController>();
     _myParent = transform.parent.gameObject;
 }
예제 #26
0
 // Use this for initialization
 protected override void Start()
 {
     base.Start();
     controller = GetComponent <UFOController>();
 }