Ejemplo n.º 1
0
        public IJT808_0x0200_Custom_Factory SetMap3 <TJT808_0x0200_CustomBody3>() where TJT808_0x0200_CustomBody3 : JT808_0x0200_CustomBodyBase3
        {
            Type type         = typeof(TJT808_0x0200_CustomBody3);
            var  instance     = Activator.CreateInstance(type);
            var  attachInfoId = (ushort)type.GetProperty(nameof(JT808_0x0200_CustomBodyBase3.AttachInfoId)).GetValue(instance);

            if (Map3.ContainsKey(attachInfoId))
            {
                throw new ArgumentException($"{type.FullName} {attachInfoId} An element with the same key already exists.");
            }
            else
            {
                Map3.Add(attachInfoId, instance);
            }
            return(this);
        }
Ejemplo n.º 2
0
 public void SelectRight()
 {
     GetComponent <AudioSource>().PlayOneShot(audio_Clip[1]);
     if (Map2.transform.position == posMap2)
     {
         iTween.MoveTo(Map2, posMap1, 0.5f);
         Map2.GetComponent <SpriteRenderer>().enabled = false;
         img2.GetComponent <SpriteRenderer>().enabled = false;
         Map3.GetComponent <SpriteRenderer>().enabled = true;
         img3.GetComponent <SpriteRenderer>().enabled = true;
         if (player.levelGame != 6)
         {
             img3.GetComponent <SpriteRenderer>().sprite = imgSprite[player.levelGame];
         }
         else
         {
             img3.GetComponent <SpriteRenderer>().sprite = imgSprite[0];
         }
         iTween.MoveTo(Map3, posMap2, 0.5f);
         Map1.transform.position = posMap3;
         player.levelGame++;
         if (player.levelGame > 6)
         {
             player.levelGame = 1;
         }
         if (player.levelGame != 6)
         {
             Map1.GetComponent <SpriteRenderer>().sprite = mapSprite[player.levelGame];
         }
         else
         {
             Map1.GetComponent <SpriteRenderer>().sprite = mapSprite[0];
         }
         //levelNameText.text = "" + player.levelGame;
     }
     else if (Map1.transform.position == posMap2)
     {
         iTween.MoveTo(Map1, posMap1, 0.5f);
         Map1.GetComponent <SpriteRenderer>().enabled = false;
         img1.GetComponent <SpriteRenderer>().enabled = false;
         Map2.GetComponent <SpriteRenderer>().enabled = true;
         img2.GetComponent <SpriteRenderer>().enabled = true;
         if (player.levelGame != 6)
         {
             img2.GetComponent <SpriteRenderer>().sprite = imgSprite[player.levelGame];
         }
         else
         {
             img2.GetComponent <SpriteRenderer>().sprite = imgSprite[0];
         }
         iTween.MoveTo(Map2, posMap2, 0.5f);
         Map3.transform.position = posMap3;
         player.levelGame++;
         if (player.levelGame > 6)
         {
             player.levelGame = 1;
         }
         if (player.levelGame != 6)
         {
             Map3.GetComponent <SpriteRenderer>().sprite = mapSprite[player.levelGame];
         }
         else
         {
             Map3.GetComponent <SpriteRenderer>().sprite = mapSprite[0];
         }
         //levelNameText.text = "" + player.levelGame;
     }
     else if (Map3.transform.position == posMap2)
     {
         iTween.MoveTo(Map3, posMap1, 0.5f);
         Map3.GetComponent <SpriteRenderer>().enabled = false;
         img3.GetComponent <SpriteRenderer>().enabled = false;
         Map1.GetComponent <SpriteRenderer>().enabled = true;
         img1.GetComponent <SpriteRenderer>().enabled = true;
         if (player.levelGame != 6)
         {
             img1.GetComponent <SpriteRenderer>().sprite = imgSprite[player.levelGame];
         }
         else
         {
             img1.GetComponent <SpriteRenderer>().sprite = imgSprite[0];
         }
         iTween.MoveTo(Map1, posMap2, 0.5f);
         Map2.transform.position = posMap3;
         player.levelGame++;
         if (player.levelGame > 6)
         {
             player.levelGame = 1;
         }
         if (player.levelGame != 6)
         {
             Map2.GetComponent <SpriteRenderer>().sprite = mapSprite[player.levelGame];
         }
         else
         {
             Map2.GetComponent <SpriteRenderer>().sprite = mapSprite[0];
         }
         //levelNameText.text = "" + player.levelGame;
     }
 }
Ejemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Rigidbody2D clone;

        if (other.tag == "LeftDoor")
        {
            GameObject  player_left = GameObject.Find("play1");
            player_left pl          = player_left.GetComponent <player_left>();
            if (pl)
            {
                pl.health -= 1;
            }
            GameObject  ball = GameObject.Find("Ball");
            Rigidbody2D body = ball.GetComponent <Rigidbody2D>();
            body.velocity = new Vector2(0, 0);
            who           = Random.Range(0, 2);
            if (who == 0)
            {
                body.transform.position = new Vector3(13, 0, 0);
                GameObject cball = GameObject.Find("Ball(Clone)");
                if (cball != null)
                {
                    Destroy(cball);
                }
                GameObject portal = GameObject.Find("portal");
                Map3       m3     = portal.GetComponent <Map3>();
                if (m3 != null)
                {
                    Map3 p = portal.GetComponent <Map3>();
                    p.timer1 = 1.0f;
                }
            }
            else
            {
                body.transform.position = new Vector3(-13, 0, 0);
                GameObject cball = GameObject.Find("Ball(Clone)");
                if (cball != null)
                {
                    Destroy(cball);
                }
                GameObject portal = GameObject.Find("portal");
                Map3       m3     = portal.GetComponent <Map3>();
                if (m3 != null)
                {
                    Map3 p = portal.GetComponent <Map3>();
                    p.timer1 = 1.0f;
                }
            }
            resetplayer();
        }

        if (other.tag == "RightDoor")
        {
            GameObject   player_right = GameObject.Find("play2");
            player_right pr           = player_right.GetComponent <player_right>();
            AI_1         pa           = player_right.GetComponent <AI_1>();
            if (pr)
            {
                pr.health -= 1;
            }
            if (pa)
            {
                pa.health -= 1;
            }
            GameObject  ball = GameObject.Find("Ball");
            Rigidbody2D body = ball.GetComponent <Rigidbody2D>();
            body.velocity = new Vector2(0, 0);
            who           = Random.Range(0, 2);
            if (who == 0)
            {
                body.transform.position = new Vector3(13, 0, 0);
                GameObject cball = GameObject.Find("Ball(Clone)");
                Destroy(cball);
                GameObject portal = GameObject.Find("portal");
                Map3       m3     = portal.GetComponent <Map3>();
                if (m3 != null)
                {
                    Map3 p = portal.GetComponent <Map3>();
                    p.timer1 = 1.0f;
                }
            }
            else
            {
                body.transform.position = new Vector3(-13, 0, 0);
                GameObject cball = GameObject.Find("Ball(Clone)");
                Destroy(cball);
                GameObject portal = GameObject.Find("portal");
                Map3       m3     = portal.GetComponent <Map3>();
                if (m3 != null)
                {
                    Map3 p = portal.GetComponent <Map3>();
                    p.timer1 = 1.0f;
                }
            }
            resetplayer();
        }

        // if the ball touches the boarder
        if (other.tag == "Left")
        {
            transform.position = new Vector3(transform.position.x + 0.4f, transform.position.y, 0);
            _body.velocity     = new Vector2(_body.velocity.x * -1, _body.velocity.y);
        }
        if (other.tag == "Right")
        {
            transform.position = new Vector3(transform.position.x - 0.4f, transform.position.y, 0);
            _body.velocity     = new Vector2(_body.velocity.x * -1, _body.velocity.y);
        }
        if (other.tag == "Top")
        {
            transform.position = new Vector3(transform.position.x, transform.position.y - 0.4f, 0);
            _body.velocity     = new Vector2(_body.velocity.x, _body.velocity.y * -1);
        }
        if (other.tag == "Bottom")
        {
            transform.position = new Vector3(transform.position.x, transform.position.y + 0.4f, 0);
            _body.velocity     = new Vector2(_body.velocity.x, _body.velocity.y * -1);
        }
        if (other.tag == "portal")
        {
            float y = Random.Range(-10, 10);
            clone          = Instantiate(_body, _body.transform.position, _body.transform.rotation);
            clone.velocity = new Vector2(_body.velocity.x, _body.velocity.y + y);
        }
        if (other.tag == "bh2")
        {
            GameObject bh1 = GameObject.Find("BH1");
            if (_body.velocity.x > 0)
            {
                transform.position = new Vector3(bh1.transform.position.x + 1.5f, bh1.transform.position.y, bh1.transform.position.z);
            }
            else
            {
                transform.position = new Vector3(bh1.transform.position.x - 1.5f, bh1.transform.position.y, bh1.transform.position.z);
            }
        }
        if (other.tag == "bh1")
        {
            GameObject bh2 = GameObject.Find("BH2");
            if (_body.velocity.x > 0)
            {
                transform.position = new Vector3(bh2.transform.position.x + 1.5f, bh2.transform.position.y, bh2.transform.position.z);
            }
            else
            {
                transform.position = new Vector3(bh2.transform.position.x - 1.5f, bh2.transform.position.y, bh2.transform.position.z);
            }
        }
        if (other.tag == "zoom")
        {
            print(_body.velocity);
            _body.velocity /= 10;
            print(_body.velocity);
            z = 1;
        }

        // if the ball touches players
        player_left player_l = other.GetComponent <player_left>();

        if (player_l != null)
        {
            Rigidbody2D player_l_rb = player_l.GetComponent <Rigidbody2D>();
            touchPlayer(player_l_rb);
        }

        player_right player_r = other.GetComponent <player_right>();

        if (player_r != null)
        {
            Rigidbody2D player_r_rb = player_r.GetComponent <Rigidbody2D>();
            touchPlayer(player_r_rb);
        }

        AI_1 ai = other.GetComponent <AI_1>();

        if (ai != null)
        {
            touchPlayer(ai._body);
        }
    }
Ejemplo n.º 4
0
        public void Register(Assembly externalAssembly)
        {
            var types = externalAssembly.GetTypes().Where(w => w.BaseType == typeof(JT808_0x0200_CustomBodyBase)).ToList();

            foreach (var type in types)
            {
                var instance = Activator.CreateInstance(type);
                var attachid = (byte)type.GetProperty(nameof(JT808_0x0200_CustomBodyBase.AttachInfoId)).GetValue(instance);
                if (Map.ContainsKey(attachid))
                {
                    throw new ArgumentException($"{type.FullName} {attachid} An element with the same key already exists.");
                }
                else
                {
                    Map.Add(attachid, instance);
                }
            }

            var types2 = externalAssembly.GetTypes().Where(w => w.BaseType == typeof(JT808_0x0200_CustomBodyBase2)).ToList();

            foreach (var type in types2)
            {
                var instance = Activator.CreateInstance(type);
                var attachid = (ushort)type.GetProperty(nameof(JT808_0x0200_CustomBodyBase2.AttachInfoId)).GetValue(instance);
                if (Map2.ContainsKey(attachid))
                {
                    throw new ArgumentException($"{type.FullName} {attachid} An element with the same key already exists.");
                }
                else
                {
                    Map2.Add(attachid, instance);
                }
            }

            var types3 = externalAssembly.GetTypes().Where(w => w.BaseType == typeof(JT808_0x0200_CustomBodyBase3)).ToList();

            foreach (var type in types3)
            {
                var instance = Activator.CreateInstance(type);
                var attachid = (ushort)type.GetProperty(nameof(JT808_0x0200_CustomBodyBase3.AttachInfoId)).GetValue(instance);
                if (Map3.ContainsKey(attachid))
                {
                    throw new ArgumentException($"{type.FullName} {attachid} An element with the same key already exists.");
                }
                else
                {
                    Map3.Add(attachid, instance);
                }
            }

            var types4 = externalAssembly.GetTypes().Where(w => w.BaseType == typeof(JT808_0x0200_CustomBodyBase4)).ToList();

            foreach (var type in types4)
            {
                var instance = Activator.CreateInstance(type);
                var attachid = (byte)type.GetProperty(nameof(JT808_0x0200_CustomBodyBase4.AttachInfoId)).GetValue(instance);
                if (Map4.ContainsKey(attachid))
                {
                    throw new ArgumentException($"{type.FullName} {attachid} An element with the same key already exists.");
                }
                else
                {
                    Map4.Add(attachid, instance);
                }
            }
        }