예제 #1
0
    void setTeam(TEAM team)
    {
        if (team == TEAM.NULL)
        {
            Debug.LogWarning("WARNING : TEAM cannot be set to null");
            return;
        }

        _team = team;
        foreach (Transform c in GetComponentsInChildren <Transform>())
        {
            if (c.GetComponent <DamagingPoint> () != null)
            {
                c.gameObject.layer = LayerHelper.GetAttackBoxLayer(team);
                c.GetComponent <DamagingPoint> ().SetDamagableLayers();
            }
            if (c.GetComponent <Hitbox> () != null)
            {
                c.gameObject.layer = LayerHelper.GetHitboxLayer(team);
            }
        }
        if (GetComponent <CharacterMovementHandler> () != null)
        {
//			print ("team : " + team);
            GetComponent <CharacterMovementHandler> ().SetLayerMask(LayerHelper.GetLayerMask(team));
        }
    }
예제 #2
0
    void instantiateProjectile(Vector3 position, Quaternion rotation, int photonViewID, int damage, TYPE type)
    {
        GameObject projectileInstance;        // = (GameObject)Instantiate (_arrowPrefab.gameObject);

        if (type == TYPE.ARROW_ROPE)
        {
            projectileInstance = (GameObject)Instantiate(_ropeArrowPrefab.gameObject);
        }
        else
        {
            projectileInstance = (GameObject)Instantiate(_arrowPrefab.gameObject);
        }

        projectileInstance.transform.position = position;

//		print (position.ToString ());
//		Debug.Break ();

        projectileInstance.transform.rotation = rotation;
        PhotonView    pv = PhotonView.Find(photonViewID);
        CombatHandler ch = pv.GetComponent <CombatHandler> ();

        Weapon weapon = projectileInstance.GetComponent <Weapon> ();

        weapon.SetOwner(ch);

        Arrow arrow = weapon.GetDamagingPoints()[0].GetComponent <Arrow>();

        //
        arrow.gameObject.layer = LayerHelper.GetAttackBoxLayer(ch.GetTeam());

        arrow.SetDamagableLayers();
        arrow.GetComponent <Collider> ().enabled = true;

        if (pv.isMine)
        {
            arrow.SetIsMine(true);
            weapon.SetDamage(damage);
        }
        else
        {
            arrow.SetIsMine(false);
        }



                #if UNITY_EDITOR
//		CameraController.CC.DevCutsceneCam();
//		CameraController.CC.CutsceneCamera.transform.SetParent(projectileInstance.transform);
//		CameraController.CC.CutsceneCamera.transform.localPosition = new Vector3(0.075f,0.04f,-0.3f);
//		CameraController.CC.CutsceneCamera.transform.localRotation = Quaternion.identity;
                #endif
    }
예제 #3
0
    private void ShootArrow()
    {
        //Calculate the damage of the arrow
        //If the current animation is DRAW, then the arrow is not at full power/speed
        //TODO: 50% threshold (arbitrary) for when the hand is not yet drawn
        if (_animator.GetCurrentAnimatorStateInfo(0).fullPathHash == AnimationHashHelper.STATE_DRAW)
        {
            aimTime = _animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
        }
        else if (_animator.GetCurrentAnimatorStateInfo(0).fullPathHash == AnimationHashHelper.STATE_AIM)           //Drawing is complete, currently 'AIM'ing
        {
            aimTime = 1f;
        }
        Transform direction = _shootingPoint;

        LayerMask  lm = LayerHelper.GetLayerMask(_combatHandler.GetTeam());
        RaycastHit hit;

        if (Physics.Raycast(CameraController.CC.CombatCamera.transform.position, CameraController.CC.CombatCamera.transform.forward, out hit, 100, lm))
        {
            direction.LookAt(hit.point);
        }
        else
        {
            direction.LookAt(CameraController.CC.CombatCamera.transform.forward * 100);
        }

//		ProjectileController.PC.InstantiateProjectile (direction.position, direction.rotation, _combatHandler.GetComponent<PhotonView>().viewID, (int)(aimTime * _damage), ProjectileController.TYPE.ARROW_ROPE);

        //
//		go = PhotonNetwork.Instantiate ("Rope_05", _combatHandler.transform.position, Quaternion.identity, 0);
        GameObject projectileInstance = PhotonNetwork.Instantiate("RopeArrow", direction.position, direction.rotation, 0);

//		projectileInstance.transform.position = direction.position;
//		projectileInstance.transform.rotation = direction.rotation;

//		PhotonView pv = PhotonView.Find (photonViewID);
        CombatHandler ch = _combatHandler;

        Weapon weapon = projectileInstance.GetComponent <Weapon> ();

        weapon.SetOwner(ch);

        Arrow arrow = weapon.GetDamagingPoints()[0].GetComponent <Arrow>();

        //
        arrow.gameObject.layer = LayerHelper.GetAttackBoxLayer(ch.GetTeam());

        arrow.SetDamagableLayers();
        arrow.GetComponent <Collider> ().enabled = true;
        arrow.SetIsMine(true);
        weapon.SetDamage(25);
    }
예제 #4
0
 public void EnableProtector(TEAM spawningTeam)
 {
     gameObject.layer = LayerHelper.GetAttackBoxLayer(spawningTeam);
 }