public override void Behave(ref Dictionary<string, object> parameters)
 {
     if (this.targetVariable != null) {
     this.target = (GameObject) parameters[this.targetVariable];
       }
       if (this.targetRigidBody == null) {
     this.targetRigidBody = this.target.GetComponent<Rigidbody2D>();
       }
       Vector2 realDistance = new Vector2(this.distance, this.distance);
       Vector2 direction = this.targetRigidBody.velocity.normalized;
       RaycastHit2D hit = Physics2D.Raycast(new Vector2(this.target.transform.position.x, this.target.transform.position.y + 0.5f), direction, this.distance, this.obstacleLayer);
       if (hit.collider != null) {
     realDistance = (Vector2)hit.point - (Vector2)this.target.transform.position;
       }
       Vector2 destinationPoint = new Vector2(this.target.transform.position.x, this.target.transform.position.y) + new Vector2(direction.x * Mathf.Abs(realDistance.x), direction.y * Mathf.Abs(realDistance.y));
       float xSize = renderer.bounds.size.x / 2f;
       float ySize = renderer.bounds.size.y / 2f;
       if (direction.x < 0) {
     destinationPoint.x += xSize;
       } else if (direction.x > 0) {
     destinationPoint.x -= xSize;
       }
       if (direction.y < 0) {
     destinationPoint.y += ySize;
       } else if (direction.y > 0) {
     destinationPoint.y -= ySize;
       }
       this.gameObject.transform.position = destinationPoint;
 }
 public KeepInsideBoundsBehaviour(GameObject gameObject, string minPositionVariable, string maxPositionVariable)
     : base(gameObject)
 {
     this.rigidBody = this.gameObject.GetComponent<Rigidbody2D>();
       this.renderer = this.gameObject.GetComponent<Renderer>();
       this.minPositionVariable = minPositionVariable;
       this.maxPositionVariable = maxPositionVariable;
 }
 public override void Behave(ref Dictionary<string, object> parameters)
 {
     float speed = (float) parameters[this.speedVariable];
       float force = (float) parameters[this.forceVariable];
       float speedMultiplier = (float) parameters[this.speedMultiplierVariable];
       if (this.targetVariable != null) {
     this.target = (GameObject) parameters[this.targetVariable];
       }
       if (this.targetRigidBody == null) {
     this.targetRigidBody = this.target.GetComponent<Rigidbody2D>();
       }
       if (this.moveX) {
     if (!this.reachX) {
       float xSize = renderer.bounds.size.x / 2f;
       float xInput = 0f;
       if (this.target.transform.position.x > this.gameObject.transform.position.x + xSize) {
     xInput = 1f;
       } else if (this.target.transform.position.x < this.gameObject.transform.position.x - xSize) {
     xInput = -1f;
       } else {
     this.reachX = true;
       }
       this.MoveX(parameters, xInput, speed, force, speedMultiplier);
     } else {
       Vector3 velocity = this.rigidBody.velocity;
       velocity.x = targetRigidBody.velocity.x;
       this.rigidBody.velocity = velocity;
     }
       }
       if (this.moveY) {
     if (!this.reachY) {
       float ySize = renderer.bounds.size.y / 2f;
       float yInput = 0f;
       if (this.target.transform.position.y > this.gameObject.transform.position.y + ySize) {
     yInput = 1f;
       } else if (this.target.transform.position.y < this.gameObject.transform.position.y - ySize) {
     yInput = -1f;
       } else {
     this.reachY = true;
       }
       this.MoveY(parameters, yInput, speed, force, speedMultiplier);
     } else {
       Vector3 velocity = this.rigidBody.velocity;
       velocity.y = targetRigidBody.velocity.y;
       this.rigidBody.velocity = velocity;
     }
       }
 }
Esempio n. 4
0
 public MoveBehaviour(GameObject gameObject)
     : base(gameObject)
 {
     this.rigidBody = this.gameObject.GetComponent<Rigidbody2D>();
 }
 // Use this for initialization
 void Start()
 {
     animator = GetComponent<Animator>();
     rigidBody = GetComponent<Rigidbody2D>();
 }
Esempio n. 6
0
 private void Awake()
 {
     //onBallLaunch = new VectorTwoEvent();
     _rigidBody          = GetComponent <Rigidbody2D>();
     _rigidBody.bodyType = RigidbodyType2D.Kinematic;
 }
Esempio n. 7
0
 /// <summary>
 /// Used as the Start() method from a MonoBehaviour
 /// Use this for initialization
 /// </summary>
 protected override void start()
 {
     rigidBody = GetComponent<Rigidbody2D>();
 }
Esempio n. 8
0
    private Rigidbody2D rb2d;                                                  // creates a variable to our rigidbody.

    void Start()
    {
        Player.GetComponent <InvertedCharacterController>().enabled = false; // calls upon the script we want that is attached to what gameobject we want.
        otherplayer.GetComponent <NormalCharacterController>();
        rb2d = GetComponent <Rigidbody2D>();                                 // calls upon our rigidbody from the editor.
    }
Esempio n. 9
0
 // Start is called before the first frame update
 private void Awake()
 {
     rb        = GetComponent <Rigidbody2D>();
     direction = transform.right;
     Destroy(gameObject, 4f);
 }
Esempio n. 10
0
 public ApplyForceBehaviour(GameObject gameObject)
     : base(gameObject)
 {
     this.rigidBody = this.gameObject.GetComponent<Rigidbody2D>();
       this.direction = Vector2.zero;
 }
Esempio n. 11
0
 void Start()
 {
     EnemyRB = GetComponent <Rigidbody2D>();
 }
Esempio n. 12
0
 private void Start()
 {
     rigidBody       = gameObject.GetComponent <Rigidbody2D>();
     initialPosition = gameObject.transform.position;
 }
Esempio n. 13
0
 void Start()
 {
     rb       = GetComponent <Rigidbody2D>();
     animator = gameObject.GetComponent <Animator>();
 }
Esempio n. 14
0
 // Start is called before the first frame update
 void Start()
 {
     rigid = GetComponent <Rigidbody2D>();
 }
Esempio n. 15
0
 float distToTarget(Rigidbody2D target)
 {
     return((body.position - target.position).magnitude);
 }
Esempio n. 16
0
    private AudioSource playerAudio; // 사용할 오디오 소스 컴포넌트

    private void Start() {
        // 게임 오브젝트로부터 사용할 컴포넌트들을 가져와 변수에 할당
        playerRigidbody = GetComponent<Rigidbody2D>();
        animator = GetComponent<Animator>();
        playerAudio = GetComponent<AudioSource>();
    }
Esempio n. 17
0
 void Start()
 {
     rb  = GetComponent <Rigidbody2D>();
     col = GetComponent <Collider2D>();
 }
Esempio n. 18
0
 // Start is called before the first frame update
 void Start()
 {
     animator       = GetComponent <Animator>();
     rb2d           = GetComponent <Rigidbody2D>();
     spriteRenderer = GetComponent <SpriteRenderer>();
 }
Esempio n. 19
0
 // Start is called before the first frame update
 void Start()
 {
     rb = gameObject.GetComponent <Rigidbody2D>();
     animator.SetInteger("walkX", 0);
     animator.SetInteger("walkY", 0);
 }
Esempio n. 20
0
 // Use this for initialization
 void Start()
 {
     player = GetComponentInParent <playerController>();
     rgbd   = GetComponentInParent <Rigidbody2D>();
 }
 private void Awake()
 {
   this.m_RigidBody3D = this.GetComponent<Rigidbody>();
   this.m_RigidBody2D = this.GetComponent<Rigidbody2D>();
   this.m_CharacterController = this.GetComponent<CharacterController>();
   this.m_PrevPosition = this.transform.position;
   this.m_PrevRotation = this.transform.rotation;
   this.m_PrevVelocity = 0.0f;
   if (!this.localPlayerAuthority)
     return;
   this.m_LocalTransformWriter = new NetworkWriter();
 }
 // Start is called before the first frame update
 void Start()
 {
     anim = GetComponent <Animator>();
     rb   = GetComponent <Rigidbody2D>();
 }
Esempio n. 23
0
    void shipCheckAndStart()
    {
        rb = gameObject.GetComponent <Rigidbody2D>();

        if (rb == null)
        {
            gameObject.AddComponent <Rigidbody2D>();
            rb = GetComponent <Rigidbody2D>();
        }

        if (_manager == null)
        {
            _manager = GameObject.FindGameObjectWithTag("manager");
        }

        if (canvas == null)
        {
            canvas = GameObject.FindGameObjectWithTag("canvas");
        }

        if (player == null)
        {
            player = GameObject.FindGameObjectWithTag("Player");
        }

        rb.gravityScale = 0f;
        sc = _manager.GetComponent <scoreManager>();

        shootTimer = 0.0f;
        lifetime   = Screen.height / 10;
        height     = -(500);

        shipName = gameObject.name;

        switch (shipName)
        {
        case "goldShip":
        case "goldShip(Clone)":
            health = 3;
            speed  = Screen.height / 13.7f;
            score  = 200.0f;
            break;

        case "fushiaShip(Clone)":
        case "fushiaShip":
            health = 4;
            speed  = Screen.height / 14.0f;
            score  = 400.0f;

            if (cannon == null)
            {
                cannon = gameObject.transform.GetChild(0).gameObject;
            }

            if (rayEnd == null)
            {
                rayEnd = gameObject.transform.GetChild(1).gameObject.transform;
            }

            rayStart = cannon.transform;

            break;

        case "redShip":
        case "redShip(Clone)":
            health  = 3;
            speed   = Screen.height / 14.3f;
            score   = 600.0f;
            ranBool = Random.Range(0, 2);

            if (ranBool == 1)
            {
                leftTurn  = true;
                rightTurn = false;
            }
            else
            {
                leftTurn  = false;
                rightTurn = true;
            }

            break;
        }
    }
Esempio n. 24
0
 private void OnEnable()
 {
     rb2d = GetComponent <Rigidbody2D>();
 }
Esempio n. 25
0
 // Use this for initialization
 void Start()
 {
     rb2d = GetComponent <Rigidbody2D>(); //check if there is a rigidbody2d component attached to it, if so, then rb2d = that rigidbody2d object
     anim = GetComponent <Animator>();    //check if there is a animator...
 }
Esempio n. 26
0
 // Use this for initialization
 void Start()
 {
     transform.position = new Vector3(4, -3, 0);
     character          = GameObject.Find("Character");
     thisBody           = GetComponent <Rigidbody2D>();
 }
Esempio n. 27
0
 private void Awake()
 {
     _rigidbody2D    = GetComponent <Rigidbody2D>();
     _collider2D     = GetComponent <Collider2D>();
     _spriteRenderer = _playerT.GetComponent <SpriteRenderer>();
 }
 private void Awake()
 {
     body2D = GetComponent <Rigidbody2D>();
 }
Esempio n. 29
0
 // Use this for initialization
 void Start()
 {
     rbody  = GetComponent <Rigidbody2D>();
     jumppp = false;
     GameManager.Instance.MyCharacter = this;
 }
Esempio n. 30
0
 private void Start()
 {
     rb = GetComponent <Rigidbody2D>();
     I  = rb.transform.position;
 }
Esempio n. 31
0
 // Use this for initialization
 void Start()
 {
     rigidBody = GetComponent<Rigidbody2D>();
 }
 // Use this for setting the portal up.
 public void getReady()
 {
     rb = player.GetComponent <Rigidbody2D>();
 }
 public UpdateVelocityBehaviour(GameObject gameObject, Vector2 multiplier)
     : base(gameObject)
 {
     this.rigidBody = this.gameObject.GetComponent<Rigidbody2D>();
       this.multiplier = multiplier;
 }
Esempio n. 34
0
 // Use this for initialization
 void Start()
 {
     curKillTimer = maxKillTimer;
     myRigidbody  = GetComponent <Rigidbody2D>();
     myRigidbody.AddForce(new Vector2(throwPowerX, throwPowerY), ForceMode2D.Impulse);
 }
Esempio n. 35
0
 public override void Reset()
 {
     this.targetRigidBody = null;
 }
Esempio n. 36
0
 // Start is called before the first frame update
 void Awake()
 {
     rigidbodyRef = GetComponent <Rigidbody2D>();
     Destroy(this.gameObject, 30);
 }
 public override void Reset()
 {
     this.targetRigidBody = null;
       this.reachX = false;
       this.reachY = false;
 }
Esempio n. 38
0
 // Start is called before the first frame update
 void Start()
 {
     playableSprite = GetComponent <SpriteRenderer>();
     playableObject = GetComponent <Rigidbody2D>();
 }
Esempio n. 39
0
    void CheckKey()
    {
        float   speed     = _mPlayerRobot.MoveSpeed;
        Vector2 direction = Vector2.zero;


        Rigidbody2D r2d = GetComponent <Rigidbody2D>();

        if (Input.GetKey(KeyCode.W))
        {
            direction += new Vector2(0, speed * Time.deltaTime);
        }
        else if (Input.GetKey(KeyCode.S))
        {
            direction += new Vector2(0, -speed * Time.deltaTime);
        }



        if (Input.GetKey(KeyCode.A))
        {
            direction += new Vector2(-speed * Time.deltaTime, 0);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            direction += new Vector2(speed * Time.deltaTime, 0);
        }

        if (direction != Vector2.zero)
        {
            transform.Translate(direction);
            Anim.SetInteger("IdeaAngleType", 0);
            Anim.SetInteger("RunAngleType", CheckDitection());
        }
        else
        {
            Anim.SetInteger("IdeaAngleType", CheckDitection());
            Anim.SetInteger("RunAngleType", 0);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (!_mPlayerRobot.IsUseCore && !_isFastMoveCd)
            {
                if (direction == Vector2.zero)
                {
                    return;
                }

                speed = _mPlayerRobot.SpecialSpeed;
                StartCoroutine(FastMoveToPosition(speed, direction));
                StartCoroutine(FastMoveCd(FastMoveCD));
                r2d.velocity = Vector2.zero;
                return;
            }
        }
        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            FindObjectOfType <HockContral>().StartHock(FindObjectOfType <Camera>().ScreenToWorldPoint(Input.mousePosition));
        }

        //if (Input.GetKeyDown(KeyCode.Z))
        //{
        //    StartCoroutine(Bump(MoveSpeed * 2,20));
        //}
    }
Esempio n. 40
0
 void Start()
 {
     anima       = GetComponent <Animator> ();
     myRigidbody = GetComponent <Rigidbody2D> ();
     target      = GameObject.FindWithTag("Player").transform;
 }
 public RestoreGravityBehaviour(GameObject gameObject, string variableName)
     : base(gameObject)
 {
     this.rigidBody = this.gameObject.GetComponent<Rigidbody2D>();
       this.variableName = variableName;
 }
Esempio n. 42
0
	void Awake()
	{
		rb2d = GetComponent<Rigidbody2D>();
	}
Esempio n. 43
0
 void Awake()
 {
     body = GetComponent<Rigidbody2D> ();
 }
Esempio n. 44
0
    void Start()
    {
//		anim = GetComponent<Animator>();
        sheepController = FindObjectOfType <SheepController> ();
        rb2d            = gameObject.GetComponent <Rigidbody2D>();
    }