Beispiel #1
0
    private void SendDisk()     //发射飞碟
    {
        float position_x = 16;

        if (dq.Count != 0)
        {
            GameObject disk = dq.Dequeue();
            dfree.Add(disk);
            disk.SetActive(true);
            float ran_y = Random.Range(1f, 4f);
            disk.GetComponent <DiskData>().direction = new Vector3(1f, ran_y, 0);
            Vector3 position = new Vector3(-disk.GetComponent <DiskData>().direction.x *position_x, ran_y, 0);
            disk.transform.position = position;
            float power = Random.Range(1f * round, 2f * round);
            float angle = Random.Range(0f, 5f);
            ima.UFOFly(disk, angle, power, ug.go, mode);
        }

        for (int i = 0; i < dfree.Count; i++)
        {
            GameObject temp = dfree[i];
            if (temp.transform.position.x > 20 && temp.gameObject.activeSelf == true)
            {
                df.FreeDisk(dfree[i]);
                dfree.Remove(dfree[i]);
                ug.ReduceBlood();
            }
        }
    }
Beispiel #2
0
    private void SendDisk()
    {
        float position_x = mode ? 16 : 11;

        if (dq.Count != 0)
        {
            GameObject disk = dq.Dequeue();
            dfree.Add(disk);
            disk.SetActive(true);
            float ran_y = mode ? Random.Range(1f, 4f) : Random.Range(3f, 4f);
            float ran_x = Random.Range(-1f, 1f) < 0 ? -1 : 1;
            disk.GetComponent <DiskData>().direction = new Vector3(ran_x, ran_y, 0);
            Vector3 position = new Vector3(-disk.GetComponent <DiskData>().direction.x *position_x, ran_y, 0);
            disk.transform.position = position;
            float power = mode ? Random.Range(20f, 30f) : Random.Range(3.5f, 5f);
            float angle = mode ? Random.Range(5f, 13f) : Random.Range(20f, 35f);
            iam.UFOFly(disk, angle, power, mode);
        }

        for (int i = 0; i < dfree.Count; i++)
        {
            GameObject temp = dfree[i];
            if (temp.transform.position.y < -10 && temp.gameObject.activeSelf == true)
            {
                df.FreeDisk(dfree[i]);
                dfree.Remove(dfree[i]);
                ug.ReduceBlood();
            }
        }
    }
Beispiel #3
0
  private void SendDisk()
  {
      float position_x = 16;

      if (diskQueue.Count != 0)
      {
          GameObject disk = diskQueue.Dequeue();
          notBeShoted.Add(disk);
          disk.SetActive(true);

          float randomY = Random.Range(2f, 4f);
          float offsetX = Random.Range(-1f, 1f) < 0 ? -1 : 1;
          disk.GetComponent <DiskData>().direction = new Vector3(offsetX, randomY, 0);
          Vector3 position = new Vector3(-disk.GetComponent <DiskData>().direction.x *position_x, randomY, 0);
          disk.transform.position = position;

          float pow = Random.Range(10f, 15f);
          float ang = Random.Range(15f, 28f);
          actionManager.UFOFly(disk, ang, pow);
      }

      for (int i = 0; i < notBeShoted.Count; i++)
      {
          GameObject temp = notBeShoted[i];

          if (temp.transform.position.y < -10 && temp.gameObject.activeSelf == true)
          {
              diskFactory.FreeDisk(notBeShoted[i]);
              notBeShoted.Remove(notBeShoted[i]);
              GUI.MinusOneSec();
          }
      }
  }
Beispiel #4
0
    public void Boomshakalaka(GameObject disk)
    {
        df.FreeDisk(disk);

        if (df.GetCount() == 0)
        {
            next_round = true;
            scoreRecorder.AddScore(round + 1);
            trial = 1;
        }
    }
Beispiel #5
0
 public void RecycleDisk()    //检查需不需要回收飞碟
 {
     for (int i = 0; i < disks.Count; i++)
     {
         if (disks[i].transform.position.z < -18)
         {
             diskFactory.FreeDisk(disks[i]);
             disks.Remove(disks[i]);
         }
     }
 }
Beispiel #6
0
    private void launchUFO()
    {
        float position_x = 16;

        if (disk_queue.Count != 0)
        {
            GameObject disk = disk_queue.Dequeue();
            disk_notshot.Add(disk);
            disk.SetActive(true);
            //设置被隐藏了或是新建的飞碟的位置
            float ran_y = Random.Range(1f, 4f);
            float ran_x = Random.Range(-1f, 1f) < 0 ? -1 : 1;
            disk.GetComponent <UFOData>().pos = new Vector3(ran_x, ran_y, 0);
            Vector3 position = new Vector3(-disk.GetComponent <UFOData>().pos.x *position_x, ran_y, 0);
            disk.transform.position = position;
            //设置飞碟初始所受的力和角度
            float speed = Random.Range(10, 30);
            float angle = Random.Range(15f, 28f);
            am.UFOFly(disk, speed, gravity, angle);
        }

        for (int i = 0; i < disk_notshot.Count; i++)
        {
            GameObject temp = disk_notshot[i];
            //飞碟飞出摄像机视野也没被打中
            if (temp.transform.position.y < -10 && temp.gameObject.activeSelf == true)
            {
                disk_factory.FreeDisk(disk_notshot[i]);
                disk_notshot.Remove(disk_notshot[i]);
                user_gui.ReduceBlood();
            }
        }
    }
Beispiel #7
0
    // 抛出飞碟
    public void ThrowDisk()
    {
        float position_x = 16;

        if (diskQueue.Count != 0)
        {
            diskNumber--;
            GameObject disk = diskQueue.Dequeue(); // 取出飞碟
            diskNotshot.Add(disk);
            disk.SetActive(true);

            // 设置飞碟的随机位置
            float ran_y = Random.Range(1f, 4f);
            float ran_x = Random.Range(-1f, 1f) < 0 ? -1 : 1;
            disk.GetComponent <DiskData>().direction = new Vector3(ran_x, ran_y, 0);
            Vector3 position = new Vector3(-disk.GetComponent <DiskData>().direction.x *position_x, ran_y, 0);
            disk.transform.position = position;

            // 设置飞碟初始所受的力和角度
            float power = Random.Range(10f, 15f);
            float angle = Random.Range(15f, 28f);
            actionManager.Fly(disk, angle, power);
        }

        for (int i = 0; i < diskNotshot.Count; i++)
        {
            GameObject temp = diskNotshot[i];
            //飞碟飞出摄像机视野也没被打中
            if (temp.transform.position.y < -20 && temp.gameObject.activeSelf == true)
            {
                diskFactory.FreeDisk(diskNotshot[i]);
                diskNotshot.Remove(diskNotshot[i]);
            }
        }
    }
    private void SendDisk()
    {
        float position_x = 16;

        if (diskQueue.Count != 0)
        {
            GameObject disk = diskQueue.Dequeue();
            diskNotHit.Add(disk);
            disk.SetActive(true);
            float ran_y = Random.Range(1f, 4f);
            float ran_x = Random.Range(-1f, 1f) < 0 ? -1 : 1;
            disk.GetComponent <DiskData>().direction = new Vector3(ran_x, ran_y, 0);
            Vector3 position = new Vector3(-disk.GetComponent <DiskData>().direction.x *position_x, ran_y, 0);
            disk.transform.position = position;
            float power = Random.Range(10f, 15f);
            float angle = Random.Range(15f, 28f);
            actionManager.UFOFly(disk, angle, power);
        }

        for (int i = 0; i < diskNotHit.Count; i++)
        {
            GameObject temp = diskNotHit[i];
            if (temp.transform.position.y < -10 && temp.gameObject.activeSelf == true)
            {
                diskFactory.FreeDisk(diskNotHit[i]);
                diskNotHit.Remove(diskNotHit[i]);
                userGUI.BloodReduce();
            }
        }
    }
    private void SendUFO()
    {
        float position_x = 16;

        if (UFO_queqe.Count != 0)
        {
            GameObject UFO = UFO_queqe.Dequeue();
            UFO_notshot.Add(UFO);
            UFO.SetActive(true);
            float ran_y = Random.Range(1f, 4f);
            float ran_x = Random.Range(-1f, 1f) < 0 ? -1 : 1;
            UFO.GetComponent <DiskData>().direction = new Vector3(ran_x, ran_y, 0);
            Vector3 position = new Vector3(-UFO.GetComponent <DiskData>().direction.x *position_x, ran_y, 0);
            UFO.transform.position = position;
            float power = Random.Range(10f, 15f);
            float angle = Random.Range(15f, 28f);
            action_manager.playDisk(UFO, angle, power, isPhysical); //改变
        }

        for (int i = 0; i < UFO_notshot.Count; i++)
        {
            GameObject temp = UFO_notshot[i];
            if (temp.transform.position.y < -10 && temp.gameObject.activeSelf == true)
            {
                UFO_factory.FreeDisk(UFO_notshot[i]);
                UFO_notshot.Remove(UFO_notshot[i]);
                user_gui.ReduceBlood();
            }
        }
    }
 public bool RoundStop()
 {
     if (round > 3)
     {
         start = false;
         if (Manager.IsAllFinished())
         {
             if (ManagerofNow)
             {
                 Destroy(this.gameObject.GetComponent <CCPhysisActionManager>());
             }
             else
             {
                 Destroy(this.gameObject.GetComponent <CCActionManager>());
             }
             DF.FreeDisk();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Beispiel #11
0
 void Update()
 {
     if (state == State.REST || state == State.STOP)
     {
         if (scoreRecorder.score <= round * 16 && state == State.REST)
         {
             state = State.LOSE;
         }
         countDown = 3f;
     }
     else if (state == State.COUNTDOWN)
     {
         Countdown();
     }
     else if (state == State.PLAYING)
     {
         for (int i = 0; i < freeDisk.Count; i++)
         {
             GameObject temp = freeDisk[i];
             if (temp.transform.position.y < -10 && temp.gameObject.activeSelf == true)
             {
                 diskFactory.FreeDisk(freeDisk[i]);
                 freeDisk.Remove(freeDisk[i]);
             }
         }
         if (freeDisk.Count == 0)
         {
             ThrowDisk();
         }
         if (diskQueue.Count == 0 && freeDisk.Count == 0)
         {
             state = State.REST;
         }
     }
 }
Beispiel #12
0
    private void SendDisk()
    {
        float position_x = 16f;

        if (disk_queue.Count != 0)
        {
            GameObject disk = disk_queue.Dequeue();
            disk_notshot.Add(disk);
            disk.SetActive(true);
            //设置被隐藏了或是新建的飞碟的位置
            float ran_y = Random.Range(1f, 4f);
            float ran_x = Random.Range(-1f, 1f) < 0 ? -1 : 1;
            disk.GetComponent <DiskData>().direction = new Vector3(ran_x, ran_y, 0);
            position_x = Random.Range(14f, 18f);
            Vector3 position = new Vector3(-disk.GetComponent <DiskData>().direction.x *position_x, ran_y, 0);
            disk.transform.position = position;
            //设置飞碟初始所受的力和角度
            // float power = Random.Range(10f, 15f);
            // float angle = Random.Range(15f, 30f);
            action_manager.fly(disk);
        }

        for (int i = 0; i < disk_notshot.Count; i++)
        {
            GameObject temp = disk_notshot[i];
            //飞碟飞出摄像机视野也没被打中
            if (temp.transform.position.y < -15 && temp.gameObject.activeSelf == true)
            {
                disk_factory.FreeDisk(disk_notshot[i]);
                disk_notshot.Remove(disk_notshot[i]);
                //玩家血量-1
                user_gui.ReduceBlood();
            }
        }
    }
Beispiel #13
0
    private void SendDisk()
    {
        float position_x = Random.Range(1, 5);

        if (disk_queue.Count != 0)
        {
            GameObject disk = disk_queue.Dequeue();
            disk_notshot.Add(disk);
            disk.SetActive(true);

            float ran_y = Random.Range(1f, 4f);
            float ran_x = Random.Range(-5f, 5f);
            disk.GetComponent <DiskData>().direction = new Vector3(ran_x, ran_y, 0);
            Vector3 position = new Vector3(-disk.GetComponent <DiskData>().direction.x *position_x, ran_y, 0);
            disk.transform.position = position;

            float power = Random.Range(10f, 15f);
            float angle = Random.Range(15f, 28f);
            action_manager.UFOFly(disk, angle, power);
        }

        for (int i = 0; i < disk_notshot.Count; i++)
        {
            GameObject temp = disk_notshot[i];

            if (temp.transform.position.y < -10 && temp.gameObject.activeSelf == true)
            {
                disk_factory.FreeDisk(disk_notshot[i]);
                disk_notshot.Remove(disk_notshot[i]);
                //玩家血量-1
                user_gui.ReduceBlood();
            }
        }
    }
Beispiel #14
0
	//暂停几秒后回收飞碟
    IEnumerator WaitingParticle(float wait_time, RaycastHit hit, DiskFactory disk_factory, GameObject d)
    {
        yield return new WaitForSeconds(wait_time);
        //等待之后执行的动作  
        hit.collider.gameObject.transform.position = new Vector3(0, -10, 0);
        DF.FreeDisk(d);//释放GameObject否则血量也会减少
    }
Beispiel #15
0
    IEnumerator WaitingParticle(float wait_time, RaycastHit hit, DiskFactory disk_factory, GameObject obj)
    {
        yield return(new WaitForSeconds(wait_time));

        hit.collider.gameObject.transform.position = new Vector3(0, -100, 0);
        disk_factory.FreeDisk(obj);
    }
Beispiel #16
0
 public void SSActionEvent(SSAction source, SSActionEventType events = SSActionEventType.Competeted,
                           int intParam = 0, string strParam = null, Object objectParam = null) //回调函数回收飞碟记录是否失分
 {
     //if (!source.gameobject.GetComponent<DiskData>().hit)
     //scoreRecorder.miss();
     diskFactory.FreeDisk(source.gameobject);
     source.gameobject.GetComponent <DiskData>().hit = false;
 }
Beispiel #17
0
    public void nextRound()
    {
        round++;

        factory.FreeDisk();
        currentTime = 0;
        currentN    = 0;
        gameStart();
    }
Beispiel #18
0
 public void SSActionEvent(SSAction source, SSActionEventType events = SSActionEventType.Competeted, int intParam = 0, string strParam = null, UnityEngine.Object objectParam = null)
 {
     if (source is CCFlyAction)
     {
         sceneController.setGameState(GameState.DROP);
         DiskFactory df = Singleton <DiskFactory> .Instance;
         df.FreeDisk(source.gameobject);
     }
 }
Beispiel #19
0
 //实现接口ISSActionCallback
 public void SSActionEvent(SSAction source, SSActionEventType events = SSActionEventType.Competeted, int intParam = 0, string strParam = null, Object objectParam = null)
 {
     if (source is PhysicMoveAction)
     {
         DiskNumber--;
         DiskFactory df = Singleton <DiskFactory> .Instance;
         df.FreeDisk(source.gameobject);
         FreeSSAction(source);
     }
 }
Beispiel #20
0
    //暂停几秒后回收飞碟
    IEnumerator WaitingParticle(float wait_time, DiskFactory diskFactory, DiskModel hitDisk)
    {
        yield return(new WaitForSeconds(wait_time));

        hitDisk.disk.SetActive(false);
        hitDisk.disk.GetComponent <ParticleSystem>().Stop();
        currentDisks.Remove(hitDisk);
        actionManager.freeAction(hitDisk);
        diskFactory.FreeDisk(hitDisk);
        diskCount--;
    }
 void Update()
 {
     if (gameState == 1)
     {
         if (userBlood <= 0 || (currentRound == totalRound && currentTrial == trialNumPerRound))
         {
             GameOver();
             return;
         }
         else
         {
             if (currentTrial > trialNumPerRound)
             {
                 levelUp();
             }
             if (throwInterval > throwSpeed)
             {
                 //随机生成飞碟个数
                 int throwCount = generateCount(currentRound);
                 ThrowDisk(throwCount);
                 throwInterval = 0;
                 currentTrial += 1;
             }
             else
             {
                 throwInterval += Time.deltaTime;
             }
         }
     }
     for (int i = 0; i < diskMissed.Count; i++)
     {
         GameObject temp = diskMissed[i];
         //飞碟飞出摄像机视野且未被打中
         if (temp.transform.position.y < -8 && temp.gameObject.activeSelf == true)
         {
             diskFactory.FreeDisk(diskMissed[i]);
             diskMissed.Remove(diskMissed[i]);
             userBlood -= 1;
         }
     }
 }
    // Update is called once per frame
    // protected new void Update()
    // {

    // }

    public void SSActionEvent(SSAction source,
                              SSActionEventType events = SSActionEventType.Completed,
                              int intParam             = 0,
                              string strParam          = null,
                              Object objectParam       = null)
    {
        // Debug.Log("飞碟被击中或飞出视界,动作结束,飞碟被销毁");
        // if (source.transform != null) {
        //     Destroy(source.transform.gameObject);
        // }
        factory.FreeDisk(source.transform.gameObject);
    }
Beispiel #23
0
    // implment interface

    /**
     * 当一个飞碟飞起落下的全部动作完成之后
     * 1. 需要做的动作总数减少
     * 2. 飞碟工厂回收一个飞碟
     * 3. 动作管理者回收一个动作
     */
    public void SSActionEvent(SSAction source,
                              SSActionEventType events = SSActionEventType.Competeted,
                              int intParam             = 0,
                              string strParam          = null,
                              Object objectParam       = null)
    {
        if (source is CCFlyAction)
        {
            DiskFactory df = Singleton <DiskFactory> .Instance;
            df.FreeDisk(source.gameobject);          //可以用这种方式获取了被挂在了特定component的游戏对象
            FreeSSAction(source);
        }
    }
 private void RoundOver()
 {
     while (Disks.Count > 0)
     {
         Factory.FreeDisk(Disks.Dequeue());
     }
     this.Round++;
     this.time    = 0;
     this.Playing = false;
     if (Round > 10)
     {
         userGUI.status = 0;
     }
 }
Beispiel #25
0
 public void SSActionEvent
     (SSAction source,
     ActionType actionType = ActionType.COMPETE,
     int i      = 0,
     string str = null,
     Object obj = null)
 {
     if (source is CCAction)
     {
         diskCnt--;
         DiskFactory factory = Singleton <DiskFactory> .Instance;
         factory.FreeDisk(source.MyGameObject);
     }
 }
Beispiel #26
0
 public void SSActionEvent(SSAction source,
                           SSActionEvents e             = global::SSActionEvents.End,
                           int n_param                  = 0,
                           string s_param               = null,
                           UnityEngine.Object obj_param = null)
 {
     if (source is CCFlyAction)
     {
         NumOfDisk--;
         DiskFactory diskFactory = Singleton <DiskFactory> .Instance;
         diskFactory.FreeDisk(source.GameObj);
         FreeSSAction(source);
     }
     throw new NotImplementedException();
 }
Beispiel #27
0
 //检查当前所有被使用的飞碟是否已经飞出视野
 //将飞出视野的飞碟“销毁”
 //每销毁一个飞碟就将当前飞碟数量减一,游戏将自动补齐缺少的飞碟
 private void removeRemoteDisk()
 {
     for (int i = 0; i < diskCount; i++)
     {
         GameObject tmp = currentDisks[i].disk;
         if (outOfSight(tmp.transform.position))
         {
             tmp.SetActive(false);
             diskFactory.FreeDisk(currentDisks[i]);
             actionManager.freeAction(currentDisks[i]);
             currentDisks.Remove(currentDisks[i]);
             diskCount--;
             life--;
         }
     }
 }
Beispiel #28
0
    //暂停几秒后回收飞碟
    IEnumerator WaitingParticle(float wait_time, DiskFactory diskFactory, DiskModel hitDisk)
    {
        yield return(new WaitForSeconds(wait_time));

        if (hitDisk.disk.active == true)
        {
            hitDisk.disk.SetActive(false);
            hitDisk.disk.GetComponent <ParticleSystem>().Stop();
            hitDisk.disk.GetComponent <Rigidbody>().velocity   = Vector3.zero;
            hitDisk.disk.GetComponent <Rigidbody>().useGravity = false;
            currentDisks.Remove(hitDisk);
            actionManager.freeAction(hitDisk);
            diskFactory.FreeDisk(hitDisk);
            diskCount--;
        }
    }
    private void SendDisk()
    {
        float position_x = 16;

        if (disk_queue.Count != 0)
        {
            GameObject disk = disk_queue.Dequeue();
            disk_notshot.Add(disk);
            disk.SetActive(true);
            float ran_y = 6;
            float ran_x = Random.Range(-1f, 1f) < 0 ? -1 : 1;
            if (round == 2)
            {
                disk.GetComponent <DiskComponent>().score = 2;
                float diff = Random.Range(1, 5);
                ran_y -= diff;
            }
            else if (round == 3)
            {
                disk.GetComponent <DiskComponent>().score = 3;
                float diff = Random.Range(6, 9);
                ran_y -= 6;
            }
            disk.GetComponent <DiskComponent>().direction = new Vector3(ran_x, ran_y, 10);
            Vector3 position = new Vector3(-disk.GetComponent <DiskComponent>().direction.x *position_x, ran_y, 15);
            disk.transform.position = position;
            float power = Random.Range(10f, 15f);
            float angle = Random.Range(0, 0);
            bool  flag  = false;
            action_manager.UFOFly(disk, angle, power, flag);
        }

        for (int i = 0; i < disk_notshot.Count; i++)
        {
            GameObject temp = disk_notshot[i];
            if (temp.transform.position.y < -10 && temp.gameObject.activeSelf == true)
            {
                disk_factory.FreeDisk(disk_notshot[i]);
                disk_notshot.Remove(disk_notshot[i]);
                user_gui.ReduceBlood();
            }
        }
    }
Beispiel #30
0
    public void hit(Vector3 pos)
    {
        Ray ray = Camera.main.ScreenPointToRay(pos);

        //Return the ray's hit
        RaycastHit[] hits;
        hits = Physics.RaycastAll(ray);
        for (int i = 0; i < hits.Length; i++)
        {
            RaycastHit hit = hits[i];

            if (hit.collider.gameObject.GetComponent <DiskData>() != null)
            {
                scoreRecorder.AddRecord(round);
                DiskFactory df = Singleton <DiskFactory> .Instance;
                df.FreeDisk(hit.collider.gameObject);
                setGameState(GameState.ROUND_END);
            }
        }
    }