コード例 #1
0
    //Método que verifica se o jogador colidiu com Colliders 2D
    private void OnCollisionEnter2D(Collision2D collision2D)
    {
        //Verifica se o jogador colidiu com o GameObject com tag "Enemy"
        if (collision2D.gameObject.tag == "Enemy")
        {
            //Pega o Script do inimigo Frog
            FrogController frog = collision2D.gameObject.GetComponent <FrogController>();

            //Se o jogador estava em State falling quando colidiu com o inimigo, chama o método Death() de FrogController e faz o jogador pular do inimigo
            if (state == State.falling)
            {
                frog.Death();
                Jump();
            }

            //Se não, troca o State do jogador para hurt e o joga para trás
            else
            {
                state = State.hurt;

                if (collision2D.gameObject.transform.position.x > transform.position.x)
                {
                    rb.velocity = new Vector2(-hurtForce, rb.velocity.y);
                }
                else
                {
                    rb.velocity = new Vector2(hurtForce, rb.velocity.y);
                }
            }
        }
    }
コード例 #2
0
ファイル: FrogController.cs プロジェクト: EternalGB/frogue
    void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }

        Instance = this;
    }
コード例 #3
0
    public void SetUp(GameManager gameManager, MazeController mazeController)
    {
        base.SetUp(mazeController);

        this.Dead = false;

        this.frogController = new FrogController(this, gameManager, mazeController);
        this.Controller     = this.frogController;
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        horizontal = Input.GetAxis("Horizontal");
        vertical   = Input.GetAxis("Vertical");

        Vector2 move = new Vector2(horizontal, vertical);

        if (!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f))
        {
            lookDirection.Set(move.x, move.y);
            lookDirection.Normalize();
        }

        if (animator != null)
        {
            animator.SetFloat("Look X", lookDirection.x);
            animator.SetFloat("Look Y", lookDirection.y);
            animator.SetFloat("Speed", move.magnitude);
        }

        if (isInvincible)
        {
            invincibleTimer -= Time.deltaTime;

            if (invincibleTimer < 0)
            {
                playerLight.color = normalPlayerLightColor;
                isInvincible      = false;
            }
            else
            {
                if (playerLight != null)
                {
                    playerLight.color = damagedPlayerLightColor;
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            LaunchCog();
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            RaycastHit2D hit = Physics2D.Raycast(rigidbody2d.position + Vector2.up * 0.2f, lookDirection, 1.5f, LayerMask.GetMask("NPC"));
            if (hit.collider != null)
            {
                FrogController froggy = hit.collider.GetComponent <FrogController>();
                if (froggy != null)
                {
                    froggy.DisplayDialog();
                }
            }
        }
    }
コード例 #5
0
ファイル: Platform.cs プロジェクト: infern/Frogger
 void OnTriggerExit2D(Collider2D col)
 {
     if (col.CompareTag("Player"))
     {
         FrogController script = col.gameObject.GetComponent <FrogController>();
         frog = null;
         script.transform.parent = null;
         script.isOnPlatform     = false;
     }
 }
コード例 #6
0
ファイル: Platform.cs プロジェクト: infern/Frogger
 //Frog moves together with platform and is immune to dying from water while its on it
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.CompareTag("Player") && active)
     {
         FrogController script = col.gameObject.GetComponent <FrogController>();
         frog = script;
         if (script.alive)
         {
             script.transform.parent = this.transform;
             script.isOnPlatform     = true;
         }
     }
 }
コード例 #7
0
    public void StartGame()
    {
        if (LilySpawner == null)
        {
            LilySpawner = FindObjectOfType <LilypadSpawner>();
        }
        LilySpawner.gameObject.SetActive(true);
        if (originalLilyDelay == -1)
        {
            originalLilyDelay = LilySpawner.SpawnInfo.DelayBetweenSpawns;
        }
        LilySpawner.SpawnInfo.DelayBetweenSpawns /= PointsMultiplier;

        if (BugsSpawner == null)
        {
            BugsSpawner = FindObjectOfType <BugsSpawner>();
        }
        BugsSpawner.gameObject.SetActive(true);
        if (originalBugsDelay == -1)
        {
            originalBugsDelay = BugsSpawner.SpawnInfo.DelayBetweenSpawns;
        }
        BugsSpawner.SpawnInfo.DelayBetweenSpawns /= PointsMultiplier;

        LilySpawner.SpawnLilypad();

        if (Frog == null)
        {
            Frog = FindObjectOfType <FrogController>();
        }
        Frog.gameObject.SetActive(true);

        LilypadController spawnedLily = GetCloseLilyPad(Frog.transform.position, 100);

        Frog.transform.position = spawnedLily.transform.position;
        Frog.SetParentLily(spawnedLily);

        if (UICtrl == null)
        {
            UICtrl = FindObjectOfType <UIController>();
        }
        UICtrl.ToggleMainMenu(false);

        if (inputCtrl == null)
        {
            inputCtrl = GetComponent <InputController>();
        }
        inputCtrl.enabled = true;
    }
コード例 #8
0
        private void MoveFromTo(int fromIndex, int toIndex)
        {
            DOTween.KillAll();

            CellController fromCell = _spawnedCells[fromIndex];
            CellController toCell   = _spawnedCells[toIndex];

            FrogController chosenFrog = fromCell.FrogController;

            toCell.FrogController   = chosenFrog;
            fromCell.FrogController = null;

            chosenFrog.transform.parent = toCell.transform;
            chosenFrog.transform.DOLocalJump(new Vector2(0, 0), 30 * Mathf.Abs(toIndex - fromIndex), 1, 0.5f).OnComplete(() =>
            {
                _gameController.MoveCurrentStateCells(fromIndex, toIndex);
            });
        }
コード例 #9
0
 //Grant point if entering this zone with each frog, kills if frog jumps into river.
 void OnTriggerStay2D(Collider2D col)
 {
     if (col.CompareTag("Player"))
     {
         FrogController script = col.gameObject.GetComponent <FrogController>();
         if (script.alive)
         {
             if (river && !script.isOnPlatform)
             {
                 script.Death();
             }
             if (!pointClaimed)
             {
                 GameController.Instance.GrantPoints(50f);
                 pointClaimed = true;
             }
         }
     }
 }
コード例 #10
0
        private void DrawLevel(List <int> levelData)
        {
            levelData.ForEach((level) =>
            {
                CellController newCell          = Instantiate(_cellPrefab, _horizontalCellsGroup);
                newCell.OnPointerClickCallback += OnCellClick;
                _spawnedCells.Add(newCell);

                if (level == GameModel.EMPTY)
                {
                    return;
                }

                FrogController newFrog = Instantiate(_frogControllerPrefab, newCell.transform);
                newFrog.RectTransform.anchoredPosition = new Vector2(0, newFrog.RectTransform.sizeDelta.y / 3);
                newFrog.Initialize(level);

                newCell.FrogController = newFrog;
            });
        }
コード例 #11
0
ファイル: Station.cs プロジェクト: infern/Frogger
    //Claim station, kills frog if it was already claimed
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.CompareTag("Player"))
        {
            FrogController script = col.gameObject.GetComponent <FrogController>();

            if (!pointClaimed)
            {
                script.StopCoroutine(script.jumpCoroutine);
                script.Respawn();
                GameController.Instance.GrantPoints(50f);
                GameController.Instance.StationCleared();
                frogObject.SetActive(true);
                aS.clip = claimedSFX;
                aS.Play();
                GameController.Instance.fadeAnim.Play("yellowBlink");
                pointClaimed = true;
            }
            else
            {
                script.Death();
            }
        }
    }
コード例 #12
0
 // Use this for initialization
 void Start()
 {
     frogController = GetComponent <FrogController>();
 }
コード例 #13
0
ファイル: Objectivo.cs プロジェクト: franco026/frog
 void Start()
 {
     frog    = FindObjectOfType <FrogController>();
     insecto = GetComponent <GameObject>();
     numb    = 0;
 }
コード例 #14
0
 // Use this for initialization
 void Start()
 {
     //This code Automatically finds the player and sets the frog controller
     GameObject[] playersList = GameObject.FindGameObjectsWithTag("Player");
     frog = playersList[0].GetComponent <FrogController>();
 }
コード例 #15
0
 public void SetFrog(FrogController _frog)
 {
     frog = _frog;
 }
コード例 #16
0
 // Start is called before the first frame update
 private void Awake()
 {
     control = FindObjectOfType <ControlScore>();
     frog    = FindObjectOfType <FrogController>();
 }
コード例 #17
0
ファイル: Cheatcodes.cs プロジェクト: Algebroix/Frogger
 private void Awake()
 {
     frogController       = GetComponent <FrogController>();
     nextLevelKeySequence = new KeyCode[nextLevel.Length];
     ParseCheat(ref nextLevelKeySequence, nextLevel);
 }
コード例 #18
0
 public void Initialize()
 {
     m_frogController = new FrogController();
     m_frogController.Initialize();
 }
コード例 #19
0
ファイル: AbejaMove.cs プロジェクト: franco026/frog
 void Awake()
 {
     from    = FindObjectOfType <FrogController>();
     control = FindObjectOfType <ControlScore>();
 }