// Start is called before the first frame update
    void Start()
    {
        if (!PlayerData.win)
        {
            audio.PlayOneShot(boom);
        }
        string name = PlayerData.currentLevel;

        data = GameObject.Find("BombData").GetComponent <BombData>();
        data.SetData("Assets/Generators/" + name + ".json");
        level.GetComponent <Text>().text = "Level: " + data.meta.name;
        time.GetComponent <Text>().text  = ((int)(PlayerData.time / 60)).ToString("00") + ":" + (PlayerData.time % 60).ToString("00.00");
        score.GetComponent <Text>().text = "Level Score:" + PlayerData.currentScore;

        if (PlayerData.win)
        {
            cause.SetActive(false);
            causeTitle.SetActive(false);
            defused.SetActive(true);
            StartCoroutine(MakeWinRequest());
        }
        else
        {
            cause.SetActive(true);
            causeTitle.SetActive(true);
            defused.SetActive(false);
            cause.GetComponent <Text>().text = PlayerData.death;
            StartCoroutine(MakeKaboomRequest());
        }

        PlayerData.UpdateLevelStats(name);
        pause = Time.time;
        StartCoroutine(MakeKaboomRequest());
    }
Ejemplo n.º 2
0
    void SendThrowBomb()
    {
        BombData bombData = new BombData();

        if (AnimatorMgr.GetIsPlaying(animator, AnimatorType.IdleThrow))
        {
            bombData.startPos = thisGo.transform.position + thisGo.transform.forward + new Vector3(0, 1f, 0);

            if (Vector3.Distance(thisGo.transform.position, new Vector3(hitPosition.x, thisGo.transform.position.y, hitPosition.z)) > 12)
            {
                hitPosition = thisGo.transform.position + (new Vector3(hitPosition.x, thisGo.transform.position.y, hitPosition.z) - thisGo.transform.position).normalized * 12;
            }
        }
        else if (AnimatorMgr.GetIsPlaying(animator, AnimatorType.RunThrow))
        {
            bombData.startPos = thisGo.transform.position + thisGo.transform.forward + new Vector3(0, 2f, 0);

            if (Vector3.Distance(thisGo.transform.position, new Vector3(hitPosition.x, thisGo.transform.position.y, hitPosition.z)) > 20)
            {
                hitPosition = thisGo.transform.position + (new Vector3(hitPosition.x, thisGo.transform.position.y, hitPosition.z) - thisGo.transform.position).normalized * 20;
            }
        }


        bombData.endPos       = hitPosition;
        bombData.durationTime = 2;
        bombData.damageRange  = 8;
        BombRequest.Instance.SendAddBombRequest(bombData);
    }
Ejemplo n.º 3
0
    private void Awake()
    {
        bombData = new BombData();

        bombData.countDown = initialbombData.countDown;
        bombData.range     = initialbombData.range;

        bombData.bombCount = initialbombData.bombCount;
        countDown          = new WaitForSeconds(bombData.countDown);

        StartCoroutine(Explosion());
    }
Ejemplo n.º 4
0
    public void Show(BombData data)
    {
        bombData = data;

        if (renderer == null)
        {
            renderer = GetComponent <Renderer>();
        }
        tweener = renderer.material.DOColor(Color.red, 3);

        Init();
    }
Ejemplo n.º 5
0
        public BombData getNextBomb(PlayerID _id)
        {
            BombData outData = new BombData();

            if (_id == PlayerID.one)
            {
                outData = getP1BombSprite();
            }
            else
            {
                outData = getP2BombSprite();
            }

            return(outData);
        }
Ejemplo n.º 6
0
        void OnAddBombReceived(EventData eventData)
        {
            byte[] bytes = (byte[])DictTool.GetValue <byte, object>(eventData.Parameters, 1);

            ProtoData.AddBombS2CEvt addBombS2CEvt = BinSerializer.DeSerialize <ProtoData.AddBombS2CEvt>(bytes);
            BombData bombData = new BombData();

            bombData.username = addBombS2CEvt.username;
            bombData.type     = (BombType)addBombS2CEvt.bombType;
            bombData.id       = addBombS2CEvt.bombId;
            bombData.startPos = new Vector3(addBombS2CEvt.startX, addBombS2CEvt.startY, addBombS2CEvt.startZ);
            bombData.endPos   = new Vector3(addBombS2CEvt.endX, addBombS2CEvt.endY, addBombS2CEvt.endZ);

            BattleMgr.Instance.bombMgr.AddBomb(bombData);
        }
    public void Start()
    {
        data           = GameObject.Find("BombData").GetComponent <BombData>();
        mainScreen     = transform.Find("Main").gameObject;
        levelScreen    = transform.Find("Levels").gameObject;
        additionalInfo = levelScreen.transform.Find("Additional Info").Find("Panel Title").GetComponent <Text>();
        scoreText      = levelScreen.transform.Find("Additional Info").Find("Score Display").GetComponent <Text>();
        titleText      = levelScreen.transform.Find("Additional Info").Find("Level Title").GetComponent <Text>();
        descText       = levelScreen.transform.Find("Additional Info").Find("Level Description").GetComponent <Text>();
        timeText       = levelScreen.transform.Find("Additional Info").Find("Best Time").GetComponent <Text>();
        levelScoreText = levelScreen.transform.Find("Additional Info").Find("Level Score").GetComponent <Text>();
        completeText   = levelScreen.transform.Find("Additional Info").Find("Complete").GetComponent <Text>();

        currentSubScreen = levelScreen;
        //levelScreen.SetActive(false);
        scoreText.text = "Total Score: " + PlayerData.totalScore;
        UpdateText();
    }
Ejemplo n.º 8
0
        private BombData getP2BombSprite()
        {
            BombData outData = new BombData();

            for (int i = 0; i < 5; i++)
            {
                if (p2BombTable[i] != null)
                {
                    outData.sprite = p2BombTable[i];
                    outData.ID     = i;
                    p2BombTable[i] = null;
                    p2Ptr++;
                    break;
                }
            }

            return(outData);
        }
Ejemplo n.º 9
0
        //获取客户端位置请求的处理的代码
        public void OnAddBombReceived(Client peer, OperationRequest operationRequest, SendParameters sendParameters)
        {
            //接收位置并保持起来
            byte[] bytes = (byte[])DictTool.GetValue <byte, object>(operationRequest.Parameters, 1);
            ProtoData.AddBombC2S addBombC2S = BinSerializer.DeSerialize <ProtoData.AddBombC2S>(bytes);

            ProtoData.AddBombS2CEvt addBombS2CEvt = new ProtoData.AddBombS2CEvt();
            addBombS2CEvt.username = peer.playerData.username;
            addBombS2CEvt.bombType = addBombC2S.bombType;
            addBombS2CEvt.bombId   = BombMgr.Instance.GetBombId();
            addBombS2CEvt.startX   = addBombC2S.startX;
            addBombS2CEvt.startY   = addBombC2S.startY;
            addBombS2CEvt.startZ   = addBombC2S.startZ;
            addBombS2CEvt.endX     = addBombC2S.endX;
            addBombS2CEvt.endY     = addBombC2S.endY;
            addBombS2CEvt.endZ     = addBombC2S.endZ;

            byte[] bytes2 = BinSerializer.Serialize(addBombS2CEvt);
            foreach (Client tempPeer in ClientMgr.Instance.BattlePeerList)
            {
                if (!string.IsNullOrEmpty(tempPeer.playerData.username))
                {
                    EventData ed = new EventData((byte)MessageCode.AddBomb);
                    Dictionary <byte, object> data = new Dictionary <byte, object>();
                    data.Add(1, bytes2);                    // 把新进来的用户名传递给其它客户端
                    ed.Parameters = data;
                    tempPeer.SendEvent(ed, sendParameters); // 发送事件
                }
            }

            BombData bombData = new BombData();

            bombData.username     = peer.playerData.username;
            bombData.nickName     = peer.playerData.nickname;
            bombData.bombId       = addBombS2CEvt.bombId;
            bombData.damageRange  = addBombC2S.damageRange;
            bombData.durationTime = addBombC2S.durationTime;
            bombData.endX         = addBombS2CEvt.endX;
            bombData.endY         = addBombS2CEvt.endY;
            bombData.endZ         = addBombS2CEvt.endZ;

            ServerMgr.Instance.bombUpdate.AddBomb(bombData);
        }
Ejemplo n.º 10
0
        //发起炸弹信息请求
        public void SendAddBombRequest(BombData bombData)
        {
            ProtoData.AddBombC2S addBombC2S = new ProtoData.AddBombC2S();
            addBombC2S.bombType     = (int)bombData.type;
            addBombC2S.durationTime = bombData.durationTime;
            addBombC2S.damageRange  = bombData.damageRange;
            addBombC2S.startX       = bombData.startPos.x;
            addBombC2S.startY       = bombData.startPos.y;
            addBombC2S.startZ       = bombData.startPos.z;
            addBombC2S.endX         = bombData.endPos.x;
            addBombC2S.endY         = bombData.endPos.y;
            addBombC2S.endZ         = bombData.endPos.z;
            byte[] bytes = BinSerializer.Serialize(addBombC2S);

            Dictionary <byte, object> data = new Dictionary <byte, object>();

            data.Add(1, bytes);

            PhotonEngine.Peer.OpCustom((byte)MessageCode.AddBomb, data, true);//把添加炸弹信息传递给服务器
        }
Ejemplo n.º 11
0
 public void AddBomb(BombData data)
 {
     if (unactiveBombStack.Count > 0)
     {
         Bomb bomb = unactiveBombStack.Pop();
         bomb.transform.position = data.startPos;
         bomb.Show(data);
         activeBombDict.Add(data.id, bomb);
         bomb.gameObject.SetActive(true);
     }
     else
     {
         Bomb bomb = GameObject.Instantiate(Resources.Load("Prefabs/Bomb") as GameObject).GetComponent <Bomb>();
         bomb.transform.SetParent(GetBombParent(), true);
         bomb.transform.position = data.startPos;
         bomb.Show(data);
         activeBombDict.Add(data.id, bomb);
         bomb.gameObject.SetActive(true);
     }
 }
Ejemplo n.º 12
0
    // 1フレーム目で処理を行う
    void Start()
    {
        // BombDataを生成
        _bombData = new BombData(_countdownTimer.GetLimitTime());

        // 毎フレーム読み込んで
        this.UpdateAsObservable()
        // _countdownTimerから経過時間を取得
        .Select(_ => _countdownTimer.GetElapsedTime())
        // 値が前回と変わっているなら
        .DistinctUntilChanged()
        // 経過時間を爆弾の時間に反映する
        .Subscribe(_ => _bombData.BombTime.Value = _countdownTimer.GetElapsedTime()
                   ).AddTo(this);

        //
        _bombData

        .BombTime
        // countdownTimerから開始してるか取得し、開始してるなら
        .Where(_ => _countdownTimer.GetIsStart())
        .Subscribe(_ =>
        {
            // bombViewの導火線にボムの時間を設定する
            _bombView.ChangeFuse(_bombData.BombTime.Value);

            // countdownTimerのタイムリミット未満の場合、導火線の音を鳴らす
            if (_bombData.BombTime.Value < _countdownTimer.GetLimitTime())
            {
                _bombSound.PlaySE((int)(BombSound.ClipName.fuseClip));
            }
            // タイムリミットを過ぎたら爆発音を鳴らす
            else
            {
                _bombSound.PlaySE((int)(BombSound.ClipName.exposionCLip));
            }
        }).AddTo(this);
    }
Ejemplo n.º 13
0
        public void CreateBomb()
        {
            if (bombCurrCD == 0)
            {
                bombCurrCD = bombCD;

                var bomb = new BombData();
                bomb.damage = URandom.Range(3f, 4f) * mass;
                bomb.lifeTime = 5;
                bomb.overrideOffsetK = true;
                bomb.yOffsetK = 0;

                ItemFactory.I.Create(bomb, currentHex, Owner);
            }
        }
Ejemplo n.º 14
0
    public void GenerateBomb()
    {
        strikes = 0;

        int      fullWeight = 0;
        BombData bombData   = null;

        //This try catch block is only necessary while in production
        //So the game can still run from the level generation scene
        try {
            bombData = GameObject.Find("BombData").GetComponent <BombData>();
        } catch {
            UnityEngine.Object o = Resources.Load("BombData");
            print(o);
            GameObject oo = GameObject.Instantiate(o) as GameObject;
            bombData = oo.GetComponent <BombData>();
            //I shouldnt need this but screw me I guess
            bombData.SetData("Assets/Generators/default.json");
            bombData.Start();
        }
        BombInfo generator = bombData.meta;

        //print(JsonUtility.ToJson(generator));
        width      = generator.width;
        height     = generator.height;
        numModules = generator.numModules;

        //Merge modules and pools in generate
        generator.MergePools();
        print(JsonUtility.ToJson(generator));

        //Count number of modules generated pre-randomizer
        int generatedModules = 0;

        //Generate a list of modules to make
        List <GameObject> genModules = new List <GameObject>();

        //Always include timer module!
        genModules.Add(timerModule);


        //Add weights to get a maximum weight value for random generation
        for (int i = 0; i < generator.pools.Count; i++)
        {
            fullWeight += generator.pools[i].weight;
        }

        //Ensure minimum module generation is done
        foreach (PoolInfo pInfo in generator.pools)
        {
            List <string> poolSpecificModules = pInfo.GetMinModules();
            foreach (string moduleName in poolSpecificModules)
            {
                genModules.Add(bombData.allModules[moduleName]);
                generatedModules++;
            }
            for (int i = 0; i < pInfo.min; i++)
            {
                genModules.Add(bombData.allModules[pInfo.Generate()]);
                generatedModules++;
            }
        }

        //Number of modules = width * height, front and back, minus 1 for timer module
        for (int i = generatedModules; i < width * height * 2 - 1; ++i)
        {
            if (i < numModules && generator.pools.Count > 0)
            {
                int rand = StaticRandom.NextInt(fullWeight);
                //Insert some fancy heuristic some other day
                int weightCounter = fullWeight;

                //We can guarantee a certain module order from the fullWeight generation
                for (int j = generator.pools.Count - 1; j >= 0; j--)
                {
                    if (rand >= weightCounter - generator.pools[j].weight)
                    {
                        string s = generator.pools[j].Generate();
                        //print(s);
                        genModules.Add(bombData.allModules[s]);
                        //Dirty maximum check
                        //Note how this ignores maximum if <= 0 on startup
                        //This IS intended
                        if (!generator.pools[j].Validate() || generator.pools[j].max == 0)
                        {
                            print("REMOVED A POOL");
                            generator.pools.RemoveAt(j);
                            //Regenrate the fullWeight value
                            fullWeight = 0;
                            for (int k = 0; k < generator.pools.Count; k++)
                            {
                                fullWeight += generator.pools[k].weight;
                            }
                        }
                        break;
                    }
                    else
                    {
                        weightCounter -= generator.pools[j].weight;
                    }
                }
            }
            else
            {
                //When number of modules is exhausted, add blanks until the list is full
                genModules.Add(blankModule);
            }
        }

        //Shuffle the list
        //WARNING: This needs to be changed if interdependent modules exist
        //Used for shuffling modules
        Debug.Log("Shuffling");
        GameObject tmp;

        for (int i = 0; i < width * height * 2; ++i)
        {
            int j = StaticRandom.NextInt(i, width * height * 2);
            tmp           = genModules[i];
            genModules[i] = genModules[j];
            genModules[j] = tmp;
        }


        //Now we actually fill the bomb with modules
        modules = new Module[width, height * 2];
        for (int x = 0; x < width; ++x)
        {
            for (int z = 0; z < height; ++z)
            {
                GameObject model = Instantiate(moduleHolder, new Vector3(edgeConstant + x * moduleHolderWidth - ((moduleHolderWidth / 2) * width - 1), 0.5f, edgeConstant + z * moduleHolderWidth - ((moduleHolderWidth / 2) * height - 1)), Quaternion.Euler(-90, 0, 0));
                GameObject go    = Instantiate(genModules[x + z * width], new Vector3(edgeConstant + x * moduleHolderWidth - ((moduleHolderWidth / 2) * width - 1), 0.5f, edgeConstant + z * moduleHolderWidth - ((moduleHolderWidth / 2) * height - 1)), Quaternion.identity);
                if (go.GetComponent <Module>() != null)
                {
                    go.GetComponent <Module>().bombSource = this;
                }
                if (go.GetComponent <BombTimerScript>())
                {
                    loadedTimerModule = go;
                }
                modules[x, z] = go.GetComponent <Module>();

                model.transform.parent = this.transform;
                go.transform.parent    = this.transform;
            }
        }

        for (int x = 0; x < width; ++x)
        {
            for (int z = height; z < height * 2; ++z)
            {
                GameObject model = Instantiate(moduleHolder, new Vector3(edgeConstant + x * moduleHolderWidth - ((moduleHolderWidth / 2) * width - 1), -0.5f, edgeConstant + (z % height) * moduleHolderWidth - ((moduleHolderWidth / 2) * height - 1)), Quaternion.Euler(90, 0, 180));
                GameObject go    = Instantiate(genModules[(width * height) + x + (z % height) * width], new Vector3(edgeConstant + x * moduleHolderWidth - ((moduleHolderWidth / 2) * width - 1), -0.5f, edgeConstant + (z % height) * moduleHolderWidth - ((moduleHolderWidth / 2) * height - 1)), Quaternion.Euler(0, 0, 180));
                if (go.GetComponent <Module>() != null)
                {
                    go.GetComponent <Module>().bombSource = this;
                }
                if (go.GetComponent <BombTimerScript>())
                {
                    loadedTimerModule = go;
                }
                modules[x, z] = go.GetComponent <Module>();

                model.transform.parent = this.transform;
                go.transform.parent    = this.transform;
            }
        }

        loadedTimerModule.GetComponent <BombTimerScript>().secondsLeft = generator.time;

        //bombData.Consume();
    }
Ejemplo n.º 15
0
 public BombItem(ItemBox box, BombData data)
     : base(box)
 {
     Damage = data.damage;
 }
Ejemplo n.º 16
0
 public Bomb(BombData data, BombView view)
 {
     Data = data;
     View = view;
 }
Ejemplo n.º 17
0
 public SpawnBombSignal(BombView view, BombData data, Vector3 position)
 {
     View     = view;
     Data     = data;
     Position = position;
 }