Beispiel #1
0
 private static void UpdateAnswerWhenLetterCaught(FallingObject letter)
 {
     addLetter = container.ToCharArray();
     addLetter[indexOfCatchedLetter] = letter.Str[0];
     indexOfCatchedLetter++;
     container = string.Join("", addLetter);
 }
Beispiel #2
0
    void ChewObjects()
    {
        float mass_to_eat = m_EatMassPerSecond * Time.deltaTime;

        while (true)
        {
            if (m_ChewingObjects.Count == 0)
            {
                return;
            }

            FallingObject fo       = m_ChewingObjects[0];
            float         progress = fo.GetChewingProcess();
            if (progress >= 1.0f)
            {
                fo.SetChewed();
                EatMass(0.0f, fo);
                continue;
            }
            float mass      = fo.GetMass();
            float mass_left = (1.0f - progress) * mass;
            if (mass_to_eat < mass_left)
            {
                EatMass(mass_to_eat);
                progress = (progress * mass + mass_to_eat) / mass;
                fo.SetChewingProcess(progress);
                break;
            }
            fo.SetChewingProcess(1.0f);
            fo.SetChewed();
            EatMass(mass_left, fo);
            mass_to_eat -= mass_left;
        }
    }
Beispiel #3
0
    private IEnumerator LoadObjectPrefabFromBundle(string url, string prefabName)
    {
        int version = 0;

        while (!Caching.ready)
        {
            yield return(null);
        }

        using (WWW www = WWW.LoadFromCacheOrDownload(url, version))
        {
            yield return(www);

            if (!string.IsNullOrEmpty(www.error))
            {
                Debug.LogError(www.error);
                yield break;
            }

            AssetBundle assetBundle = www.assetBundle;

            if (!assetBundle)
            {
                Debug.LogError("Failed to load assetbundle: " + url);
                yield break;
            }

            GameObject    go           = assetBundle.LoadAsset <GameObject>(prefabName);
            FallingObject circlePrefab = go.GetComponent <FallingObject>();
            assetBundle.Unload(false);
            circlesManager.Initialize(circlePrefab);
            circlesManager.NextLevel(game.Level);
        }
    }
Beispiel #4
0
    void TryToChewObject(GameObject go)
    {
        if (!IsOk())
        {
            return;
        }
        FallingObject falling_obj = (FallingObject)go.GetComponent(typeof(FallingObject));

        // Set up chewing
        float max_mass            = 150.0f;
        float percent_full        = Mathf.Clamp01(m_MassChewingObjs / max_mass);
        float max_chewing_start_p = 4.0f;
        float chewing_start_p     = percent_full * max_chewing_start_p + 1.0f;

        falling_obj.SetChewingPos(chewing_start_p);
        float min_angle_range = 0.0f;
        float max_angle_range = ((float)Math.PI) * 2.0f / 3.0f;
        float angle_range     = Mathf.Lerp(min_angle_range, max_angle_range, 1.0f - percent_full);
        float chewing_angle   = UnityEngine.Random.Range(Mathf.PI / 2.0f - angle_range, Mathf.PI / 2.0f + angle_range);

        falling_obj.SetChewingAngle(chewing_angle);

        // Try to chew
        bool res_ok = falling_obj.TryToChew(this.gameObject);

        if (!res_ok)
        {
            return;
        }

        StartChewObjects(falling_obj);
    }
Beispiel #5
0
 public static void PopulateObjectProperties()
 {
     Debug.Log("Populating default values to falling objects...");
     // In future change this to objects added to a global list instead of objectpooler
     if (ObjectPooler.Instance.pooledObjects.Count > 0)
     {
         for (int i = 0; i < ObjectPooler.Instance.pooledObjects.Count; i++)
         {
             FallingObject obj = ObjectPooler.Instance.pooledObjects[i].GetComponent <FallingObject>();
             if (obj != null)
             {
                 if (TrinaxGlobal.Instance.scene == SCENE.MAIN)
                 {
                     GetFallingObjectProperties(obj);
                 }
                 else
                 {
                     GetTrainingFallingObjectProperties(obj);
                 }
             }
         }
     }
     else
     {
         return;
     }
 }
 void EndCapture()
 {
     targetting = null;
     if (sight_ != null) {
         //Destroy (sight_);
         sight_ = null;
     }
 }
    public bool Spawn(float spawn_move, bool is_right)
    {
        float privilege = Mathf.Abs(m_LeftOrRightPrivilege);

        privilege *= is_right == (m_LeftOrRightPrivilege > 0.0) ? 1.0f : -1.0f;
        const float max_privilege = 10.0f;

        privilege *= max_privilege;

//		Debug.Log(m_LeftOrRightPrivilege + " " + privilege + " " + m_DeltaSpawnMove);

        // Should we  do this?
        float min_delta_spawn_move = 4.0f;
        float max_delta_spawn_move = 15.0f;

        float res_delta_spawn_move = m_DeltaSpawnMove - privilege;

        res_delta_spawn_move = Mathf.Clamp(res_delta_spawn_move,
                                           min_delta_spawn_move, max_delta_spawn_move);


        if (spawn_move > res_delta_spawn_move * m_SpeedDeltaSpawnMoveCoef)
        {
            Vector3 pos = new Vector3(3.0f * (is_right ? 1.0f : -1.0f), 30.0f, 0.0f);

            GameObject    go          = MonoBehaviour.Instantiate(m_GameContr.m_FallingObject, pos, Quaternion.identity) as GameObject;
            FallingObject falling_obj = (FallingObject)go.GetComponent(typeof(FallingObject));
            m_GameContr.GetConveyor(is_right).AddObject(falling_obj);

            falling_obj.SetRotationSpeed((Random.value - 0.5f) * 10.0f);
            falling_obj.transform.rotation = Quaternion.Euler(0.0f, 0.0f, Random.value * 360.0f);

            // select object

            SpawnObjectType obj_type = GetObjectType(is_right);
            falling_obj.SetType(obj_type);
            SpawnObjectsInfo obj_info = m_SpawnObjects[obj_type];

            go.rigidbody2D.mass = obj_info.m_Mass;

            SpriteRenderer sprite_rend = falling_obj.GetComponentInChildren(typeof(SpriteRenderer)) as SpriteRenderer;
            Sprite         sprite      = Resources.Load <Sprite>(obj_info.m_SpriteName);
            if (!sprite)
            {
                Debug.LogWarning("Can't load Cake");
            }
            sprite_rend.sprite = sprite;

            float scale = 1.0f;
            go.transform.localScale = new Vector3(scale, scale, 1.0f);

            return(true);
        }
        else
        {
            return(false);
        }
    }
 void StartCapture(FallingObject target)
 {
     if (target == null) {
         EndCapture ();
         return;
     }
     targetting = target;
     targettingTime_ = 0;
 }
Beispiel #9
0
 private void OnCollisionEnter(Collision collision)
 {
     if (pointsEarned) //metal
     {
         if (collision.gameObject.tag == "Surface")
         {
             ImpactFloor();
         }
         else
         {
             Obstacle o = collision.gameObject.GetComponent <Obstacle>();
             if (o != null)
             {
                 if (o.DisableObstacle())
                 {
                     ObstacleSpawner.DisableForSeconds(o, 5f);
                 }
             }
             else
             {
                 FallingObject c = collision.gameObject.GetComponent <FallingObject>();
                 if (c != null)
                 {
                     c.SuccessfullyClick();
                 }
             }
         }
     }
     else //wooden thing
     {
         if (collision.gameObject.tag == "Surface" || collision.gameObject.tag == "Obstacle")
         {
             ImpactFloor();
         }
         else
         {
             Block b = collision.gameObject.GetComponent <Block>();
             if (b != null)
             {
                 if (b.isGrounded)
                 {
                     ImpactFloor();
                 }
                 else
                 {
                     if (audioMod != null)
                     {
                         audioMod.PlayAudioClip(2);
                     }
                 }
             }
         }
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        playerHolding = false;
        petHolding    = false;
        petCanCatch   = false;
        hspeed        = 0;
        gamingTimer   = 0;

        coll   = GetComponentInChildren <Collider>();
        faller = GetComponent <FallingObject>();
    }
Beispiel #11
0
 public void SetFallingObject(FallingObject o)
 {
     if (_fallingObject == null)
     {
         _fallingObject = o;
     }
     else
     {
         Destroy(o.gameObject);
     }
 }
Beispiel #12
0
 public static void GetFallingObjectProperties(FallingObject obj)
 {
     for (int i = 0; i < TrinaxGlobal.Instance.gameSettings.GameObjs.GameObj.Count; i++)
     {
         if (obj.type.ToString() == TrinaxGlobal.Instance.gameSettings.GameObjs.GameObj[i].name)
         {
             obj.timeScale = TrinaxGlobal.Instance.gameSettings.GameObjs.GameObj[i].objectProperties.dropSpeed;
             obj.damage    = TrinaxGlobal.Instance.gameSettings.GameObjs.GameObj[i].objectProperties.damage;
         }
     }
 }
 private IEnumerator StepByStepGenerator(float waitTime)
 {
     while (true)
     {
         GameObject fallingObject = Instantiate(fallingObjectTemplate, new Vector2(Random.Range(-width / 2f, width / 2f), height), Quaternion.identity);
         float      ratio         = 1f;
         fallingObject.transform.localScale = new Vector3(ratio, ratio, ratio);
         FallingObject fallingObjectCtrl = fallingObject.AddComponent <FallingObject>();
         fallingObjectCtrl.destroyY = destroyY;
         yield return(new WaitForSeconds(waitTime));
     }
 }
Beispiel #14
0
 private void IncreasePool()
 {
     for (int i = 0; i < poolSize; i++)
     {
         int           fallingObjectNumber = Random.Range(0, fallingObject.Length);
         GameObject    newObject           = Instantiate(fallingObject[fallingObjectNumber], poolParent.transform);
         FallingObject newfallingObject    = newObject.GetComponent <FallingObject>();
         newfallingObject.SetPool(this);
         newObject.SetActive(false);
         pool.Enqueue(newObject);
     }
 }
    public void Initialize(FallingObject prefab)
    {
        if (!prefab)
        {
            Debug.LogError("CirclesManager.Initialize(): prefab is null");
            return;
        }

        this.prefab        = prefab;
        this.isInitialized = true;
        pool = new Pool <FallingObject>(this.prefab);
    }
 private void CheckAndRecycle(FallingObject fallingObject)
 {
     if (fallingObject.LevelCreated == cachedLevel)
     {
         Debug.Log("An object put to Pool");
         pool.Put(fallingObject);
     }
     else
     {
         Debug.LogWarning("An object destroyed");
         Object.Destroy(fallingObject.gameObject);
     }
 }
    private IEnumerator CreateObjectAtRandomTime()
    {
        float period = difficultyCalc.GetObjectSpawningPeriod(cachedLevel);

        while (true)
        {
            yield return(new WaitForSeconds(period));

            FallingObject nextCircle = pool.Get();
            nextCircle.transform.SetParent(gameLevel);
            InitializeCircleComponents(nextCircle);
        }
    }
Beispiel #18
0
    public void LoadTileAnimations()
    {
        //This function loads all tile animations into the tileEffects map and then hides the visual effects
        //loading all the effects
        HeavyRainEffect rainEffect = GameObject.Find("HeavyRainEffect").GetComponent <HeavyRainEffect>();

        tileEffects.Add("rain", rainEffect);
        FallingObject fallingObject = GameObject.Find("FallingObject").GetComponent <FallingObject>();

        tileEffects.Add("fall", fallingObject);
        RisingObject risingObject = GameObject.Find("JerryCan").GetComponent <RisingObject>();

        tileEffects.Add("jerry", risingObject);
        LeftMovingObject slideObject = GameObject.Find("LeftMovingObject").GetComponent <LeftMovingObject>();

        tileEffects.Add("slide", slideObject);
        SmokeEffect smokeEffect = GameObject.Find("SmokeEffect").GetComponent <SmokeEffect>();

        tileEffects.Add("smoke", smokeEffect);
        LeftMovingObject fishObject = GameObject.Find("FishEffect").GetComponent <LeftMovingObject>();

        tileEffects.Add("fish", fishObject);
        LeftMovingObject screenObject = GameObject.Find("SlidingScreenEffect").GetComponent <LeftMovingObject>();

        tileEffects.Add("screen", screenObject);
        FallingObject soapObject = GameObject.Find("FallingSoapEffect").GetComponent <FallingObject>();

        tileEffects.Add("soap", soapObject);
        WinEffect winEffect = GameObject.Find("WinEffect").GetComponent <WinEffect>();

        tileEffects.Add("win", winEffect);
        LeftMovingObject tongueObject = GameObject.Find("TongueEffect").GetComponent <LeftMovingObject>();

        tileEffects.Add("tongue", tongueObject);


        //resizing and hiding the effects
        foreach (string effect in tileEffects.Keys)
        {
            //set parameters of effects
            float[] animParams = GameData.GetAnimationParams();
            tileEffects[effect].setParameters(animParams[0], animParams[1], animParams[2], animParams[3]);

            //resize effects
            tileEffects[effect].resizeEffect();

            //hide effects
            tileEffects[effect].hideEffect();
        }
    }
Beispiel #19
0
    void IncreaseDifficulty()
    {
        for (int i = 0; i < ObjectPooler.Instance.pooledObjects.Count; i++)
        {
            if (ObjectPooler.Instance.pooledObjects[i].GetComponent <FallingObject>() != null)
            {
                FallingObject obj = ObjectPooler.Instance.pooledObjects[i].GetComponent <FallingObject>();

                //float temp = obj.timeScale;
                //float scaled = temp / difficultyMultiplier;
                obj.timeScale *= difficultyMultiplier;
            }
        }
    }
Beispiel #20
0
    //IEnumerator Udate() {
    void OnCollisionEnter(Collision other)
    {
        if (other.transform.tag == "Ball")
        {
            Ball_Action bAction = other.gameObject.GetComponent <Ball_Action>();
            if (bAction.isAttacking && bAction.isAttackerPlayer == false)
            {
                Hp--;
                StartCoroutine(HitProcess(true));

                print("플레이어 얻어맞음");
                animator.SetTrigger("Damage");
                // yield return new WaitForSeconds(1);
                damaged = true;


                if (Hp <= 0)
                {
                    //healthSlider.value = 0;
                    print("플레이어죽음ㅋ");
                    //Destroy(this.gameObject);
                    Lose.SetActive(true);
                }
            }
        }
        else if (other.transform.tag == "Hurdle")
        {
            rbody.AddExplosionForce(500f, other.contacts[0].point, 10f);

            Hp--;
            print("플레이어 얻어맞음");

            if (Hp <= 0)
            {
                print("플레이어죽음ㅋ");

                Lose.SetActive(true);
            }
        }
        else if (other.transform.tag == "Drop")
        {
            FallingObject fo = other.gameObject.GetComponent <FallingObject>();
            if (fo.falling)
            {
                animator.SetBool("Dozed", true);
                StartCoroutine(HitProcess(false));
            }
        }
    }
    private void InitializeCircleComponents(FallingObject fallingObject)
    {
        float localScale = difficultyCalc.GetRandomScale();

        fallingObject.Initialize(difficultyCalc, localScale, cachedLevel);
        fallingObject.enabled = true;

        float spawnPointX = Random.Range(spawningStart.position.x, spawningEnd.position.x);

        fallingObject.transform.position = new Vector3(spawnPointX, spawningStart.position.y, 0f);

        var coloredCircle = fallingObject.GetComponent <RandomColoredCircle>();

        coloredCircle.Initialize(localScale);
    }
    void AddCaptured(FallingObject fo)
    {
        if (foundedObjects_.Contains (fo)) return;

        score += fo.score;

        print ("captred " + fo.name);
        sight_ = Instantiate (this.captureingSight, fo.transform.position, fo.transform.rotation) as GameObject;
        sight_.transform.parent = fo.transform;
        sight_.transform.localScale = new Vector3 (10, 10, 10);

        foundedObjects_.Add (fo);

        Instantiate (this.lockOn, fo.transform.position, fo.transform.rotation);
    }
Beispiel #23
0
 void EatMass(float mass, FallingObject fo = null)           // if fo != null => destroy the object
 {
     m_MonsterContr.EatMass(mass);
     if (fo)
     {
         m_ChewingObjects.Remove(fo);
         Destroy(fo);
     }
     m_MassChewingObjs -= mass;
     if (m_MassChewingObjs < 0.001f)
     {
         m_State = HeadState.Stationary;
     }
     else
     {
         m_State = HeadState.Chewing;
     }
 }
Beispiel #24
0
    private void OnTriggerEnter(Collider other)
    {
        if (pointsEarned) //metal
        {
            if (other.gameObject.tag == "Surface")
            {
                if (pointsEarned && landFX != null)
                {
                    Instantiate(landFX, other.ClosestPointOnBounds(transform.position), Quaternion.identity, null);
                    landFX = null;
                    dragFX.SetActive(true);
                }
                foreach (Collider c in GetComponentsInChildren <Collider>())
                {
                    c.isTrigger = false;
                }
                ImpactFloor();
            }
            else if (other.gameObject.tag == "Obstacle")
            {
                Obstacle o = other.gameObject.GetComponent <Obstacle>();
                if (o != null)
                {
                    if (o.DisableObstacle())
                    {
                        if (audioMod != null)
                        {
                            audioMod.PlayAudioClip(4);
                        }

                        ObstacleSpawner.DisableForSeconds(o, 5f);
                    }
                }
            }
            else
            {
                FallingObject c = other.GetComponent <FallingObject>();
                if (c != null)
                {
                    c.SuccessfullyClick();
                }
            }
        }
    }
Beispiel #25
0
    private static void CollisionDetection(FallingObject fallingObject, Player player)
    {
        if ((fallingObject.Y == consoleHeight - 4) &&
            (fallingObject.X == player.X || fallingObject.X == player.X + 1 || fallingObject.X == player.X + 2))
        {
            PrintOnPosition(player.X, player.Y, player.Str, player.Color);  // Redraw player after collision
            fallingObject.FallDown();   // Object removed from the playfield.

            if (fallingObject is Bomb)
            {
                if (livesCount > 1)
                {
                    livesCount--;
                    Console.SetCursorPosition(0, 1);
                    RedrawLivesBar();
                }
                else if (livesCount == 1)
                {
                    livesCount--;
                    Console.SetCursorPosition(0, 1);
                    RedrawLivesBar();
                    isGameOver = true;
                }
            }
            else if (fallingObject is Del)
            {
                if (indexOfCatchedLetter != 0)
                {
                    UpdateAnswerWhenDeleteCaught();
                }
                Console.SetCursorPosition(0, 8);
                RedrawAnswerBar(container);
            }
            else if (fallingObject is Letter)
            {
                if (indexOfCatchedLetter < correctAnswer.Length)
                {
                    UpdateAnswerWhenLetterCaught(fallingObject);
                }
                Console.SetCursorPosition(0, 8);
                RedrawAnswerBar(container);
            }
        }
    }
Beispiel #26
0
    private static void CollisionDetection(FallingObject fallingObject, Player player)
    {
        if ((fallingObject.Y == consoleHeight - 4) &&
            (fallingObject.X == player.X || fallingObject.X == player.X + 1 || fallingObject.X == player.X + 2))
        {
            PrintOnPosition(player.X, player.Y, player.Str, player.Color); // Redraw player after collision
            fallingObject.FallDown();                                      // Object removed from the playfield.

            if (fallingObject is Bomb)
            {
                if (livesCount > 1)
                {
                    livesCount--;
                    Console.SetCursorPosition(0, 1);
                    RedrawLivesBar();
                }
                else if (livesCount == 1)
                {
                    livesCount--;
                    Console.SetCursorPosition(0, 1);
                    RedrawLivesBar();
                    isGameOver = true;
                }
            }
            else if (fallingObject is Del)
            {
                if (indexOfCatchedLetter != 0)
                {
                    UpdateAnswerWhenDeleteCaught();
                }
                Console.SetCursorPosition(0, 8);
                RedrawAnswerBar(container);
            }
            else if (fallingObject is Letter)
            {
                if (indexOfCatchedLetter < correctAnswer.Length)
                {
                    UpdateAnswerWhenLetterCaught(fallingObject);
                }
                Console.SetCursorPosition(0, 8);
                RedrawAnswerBar(container);
            }
        }
    }
Beispiel #27
0
    public void PauseNormalPlay()
    {
        player.FreezePlayerMovement();
        SpawnManager.Instance.DeactivateBehaviour();
        if (cameraProperties.redVignetteOverlay.enabled)
        {
            cameraProperties.redVignetteOverlay.enabled = false;
        }

        for (int i = 0; i < ObjectPooler.Instance.pooledObjects.Count; i++)
        {
            if (ObjectPooler.Instance.pooledObjects[i].GetComponent <FallingObject>() != null)
            {
                FallingObject obj = ObjectPooler.Instance.pooledObjects[i].GetComponent <FallingObject>();

                obj.RigidbodySimulation(false);
            }
        }
    }
Beispiel #28
0
    void StartChewObjects(FallingObject falling_obj)
    {
        GameObject go = falling_obj.gameObject;

        m_ChewingObjects.Add(falling_obj);
        m_MassChewingObjs += falling_obj.GetMass();
        float speed_was = falling_obj.GetSpeed();

        ApplyImpulse(go.rigidbody2D.mass * speed_was);

        // Report to conveyor
        m_LevelController.GetConveyor(m_IsRightHead).UnlinkObject(falling_obj);

        // Back off
        StartCoroutine(Backoff(0.3f));

        // Play sound
        audio.PlayOneShot(m_ImpactAudio, 1.0f);
    }
Beispiel #29
0
 void CreateObject()
 {
     if (0.00f <= timeCount)
     {
         if (check)
         {
             listOrder     += 1;
             mFallingObject = new FallingObject(ref1, bar, defaultRedbullCan1, flyingRedbulCan1, velocity1, score1, displayedScoreGameObject, listOrder);
             mFallingObjectList.Add(mFallingObject);
             check = !check;
         }
         else
         {
             listOrder     += 1;
             mFallingObject = new FallingObject(ref1, bar, defaultRedbullCan2, flyingRedbulCan2, velocity2, score2, displayedScoreGameObject, listOrder);
             mFallingObjectList.Add(mFallingObject);
             check = !check;
         }
     }
 }
Beispiel #30
0
 public static void GetTrainingFallingObjectProperties(FallingObject obj)
 {
     for (int i = 0; i < TrinaxGlobal.Instance.gameSettings.GameObjs.GameObj.Count; i++)
     {
         if (obj.type.ToString() == TrinaxGlobal.Instance.gameSettings.GameObjs.GameObj[i].name)
         {
             for (int j = 0; j < SliderManager.Instance.trainingGameSliders.Count; j++)
             {
                 if (SliderManager.Instance.trainingGameSliders[j].slider_type == SLIDER_TYPE.DROP_SPEED)
                 {
                     obj.timeScale = SliderManager.Instance.trainingGameSliders[j].val;
                 }
                 else if (SliderManager.Instance.trainingGameSliders[j].slider_type == SLIDER_TYPE.DAMAGE)
                 {
                     obj.damage = SliderManager.Instance.trainingGameSliders[j].val;
                 }
             }
         }
     }
 }
Beispiel #31
0
    public void ResumeNormalPlay()
    {
        player.UnFreezePlayerMovement();
        SpawnManager.Instance.ActivateBehaviour();
        levelManager.StartGameTimer();

        if (hud.heartController.lastLife)
        {
            cameraProperties.redVignetteOverlay.enabled = true;
        }

        for (int i = 0; i < ObjectPooler.Instance.pooledObjects.Count; i++)
        {
            if (ObjectPooler.Instance.pooledObjects[i].GetComponent <FallingObject>() != null)
            {
                FallingObject obj = ObjectPooler.Instance.pooledObjects[i].GetComponent <FallingObject>();

                obj.RigidbodySimulation(true);
            }
        }
    }
Beispiel #32
0
 private static void UpdateAnswerWhenLetterCaught(FallingObject letter)
 {
     addLetter = container.ToCharArray();
     addLetter[indexOfCatchedLetter] = letter.Str[0];
     indexOfCatchedLetter++;
     container = string.Join("", addLetter);
 }
    static void Main()
    {
        Console.WindowHeight = 45;
        Console.WindowWidth = 90;
        Console.BufferHeight = Console.WindowHeight;
        Console.BufferWidth = Console.WindowWidth;
        Console.CursorVisible = false;
        int speed = 100;
        Random randomGenerator = new Random();
        List<FallingObject> fallingObjects = new List<FallingObject>();
        Car myCar = new Car();
        myCar.x = Console.WindowWidth / 2;
        myCar.y = Console.WindowHeight - 2;
        myCar.c = 'X';
        myCar.color = ConsoleColor.Yellow;

        while (true)
        {
            // draw Rocks
            FallingObject rock = new FallingObject();
            rock.color = ConsoleColor.Red;
            rock.x = randomGenerator.Next(1, Console.WindowWidth);
            rock.y = 1;
            rock.c = '#';
            fallingObjects.Add(rock);

            List<FallingObject> newList = new List<FallingObject>();

            for (int i = 0; i < fallingObjects.Count; i++)
            {
                FallingObject oldRock = fallingObjects[i];
                FallingObject newRock = new FallingObject();
                clear(oldRock.x, oldRock.y);
                newRock.x = oldRock.x;
                newRock.y = oldRock.y + 1;
                newRock.c = oldRock.c;
                newRock.color = oldRock.color;
                if (newRock.y < Console.WindowHeight)
                {
                    newList.Add(newRock);
                }

            }
            fallingObjects = newList;
            foreach (FallingObject fRock in fallingObjects)
            {

                printAt(fRock.x, fRock.y, fRock.c, fRock.color);
            }
            //Move Car
            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo pressedKey = Console.ReadKey(true);
                clear(myCar.x, myCar.y);
                while (Console.KeyAvailable)
                {
                    Console.ReadKey(true);
                }
                if (pressedKey.Key == ConsoleKey.LeftArrow)
                {
                    if (myCar.x - 1 >= 0)
                    {
                        myCar.x -= 1;
                    }
                }
                else if (pressedKey.Key == ConsoleKey.RightArrow)
                {
                    if (myCar.x + 1 < Console.WindowWidth)
                    {
                        myCar.x += 1;
                    }
                }

            }

            //draw Objects
            printAt(myCar.x, myCar.y, myCar.c, myCar.color);

            //slowDown
            Thread.Sleep(speed);
        }
    }
Beispiel #34
0
 private void NextLevel()
 {
     _currentLevel++;
     _fallingObject = null;
     _itemSelection.PrepareLevel(_levelLoader.GetLevel(_currentLevel));
 }
Beispiel #35
0
 public bool UnlinkObject(FallingObject fo)
 {
     return(m_ChewingObjects.Remove(fo));
 }
    // Update is called once per frame
    void Update()
    {
        distanceText.text = "Distance:" + transform.position.y + "m";
        scoreText.text = "Score:" + score;

        if (levelManager_ == null) {
            levelManager_ = FindObjectOfType<LevelManager> ();
        }
        if (levelManager_ != null && levelManager_.gaming == false) {
            return;
        }

        RaycastHit hitInfo;

        if (Physics.Raycast( head.position, head.forward, out hitInfo, 400.0f, 1 << 9)) {
            if (hitInfo.rigidbody != null) {
                FallingObject fo = hitInfo.rigidbody.gameObject.GetComponent<FallingObject> ();
                if (fo != targetting && fo == null) {
                    EndCapture ();
                }
                if (fo != targetting && fo != null) {
                    StartCapture (fo);
                }
            }
        }
        if (targetting != null) {
            targettingTime_ += Time.deltaTime;
        }

        if (targettingTime_ > lockOnTime && targetting != null) {
            AddCaptured (targetting);
            //targetting.GetComponent<Collider> ().enabled = false;
            //print ("founded " + targetting +  "  score:" + targetting.score);
            targetting = null;
            targettingTime_ = 0;
        }

        // 最大速度を設定
        if (rigidbody_.velocity.y < -maxVelocityY) {
            rigidbody_.velocity = new Vector3 (0, -maxVelocityY, 0);
        }
    }
 public void RecycleObject(FallingObject fallingObject)
 {
     fallingObject.enabled            = false;
     fallingObject.transform.position = spawningStart.position;
     CheckAndRecycle(fallingObject);
 }