예제 #1
0
    void CallVictory()
    {
        int PlayerLayer = 12;
        int EnemyLayer  = 11;

        //Debug.Log("enemy ignored");


        if (!IsMenuAnimation)
        {
            PlayerPrefs.SetInt(ActualStagePref, 1);

            //ignorar colisão entre enemy e player
            Physics2D.IgnoreLayerCollision(PlayerLayer, EnemyLayer, true);



            //deixar o planeta oculto

            Time.timeScale = 0;
            controller.GetComponent <Animator> ().SetTrigger("Victory");
        }
        Destroy(gameObject);
    }
예제 #2
0
    //======== COLLISION ========//
    void OnCollisionEnter2D(Collision2D col)
    {
        Physics2D.IgnoreLayerCollision(8, 9);

        switch (col.gameObject.layer)
        {
        case (11):
        {
            Vector2 newVel = new Vector2();
            if (lastmove == LASTMOVE.s_UP)
            {
                newVel.y = -50;
            }
            else if (lastmove == LASTMOVE.s_DOWN)
            {
                newVel.y = 50;
            }
            else if (lastmove == LASTMOVE.s_LEFT)
            {
                newVel.x = 50;
            }
            else
            {
                newVel.x = -50;
            }

            rb2d.velocity = newVel;
            pushedBack    = true;
            playerHealth -= 10;
        }
        break;

        default:
            break;
        }
    }
    private void Update()
    {
        if (GODMODE)
        {
            Physics2D.IgnoreLayerCollision(0, 8, true);
        }
        else if (!PlayerDied && !_invulnerable)
        {
            Physics2D.IgnoreLayerCollision(0, 8, false);
        }

        if (_playerRigidBody.velocity.y != 0)
        {
            IsPlayerTouchingGround = false;
        }

        if (_playerRigidBody.velocity.x != 0)
        {
            IsPlayerWalking = true;
        }
        else
        {
            IsPlayerWalking = false;
        }

        if (FinishedLevel && !_startedWalkingOut)
        {
            _startedWalkingOut = true;

            Physics2D.IgnoreLayerCollision(0, 8, true);
            Physics2D.IgnoreLayerCollision(0, 11, true);
            PlayerDirection  = Vector2.right;
            IsPlayerShooting = false;
            StartCoroutine(WalkOutOfLevel());
        }
    }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     Player.score          = 0;
     Player.timeGame       = 1000;
     gamecamera            = GameObject.FindGameObjectWithTag("MainCamera");
     cameraFollow          = (CameraFollow)gamecamera.GetComponent("CameraFollow");
     pauseMenu             = (PauseMenu)gamecamera.GetComponent("PauseMenu");
     rb2d                  = gameObject.GetComponent <Rigidbody2D>();
     anim                  = gameObject.GetComponent <Animator>();
     currentLife           = maxLife;
     timerAttack           = 0;
     timeMatrix            = 0;
     timeToRefleshTimeGame = 0;
     timeToShowGo          = 0;
     isLookingToRight      = true;
     goAlertArrow.GetComponent <Renderer>().enabled = false;
     activeBlinkHurt  = false;
     currentTimeBlink = 0;
     //------------- Calcular ancho de la cámara.
     widthCamera = UserInterfaceGraphics.getWidthCamera() / 2;
     // Para cuando muere el player y vuelve a iniciarse el juego.
     Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY_SHOOT, UserInterfaceGraphics.LAYER_PLAYER, false);
     Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY, UserInterfaceGraphics.LAYER_PLAYER, false);
 }
예제 #5
0
    void Awake()
    {
        Application.targetFrameRate = 60;

        // add our one-way platforms to our normal platform mask so that we can land on them from above
        platformMask |= oneWayPlatformMask;

        // cache some components
        m_boxCollider = GetComponent <BoxCollider2D>();
        m_rigidBody2D = GetComponent <Rigidbody2D>();

        // here, we trigger our properties that have setters with bodies
        SkinWidth = m_skinWidth;

        // Ignore all layers that are not on Trigger Mask.
        // Everything else will be handled by the Actor.
        for (var i = 0; i < 32; i++)
        {
            if ((triggerMask.value & 1 << i) == 0)
            {
                Physics2D.IgnoreLayerCollision(gameObject.layer, i);
            }
        }
    }
예제 #6
0
        private void Awake()
        {
            Log.Print("Monster: Initialization");
            anim       = GetComponent <Animator>();
            _rigidbody = GetComponent <Rigidbody2D>();

            GetHashIDs();

            if (onAwakeIdle == false)
            {
                idle = false;
            }

            bool result = LoadToJsonData(ID);

            if (result == false)
            {
                Log.PrintError("Not Initialize Monster In Awake Function");
            }

            DataTableLinking();

            Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Monster"), LayerMask.NameToLayer("Monster"));
        }
예제 #7
0
 void Update()
 {
     if (health <= 0)
     {
         Dead();
     }
     else
     {
         if (isHit)
         {
             invulTime();
             Physics2D.IgnoreLayerCollision(8, 9, isInvul);
             Physics2D.IgnoreLayerCollision(8, 12, isInvul);
         }
         if (Input.GetButtonDown("Jump") && airborne == false)
         {
             playerRB.AddForce(Vector2.up * jumpSpeed);
             animator.SetBool("airborne", true);
             airborne = true;
         }
         Physics2D.IgnoreLayerCollision(8, 11, playerRB.velocity.y > 0);
     }
     if (isAttacking)
     {
         if (attackTimer > 0)
         {
             attackTimer -= Time.deltaTime;
         }
         else
         {
             animator.SetBool("attacking", false);
             isAttacking           = false;
             attackTrigger.enabled = false;
         }
     }
 }
예제 #8
0
    void Start()
    {
        int throttleTime = 150;

        var scoreGameObject = GameObject.Find("Score");

        ScoreText = scoreGameObject.GetComponent <TextMeshProUGUI>();
        BonusUI   = BonusPoints.GetComponent <BonusPoints>();

        Physics2D.IgnoreLayerCollision(8, 8, true);
        var x      = EnemyLaunch.GetComponent <MeshCollider>();
        var bounds = x.bounds;
        Func <TimeSpan, bool> lowerLimt =
            _ => MousePosition.ToWorldSpace().Position.y > ToLow;
        var left = LeftMissileBase.GetComponent <MissileBase>();

        OnKey(left.Key).Throttle(throttleTime).Where(lowerLimt).Sink(left.Launch);
        var center = CenterMissileBase.GetComponent <MissileBase>();

        OnKey(center.Key).Throttle(throttleTime).Where(lowerLimt).Sink(center.Launch);
        var right = RightMissileBase.GetComponent <MissileBase>();

        OnKey(right.Key).Throttle(throttleTime).Where(lowerLimt).Sink(right.Launch);
    }
예제 #9
0
    //void Curseur()
    //{
    //    float canvasScale = canvas.scaleFactor;
    //    Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    //    direction = mousePos - transform.position;
    //    direction = direction.normalized;
    //    Vector2 screenPos = Camera.main.WorldToScreenPoint(Vector3.right * transform.localScale.x / 2.0f) - Camera.main.WorldToScreenPoint(Vector2.zero);
    //    direction *= ((screenPos.x / Camera.main.orthographicSize / 5) + (500 / Camera.main.orthographicSize) / 5) * canvasScale ;
    //    Vector2 cellScreenPosition = Camera.main.WorldToScreenPoint(transform.position);
    //    var angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
    //    Arrow.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
    //    Arrow.GetComponent<RectTransform>().localPosition = ((cellScreenPosition + direction) / canvasScale);
    //}
    // ---------------------------------------------------------------- NOT GLACE
    #region notGlace
    IEnumerator Dash()
    {
        canDash = false;
        shield.SetActive(true);
        shieldUI.SetActive(false);
        Physics2D.IgnoreLayerCollision(9, 10, true);
        FindObjectOfType <T10_AudioManager>().Play("shield");
        speed *= 3;
        yield return(new WaitForSeconds(0.3f));

        speed /= 3;
        shield.GetComponent <Animator>().SetTrigger("end");
        yield return(new WaitForSeconds(0.5f));

        Physics2D.IgnoreLayerCollision(9, 10, false);
        shield.SetActive(false);

        yield return(new WaitForSeconds(dashDelay.Value));

        shieldUI.SetActive(true);

        canDash = true;
        //yield return new
    }
예제 #10
0
    // If player is alive instantiate three enemy projectiles and fire at the player
    public void TripleAttack()
    {
        tripleTimer = 0f;
        if (playerHealth.currentHealth > 0 && enemyHealth.currentHealth > 0)
        {
            Physics2D.IgnoreLayerCollision(3, 3);
            int   numberOfShots = 3;
            float degree        = 90f;
            for (float i = 0; i < numberOfShots; ++i)
            {
                Quaternion rotation = Quaternion.Euler(0, 0, degree);

                Physics2D.IgnoreLayerCollision(3, 3);
                Rigidbody2D proj = (Rigidbody2D)Instantiate(projectile, this.transform.position, rotation);
                proj.tag = "EnemyProjectile";
                // proj.GetComponent<Rigidbody2D>().AddForce(player.transform.position.normalized * projImpulse, ForceMode2D.Impulse);
                Vector3 direction = (player.transform.position - transform.position);
                proj.AddForce(-(proj.transform.right - direction).normalized * projImpulse, ForceMode2D.Impulse);
                Debug.Log(direction + "      " + direction.normalized);
                Destroy(proj.gameObject, 5);
                degree += degree;
            }
        }
    }
예제 #11
0
    public void ThreeSixtyAttack()
    {
        threeSixtyTimer = 0f;
        if (playerHealth.currentHealth > 0 && enemyHealth.currentHealth > 0)
        {
            Physics2D.IgnoreLayerCollision(3, 3);
            int   numberOfShots = 12;
            float degree        = 360f / numberOfShots;
            for (float i = -180f; i < 180f; i += degree)
            {
                Quaternion rotation = Quaternion.Euler(0, 0, i);

                Physics2D.IgnoreLayerCollision(3, 3);
                Rigidbody2D proj = (Rigidbody2D)Instantiate(projectile, this.transform.position, rotation);
                proj.tag = "EnemyProjectile";
                // proj.GetComponent<Rigidbody2D>().AddForce(player.transform.position.normalized * projImpulse, ForceMode2D.Impulse);
                // Vector2 direction = (player.transform.position - transform.position);
                proj.AddForce(proj.transform.right * projImpulse, ForceMode2D.Impulse);
                // Debug.Log(direction + "      " + direction.normalized);

                Destroy(proj.gameObject, 5);
            }
        }
    }
예제 #12
0
    private void FixedUpdate()
    {
        Physics2D.IgnoreLayerCollision(2, 1);
        if (blockfalling)
        {
            if (Input.GetMouseButtonUp(0))
            {
                BAS.HoldBlock();
            }
        }
        if (Input.GetMouseButton(0) && !BAS.isHook && !blockfalling)
        {
            Vector2 mousepos = Vector2.zero;

            mousepos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            transform.localPosition = new Vector3(mousepos.x, 9f);
        }
        else if (Input.GetMouseButtonUp(0) && BAS.isHook == false && blockfalling == false)
        {
            BAS.DropBlock();
            blockfalling = true;
        }
    }
예제 #13
0
    void OnTriggerExit2D(Collider2D other)
    {
        //Enables water movement and water animations
        if (other.gameObject.CompareTag("Water"))
        {
            insideWater = false;
            myAnimator.SetBool("InsideWater", false);
        }


        if (other.gameObject.CompareTag("Ladder"))
        {
            ladderZone = false;

            interactedWithLadder = false;

            onLadder = false;

            myAnimator.SetBool("ClimbingLadder", false);

            myRigidbody.gravityScale = gravityStore;

            Physics2D.IgnoreLayerCollision(9, 8, false);
        }


        if (other.gameObject.CompareTag("Fire"))
        {
            fire = false;
        }

        if (other.gameObject.CompareTag("TouchingFire"))
        {
            touchingFire = false;
        }
    }
예제 #14
0
    void ModifyStature(Stature newStature)
    {
        stature = newStature;
        DisableColliders();
        //References._DamageManager.isInvulnerable = false;
        Physics2D.IgnoreLayerCollision(8, 9, false);
        switch (stature)
        {
        case Stature.dropped:
            References._SpriteRenderer.sprite = References.DropSprite;
            References._SpriteRenderer.color  = Color.red;
            References.DropCollider.enabled   = true;
            break;

        case Stature.ducked:
            References._SpriteRenderer.sprite = References.DuckSprite;
            References._SpriteRenderer.color  = Color.yellow;
            References.DuckCollider.enabled   = true;
            break;

        case Stature.rolling:
            //References._DamageManager.isInvulnerable = true;
            Physics2D.IgnoreLayerCollision(8, 9, true);
            References._SpriteRenderer.sprite = References.RollSprite;
            References._SpriteRenderer.color  = Color.cyan;
            References.RollCollider.enabled   = true;
            break;

        case Stature.standing:
        default:
            References._SpriteRenderer.sprite = References._Sprite;
            References._SpriteRenderer.color  = Color.white;
            References._Collider2D.enabled    = true;
            break;
        }
    }
예제 #15
0
    void Update()
    {
        if (move3 && isSubmarine == false)
        {
            movement = CrossPlatformInputManager.GetAxis("Horizontal");
        }
        if (move3 && isSubmarine)
        {
            movement_horizontal = CrossPlatformInputManager.GetAxis("Horizontal") * sub_horspeed;
            movement_vertical   = CrossPlatformInputManager.GetAxis("Vertical") * sub_verspeed;
        }
        if (followcamera)
        {
            transform.position = targetcamera.position + offset;
        }

        if (Input.GetKeyDown(KeyCode.B) || CrossPlatformInputManager.GetButtonDown("BoatButton"))
        {
            rb2D.isKinematic = false;
            followcamera     = false;
            move3            = true;
            Physics2D.IgnoreLayerCollision(10, 12, false);
        }
    }
예제 #16
0
    void FixedUpdate()
    {
        if (haciaIzquierda == true)
        {
            rigidBody.velocity = new Vector2(-velocidad, rigidBody.velocity.y);
            animador.SetInteger("Izquierda", 1);
        }
        else
        {
            rigidBody.velocity = new Vector2(velocidad, rigidBody.velocity.y);
            animador.SetInteger("Izquierda", 0);
        }

        if (haciaArriba == true)
        {
            rigidBody.velocity = new Vector2(rigidBody.velocity.x, velocidad);
        }
        else
        {
            rigidBody.velocity = new Vector2(rigidBody.velocity.x, -velocidad);
        }
        Physics2D.IgnoreLayerCollision(13, 13);   //ESTO ES PARA QUE NO SE CHOQUEN LOS BICHOS ENTRE S�
        Physics2D.IgnoreLayerCollision(13, 15);   //ESTO ES PARA QUE NO SE CHOQUEN LOS BICHOS CON LAS MONEDAS
    }
예제 #17
0
    void Start()
    {
        rb = GetComponent <Rigidbody2D>();
        //offset = transform.position - player.transform.position;

        //Cria o objeto vazio
        leftCollider = new GameObject().transform;
        //Dã nome a ele
        leftCollider.name = "LeftCollider";
        //Adiciona o colisor
        leftCollider.gameObject.AddComponent <BoxCollider2D>();
        leftCollider.gameObject.AddComponent <Rigidbody2D>();
        leftCollider.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;
        //faz do colisor filho da camera para que se mova junto com ela
        leftCollider.parent = transform;
        //dá a layer de "LeftCollider" ao colisor
        leftCollider.gameObject.layer = LayerMask.NameToLayer("LeftCollider");
        // Dá a tag de "LeftCollider" ao colisor
        leftCollider.gameObject.tag = "LeftCollider";
        //determina que as colisões entre os inimigos e o leftCollider serão ignoradas
        Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Enemies"), LayerMask.NameToLayer("LeftCollider"));
        Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Environment"), LayerMask.NameToLayer("LeftCollider"));
        Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("PowerUps"), LayerMask.NameToLayer("LeftCollider"));
        //Gera as coordenadas do mundo
        cameraPos    = /*Camera.main.*/ transform.position;
        screenSize.x = Vector2.Distance(Camera.main.ScreenToWorldPoint(new Vector2(0, 0)), Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, 0))) * 0.5f;
        screenSize.y = Vector2.Distance(Camera.main.ScreenToWorldPoint(new Vector2(0, 0)), Camera.main.ScreenToWorldPoint(new Vector2(0, Screen.height))) * 0.5f;
        //modifica as coordenadas para equivaler a extremidades
        leftCollider.localScale = new Vector3(colDepth, screenSize.y * 2, colDepth);
        leftCollider.position   = new Vector3(cameraPos.x - screenSize.x - (leftCollider.localScale.x * 0.5f), cameraPos.y, zPosition);

        //limite direita
        Limite_direita.transform.position = new Vector3(cameraPos.x + screenSize.x, cameraPos.y, zPosition);

        yPosition = transform.position.y;
    }
예제 #18
0
    private void Start()
    {
        // 利用程式取得元件
        // 傳回元件 取得元件<元件名稱>() - <泛型>
        // 取得跟此腳本同一層的元件
        Rig2D = GetComponent <Rigidbody2D>();
        Ani   = GetComponent <Animator>();
        Aud   = GetComponent <AudioSource>();

        // 粒子系統 = 變形元件,搜尋子物件("子物件名稱")
        ps = transform.Find("集氣特效").GetComponent <ParticleSystem>();


        // 2D 物理,忽略圖層的物理碰撞(圖層1,圖層2,是否要忽略)
        Physics2D.IgnoreLayerCollision(9, 10, true);

        // 遊戲物件.尋找("物件名稱 - 絕對不要有相同名稱")
        // 絕對不要再 Update 系列事件內使用
        // 不能尋找隱藏物件 會導致錯誤
        imgHp       = GameObject.Find("血條").GetComponent <Image>();
        textHp      = GameObject.Find("生命").GetComponent <Text>();
        textHp.text = life.ToString();
        hpMax       = HP;
    }
예제 #19
0
 void DoPhaseWalk(bool on)
 {
     if (on)
     {
         // Enter phasewalk
         Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Player"),
                                        LayerMask.NameToLayer("Phasewalk"));
         phaseWalkEnergyDrain = 0;
         var mats = PhasewalkTiles.GetComponent <MeshRenderer>().materials;
         mats[0] = TransparentTiles;
         PhasewalkTiles.GetComponent <MeshRenderer>().materials = mats;
     }
     else
     {
         // Drop out of phasewalk
         Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Player"),
                                        LayerMask.NameToLayer("Phasewalk"),
                                        false);
         phaseWalking = false;
         var mats = PhasewalkTiles.GetComponent <MeshRenderer>().materials;
         mats[0] = NormalTiles;
         PhasewalkTiles.GetComponent <MeshRenderer>().materials = mats;
     }
 }
예제 #20
0
    private void Start()
    {
        isGameOver     = false;
        isCountingDown = false;
        isProjectile   = false;

        AssignPlayers();

        if (!mapCamera)
        {
            mapCamera = Camera.main;
        }
        else
        {
            Debug.Log("Camera already referenced? HOW?");
        }

        gameOverText.SetActive(false);
        restartButton.SetActive(false);
        currentIntervalTime = intervalTime;
        Physics2D.IgnoreLayerCollision(0, 9, true);
        Physics2D.IgnoreLayerCollision(8, 9, true);
        ChangeTurn();
    }
    // Checks if there is a collision between the player and any enemies
    void OnCollisionEnter2D(Collision2D collision)
    {
        Enemy_Controller enemy = collision.collider.GetComponent <Enemy_Controller>();

        if (enemy != null)
        {
            bool enemyHurt = false;
            enemyLayer = collision.gameObject.layer;
            foreach (ContactPoint2D point in collision.contacts)
            {
                if (point.normal.y >= 0.9f)
                {
                    Vector2 velocity = myBody.velocity;
                    velocity.y      = jumpForce / 2;
                    myBody.velocity = velocity;
                    enemy.Hurt();
                    enemyHurt = true;
                }
            }
            if (!enemyHurt && !isShielded)
            {
                Hurt();
            }
            if (isShielded)
            {
                // Ignore layer "Enemy"
                Physics2D.IgnoreLayerCollision(enemyLayer, gameObject.layer, true);
            }
        }

        if (collision.collider.tag == "Kill zone")
        {
            Application.LoadLevel("Game over");
        }
        // TODO: Fix so that the player doesn't die when getting hit by falling objects.
    }
예제 #22
0
 void Start()
 {
     color = new Color32(65, 234, 101, 255);
     this.GetComponent <SpriteRenderer>().color = color;
     body = GetComponent <Rigidbody2D>();
     body.freezeRotation = true;
     maxHealth           = 100;
     health            = maxHealth;
     maxStamina        = 100;
     stamina           = maxStamina;
     attack            = 5;
     defense           = 5;
     maxSpeed          = 1;
     dashTime          = 0.15f;
     jumpAmount        = 100f;
     numJumps          = 1;
     jumpCounter       = numJumps;
     numDashes         = 3;
     dashCounter       = numDashes;
     recoveryTime      = 1f;
     incapacitatedTime = 0.3f;
     expToNextLevel    = expFormula();
     Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("PhysicsObject"), LayerMask.NameToLayer("PhysicsObject"));
 }
예제 #23
0
    void Start()
    {
        groundedCheckReset = numUpdatesToIgnoreGroundedCheck;
        rb = transform.GetComponent <Rigidbody2D>();
        timeSinceLastProjectile = fireRate;
        rocket1.color           = active;
        rocket2.color           = active;
        rocket3.color           = active;
        input = GetComponent <GunInput>();

        Physics2D.IgnoreLayerCollision(8, 8);//objects on layer of player cannot collide with one another, meaning players cannot bump into one another
        Physics2D.IgnoreLayerCollision(8, 10);
        Physics2D.IgnoreLayerCollision(10, 10);
        Physics2D.IgnoreLayerCollision(8, 9);
        Physics2D.IgnoreLayerCollision(9, 13);
        Physics2D.IgnoreLayerCollision(8, 14);
        Physics2D.IgnoreLayerCollision(10, 11);
        Physics2D.IgnoreLayerCollision(11, 13);
        Physics2D.IgnoreLayerCollision(10, 14);
        Physics2D.IgnoreLayerCollision(15, 14);
        //projectiles ignore tpboxes
        Physics2D.IgnoreLayerCollision(9, 12, true);
        Physics2D.IgnoreLayerCollision(11, 12, true);
    }
예제 #24
0
    public IEnumerator <float> DoingJob()
    {
        //PlayerAnimationHelper.ResetPlayer();
        Debug.Log("StartedWork");
        JobManager.Instance.CurrentJob.ShowUpAtWork();
        Physics2D.IgnoreLayerCollision(GameLibOfMethods.player.layer, 10, true);

        GameLibOfMethods.cantMove = true;

        GameLibOfMethods.player.GetComponent <Rigidbody2D>().velocity = Vector2.zero;

        GameClock.ChangeSpeedToSleepingSpeed();

        while (JobManager.Instance.CurrentJob != null && System.TimeSpan.FromSeconds(JobManager.Instance.CurrentWorkingTime).Hours <= JobManager.Instance.CurrentJob.WorkingTimeInHours && !Input.GetKeyDown(KeyCode.P))
        {
            JobManager.Instance.CurrentWorkingTime += (Time.deltaTime * GameClock.TimeMultiplier) * GameClock.Speed;
            GameLibOfMethods.progress = JobManager.Instance.CurrentWorkingTime / (float)System.TimeSpan.FromHours(JobManager.Instance.CurrentJob.WorkingTimeInHours).TotalSeconds;
            // Debug.Log("Current job progress is " + GameLibOfMethods.progress + ". Working time in seconds: " + JobManager.Instance.CurrentWorkingTime + ". And required work time is " + JobManager.Instance.CurrentJob.WorkingTimeInSeconds);
            yield return(0f);
        }


        GameLibOfMethods.progress = 0;
        if (JobManager.Instance.CurrentJob != null)
        {
            JobManager.Instance.CurrentJob.Finish();
            JobManager.Instance.CurrentWorkingTime = 0;
        }

        Debug.Log("Called car back from work");
        CarToPlayerHouse();

        yield return(0f);

        GameClock.ResetSpeed();
    }
예제 #25
0
    private IEnumerator OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player" && state._currentState != CatBehaviour.catState.Idle && player != null)
        {
            state._currentState = CatBehaviour.catState.Attack;
            state.anim.SetTrigger("Attack");
            audioSour.PlayOneShot(playerHit);
            audioSour.PlayOneShot(catAttack);
            Player.health    -= 30;
            playerRb.velocity = Vector3.zero;
            Physics2D.IgnoreLayerCollision(9, 10);
            StartCoroutine("Flashing");
            if (player.transform.localScale.x < 0)
            {
                playerRb.AddForce(new Vector3(-1.5f, 3f, 0), ForceMode2D.Impulse);
            }
            else
            {
                playerRb.AddForce(new Vector3(1.5f, 3f, 0), ForceMode2D.Impulse);
            }

            yield return(null);
        }
    }
        void Awake()
        {
            // add our one-way platforms to our normal platform mask so that we can land on them from above
            hitByWall     = bounceDirection.none;
            platformMask |= oneWayPlatformMask;

            // cache some components
            transform   = GetComponent <Transform>();
            boxCollider = GetComponent <BoxCollider2D>();
            //rigidBody2D = GetComponent<Rigidbody2D>();

            // here, we trigger our properties that have setters with bodies
            skinWidth = _skinWidth;

            // we want to set our CC2D to ignore all collision layers except what is in our triggerMask
            for (var i = 0; i < 32; i++)
            {
                // see if our triggerMask contains this layer and if not ignore it
                if ((triggerMask.value & 1 << i) == 0)
                {
                    Physics2D.IgnoreLayerCollision(gameObject.layer, i);
                }
            }
        }
    public void ResetPlayer()
    {
        Physics2D.IgnoreLayerCollision(0, 4, false);
        _playerRigidBody.velocity = Vector2.zero;
        GetComponent <Animator>().SetTrigger("Jump");

        float __xPosition = transform.position.x;

        if (__xPosition > Camera.main.transform.position.x || __xPosition < Camera.main.transform.position.x - 4f)
        {
            __xPosition = Camera.main.transform.position.x - 1f;
        }

        transform.position = new Vector3(__xPosition, 2f, 0f);


        CurrentWeapon         = Weapon.REGULAR;
        IsPlayerTouchingWater = false;
        PlayerDied            = false;
        PlayerDirection       = new Vector2(1f, 0f);
        ShotSpeedModificator  = 1f;

        StartCoroutine(FlickerInvulnerable());
    }
예제 #28
0
    public override void Shoot()
    {
        Vector3 temp = new Vector3();

        // if (player.playerManager.GetStateInput().spriteRenderer.flipX) {
        //     Debug.Log("The sprite is flipped!");
        //     firePt.position = new Vector3(firePt.position.x - .08f, firePt.position.y, firePt.position.z);
        //     temp = new Vector3(firePt.position.x - .08f, firePt.position.y, firePt.position.z);
        // } else {
        //     Debug.Log("The sprite is fine!");
        //     temp = firePt.right;
        // }
        temp    = firePt.right;
        temp.y += Random.Range(-0.1f, 0.1f);

        RaycastHit2D hitInfo = Physics2D.Raycast(firePt.position, temp, maxRange);

        Physics2D.IgnoreLayerCollision(8, Physics2D.IgnoreRaycastLayer);
        Debug.Log(hitInfo);
        if (hitInfo)
        {
            bulletTrail.SetPosition(0, firePt.position);
            bulletTrail.SetPosition(1, hitInfo.point);

            GameObject new_hit = (GameObject)Instantiate(hitEffect, hitInfo.point, Quaternion.identity);
            Destroy(new_hit, 0.267f);
        }
        else
        {
            Debug.Log("Nothing");
            bulletTrail.SetPosition(0, firePt.position);
            bulletTrail.SetPosition(1, firePt.position + temp * maxRange);
        }
        player.playSound(fireSound);
        player.showBulletTrail(bulletTrail);
    }
예제 #29
0
 void OnTriggerStay2D(Collider2D collision)
 {
     anim.ChangeAnimationState(onGround);
     if (Input.GetKeyDown("e"))
     {
         Debug.Log("Se presiono E");
         newPos = player.transform.position;
         if (side > 0)
         {
             newPos.x += -0.45f;
             newPos.y += 0.07f;
         }
         else if (side < 0)
         {
             newPos.x += 0.45f;
             newPos.y += 0.07f;
             transform.localRotation = Quaternion.Euler(0, 180, 0);
         }
         transform.position = newPos;
         transform.parent   = player.transform;
         playerMov.holding  = true;
         Physics2D.IgnoreLayerCollision(8, 9);
     }
 }
예제 #30
0
    // Update is called on each frame, this way the character immediately reacts to jumps.
    void Update()
    {
        getControls();

        // This code is necessary for one-way platforms
        if (rigidbody2D.velocity.y < 0)
        {
            Physics2D.IgnoreLayerCollision(2, 11, false);
        }

        if (!dead)
        {
            if ((canBoost) && Input.GetButtonDown("Fire2"))
            {
                StartCoroutine(Boost(.15f));                   //Start the Coroutine called "Boost", and feed it the time we want it to boost us
            }
            OnDeath();
            doDoubleJump();
            if (grounded)
            {
                doJump();
            }
        }
    }