예제 #1
0
    void Update()
    {
        gunTrans   = playerCharacter.GetComponentInChildren <GunController>();
        swordTrans = playerCharacter.GetComponentInChildren <SwordController>();

        if (gunTrans != null && gunTrans.isActiveAndEnabled)
        {
            playerTransform = gunTrans.GetComponent <Transform>();
        }
        else if (swordTrans != null && swordTrans.isActiveAndEnabled)
        {
            playerTransform = swordTrans.GetComponent <Transform>();
        }

        enemyAgent.SetDestination(playerTransform.position);

        enemyPlayerDistance = Mathf.Abs(Vector3.Distance(playerTransform.position, transform.position));

        if (enemyPlayerDistance <= thresholdVisiblityDistance)
        {
            bulletRenderer.enabled = true;
        }
        else
        {
            bulletRenderer.enabled = false;
        }

        if (enemyLife <= 0f)
        {
            // Debug.Log("enemy killed!");
            gameManager.enemyKilled();
            Destroy(gameObject);
        }
    }
예제 #2
0
 void Update()
 {
     Jump();
     if (mask6.GetComponent <BoxCollider2D>().enabled == false && crate2ready)
     {
         crate2.GetComponent <Rigidbody2D>().gravityScale = 0.5f;
         crate2.GetComponent <BoxCollider2D>().enabled    = true;
         crate2.transform.position = new Vector2(2.5f, 1.5f);
         crate2ready = false;
     }
     if (Input.GetKeyDown(KeyCode.P))
     {
         SwordController sword = GetComponentInChildren <SwordController>();
         sword.SendMessage("SwingSword");
         swordsound.Play();
     }
     if (Input.GetKeyDown(KeyCode.E))
     {
         if (hat.transform.parent == this)
         {
             hat.SendMessage("Escape");
         }
     }
     if (winner)
     {
         winTime += Time.deltaTime;
     }
 }
예제 #3
0
 // Start is called before the first frame update
 void Start()
 {
     anim         = this.GetComponent <Animator>();
     movement     = this.GetComponent <MoveController>();
     swordControl = this.GetComponent <SwordController>();
     cutPlane.gameObject.SetActive(false);
 }
예제 #4
0
 void Awake()
 {
     m_Animator    = GetComponent <Animator>();
     m_Rigidbody2D = GetComponent <Rigidbody2D>();
     m_Shadow      = GetComponentInChildren <ShadowController>();
     m_Sword       = GetComponentInChildren <SwordController>();
 }
예제 #5
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        if ((collider.gameObject.tag == "lethalSword" || collider.gameObject.tag == "blockingSword") && !alternateSwordHitBox.Equals(collider.gameObject))
        {
            Vector3         otherPlayerPosition = Vector3.zero;
            SwordController swordController     = collider.gameObject.GetComponent <SwordController>();
            if (swordController != null)
            {
                otherPlayerPosition = swordController.currentPlayer.transform.position;
            }
            else
            {
                otherPlayerPosition = collider.gameObject.transform.position;
            }

            currentPlayerController.setReeling();
            Vector3 force = currentPlayer.transform.position - otherPlayerPosition;
            currentPlayer.GetComponent <Rigidbody2D>().AddForce(force * 250f);
            canHitPlayer = false;
        }
        else if (canHitPlayer && collider.gameObject.tag == "player" && !currentPlayer.Equals(collider.gameObject))
        {
            collider.gameObject.GetComponent <PlayerController> ().takeDamage(currentPlayer.GetComponent <PlayerController>());
            //GameObject swordClash = Instantiate<GameObject>(swordClashPrefab);
            //swordClash.transform.position = (collider.transform.position+transform.position)/2f;
        }
    }
예제 #6
0
 public void Initialize()
 {
     if (CurrentCharacter != null)
     {
         Destroy(CurrentCharacter.gameObject);
     }
     CurrentCharacter = Instantiate(CharacterBase);
 }
예제 #7
0
    void UpdateSword()
    {
        SwordController sc = gameObject.GetComponentInChildren <SwordController>();

        sc.UpdateColour(attackPower / 100);

        attacking = sc.UpdateSword(attacking, charging);
    }
예제 #8
0
 public virtual void PickUp(SwordController sword)
 {
     rb.bodyType = RigidbodyType2D.Kinematic;
     transform.DOKill();
     transform.SetParent(sword.bladePos);
     transform.localPosition = Vector3.zero;
     transform.localRotation = sword.transform.rotation;
     state = PickUpState.PickedUp;
 }
예제 #9
0
    private void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");

        sc = gameObject.GetComponentInChildren <SwordController>();

        r = GetComponent <MeshRenderer>();
        r.material.color = Color.green;
    }
예제 #10
0
    void Start()
    {
        _swordController = GetComponentInChildren <SwordController>();

        _inputActions = new PlayerInputAction();
        _inputActions.Enable();

        // attack
        _inputActions.Player.Attack.performed += _ => _swordController.SwingSword();
    }
예제 #11
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject other = collision.gameObject;

        if (other.CompareTag("Bad"))
        {
            SwordController sc = other.GetComponent <SwordController> ();
            health -= sc.damage;
        }
    }
예제 #12
0
    void Start()
    {
        bulletRenderer  = GetComponent <MeshRenderer>();
        gameManager     = gameManagerObject.GetComponent <GameMamager>();
        playerCharacter = GameObject.FindGameObjectWithTag("Player");
        gunTrans        = playerCharacter.GetComponentInChildren <GunController>();
        swordTrans      = playerCharacter.GetComponentInChildren <SwordController>();

        InvokeRepeating("hitPlayer", 3, 1);
    }
예제 #13
0
 private void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
     swordTrail.Stop();
 }
예제 #14
0
 void Awake()
 {
     /* Singleton */
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         DestroyImmediate(gameObject);
     }
     /* End of Singleton */
 }
예제 #15
0
    // Start is called before the first frame update
    void Start()
    {
        anim         = this.GetComponent <Animator>();
        input        = this.GetComponent <MoveController>();
        aimControl   = this.GetComponent <AimController>();
        swordControl = this.GetComponent <SwordController>();
        skinMeshList = GetComponentsInChildren <SkinnedMeshRenderer>();

        impulse = FindObjectOfType <CinemachineFreeLook>().GetComponent <CinemachineImpulseSource>();
        Volume        postVolume  = FindObjectOfType <Volume>();
        VolumeProfile postProfile = postVolume.profile;

        postProfile.TryGet <LensDistortion>(out distorsion);
    }
예제 #16
0
 private void CheckCollider(Collider c, bool isStay)
 {
     if (c.tag == enemy)
     {
         SwordController sword = c.GetComponent <SwordController>();
         if (sword)
         {
             if (sword.isAttacking && !sword.SetHit(this))
             {
                 TakeDamage(2);
             }
         }
         else if (!isStay)                   //Only sword attacks are valid for OnTriggerStay
         {
             TakeDamage(2);
         }
     }
 }
예제 #17
0
    public override void Initialize(GameObject obj)
    {
        if (swordTriggerable == null)
        {
            //GameObject player = GameObject.FindGameObjectWithTag(playerTag).transform.root.gameObject;
            swordTriggerable = obj.GetComponent <SwordTriggerable>();
            //No funciona pq esta disable la espada
            espadaGO = obj.transform.Find("Espada").gameObject;
            //espadaGO = GameObject.FindGameObjectsWithTag(espadaGameObjectTag)[0];
            //posiblie solucion al disable
            swordTriggerable.swordGO = espadaGO;

            swordController = espadaGO.GetComponentInChildren <SwordController>();
            swordTriggerable.swordController = swordController;

            Sword = swordController.SwordSc;
            swordTriggerable.sword = Sword;
        }
    }
예제 #18
0
    void Update()
    {
        Jump();

        if (Input.GetKeyDown(KeyCode.P))
        {
            SwordController sword = GetComponentInChildren <SwordController>();
            sword.SendMessage("SwingSword");
            swordsound.Play();
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            if (hat.transform.parent == this)
            {
                hat.SendMessage("Escape");
            }
        }
        if (winner)
        {
            winTime += Time.deltaTime;
        }
    }
예제 #19
0
    private void hitPlayer()
    {
        gunTrans   = playerCharacter.GetComponentInChildren <GunController>();
        swordTrans = playerCharacter.GetComponentInChildren <SwordController>();

        if (gunTrans != null && gunTrans.isActiveAndEnabled)
        {
            playerTransform = gunTrans.GetComponent <Transform>();
        }
        else if (swordTrans != null && swordTrans.isActiveAndEnabled)
        {
            playerTransform = swordTrans.GetComponent <Transform>();
        }

        float distance = Vector3.Distance(playerTransform.position, transform.position);

        distance = Mathf.Abs(distance);

        if (distance < enemyHitDistance)
        {
            // Debug.Log("player hit!");
            playerCharacter.GetComponent <PlayerContoller>().playerLife -= enemyHitDamag;
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        body                    = transform.Find("Body").gameObject;
        bodyController          = body.GetComponent <BodyController>();
        pAnim                   = body.GetComponent <Animator>();
        rbPlayer                = GetComponent <Rigidbody>();
        dirt                    = transform.Find("Dirt").gameObject;
        mainCamera              = GameObject.Find("Main Camera");
        swordObject             = transform.Find("Sword").gameObject;
        swordController         = swordObject.GetComponent <SwordController>();
        swordController.pScript = this;
        sound                   = GetComponent <AudioSource>();
        hpView                  = GameObject.Find("HP View").GetComponent <TextMeshProUGUI>();

        killsView = GameObject.Find("Kills View").GetComponent <TextMeshProUGUI>();


        Physics.gravity = Menu.gravity * gravityModifier;
        updateView();

        //initialSpeed = speed;

        SetBounds();
    }
예제 #21
0
 public override void PickUp(SwordController sword)
 {
     base.PickUp(sword);
     transform.localEulerAngles = Vector3.zero;
     transform.DOKill();
 }
예제 #22
0
 void Start()
 {
     sc = SWROD.GetComponent<SwordController>();
     SWROD.SetActive(false);
 }
예제 #23
0
 public override void PickUp(SwordController sword)
 {
     base.PickUp(sword);
 }