Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        Vector3    right = transform.TransformDirection(Vector3.right) * 20;
        Vector3    left  = transform.TransformDirection(Vector3.left) * 20;

        Debug.DrawRay(transform.position, right, Color.green);
        Debug.DrawRay(transform.position, left, Color.green);

        if (Input.GetKeyDown(KeyCode.LeftAlt) || Input.GetKeyDown(KeyCode.Mouse1))
        {
            //check to see if ship is near atat
            if (Physics.Raycast(transform.position, left, out hit, 20) || Physics.Raycast(transform.position, right, out hit, 20) && hit.collider.tag == "ATAT")
            {
                //create cable
                RopeScript cableScript = TowCable.GetComponent <RopeScript>();
                cableScript.target = hit.transform;
                cableScript.Attach();
            }
            else
            {
                TowCableOutOfRange.Play();
            }
        }
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            if (PM.destroyRope)
            {
                RemoveLineTarget();

                RopeScript ropeScript = GetComponentInParent <RopeScript>();
                if (ropeScript != null)
                {
                    ropeScript.RopeIsDestroyed();
                }
                DestroyNode();
            }
        }
        else if (other.CompareTag("Wall"))
        {
            RemoveLineTarget();
            DestroyNode();
            // RemoveLineTarget();

            //transform.parent = null;

            /* RemoveLineTarget();
             * gameObject.SetActive(false);*/
            /*alreadyUsed = true;
             * gameObject.SetActive(false);*/
            //RemoveLineTarget();
        }
    }
Ejemplo n.º 3
0
 public void CreateRope(GameObject target)
 {
     currentHook = ropePool.GetPooledObject();
     currentHook.transform.position = transform.position;
     currentHook.transform.rotation = Quaternion.identity;
     currentHook.SetActive(true);
     ropeScript = currentHook.GetComponent <RopeScript>();
     ropeScript.AddRope(target);
     PM.SetPlayerState(States.STATE_HOOKED);
 }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Awake()
 {
     Debug.Log("hello world!");
     if (FindObjectOfType <PhotonView>() == null)
     {
         Debug.Log("There aren't any players, debug mode ACTIVATE");
         GameObject kid = (GameObject)Instantiate(Resources.Load("Kid1"));
         GameObject.Find("Main Camera").GetComponent <CameraFollow>().target = kid.GetComponent <Controller2D>();
         RopeScript r = GameObject.Find("Grid").transform.Find("Ropes").GetComponent <RopeScript>();
         r.player       = kid;
         r.playerScript = kid.GetComponent <Player>();
         kid.GetComponent <Player>().forceMovement = true;
     }
 }
Ejemplo n.º 5
0
    public void CutRope(Vector3 cuttingPos, string cutter)
    {
        if (hook.currentProjectile != null)
        {
            if (hook.currentProjectile.GetComponent <Projectile>().hooked&& hook.playerMovement.playerNumber != cutter)
            {
                projectile.GetComponent <Projectile>().cut = true;

                lifeManager = hook.player.GetComponent <PlayerLifeManager>();
                lifeManager.CancelCleanLastAttacker();
                lifeManager.lastAttacker = cutter;
                lifeManager.CleanLastAttacker();

                //Rope to projectile
                GameObject cutRope = new GameObject();
                cutRope.AddComponent <LineRenderer>();
                cutRope.GetComponent <LineRenderer>().sortingLayerName = "Rope";
                cutRope.AddComponent <RopeScript>();
                RopeScript script = cutRope.GetComponent <RopeScript>();
                script.color              = hook.line.startColor;
                script.startPosition      = projectile.GetComponent <Projectile>().pivot;
                script.endPosition        = cuttingPos;
                script.firstConnectedBody = projectile;

                Instantiate(Resources.Load <ParticleSystem>("Prefabs/CutHook/Cut"), cuttingPos, transform.rotation);
                StartCoroutine(CancelVibration(Vibrations.PlayVibration("RopeCut", hook.playerMovement.playerInputDevice)));
                AudioManager.instance.PlaySound("ropeCut", hook.playerMovement.playerNumber + "Arrow");

                //Rope to player
                hook.ropeCut = true;
                GameObject cutRope2 = new GameObject();
                cutRope2.AddComponent <LineRenderer>();
                cutRope2.GetComponent <LineRenderer>().sortingLayerName = "Rope";
                cutRope2.AddComponent <RopeScript>();
                RopeScript script2 = cutRope2.GetComponent <RopeScript>();
                script2.connectedToPlayer  = true;
                script2.color              = hook.line.startColor;
                script2.startPosition      = hook.player.transform.position;
                script2.endPosition        = cuttingPos;
                script2.firstConnectedBody = hook.player;
                script2.hookScript         = hook;

                hook.DisableRope(true);
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     pos = this.gameObject.GetComponent<Transform>();
     ropeS = rope.GetComponent<RopeScript>();
 }