예제 #1
0
    void Start()
    {
        targetObjects = GameObject.FindGameObjectsWithTag("Player");

        rigidbody   = GetComponent <Rigidbody2D>();
        animator    = GetComponent <Animator>();
        sprRenderer = GetComponent <SpriteRenderer>();
        hitCheck    = GetComponent <HitCheck>();

        aud = GetComponent <AudioSource>();
        if (aud == null)
        {
            aud = FindObjectOfType <AudioSource>();
        }

        actionTimer = Random.Range(actionMinDelay, actionMaxDelay);

        angleAtTargetTimer = angleAtTargetTime;

        if (type == EnemyAIType.Rotational)
        {
            trail = transform.GetChild(3).gameObject.GetComponent <TrailRenderer>();
        }

        if (containsPieces)
        {
            pieces = transform.GetChild(5).gameObject;
            pieces.transform.parent   = null;
            pieces.transform.position = transform.position;
        }
    }
예제 #2
0
 void Awake()
 {
     barFill          = GetComponent <Image>();
     hitCheck         = infoObject.GetComponent <HitCheck>();
     playerController = infoObject.GetComponent <PlayerController>();
     prevPos          = transform.parent.localPosition;
     prevScale        = transform.localScale;
 }
예제 #3
0
 // Use those for TriggerCheck
 protected void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "HitBox")
     {
         HitCheck hit = collision.GetComponent <HitCheck>();
         if (CanHit)
         {
             FX.EffectPlay(FX.PCS.PC_HIT);
         }
         Hit(hit.Weapon.ATK * ((100 + hit.Player.ATK) / 100), hit.Weapon.PushValue, hit.Weapon.Player.transform.position);
     }
 }
예제 #4
0
    private void Start()
    {
        if (name == "Player1")
        {
            playerNo = 1;
        }
        else if (name == "Player2")
        {
            playerNo = 2;
        }

        rigidbody   = GetComponent <Rigidbody2D>();
        animator    = GetComponent <Animator>();
        sprRenderer = GetComponent <SpriteRenderer>();
        hitCheck    = GetComponent <HitCheck>();

        aud = GetComponent <AudioSource>();
        if (aud == null)
        {
            aud = FindObjectOfType <AudioSource>();
        }

        if (playerNo == 1)
        {
            if (TogglesValues.p1controller == "")
            {
                if (GameManager.singleGame)
                {
                    inputExtensionString = "SinglePlayer";
                }
                else
                {
                    inputExtensionString = playerNo.ToString();
                }
            }
            else
            {
                inputExtensionString = TogglesValues.p1controller;
            }
        }
        else if (playerNo == 2)
        {
            if (TogglesValues.p2controller == "")
            {
                inputExtensionString = playerNo.ToString();
            }
            else
            {
                inputExtensionString = TogglesValues.p2controller;
            }
        }
    }
예제 #5
0
    // Start is called before the first frame update
    void Start()
    {
        //アニメーション用
        characterController = GetComponent <CharacterController>();
        animator            = GetComponent <Animator>();

        animator.SetInteger("Direction", direction);

        top    = transform.Find("TopBox").GetComponent <HitCheck>();
        right  = transform.Find("RightBox").GetComponent <HitCheck>();
        bottom = transform.Find("BottomBox").GetComponent <HitCheck>();
        left   = transform.Find("LeftBox").GetComponent <HitCheck>();
    }
예제 #6
0
    void Start()
    {
        rigidbody   = GetComponent <Rigidbody2D>();
        animator    = GetComponent <Animator>();
        sprRenderer = GetComponent <SpriteRenderer>();
        hitCheck    = GetComponent <HitCheck>();

        aud = GetComponent <AudioSource>();
        if (aud == null)
        {
            aud = FindObjectOfType <AudioSource>();
        }

        shingObject = transform.GetChild(1).GetChild(0).gameObject;
    }
예제 #7
0
    public override void SpawnEffect()
    {
        HitCheck child = Instantiate(Effect[Si], transform.position, transform.rotation).GetComponentInChildren <HitCheck>();

        child.Weapon = this;
    }
    public IEnumerator EndGame(bool win = false)
    {
        gameState = GameState.Ended;

        percentage.SetText(Mathf.RoundToInt((levelLength - targets.Count) / (float)levelLength * 100) + "%");

        loseScreen.SetActive(true);

        if (win)
        {
            loseText.SetText("You Win!");
            percentage.SetText("100%");
            progressBar.value = 1f;
        }

        //if(score > highScore) {
        //    highScore = score;
        //    PlayerPrefs.SetInt("HighScore", highScore);
        //    highScoreText.SetText("" + highScore);
        //}


        foreach (Target t in targets)
        {
            targetPool.Return(t.gameObject);
        }
        targets.Clear();


        foreach (GameObject obj in dominoes)
        {
            obj.GetComponent <Rigidbody>().isKinematic = false;
            hitCheck             = obj.AddComponent <HitCheck>();
            hitCheck.requiredTag = "Domino";

            if (obj.transform.localRotation == Quaternion.identity)
            {
                hitCheck.clip = fall1;
            }
            else
            {
                hitCheck.clip = fall2;
            }
        }



        Vector3 targetPos = path.transform.position + camOffset * 5f;
        Camera  camScript = cam.GetComponent <Camera>();

        while ((cam.position - targetPos).magnitude > 0.05f)
        {
            cam.position = Vector3.Lerp(cam.position, targetPos, 0.05f);
            camScript.orthographicSize = Mathf.Lerp(camScript.orthographicSize, camZoom, 0.05f);
            yield return(0);
        }
        dominoes[0].GetComponent <Rigidbody>().AddForce(dominoes[0].transform.forward * 100f);

        if (dominoes.Count > 2)
        {
            while (!hitCheck.isHit)
            {
                yield return(0);
            }
        }
        Destroy(hitCheck);
        yield return(new WaitForSeconds(2f));

        if (win)
        {
            yield return(new WaitForSeconds(image.Reveal() + 2f));

            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
        }
        else
        {
            playAgain.SetActive(true);
        }
    }