예제 #1
0
    //
    public bool CanDestoryFrontCar(string p_target_id)
    {
        if (!carJSON.GetField("target_vehecle").HasField(p_target_id))
        {
            return(false);
        }
        float possibility = carJSON.GetField("target_vehecle").GetField(p_target_id).n;

        return(UtilityColl.FlipCoin(possibility));
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (_countDown >= _rebornTime && activate)
        {
            int        randomCharacterIndex = Random.Range(0, characterJSON.Count - 1);
            string     oldWomanID           = characterJSON[randomCharacterIndex].GetField("id").str;
            JSONObject characterComp        = GameManager.instance.GetJSONComponent(oldWomanID);

            Sprite oldWomanSprite = UtilityColl.LoadSpriteFromMulti(oldWomanImages, oldWomanID);
            _rebornTime = characterJSON[randomCharacterIndex].GetField("frequency").num;
            OldLaddy oldLaddy = GameObject.Instantiate(_oldLaddy, transform.position, transform.rotation, transform).GetComponent <OldLaddy>();
            oldLaddy.init(new Vector3(TargetLine.transform.position.x + Random.Range(-1 * LineLong, LineLong), TargetLine.transform.position.y, 0),
                          characterComp, oldWomanID, oldWomanSprite
                          );

            _countDown = 0;
        }
        _countDown += Time.deltaTime;
    }
예제 #3
0
    private void SetCarSpawnGenerator(float p_streetBottomPosition, int p_carSlot)
    {
        float centerAxisX = streetObject.transform.position.x,
              halfWidth   = (streetObject.size.x / 2),
              xLeftPos    = centerAxisX - halfWidth,
              xRightPos   = centerAxisX + halfWidth;

        for (int i = 0; i < p_carSlot; i++)
        {
            bool isFaceLeft = UtilityColl.FlipCoin(0.5f);

            float   carSpawnYPos = p_streetBottomPosition + (slotheight * i) + (slotheight / 2f);
            Vector2 carSpawnPos  = new Vector2((isFaceLeft) ?  xLeftPos : xRightPos,
                                               carSpawnYPos);
            Vector2 carDirection = (isFaceLeft) ?  Vector2.right :Vector2.left;

            CarSpawn gCarSpawn = CreateCarSpawn(carSpawnPos, carDirection);
            // Vector2 carSpawnPosition,
            // spawnDir = ;
            carSpawnPointList.Add(gCarSpawn);
        }
    }