예제 #1
0
    private movements playerCtrl;    // Reference to the PlayerControl script.
    //	private HeroVida Alive;
    //private Animator anim;					// Reference to the Animator component.


    void Awake()
    {
        // Setting up the references.
        //anim = transform.root.gameObject.GetComponent<Animator>();
        playerCtrl = transform.root.GetComponent <movements>();
        //Alive = GetComponent <HeroVida>();
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        timeRemaining -= Time.deltaTime;

        if (timeRemaining < 0)
        {
            timeRemaining = 5f;



            int x = SendSerial.sendAndReceive("5"); //make 5 later

            string spriteName = "ts_" + x.ToString();



            //Sprite tsSprite = Resources.Load(spriteName, typeof(Sprite)) as Sprite;

            //GetComponent<SpriteRenderer>().sprite = tsSprite;
            img.sprite = sprites[x];
            print(x + " was just recieved, nice");



            if (x == 6 && running == false)
            {
                running = true;

                GameObject theDude    = GameObject.Find("Y_Bot");
                movements  transClass = (movements)theDude.GetComponent(typeof(movements));
                transClass.changeTheDude();
            }
        }
    }
예제 #3
0
    void OnCollisionEnter2D(Collision2D  other)
    {
        try{
            //anim.SetTrigger("Attack");
            if (other != null && other.gameObject != null && other.gameObject.tag == "Enemy") {
                movementScript = other.gameObject.GetComponent<movements>();
                movementScript.collision = true;
                Collider2D collider = other.collider;
                if(collider.name.Contains("Enemy"))
                {
                    movementScript.collisionRight = other.gameObject.GetComponent<Rigidbody2D>().position.x >
                        this.gameObject.GetComponent<Rigidbody2D>().position.x;
                    movementScript.collisionUp = other.gameObject.GetComponent<Rigidbody2D>().position.y >
                        this.gameObject.GetComponent<Rigidbody2D>().position.y;
                }
            }
            if(other != null && other.gameObject != null && other.gameObject.tag == "Player")
            {
                //Debug.Log("Gerad!!!! movementScript.playerCollision1: " + movementScript.playerCollision);
                //GameObject player = GameObject.FindGameObjectsWithTag("Player")[0];
                //enemyAttributes.Engaged = true;
                //enemyAttributes.Health -= 10;
                //if(enemyAttributes.Health <= 0){
                //	Destroy(enemyAttributes.gameObject);
                //}
                //Debug.Log(other.name + ": " + enemyAttributes.Health);

            }
        }catch(MissingReferenceException ex){

        }
        /*Vector2 enemyPosition = GetComponent<Rigidbody2D> ().position;
        float x;
        float y;
        if (enemyPosition.x >= other.attachedRigidbody.position.x) {
            x = -1;
        } else {
            x = 1;
        }
        if (enemyPosition.y >= other.attachedRigidbody.position.y) {
            y = -1;
        } else {
            y = 1;
        }

        Vector2 movement = new Vector3 (x, y);
        float speed = movements.GetSpeed ();
        GetComponent<Rigidbody2D> ().velocity = movement * speed;
        GetComponent<Rigidbody2D> ().position = new Vector2
            (
                Mathf.Clamp (GetComponent<Rigidbody2D> ().position.x, -5.0f, 5.0f),
                Mathf.Clamp (GetComponent<Rigidbody2D> ().position.y, -5.0f, 5.0f)
                );*/
        //Debug.Log ("Trigger Hit");
        /*if (movements.getEngaged()) {
            Vector2 movement = new Vector3 (moveHorizontal, moveVertical);
            GetComponent<Rigidbody2D> ().velocity = movement * speed;
        }*/
    }
예제 #4
0
 // Use this for initialization
 void Awake()
 {
     anime           = GetComponent <Animator>();
     GunScript       = GetComponent <Gun> ();
     MovementsScript = GetComponent <movements> ();
     //CheckAlive ();
     currentHealth         = startingHealth;
     healthSlider.maxValue = startingHealth;
     healthSlider.value    = currentHealth;
 }
예제 #5
0
 protected GameScene(IntPtr handle) : base(handle)
 {
     fetch    = new setup1();
     data     = new fetch_data();
     move     = new movements();
     player1  = new Sprite.Entity(fetch.p1());
     sprites  = new Sprite[10, 10, 3];
     Nextmove = false;
     //accelx = 0;
     //accely = 0;
     Height             = Frame.Size.Height;
     Width              = Frame.Size.Width;
     bg                 = SKSpriteNode.FromImageNamed("background/background");
     player1.spriteNode = SKSpriteNode.FromImageNamed(player1.spritef);
     //p1 = SKSpriteNode.FromImageNamed("sprites/player/p1front");
 }
예제 #6
0
 void Start()
 {
     playerScript = player.GetComponent<movements>();
 }
예제 #7
0
 void Start()
 {
     playerScript = player.GetComponent <movements>();
 }
예제 #8
0
 var(movements, state, enemies) = message;
예제 #9
0
 void Start()
 {
     CircleCollider2D collider = GetComponent<CircleCollider2D> ();
     //collider.radius = seperation;
     //AI_Attributes.Engaged = false;
     collision = false;
     movementScript = new movements ();
 }