상속: MonoBehaviour
예제 #1
0
        public void SetColor(Grapple.Drawing.Color color, float width)
        {
            var drawingColor = System.Drawing.Color.FromArgb(color.Alpha, color.Red, color.Green, color.Blue);

            pen = new Pen(drawingColor, width);
            brush = new SolidBrush(drawingColor);
        }
예제 #2
0
        public override void Update()
        {
            if (!this.isServerForObject)
            {
                return;
            }
            if (!this._stuck)
            {
                base.Update();
            }
            else if (this.swingOwner != null)
            {
                Thing ropeParent = (Thing)this.swingOwner.GetRopeParent((Thing)this);
            }
            if (!(this._owner is Grapple) || !this._inGun)
            {
                return;
            }
            Grapple owner = this._owner as Grapple;

            this.position      = owner.barrelPosition;
            this.depth         = owner.depth - 1;
            this.hSpeed        = 0.0f;
            this.vSpeed        = 0.0f;
            this.graphic.flipH = (double)owner.offDir < 0.0;
        }
예제 #3
0
 // Start is called before the first frame update
 void Start()
 {
     grapple    = GameObject.Find("Grapple").GetComponent <Grapple>();
     player     = GameObject.Find("PCollider");
     rb         = GetComponent <Rigidbody>();
     Can_Attack = true;
 }
예제 #4
0
    // Gets called on fire input
    private void Fire()
    {
        if (grapple == null)
        {
            // Just in case
            DistanceJoint2D joint = GetComponent <DistanceJoint2D>();
            if (joint != null)
            {
                Destroy(joint);
            }

            grapple = Game.InstantiatePrefab("Grapple", transform.position, transform).GetComponent <Grapple>();
        }
        else
        {
            // Just in case
            DistanceJoint2D joint = GetComponent <DistanceJoint2D>();
            if (joint != null)
            {
                Destroy(joint);
            }

            Destroy(grapple.gameObject);
        }
    }
예제 #5
0
    IEnumerator RespawnCoroutine(float spawnTime)
    {
        //Respawn Coroutine
        yield return(new WaitForSeconds(spawnTime));

        messageWindow.SetActive(true);
        //sightImage.SetActive(true);
        int playerIndex = Random.Range(0, playerModel.Length);
        int spawnIndex  = Random.Range(0, spawnPoints.Length);

        player = PhotonNetwork.Instantiate(playerModel[playerIndex].name, spawnPoints[spawnIndex].position, spawnPoints[spawnIndex].rotation, 0);

        // Scripts to run to the network
        PlayerHealth playerHealth = player.GetComponent <PlayerHealth>();
        PlugWire     plugWire     = player.GetComponent <PlugWire>();
        Grapple      grapple      = player.GetComponent <Grapple>();

        // Enabling networking on the scripts
        playerHealth.enabled = true;
        plugWire.enabled     = true;
        grapple.enabled      = true;

        playerHealth.RespawnEvent    += Respawn;
        playerHealth.AddMessageEvent += AddMessage;

        sceneCamera.enabled = false;
        if (spawnTime == 0)
        {
            AddMessage("Player " + PhotonNetwork.LocalPlayer.NickName + " Joined Game.");
        }
        else
        {
            AddMessage("Player " + PhotonNetwork.LocalPlayer.NickName + " Respawned.");
        }
    }
예제 #6
0
 // Use this for initialization
 void Start()
 {
     _hingeJoint          = GetComponent <HingeJoint2D>();
     _instanciatedGrapple = Instantiate(grapplePrefab);
     _instanciatedGrapple.transform.parent        = this.transform;
     _instanciatedGrapple.transform.localPosition = Vector3.zero;
     _instanciatedGrapple.origin = _hingeJoint;
 }
예제 #7
0
 void Start()
 {
     rb                = GetComponent <Rigidbody2D>();
     anim              = GetComponent <Animator>();
     cc                = GetComponent <CameraController>();
     sr_Component      = GetComponent <SpriteRenderer>();
     grapple_Component = GetComponent <Grapple>();
 }
예제 #8
0
 private void Awake()
 {
     gunShot       = GetComponent <AudioSource>();
     playerStat    = GetComponentInParent <PlayerStats>();
     playerAmmo    = GetComponentInParent <PlayerAmmo>();
     playerGrapple = GetComponentInParent <Grapple>();
     gunAnimation  = GetComponent <ProceduralGunAnimation>();
 }
예제 #9
0
    void Start()
    {
        allInstantiated = false;
        // instantiate hooks and player controller
        grapplingHook1 = Instantiate(grapplingHookPrefab);
        grapplingHook1.SetActive(false);
        grapple1        = grapplingHook1.GetComponent <Grapple>();
        grapple1.player = gameObject;

        grapplingHook2 = Instantiate(grapplingHookPrefab);
        grapplingHook2.SetActive(false);
        grapple2        = grapplingHook2.GetComponent <Grapple>();
        grapple2.player = gameObject;

        controller = GetComponent <PlayerController>();
        rb         = GetComponent <Rigidbody2D>();

        // instantiate hook indicators
        lIndicator = Instantiate(indicatorPrefab);
        rIndicator = Instantiate(indicatorPrefab);
        lIndicator.SetActive(false);
        rIndicator.SetActive(false);

        // instantiate aiming reticles
        lReticle = Instantiate(reticlePrefab);
        rReticle = Instantiate(reticlePrefab);
        lReticle.SetActive(false);
        rReticle.SetActive(false);

        // set hook outline
        Transform[] outline1 = grapplingHook1.transform.Find("Visual").gameObject.GetComponentsInChildren <Transform>();
        if (outline1.Length >= 5)
        {
            outline1[1].localPosition = outlineOffset * Vector3.up;
            outline1[2].localPosition = -outlineOffset * Vector3.up;
            outline1[3].localPosition = outlineOffset * Vector3.right;
            outline1[4].localPosition = -outlineOffset * Vector3.right;
        }
        Transform[] outline2 = grapplingHook2.transform.Find("Visual").gameObject.GetComponentsInChildren <Transform>();
        if (outline2.Length >= 5)
        {
            outline2[1].localPosition = outlineOffset * Vector3.up;
            outline2[2].localPosition = -outlineOffset * Vector3.up;
            outline2[3].localPosition = outlineOffset * Vector3.right;
            outline2[4].localPosition = -outlineOffset * Vector3.right;
        }

        // instantiate ropes
        // rope1 = Instantiate(ropePrefab);
        // ManageRope manager1 = rope1.GetComponent<ManageRope>();
        // manager1.player = gameObject;
        // manager1.hook = grapplingHook1;
        // rope2 = Instantiate(ropePrefab);
        // ManageRope manager2 = rope2.GetComponent<ManageRope>();
        // manager2.player = gameObject;
        // manager2.hook = grapplingHook2;
        allInstantiated = true;
    }
예제 #10
0
 public GrappleHook(Grapple ownerVal)
     : base(0.0f, 0.0f)
 {
     this._owner          = ownerVal;
     this.graphic         = new Sprite("harpoon");
     this.center          = new Vec2(8f, 8f);
     this.collisionOffset = new Vec2(-5f, -1.5f);
     this.collisionSize   = new Vec2(10f, 5f);
 }
예제 #11
0
	float effectsDisplayTime = 0.2f;                // The proportion of the timeBetweenBullets that the effects will display for.

	// Use this for initialization
	void Awake () 
	{
        grappleScript = GetComponentInParent<Grapple>();
		shootableMask = LayerMask.GetMask ("Shootable");
		gunLine = GetComponentInChildren <LineRenderer> ();
		gunAudio = GetComponent<AudioSource> ();
		gunLight = GetComponent<Light> ();
        kickBack = GetComponentInParent<KickBack>();
	}
예제 #12
0
    private void Start()
    {
        kb          = GetComponent <FPSKinematicBody>();
        groundCheck = GetComponent <FPSGroundCheck>();
        playerStats = GetComponent <PlayerStats>();
        grapple     = GetComponent <Grapple>();

        ConvertDecelerationPercentToUsableConstant();
        CalculateHorizontalBoostYOffset();
    }
 void Start()
 {
     grapple = hook.GetComponent <Grapple>();
     rope    = new List <GameObject>();
     // instantiate rope segments at appropriate intervals to form a maxDistance long rope
     for (float f = 0; f < grapple.maxDistance; f += segmentLength)
     {
         rope.Add(Instantiate(ropeSegmentPrefab, new Vector3(0, f, 0), Quaternion.identity, transform));
     }
     ropeLength = segmentLength * rope.Count;
 }
예제 #14
0
    private void Start()
    {
        GameObject player = GameObject.Find("player");

        look       = player.GetComponent <FPSLook>();
        grapple    = player.GetComponent <Grapple>();
        mainCamera = GameObject.Find("mainCamera").GetComponent <Camera>();
        image      = GetComponent <RawImage>();

        Hide();
    }
예제 #15
0
    private void Start()
    {
        GameObject player = GameObject.Find("player");

        grapple       = player.GetComponent <Grapple>();
        kinematicBody = player.GetComponent <FPSKinematicBody>();

        cameraComponent = GetComponent <Camera>();
        startFov        = cameraComponent.fieldOfView;
        fov             = startFov;
        targetFov       = fov;
    }
예제 #16
0
 public void SetGrapple(Grapple g)
 {
     if (grapple != null)
     {
         Destroy(grapple.gameObject);
     }
     grapple = g;
     if (grapple)
     {
         grapple.InitSwing(this, velocity);
     }
 }
예제 #17
0
    // Use this for initialization
    void Start()
    {
        footstepSoundLoc = GameObject.Find("FootstepSoundLoc").GetComponent <AudioSource>();
        rotation         = Camera.main.transform.eulerAngles;
        playerGrapple    = GetComponent <Grapple>();
        p_rigidbody      = GetComponent <Rigidbody>();
        jState           = JumpState.Grounded;
        Rigid            = GetComponent <Rigidbody>();
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
        playerCanJump    = true;
        FPGUN            = GameObject.Find("FP_Gun");
        GUN  = GameObject.Find("Gun");
        time = 0;
        getPickup("Gun Pickup");
        idle = true;
        if (hasGun)
        {
            if (is3D)
            {
                GameObject.Find("FP_Gun").SetActive(true);
            }
            else
            {
                GameObject.Find("Gun").SetActive(true);
            }
        }
        else
        {
            if (is3D)
            {
                GameObject.Find("FP_Gun").SetActive(false);
            }
            else
            {
                GameObject.Find("Gun").SetActive(false);
            }
        }

        if (!is3D)
        {
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.Confined;
        }

        //shotPoint = transform.Find("Camera/FP_Gun/Gun/FirePoint");
        //is3D = true;


        VShift = Vector3.zero;
        HShift = Vector3.zero;
    }
    void FindPlayer()
    {
        GameObject tmp = GameObject.FindGameObjectWithTag("Player");

        if (tmp != null)
        {
            playerTarget  = tmp.transform;
            playerGrapple = playerTarget.GetComponent <Grapple>();
        }
        else
        {
            Debug.Log("No Player Object Found.");
        }
    }
예제 #19
0
    // camera rotation effect on turning

    private void Awake()
    {
        // get reference
        Controls         = new Input_Default();
        playerController = Player.GetComponent <MechPlayerController>();
        grapple          = Player.GetComponent <Grapple>();

        // get input
        Controls.Player.Throttle.performed   += Throttle => throttle = (Throttle.ReadValue <float>());
        Controls.Player.LookAround.performed += LookAround => lookAround = (LookAround.ReadValue <Vector2>());
        Controls.Player.Grapple.performed    += grapplectx => grapple.StartGrapple();
        Controls.Player.Grapple.canceled     += grapplectx => grapple.CancleGrapple();
        Controls.Player.jump.performed       += jump => playerController.Jump();
    }
예제 #20
0
 // Use this for initialization
 void Start()
 {
     instance              = this;
     hookPosition          = GameObject.Find("HookedIndicator").transform.Find("Sprite").gameObject;
     grappleHitAudio       = GameObject.Find("Audio").transform.Find("GrappleHit").GetComponent <AudioSource> ();
     grappleShootAudio     = GameObject.Find("Audio").transform.Find("GrappleShoot").GetComponent <AudioSource> ();
     pointAngle            = PlayerControl.instance.pointAngle * Mathf.PI / 180f;
     transform.position    = hookPosition.transform.position;
     transform.eulerAngles = new Vector3(0f, 0f, pointAngle);
     origin = transform.position;
     PlayerControl.instance.hookObj = this;
     transform.rotation             = PlayerControl.instance.playerHook.transform.rotation;
     rope = Instantiate(grappleRope);
     grappleShootAudio.Play();
 }
예제 #21
0
        void OnCollisionEnter(Collision col)
        {
            Controller player    = GameManager.instance.GetPlayer(fromPlayer);
            Vector3    playerPos = player.transform.position + new Vector3(0, 1, 0);
            GameObject obj       = col.gameObject;

            if ((obj.tag == "Ground" || (obj.transform.parent != null && obj.transform.parent.tag == "Ground")) &&
                !player.ParkourComponent.Grappling && Vector3.Distance(playerPos, transform.position) <= maxGrappleDistance)
            {
                Grapple grapple = player.gameObject.AddComponent <Grapple>();
                grapple.Ground   = col.gameObject;
                grapple.Position = transform.position - col.gameObject.transform.position;
                player.ParkourComponent.Grappling = true;
            }
        }
예제 #22
0
    //Grabbing scripts we need from player
    void Awake()
    {
        myStats      = GetComponent <PlayerStats>();
        myUI         = GetComponentInChildren <PlayerUI>();
        myMove       = GetComponent <PlayerMovement>();
        weaponSprite = GetComponentInChildren <WeaponSpriteController>();
        grapple      = GetComponentInChildren <Grapple>();
        grapple.transform.localPosition = new Vector2();
        grapple.gameObject.SetActive(false);

        menu = GameObject.Find("MenuCanvas").GetComponent <MenuController>();

        //Test for adding a weapon to player
        loadWeapons();
        assignWeapon(0);
        assignWeapon(1);
    }
    void Awake()
    {
        myStats          = GetComponent <PlayerStats>();
        anim             = GetComponent <Animator>();
        r                = GetComponent <SpriteRenderer>();
        jumpCheck        = GetComponentInChildren <JumpCheck>();
        weaponSprite     = GetComponentInChildren <WeaponSpriteController>();
        grapple          = GetComponentInChildren <Grapple>();
        slopeCheckBottom = GetComponentInChildren <SlopeCheckBottom>();
        slopeCheckTop    = GetComponentInChildren <SlopeCheckTop>();
        movementCheck    = GetComponentInChildren <MovementCheck>();

        collisionMask = LayerMask.GetMask("Ground");

        calculateRays();
        updateRaycastOrigins();
    }
예제 #24
0
    void Start()
    {
        if (grappleGO)
        {
            grappleGO.SetActive(false);
            grapple = grappleGO.GetComponent <Grapple>();
            Physics2D.IgnoreCollision(GetComponent <Collider2D>(), grappleGO.GetComponent <Collider2D>());
        }
        lineRenderer = GetComponentInChildren <LineRenderer>();
        rb2d         = GetComponent <Rigidbody2D>();

        source     = GetComponent <AudioSource>();
        col        = GetComponent <Collider2D>();
        shootSound = Resources.Load <AudioClip>("Audio/SFX/ShootSound");
        arrow      = transform.Find("Aim").GetChild(0);
        playerInfo = GetComponent <PlayerInfo>();
    }
예제 #25
0
    private void Awake()
    {
        mesh        = GetComponent <MeshFilter>().sharedMesh;
        vertexCount = mesh.vertexCount;

        initialVertices = mesh.vertices;

        vertexSwapA = new Vector3[vertexCount];
        vertexSwapB = new Vector3[vertexCount];

        vertexSwap = vertexSwapA;

        GameObject player = GameObject.Find("player");

        grapple = player.GetComponent <Grapple>();
        look    = player.GetComponent <FPSLook>();
    }
예제 #26
0
 public void CheckRockAttach(Grapple bh)
 {
     if (bh.grappleShooter.gameObject != activePlayer)
     {
         for (int i = 0; i < playerList.Length; i++)
         {
             if (bh.grappleShooter.gameObject == playerInfoList[i].gameObject)
             {
                 SwitchMainPlayer(i);
                 //Debug.Log("here");
                 pulling = true;
             }
             else
             {
                 playerInfoList[i].GetComponent <GrappleShooter>().Detach();
             }
         }
     }
 }
    void Update()
    {
        //grapple code
        if (Input.GetMouseButtonDown(1))
        {
            //only allow one grappling hook to exist at once
            if (grappleInst)
            {
                grappleInst.breakGrapple();
                Destroy(grappleInst.gameObject);
            }

            if (!is2D)
            {
                //Debug.Log(Input.mousePosition + ", " + GetWorldPositionOnPlane(Input.mousePosition, 0));
                mousePos = GetWorldPositionOnPlane(Input.mousePosition, 0);
                dir      = mousePos - transform.position;
                dir.z    = 0; //zero out depth just to make sure
            }
            else
            {
                mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                dir      = mousePos - transform.position;
                dir.z    = 0; //zero out depth just to make sure
            }


            grappleInst                = Instantiate(grapple, transform.position, Quaternion.identity) as Grapple;
            grappleInst.holder         = transform;
            grappleInst.playerMovement = playerMovement;
            grappleInst.launchGrapple(Vector3.ClampMagnitude(dir, 1));
        }

        //allow player to break grapple at any time
        if (grappleInst && (Input.GetKeyDown(breakKey) || Input.GetKeyDown(playerMovement.jump) ||
                            Input.GetKeyDown(playerMovement.moveLeft) || Input.GetKeyDown(playerMovement.moveRight)))
        {
            grappleInst.breakGrapple();
            Destroy(grappleInst.gameObject);
        }
    }
예제 #28
0
    // Start is called before the first frame update
    void Start()
    {
        // Instantiate two grapples - Make them children of each controller respectively
        leftGrapple  = Instantiate(leftGrapplePrefab, GameObject.FindGameObjectWithTag("leftController").transform);
        rightGrapple = Instantiate(rightGrapplePrefab, GameObject.FindGameObjectWithTag("rightController").transform);

        // Get references to grapple scripts
        left  = leftGrapple.GetComponent <Grapple>();
        right = rightGrapple.GetComponent <Grapple>();

        // Assign left controller to left grapple
        left.GetSource = SteamVR_Input_Sources.LeftHand;

        // Assign the right controller as the OTHER controller
        left.OtherGrapple = right;

        // Assign right controller to right grapple
        right.GetSource = SteamVR_Input_Sources.RightHand;

        // Assign the left controller as the OTHER controller
        right.OtherGrapple = left;
    }
    public void shootGrapple(Vector3 position)
    {
        if (grappleObject)
        {
            releaseGrapple();
        }

        if (grapplePrefab)
        {
            grappleObject = Instantiate(grapplePrefab);
        }
        else
        {
            grappleObject = new GameObject("grappleHost");
        }

        grappleObject.transform.parent   = transform;
        grappleObject.transform.position = Vector3.zero;

        grapple = grappleObject.AddComponent <Grapple>();
        grapple.shoot(this, position - transform.position);
    }
예제 #30
0
    public GameObject SpawnPlayer(Vector3 position, int i)
    {
        GameObject player;

        if (PlayerPrefs.GetInt("IsAI" + i) == 1)
        {
            player = Instantiate(AIPrefab, position, Quaternion.identity);
        }
        else
        {
            player = Instantiate(playerPrefab, position, Quaternion.identity);
        }
        GameObject gsGO = Instantiate(grappleShooter, position, Quaternion.identity);
        PlayerInfo pi   = player.GetComponent <PlayerInfo>();

        pi.PlayerNumber = i;
        GrappleShooter gs = player.GetComponent <GrappleShooter>();

        gs.grappleGO = gsGO;
        Grapple g = gsGO.GetComponent <Grapple>();

        g.grappleShooter = gs;
        return(player);
    }
예제 #31
0
 /// <summary>
 /// The grapple Hook will call this function to let the player know where to get pulled towards.  Could also concievably yank the player around
 /// HL barnacle style
 /// </summary>
 /// <param name='destination'>
 /// Point of attraction
 /// </param>
 /// <param name='thing'>
 /// Grappling hook that is doing the pulling
 /// </param>
 public void grabbed(Vector3 destination, Grapple thing)
 {
     now = state.PULLING;
     grappleAnchor = destination;
     grabby = thing;
 }
예제 #32
0
    // Update is called once per frame
    /// <summary>
    /// Update this instance.
    /// </summary>
    void Update()
    {
        CapsuleCollider physicall = (CapsuleCollider)this.GetComponent("CapsuleCollider");

        Ray mouseLine = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit stuff;

        //Debug.DrawRay(mouseLine.origin, mouseLine.direction, Color.red);

        //Debug.Log("Grabber is layer :" + (LayerMask.NameToLayer("grabber").ToString())+ " from " + Camera.mainCamera.ToString() + "originating"
        //	+ mouseLine.origin.ToString());

        //try to get the direction of movement from the mouse
        Vector2 screenHere = Camera.mainCamera.WorldToScreenPoint(this.transform.position);

        float mouseVector = Input.mousePosition.x - screenHere.x;

        //check for click action
        if(Input.GetMouseButtonDown(0) && !deployed)// && (now == state.SETTOJUMP || now == state.GRAPPLED))
        {

            //check for hit
            if(Physics.Raycast(mouseLine, out stuff, Mathf.Infinity, mouselayermask))
            {
                //check of type
                if(stuff.transform.tag == "mousePlane")
                {
                    //deploy grapple hook
                    Transform temp = (Transform)Object.Instantiate(launcher);
                    grabby = (Grapple)temp.GetComponent("Grapple");
                    grabby.passInfo(grappleRange, grappleSpeed, grappleReturnSpeed, handLocation, stuff.point, grappleFloatTime, this);

                    deployed = true;
        #if DEBUG
                    Debug.Log(stuff.transform.tag.ToString());
        #endif
                }

            }

        }

        if(Mathf.Abs(mouseVector) > mouseSpeedControlMax)
        {
            //cap the the distance
            mouseVector = mouseSpeedControlMax * (mouseVector/Mathf.Abs(mouseVector));
        }

        //scale the speed based of of the distance
        float speedScale = mouseVector/mouseSpeedControlMax;

        currentMovement.x = goSpeed * speedScale;

        oldFacing = facingRight;
        if(currentMovement.x > 0)
        {
            facingRight = true;
            if(oldFacing != facingRight)
                now = state.TURNING;
        }
        else if (currentMovement.x < 0)
        {
            facingRight = false;
            if(oldFacing != facingRight)
                now = state.TURNING;
        }

        //the mechanics of jumping
        //yes, the implication is that you can't turn while jumping
        if(now == state.TURNING)
        {
            currentMovement.x = 0;
            if(this.transform.localEulerAngles.y < 90 && facingRight)
            {
                now = state.FALLING;
            }
            else if(this.transform.localEulerAngles.y > 90 && !facingRight)
            {
                now = state.FALLING;
            }
        }
        else if(now == state.JUMPING)
        {
            if(now != last)
            {
                //start of jump, apply force
                currentMovement.y = JumpForce;

            }
            else
            {	//starting to fallllll
                float newSpeed = Time.deltaTime * -upGrav + currentMovement.y;
                if (newSpeed <= 0)
                {
                    now = state.FALLING;
                }
                //bumped head, fall.

                else if ((allCollisions & TOP)  > 0)
                {
        #if DEBUG
                    Debug.Log("Bonked Head, falling");
        #endif
                    newSpeed = 0;
                    now = state.FALLING;
                }

                currentMovement.y = newSpeed;
        #if DEBUG
                Debug.Log("Jumping at: " + currentMovement.y.ToString());
        #endif

            }
        }

        else if ( now == state.FALLING)
        {

            float newSpeed = Time.deltaTime * -downGrav + currentMovement.y;
            //started falling recently, this bit reduces airtime
            if (now != last)
            {
                newSpeed = -DownForce;
            }

            //hitting the ground is a good time to stop falling
            //if(isGrounded)
            if(((CharacterController)this.GetComponent("CharacterController")).isGrounded)
            {
                now = state.SETTOJUMP;
                newSpeed = 0;
            }
            currentMovement.y = newSpeed;
        #if DEBUG
            Debug.Log("Falling at: " + currentMovement.y.ToString());
        #endif

            //once away from the bar, allow for bar grab
            if(!nearBar && state2 == secondary.RELEASED)
            {
        #if DEBUG
                Debug.Log("...and Reset!");
        #endif
                state2 = secondary.NONE;
            }
        }

        else if( now == state.GRAPPLED)
        {
            //for testing purposes...
            //assuming lateral movement
            Vector3 slope = barEnd.transform.position - barStart.transform.position;
            slope.Normalize();
            currentMovement = currentMovement.x * slope;
        #if DEBUG
            Debug.Log("GRABBED");
        #endif
            if( Input.GetMouseButtonDown(1))
            {
        #if DEBUG
                Debug.Log("released!");
        #endif
                state2 = secondary.RELEASED;
                now = state.FALLING;
            }

            //end of the bar!
            if(transform.position.x > barEnd.transform.position.x || transform.position.x < barStart.position.x)
            {
                now = state.FALLING;
            }

            lastBar = prospectiveBar;
        }

        else if(now == state.SETTOJUMP)
        {
            state2 = secondary.NONE;
            if (!((CharacterController)this.GetComponent("CharacterController")).isGrounded)
            {
                now = state.FALLING;
            }

        }

        if (now == state.JUMPING && prospectiveBar == lastBar)
        {
            //do nothing, basically
        }
        else if(now == state.JUMPING || now == state.FALLING)
        {
            //should I grab a bar?  Where should I stick if I do?
            if(nearBar && state2 != secondary.RELEASED && now != state.GRAPPLED)
            {
        #if DEBUG
                Debug.Log("latched...");
        #endif

                Vector3 tempstuff = new Vector3(0,0,0);
                tempstuff = Vector3.Lerp(barStart.position, barEnd.position, (this.transform.position.x - barStart.transform.position.x)/(barEnd.transform.position.x - barStart.transform.position.x));
                tempstuff -= transform.Find("handLocation").transform.position - this.transform.position;

                //Debug.Log("at: " + this.transform.position.ToString() + " Warping to: " + tempstuff.ToString());
                this.transform.position = tempstuff;

                //move the hand to line up with the bar.
                //TEST: make it go to start

                //change the state to recognize the gwapplin'
                now = state.GRAPPLED;
            }
        }
        else if(now == state.PULLING)
        {
            if(last != state.PULLING)
            {
                grappleOld = this.transform.position;
            }

            length += grappleSpeed * Time.deltaTime;

            this.transform.position = Vector3.Lerp(grappleOld, grappleAnchor, length);

            if( length >= 1)
            {
                length = 0;
                now = state.FALLING;
                this.retracted();
                Destroy(grabby.gameObject);

            }
        }

        if(facingRight && this.transform.localEulerAngles.y != 0)
        {
            this.transform.RotateAroundLocal(Vector3.up, -turnRate * Time.deltaTime);
            if ((this.transform.localEulerAngles.y > 350 || this.transform.localEulerAngles.y < 10) )
            {
                tempRotation = this.transform.localEulerAngles;
                tempRotation.y = 0;
                this.transform.localEulerAngles = tempRotation;
                //Debug.Log("derp" + this.gameObject.transform.localEulerAngles.ToString());
            }
        }
        else if (!facingRight && !(this.transform.localEulerAngles.y > 170 && this.transform.localEulerAngles.y < 190))
        {
            this.transform.RotateAroundLocal(Vector3.up, turnRate * Time.deltaTime);
            if (this.transform.localEulerAngles.y > 170 && this.transform.localEulerAngles.y < 190)
            {
                tempRotation = this.transform.localEulerAngles;
                tempRotation.y = 180;
                this.transform.localEulerAngles = tempRotation;
                Debug.Log(this.gameObject.transform.localEulerAngles.ToString());
            }
        }

        //this.transform.position += currentMovement * Time.deltaTime;
        CharacterController mover = (CharacterController)this.GetComponent("CharacterController");

        if(!(now == state.PULLING))
        mover.Move(currentMovement * Time.deltaTime);
        #if DEBUG
        //Debug.Log(currentMovement.ToString() + " , " + this.transform.position.ToString());
        #endif
        //physicall.velocity = currentMovement * Time.deltaTime;
        //Debug.Log("actually movintg: " + (physicall.position + currentMovement * Time.deltaTime).ToString());

        //physicall.AddForce(currentMovement);

        last = now;
    }
예제 #33
0
 private void Start()
 {
     grapple     = GameObject.Find("player").GetComponent <Grapple>();
     seekerImage = GetComponent <Image>();
 }
예제 #34
0
 void Start()
 {
     myGrap = GetComponentInParent <Grapple>();
 }
예제 #35
0
    void Start()
    {
        Si_Grappple = this;
        goPlayer = this.gameObject;
        rb = GetComponent<Rigidbody>();
        isGrappling = false;

        /*foreach (Transform child in transform)
        {
            if (child.name == "GrappleParticle")
            {
                grappleParticleObject = child.gameObject;
            }
        }*/
        grapplePaticleSystem = grappleParticleObject.GetComponent<ParticleSystem>();
    }