Inheritance: RaycastController
Example #1
0
	void Start () {
		controller = GetComponent<Controller2D> ();
		
		gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
		maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
		minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity)  * minJumpHeight);
	}
	//Note: Only the host can decide who got hit.
	public override void PowerActionEnter (GameObject player, Controller2D controller)
	{
		//cant stick to yourself again. also wait for response rpc before sending another one.
		if (controller.hasbomb || sentRPC) {
				return;
		}
		if (stickready) {
			//No need to confirm getting stuck if you're the server.
			if (Network.isServer)
            {
				if (Analytics.Enabled) 
                {
						GA.API.Design.NewEvent ("Players Stuck", player.transform.position);
				}
			
				networkView.RPC ("AttachToPlayer", RPCMode.Others, Network.player, firststick);
				//do this second so that firstick isnt changed until the end.
				AttachToPlayer (Network.player, firststick);
			} else {
				//We call this incase two people get stuck at around the same time, so that bombs dont
				//stick to different characters on different clients. 
				//Those with lower ping at a disadvantage (since their message gets there first)
				// but its probably not important for now.
								
				if (Analytics.Enabled) {
						GA.API.Design.NewEvent ("Bomb Transfers", player.transform.position);
				}

				sentRPC = true;
				networkView.RPC ("IThinkIGotStuck", RPCMode.Server);
			}
		}
		
	}
	public override void PowerActionEnter(GameObject player, Controller2D controller)
    {
        applyDmg = controller.GetComponent<PlayerStatus>();
		if (trapDuration > slowDuration)
        {
            if (!used)
            {
                used = true;

				player.rigidbody2D.drag = 0;
				applyDmg.Frozen();
                frozenEffect = (GameObject)Instantiate(Resources.Load("FrozenEffect"), player.transform.position, Quaternion.identity);
                frozenEffect.GetComponent<FrozenEffect>().player = controller;
                frozenplayer = controller;
                currentplayer = player;

                networkView.RPC("FreezeFollow", RPCMode.Others, Network.player);
				if(Analytics.Enabled){
					GA.API.Design.NewEvent("Times Frozen", player.transform.position);
				}
            }
        }
        else
        { 
            player.rigidbody2D.drag = 100f;
        }

	
		
	}
	public override void PowerActionEnter(GameObject player, Controller2D controller){
		insideExplosionRange = true;
		target = player;
		controller.powerInvulnerable = true;
        if (playerController == null)
            playerController = controller;
	}
Example #5
0
    void Start()
    {
        controller = GetComponent<Controller2D> ();

        gravity = -(2 * jumpHeight) / (timeToJumpApex * timeToJumpApex);
        jumpVelocity = Mathf.Abs(gravity * timeToJumpApex);
    }
Example #6
0
    //GameObject arm;
    void Start()
    {
        sounds = GetComponents<AudioSource> ();
        gruntSound = sounds [0];

        controller = GetComponent<Controller2D> ();
        animator = GetComponent<Animator> ();

        Cursor.SetCursor(cursorTexture, hotSpot, cursorMode);

        currentHealth = maxHealth;
        Debug.Log("Current Health: " + currentHealth);

        timeHit = Time.time;
        currentTime = Time.time;
        invincibilityTime = 1;

        direction = 1;
        _posX = transform.position.x;
        someScale = transform.localScale.x;

        gravity = -(2 * maxJumpHeight) / Mathf.Pow (timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt (2 * Mathf.Abs (gravity) * minJumpHeight);
        //print ("Gravity: " + gravity + "  Jump Velocity: " + maxJumpVelocity);

        pivot = transform.FindChild("Pivot").gameObject;
    }
Example #7
0
	void Start()
	{
		base.Start();
		controller = GetComponent<Controller2D>();
		spriteRenderer = GetComponent<SpriteRenderer>();
		enemySpeed = -enemySpeed;
	}
    void Start()
    {
        gameControl = GameObject.FindGameObjectWithTag("GameController");

        target = GameObject.FindGameObjectWithTag("Player").transform.GetComponent<Controller2D>();
        focusArea = new FocusArea (target.collider.bounds, focusAreaSize);
    }
	public override void PowerActionEnter (GameObject player, Controller2D controller)
	{
		if (Analytics.Enabled) {
			GA.API.Design.NewEvent ("BlackHole Deaths", player.transform.position);
		}
		controller.Die();
	}
Example #10
0
	void Start() {
		controller = GetComponent<Controller2D> ();

		gravity = -(2 * jumpHeight) / Mathf.Pow (timeToJumpApex, 2);
		jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
		print ("Gravity: " + gravity + "  Jump Velocity: " + jumpVelocity);
	}
Example #11
0
	void Start()
	{
		spriteRenderer = GetComponent<SpriteRenderer>();
		controller = GetComponent<Controller2D>();
		animator = GetComponent<Animator>();
		abilityManager = GetComponent<AbilityManager>();
		gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); // This is some physics formula :)
		maxJumpVelocity = Mathf.Abs(gravity * timeToJumpApex);
		minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
		controller.OnEnemyCollision += OnEnemyCollision;
		controller.OnCollectableCollision += OnCollectableCollision;

		// TODO: Update enemies list on Update method but with Enumerator on every 1-2 seconds
		// TODO: We may not need to update the list on every frame but just to find the new closest enemy.
		// TODO: The update for the list entries must be done via message when new enemy dies or spawns.
		Enemies = GameObject.FindGameObjectsWithTag("Enemy").ToList();

		foreach (GameObject enemy in Enemies)
		{
			Enemy enemyComponent = enemy.GetComponent<Enemy>();
			enemyComponent.OnDeath += OnEnemyDeath;
		}

		// Currently not working. Find a way to fix this or use mouse targeting
		//StartCoroutine(FindClosestEnemy());
	}
Example #12
0
 void Start()
 {
     audioSource = GetComponent<AudioSource> ();
     controller = GetComponent<Controller2D> ();
     shootTime = shootTimeNormal;
     direction = (Random.Range (1, 11) > 5 ? 1 : -1);
 }
Example #13
0
 protected virtual void Start()
 {
     player = GetComponent<Player>();
     input = player.InputPlayer;//GetComponent<InputController>();
     controller = GetComponent<Controller2D>();
     movementSpecial = GetComponent<OnMovementSpecial>();
 }
Example #14
0
    void Start() {
        controller = GetComponent<Controller2D>();
        SaveLoad.Load();
        Checkpoint.CheckpointsList = GameObject.FindGameObjectsWithTag("Checkpoint");

        Debug.Log("Player loaded checkpoint: " + SaveLoad.save.checkpoint);

        if (SaveLoad.save.checkpoint != "")
        {
            Checkpoint cp = GameObject.Find(SaveLoad.save.checkpoint).GetComponent<Checkpoint>();

            //cp.activated = true;
            cp.ActivateCheckpoint();

            this.Respawn();
        } 

        animator = GetComponent<Animator>(); //assign the Animator component on the player gameobject to our new reference var. 

        //set up jump physics
		gravity = -(2 * maxJumpHeight) / Mathf.Pow (timeToJumpApex, 2);
		maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
		minJumpVelocity = Mathf.Sqrt (2 * Mathf.Abs (gravity) * minJumpHeight);
		print ("Gravity: " + gravity + "  Jump Velocity: " + maxJumpVelocity);
	}
	public override void PowerActionEnter(GameObject player, Controller2D controller){
		if( on ){
			portalTo.GetComponent<TeleportPortals>().on = false;
			player.transform.position = portalTo.transform.position;
		}
		Debug.Log( "PORTAL" );
	}
Example #16
0
	void Update()
	{
        myTarget = camScript.target;
        if (enabled) {
			state = myAnimator.GetInteger("state");
			handleMovements();
			handleSpriteFacing();
			handleJumpHeight();
			handlePlayerMovementSpeed ();
			handleBodyCollisions();
			handleLayers();
		}

		if (!enabled && notOnNose) {
			velocity.x = 0;
			velocity.y += -10 * Time.deltaTime;
			myController.Move (velocity * Time.deltaTime);
			


		}

        if (myTarget.tag == "Player")
        {
            
            playerAnim.SetLayerWeight(2, 0);
        }
        else
        {
           
            playerAnim.SetLayerWeight(2, 1);
        }

    }
Example #17
0
    private void Start()
    {
        parent = get_enemy_parent();
        parent.set_type(EnemyType.GROUND);

        rigid_body = GetComponent<Rigidbody2D>();
        controller = GetComponent<Controller2D>();
    }
	public override void PowerActionEnter(GameObject player, Controller2D controller){

		if(Analytics.Enabled){
			GA.API.Design.NewEvent("Spike Death", player.transform.position);
		}
		
		controller.Die(DeathType.RIPPED);
	}
Example #19
0
 // Use this for initialization
 void Start()
 {
     player = transform.GetComponentInParent<Player>();
     controller = transform.GetComponentInParent<Controller2D>();
     anim = transform.GetComponent<Animator>();
     velocityX = player.velocity.x;
     cam = Camera.main;
 }
Example #20
0
    void Start()
    {
        myAnimator = GetComponent<Animator>();
		renderer = GetComponent<SpriteRenderer> ();
        myController = GetComponent<Controller2D>();
        gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = Mathf.Abs(gravity * timeToJumpApex);
    }
Example #21
0
 void Start()
 {
     // We set the controller and input handler for this object, as well as calculating the gravity and jump velocity.
     controller = GetComponent<Controller2D>();
     inputHandler = GetComponent<InputHandler>();
     gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
     jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
 }
Example #22
0
 void Start()
 {
     controller = GetComponent<Controller2D> ();
     left = true;
     //calculate the physics values based on the settings
     gravity = -(2 * jumpHeight) / Mathf.Pow (jumpTime, 2);
     jumpVelocity = Mathf.Abs (gravity) * jumpTime;
 }
 public void Start()
 {
     controller = GetComponent<Controller2D>();
     direction = new Vector2(-1, 0);
     startPosition = transform.position;
     velocity = new Vector3(moveSpeed, 0, 0);
     velocity.x *= direction.x;
 }
Example #24
0
    public void Initialise()
    {
        controller = GetComponent<Controller2D>();

        gravity = -(2 * maxJumpHeight) / Mathf.Pow (timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs (gravity) * timeToJumpApex;
        print ("Gravity: " + gravity + "Jump Velocity: " + maxJumpVelocity);
    }
Example #25
0
 public override void Start( ) {
     sprite = GetComponent<SpriteRenderer>();
     controller = GetComponent<Controller2D>();
     anim = GetComponent<Animator>();
     base.Start();
     maxJumpVelocity = Mathf.Abs( gravity ) * timeToJumpApex;
     minJumpVelocity = Mathf.Sqrt( 2 * Mathf.Abs( gravity ) * minJumpHeight );
 }
	public override void PowerActionEnter(GameObject player, Controller2D controller)
    {
        if(Analytics.Enabled){
			GA.API.Design.NewEvent("Explosion Death", transform.position);
		}

        controller.Die(DeathType.EXPLOSION);
	
	}
Example #27
0
 void Start()
 {
     controller = GetComponent<Controller2D>();
     gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
     jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
     Time.timeScale = 1;
     lives = 3;
     Anim = GetComponent<Animator>();
 }
Example #28
0
 void Start()
 {
     player = transform.GetComponentInParent<Player>();
     controller = GetComponent<Controller2D>();
     velocity.x = player.velocity.x;
     cam = Camera.main;
     anim = GetComponent<Animator>();
     renderer = GetComponent<SpriteRenderer>();
 }
Example #29
0
    public Vector2 playerInput; // Made public for CameraFollow, why hiddent? E11 end.

    //void Awake() { S = this; }

    // ??? ->RaycastController start() is virtual... @5:00 in E06 Tutorial Video SL ######
    public override void Start()
    {
        S = this;

        // So we can have a start in 'RaycastController' and any extended script.
        base.Start();

        collisions.faceDir = 1;
    }
 // Use this for initialization
 void Start()
 {
     controller = GetComponent<Controller2D>();
     jumped = false;
     isCooldown = false;
     canPull = false;
     gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
     jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
 }
Example #31
0
    // --------------------------------------------------------------------------------
    // Methods
    // --------------------------------------------------------------------------------

    void Start()
    {
        playerSpriteTransform = GetComponentInChildren <Transform>();
        playerSpriteRenderer  = GetComponentInChildren <SpriteRenderer>();
        playerAnimation       = GetComponent <PlayerAnimation>();

        controller     = GetComponent <Controller2D> ();
        boxCollider    = GetComponent <BoxCollider2D> ();
        colliderHeight = boxCollider.size.y;

        gravity = -40;
    }
Example #32
0
 public override void Start()
 {
     base.Start();
     controller = GetComponent <Controller2D>();
     if (attackPivot)
     {
         attackSpriteRenderer = attackPivot.transform.GetComponentInChildren <SpriteRenderer>();
         attackSpriteRenderer.transform.position   += Vector3.right * range / 2;
         attackSpriteRenderer.transform.localScale += new Vector3(range, range, range);
     }
     range *= collider.bounds.size.x;
 }
Example #33
0
    // Start is called before the first frame update
    void Awake()
    {
        seeker     = GetComponent <Seeker>();
        controller = GetComponent <Controller2D>();

        OnFinishPath += DefaultMethod;


        dmg = GetComponentInChildren <Damageable>();

        originPos = transform.position;
    }
Example #34
0
    //public SpriteRenderer spriteRenderer;
    //public Animator animator;

    void Start()
    {
        controller = GetComponent <Controller2D>();
        //spriteRenderer = GetComponent<SpriteRenderer>();
        //animator = GetComponent<Animator>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);

        isControlled = true;
    }
Example #35
0
    void Start()
    {
        controller = GetComponent <Controller2D> ();

        gravity      = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;

        camSize = Camera.main.aspect * Camera.main.orthographicSize;

        InvokeRepeating("runningSound", 0.00f, 0.3f);
        InvokeRepeating("slidingSound", 0.0f, 0.2f);
    }
Example #36
0
    // Use this for initialization
    void Start()
    {
        controller = GetComponent <Controller2D>();
        rb         = GetComponent <Rigidbody2D>();

        // Kinematic equations!
        timeToJumpApex  = Mathf.Sqrt((2 * maxJumpHeight) / -Physics2D.gravity.y);
        maxJumpVelocity = Mathf.Abs(Physics2D.gravity.y) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(Physics2D.gravity.y) * minJumpHeight);

        jumpsLeft = maxMultiJumps;
    }
    private void OnCollisionStay2D(Collision2D collision)
    {
        Controller2D controller = collision.gameObject.GetComponent <Controller2D>();

        if (controller == null)
        {
            return;
        }
        Vector3 impactDirection = collision.gameObject.transform.position - transform.position;

        Hurt(impactDirection);
    }
Example #38
0
 void Start()
 {
     ps           = null;
     player       = null;
     velocity     = Vector3.zero;
     c2d          = GetComponent <Controller2D>();
     partSys      = GetComponent <ParticleSystem>();
     audsrc       = GetComponent <AudioSource>();
     defaultColor = transform.GetChild(0).GetComponent <SpriteRenderer>().material.color;
     initialLoc   = transform.position;
     ReloadMaster.AddToMaster(this);
 }
Example #39
0
    void Awake()
    {
        controller  = GetComponent <Controller2D>();
        surrounding = GetComponent <SurroundingCheck>();
        chargeBar   = GetComponentInChildren <ChargeBar>();

        gravity   = -(2 * jumpHeight) / Mathf.Pow(jumpAccend, 2);
        jumpForce = Mathf.Abs(gravity * jumpAccend);

        input.pHorizontal = 1;
        state             = STATE.IDLE;
    }
Example #40
0
    void Start()
    {
        controller      = GetComponent <Controller2D>();
        gravity         = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpVelocity);

        sprite = GetComponent <SpriteRenderer>();
        anim   = GetComponent <Animator>();

        jumpRequest = false;
    }
Example #41
0
    /// <summary>
    /// Create and return an initialized state
    /// </summary>
    public virtual State Enter(Player owner)
    {
        this.owner = owner;
        controller = owner.controller;

        gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        controller.allowPassThrough = allowPassThrough;
        maxJumpVelocity             = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity             = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);

        return(this);
    }
Example #42
0
 // Start is called before the first frame update
 void Start()
 {
     gravity      = -(jumpHeight * 2) / (jumpTimeApex * jumpTimeApex);
     jumpVelocity = Mathf.Abs(gravity) * jumpTimeApex;
     controller   = GetComponent <Controller2D>();
     controller.maxWalkableAngle    = maxWalkAngle;
     controller.maxDescendableAngle = maxDescentAngle;
     print(gravity);
     animator             = GetComponent <Animator>();
     spriteRenderer       = GetComponent <SpriteRenderer>();
     spriteRenderer.color = characterTint;
 }
    public void Animate(Vector3 velocity, bool isClimbing, Controller2D controller)
    {
        velocity.x = Mathf.Abs(velocity.x);
        velocity.y = Mathf.Abs(velocity.y);

        animName  = "CharacterIdle";
        nextState = 0;

        if (!isClimbing && velocity.x > 0.2 && velocity.y < 0.2 && controller.collisions.below)
        {
            animName  = "CharacterWalking";
            nextState = 1;
            if (velocity.x > 4)
            {
                SoundManager.Instance.Run();
                animName = "CharacterRunning";

                nextState = 5;
            }
            else
            {
                SoundManager.Instance.Walk();
            }
        }
        else if (!isClimbing && velocity.y != 0)
        {
            animName = "CharacterJumping";

            nextState = 2;
        }
        else if (isClimbing && Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0)
        {
            animName = "CharacterClimbingIdle";

            nextState = 4;
        }
        else if (isClimbing && (velocity.x != 0 || velocity.y != 0))
        {
            SoundManager.Instance.Climb();
            animName = "CharacterClimbing";

            nextState = 3;
        }

        if (currentState != nextState)
        {
            currentState = nextState;
            animator.Play(animName);
            shadowAnimator.Play(animName);
            animator.SetInteger("State", nextState);
            shadowAnimator.SetInteger("State", nextState);
        }
    }
Example #44
0
    void Start()
    {
        Controller   = GetComponent <Controller2D>();
        gravity      = -(2 * jumpHeight) / Mathf.Pow(timeToApex, 2);
        jumpVelocity = Mathf.Abs(gravity) * timeToApex;
        // Animation = GetComponent<Animation>();
        minSpeed     = 30f;
        maxSpeed     = 105f;
        newTimeScale = Time.timeScale / slowFactor;

        this.gameObject.GetComponent <SpriteRenderer>().sprite = Moving;
    }
Example #45
0
 private void Start()
 {
     targetList = FindObjectsOfType <Controller2D>();
     foreach (Controller2D potentialTarget in targetList)
     {
         if (potentialTarget.gameObject.tag == "Player")
         {
             target = potentialTarget;
         }
     }
     focusArea = new FocusArea(target.collider.bounds, focusAreaSize);
 }
Example #46
0
    void Start()
    {
        controller = GetComponent <Controller2D>();

        /* jump height = initial velocity * time + (accelaration * time^2) / 2
         * /*  -> accelaration = jump height * 2 / time^2 */
        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity * timeToJumpApex);

        /* vf^2 = 2 * acc * displacement */
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
    }
Example #47
0
    protected override void OnUpdate()
    {
        controller       = GetComponent <Controller2D>();
        directionalInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        directionalInput.Normalize();


        state = state.Update(this, currentOrientation);
        print(state);

        AnimatorStuff();
    }
 // Use this for initialization
 void Start()
 {
     // get the player controller that handles movement and collisions
     controller = GetComponent <Controller2D>();
     // deltaMovement = velocityInitiial * time + (acceleration * time^2)/2
     // jumpHeight = (gravity * timeToJumpApex^2)/2
     gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
     // velFinal = velInitial + acceleration * time
     maxJumpVelocity = Mathf.Abs(gravity * timeToJumpApex);
     // velFinal^2 = velInit^2 + 2 * accleration * displacement
     minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
 }
Example #49
0
    protected override void Start()
    {
        base.Start();
        Controller = GetComponent <Controller2D>();
        MyAnimator = GetComponentInChildren <Animator>();
        stats      = new StatCollection(statTemplate);

        gravity = -(1 * maxJumpheight) / Mathf.Pow(timeToJumpApex, 2);

        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
    }
Example #50
0
    void Start()
    {
        controller = GetComponent <Controller2D>();

        //explanation of the following math: https://www.youtube.com/watch?v=PlT44xr0iW0&t=9s at around 6 minutes
        //can move the following code to update to mess with parameters in real time for when getting the right gravity, jumpping, etc.
        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        //math here: https://www.youtube.com/watch?v=rVfR14UNNDo&t=2s
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
        //Debug.Log("Gravity " + gravity + " jump velocity: " + maxJumpVelocity);
    }
Example #51
0
    void Start()
    {
        controller = GetComponent <Controller2D>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(Mathf.Abs(gravity) * minJumpHeight);
        print("Gravity: " + gravity + " Jump velocity: " + maxJumpVelocity);

        moveSpeedOld  = moveSpeed;
        moveDashSpeed = moveSpeed * dashFactor;
    }
Example #52
0
    // Use this for initialization
    void Start()
    {
        NPCController = gameObject.GetComponent <Controller2D>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(jumpSpeed, 2);          // calculate gravity
        maxJumpVelocity = Mathf.Abs(gravity) * jumpSpeed;                          // calculate jumpVelocity
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);      // calculate jumpVelocity

        NPCCanvas.SetActive(false);

        defaultTalkTimer = talkTimer;
    }
Example #53
0
    private void Start()
    {
        controller = GetComponent <Controller2D>();

        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);

        //print("Gravity: " + gravity + " Jump Velocity: " + maxJumpVelocity);

        playerActions = PlayerActions.CreateWithDefaultBindings();
    }
Example #54
0
    // Start is called before the first frame update
    void Awake()
    {
        controller = GetComponent <Controller2D>();
        sfx        = GetComponent <AudioSource>();
        if (sword)
        {
            sword.OnAttack     += AttackFreeze;
            sword.OnExitAttack += ExitAttackFreeze;
        }

        OnCollectCoin += AddCoins;
    }
Example #55
0
 private void Start()
 {
     //Setta le regole di gravità e trova il Controller2D
     controller = GetComponent <Controller2D>();
     playerAnimationController  = GetComponent <PlayerAnimationController>();
     originalGravity            = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
     maxJumpVelocity            = Mathf.Abs(originalGravity) * timeToJumpApex;
     minJumpVelocity            = Mathf.Sqrt(2 * Mathf.Abs(originalGravity) * minJumpHeight);
     contactFilter.useLayerMask = true;
     contactFilter.layerMask    = contactMask;
     contactFilter.useTriggers  = true;
 }
Example #56
0
 private void Start()
 {
     controller      = GetComponent <Controller2D>();
     platformManager = FindObjectOfType <PlatformManager>();
     gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
     maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
     minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
     audioSource     = GetComponent <AudioSource>();
     anim            = GetComponentInChildren <Animator>();
     jumpEffect      = GetComponent <JumpEffect>();
     input           = GetComponent <PlayerInput>();
 }
Example #57
0
 void Start()
 {
     doubleJumpParticle  = gameObject.transform.GetChild(6).GetChild(0).GetComponent <ParticleSystem>();
     tripleJumpParticle  = gameObject.transform.GetChild(7).GetChild(0).GetComponent <ParticleSystem>();
     paintingSoundSource = gameObject.transform.GetChild(8).GetComponent <AudioSource>();
     jumpSoundSource     = gameObject.transform.GetChild(9).GetComponent <AudioSource>();
     pullPush            = GetComponent <PullPush>();
     controller          = GetComponent <Controller2D>();
     abilities           = GetComponent <Abilities>();
     animator            = GetComponent <Animator>();        //ANIMATION
     createSplat         = GetComponent <CreateSplat>();
 }
Example #58
0
    void Start()
    {
        controller = GetComponent <Controller2D> ();

        //added this part now
        facingRight = true;


        gravity      = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        print("Gravity: " + gravity + " Jump Velocity: " + jumpVelocity);
    }
    //AnimationClip m_nowPlaying = null;

    // Use this for initialization
    void Start()
    {
        controller = GetComponent <Controller2D> ();
        //m_anim = GetComponent<SpriteAnim> ();
        m_animController = GetComponent <AnimController2D> ();

        animator = GetComponent <Animator> ();

        gravity         = (-2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = (Mathf.Abs(gravity) * timeToJumpApex);
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
        print("Gravity: " + gravity + "   Jump Velocity: " + maxJumpVelocity);
    }
Example #60
0
    private void Start()
    {
        currentHP = maxHP;

        controller = GetComponent <Controller2D>();
        aliveGO    = transform.Find("Vase").gameObject;
        player     = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
        gm         = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();


        aliveAnim = aliveGO.GetComponent <Animator>();
        rbAlive   = aliveGO.GetComponent <Rigidbody2D>();
    }