Example #1
0
    //const string ATK = "Joystick1Button0";

    //const string JUMP = "Joystick1Button1";

    //const string SHANJIN = "Joystick1Button2";

    //const string SKILL = "Joystick1Button3";



    // Use this for initialization
    void Start()
    {
        _body      = GetComponent <GameBody>();
        _jijiaBody = GetComponent <JijiaGamebody>();
        //print("body: "+_body.);
        //ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.ROLECANCONTROL, this.IsRoleCanControl);
    }
Example #2
0
    public void GetStart(GameObject obj)
    {
        EnemyObj = obj;

        //提高硬值
        if (!isAcing)
        {
            isAcing = true;
            GetComponent <RoleDate>().addYZ(addYZNum);
            gameBody = GetComponent <GameBody>();
            _aiBase  = GetComponent <AIBase>();

            if (RunName == "" || !gameBody.GetDB().animation.HasAnimation(RunName) || !gameBody.GetDB().animation.HasAnimation(AtkName))
            {
                AcOver();
                return;
            }
            oldRunName   = gameBody.GetRunName();
            oldRunSpeedX = gameBody.maxSpeedX;
            //print("---------------->AtkName    " + AtkName + "   RunName  " + RunName+ "     oldRunName  "+ oldRunName);

            gameBody.RunACChange(RunName, moveSpeedX);

            if (AudioRunCut)
            {
                AudioRunCut.Play();
            }
        }
    }
Example #3
0
    public override void GetStart(GameObject targetObj)
    {
        if (_targetObj == null)
        {
            _targetObj = targetObj.transform;
        }


        ChongJiStartPos = this.transform.position;

        if (GlobalTools.GetDistanceByTowPoint(this.transform.position, _targetObj.transform.position) < 2)
        {
            ReSetAll();
            print("cj  start 起始距离 在 小于2 直接  Over!! ");
            //ChongjiOver();
            return;
        }

        isGetOver = false;

        isStarting     = true;
        IsGetTargetPos = false;

        _gameBody = GetComponent <GameBody>();
        //print("this.transform.position:   " + this.transform.position);
    }
Example #4
0
    void Awake()
    {
        /*Dictionary<string, bool> dic = new Dictionary<string, bool>();
         * ArrayList list = new ArrayList();
         * int count = 0;
         * DateTime dateBegin = DateTime.Now;
         * for (int y = -100; y < 100; y++)
         * {
         *  for(int x = -100; x < 100; x++)
         *  {
         *      if(UnityEngine.Random.Range(0f,1f) < 0.05f)
         *      {
         *          GameBody body = BufferManager.Instance.CreateGameBody(x, y);
         *          Ceil ceil = body.ceils[0] as Ceil;
         *          ceil.gameObject.AddComponent<ControllerRandomAbility>();
         *          count++;
         *      }
         *  }
         * }
         * Debug.Log("All:" + count);*/

        for (int i = -20; i < 20; i++)
        {
            BufferManager.Instance.CreateGameBody(i, -2);
        }
        for (int i = 1; i < 20; i++)
        {
            BufferManager.Instance.CreateGameBody(-20, -2 + i);
            BufferManager.Instance.CreateGameBody(20, -2 + i);
        }
        GameBody body = BufferManager.Instance.CreateGameBody(0, 0);
        Ceil     ceil = body.ceils [0] as Ceil;

        ceil.gameObject.AddComponent <ControllerAbility> ();
    }
Example #5
0
    // Use this for initialization
    void Start()
    {
        gameBody = GetComponent <GameBody>();

        //DataZS d = DataZS.GetInstance();
        //Type myType = typeof(DataZS);
        //PropertyInfo myPropInfo = myType.GetProperty("tt");
        //print("-------------------->  "+ (myPropInfo == null)+"  >  "+ myPropInfo+"   length "+ arrays.Length);
    }
Example #6
0
 // Start is called before the first frame update
 protected virtual void Start()
 {
     if (IsGetBody)
     {
         //print("  释放技能 ??  start! ");
         _gameBody = GetComponent <GameBody>();
         _gameBody.GetDB().AddDBEventListener(DragonBones.EventObject.FRAME_EVENT, this.ShowACTX);
     }
 }
Example #7
0
    public void DeleteGameBodyCoord(GameBody body)
    {
        ArrayList ceils = body.ceils;

        foreach (Ceil ceil in ceils)
        {
            coords.Remove(ceil.coordx + "," + ceil.coordy);
        }
    }
Example #8
0
    public void AddGameBodyToWorld(GameBody body)
    {
        ArrayList ceils = body.ceils;

        foreach (Ceil ceil in ceils)
        {
            coords.Add(ceil.coordx + "," + ceil.coordy, ceil);
        }
    }
Example #9
0
    public void ChangeGameBodyCoord(GameBody body)
    {
        ArrayList ceils = body.ceils;

        foreach (Ceil ceil in ceils)
        {
            coords.Add(ceil.coordx + "," + ceil.coordy, ceil);
        }
    }
Example #10
0
    public GameBody CreateGameBody(int coordx, int coordy)
    {
        GameObject obj  = new GameObject();
        GameBody   body = obj.AddComponent <GameBody> ();

        body.ChangeCoord(coordx, coordy);
        body.AddCeil(CreateCeil(), 0, 0);
        WorldManager.Instance.AddGameBodyToWorld(body);
        return(body);
    }
Example #11
0
 // Start is called before the first frame update
 void Start()
 {
     _gameBody  = GetComponent <GameBody>();
     _roledate  = GetComponent <RoleDate>();
     _aiAirBase = GetComponent <AIAirBase>();
     if (!_db)
     {
         _db = _gameBody.GetDB();
     }
 }
Example #12
0
 // Use this for initialization
 void Start()
 {
     if (player == null)
     {
         player = GlobalTools.FindObjByName("player");
         if (player)
         {
             playerObj = player.GetComponent <GameBody>();
         }
     }
     chushi = btnImg.transform.position;
 }
Example #13
0
    // Use this for initialization
    void Start()
    {
        // GetTypePC();
        //GetTypeMobile();
        if (player == null)
        {
            player = GlobalTools.FindObjByName("player");
            if (player)
            {
                playerObj = player.GetComponent <GameBody>();
            }
        }

        //this.GetComponent<Canvas>().Get = GlobalTools.FindObjByName("Main Camera");

        if (Globals.isPC)
        {
            GetTypePC();
        }
        else
        {
            GetTypeMobile();
        }

        btn_zt.onClick.AddListener(GetSetUI);
        Txt_BossName.GetComponent <CanvasGroup>().alpha = 0;
        saveing.GetComponent <CanvasGroup>().alpha      = 0;

        ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.GAME_SAVEING, this.GetSaveing);
        ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.GAME_RESTART, this.RemoveSelfAndRestart);
        ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.BOSS_NAME, this.ShowBossNameTxt);
        GetMainCamera();

        //screenChangeZZ.gameObject.SetActive(false);
        //这里是控制 开始遮罩的
        this.screenChangeZZ.GetComponent <CanvasGroup>().alpha = 1;
        screenLoadTxt.text = "";
        //StartCoroutine(IHideZZByTimes(0.5f));
        if (GlobalTools.FindObjByName("maps") && GlobalTools.FindObjByName("maps").GetComponent <GetReMap2>())
        {
            StartCoroutine(IHideZZByTimes(0.2f));
        }
        else
        {
            HideUIZZ();
        }

        print("   playerUI***************************************** ");
        //GlobalSetDate.instance.Hide_UIZZ();
    }
Example #14
0
    // Start is called before the first frame update
    void Start()
    {
        _gameBody = GetComponent <GameBody>();
        _roleDate = GetComponent <RoleDate>();
        _gameBody.GetDB().AddDBEventListener(DragonBones.EventObject.FRAME_EVENT, this.ShowACTX);

        ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.ZD_SKILL_SHOW, ZDSkillShow);
        //ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.ZD_SKILL_OVER, ZDSkillOver);
        ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.ZD_SKILL_OVER_ALL, ZDSkillOverAll);
        //print(" zd **********************  正厅了 ");

        _yuanshiOverDelayTimes = OverDelayTimes;
        _AtkDistances          = AtkDistances;
        TheStart();
    }
Example #15
0
    public void GetBeHit(JN_Date jn_date, float sx)
    {
        //print("被击中 !! "+this.transform.name+"   攻击力 "+ jn_date.atkPower+"  我的防御力 "+this.GetComponent<RoleDate>().def);


        gameBody = GetComponent <GameBody>();

        roleDate = GetComponent <RoleDate>();
        if (roleDate.isDie)
        {
            return;
        }

        float addxue = jn_date.atkPower - this.GetComponent <RoleDate>().def;

        addxue         = addxue > 0 ? addxue : 1;
        roleDate.live -= addxue;
        if (roleDate.live < 0)
        {
            roleDate.live = 0;
        }
        //print("live "+ roleDate.live);
        if (!roleDate.isCanBeHit)
        {
            return;
        }

        if (gameBody != null)
        {
            //判断是否破防   D 代办事项
            if (jn_date.atkPower - roleDate.yingzhi > 0)
            {
            }
            gameBody.HasBeHit();
        }



        //判断是否在躲避阶段  无法被攻击
        //判断击中特效播放位置
        //击退 判断方向
        float _psScaleX = sx;

        //判断是否在空中
        //挨打动作  判断是否破硬直
        //判断是否生命被打空
        Bloods(_psScaleX);
    }
Example #16
0
    public void GetStart()
    {
        //停止移动 取消 寻路 和移动
        GetComponent <AirGameBody>().GetStop();
        //动作
        gameBody = GetComponent <GameBody>();
        if (gameBody.GetDB().animation.HasAnimation(""))
        {
            gameBody.GetAcMsg("");
        }
        //动作做完冲刺弹射  速度用推力还是速度? 测试再看
        BumpSpeed = GetJiaodu();
        //gameBody.GetPlayerRigidbody2D().AddForce(BumpSpeed*400);
        //弹力炸弹
        //速度的话 要计算速度 总速度 或者 横向速度

        //播放特效
        TuoWeiTXPlay();

        isStart = true;
    }
Example #17
0
    void OnTriggerEnter2D(Collider2D Coll)
    {
        gameBody     = Coll.GetComponent <GameBody>();
        roleDate     = Coll.GetComponent <RoleDate>();
        _rigidbody2D = Coll.GetComponent <Rigidbody2D>();

        //atkObj = txObj.GetComponent<JN_base>().atkObj;
        //print(atkObj.name);

        print(" ---coll name " + Coll.name + "    roledate " + roleDate);

        if (roleDate && !IsCanHitBoss && roleDate.enemyType == "boss")
        {
            return;
        }

        JN_Date jn_date = GetComponent <JN_Date>();

        if (roleDate != null && roleDate.team != jn_date.team)
        {
            //print("击中的2Dbox  "+Coll.GetComponent<BoxCollider2D>().transform.position);

            if (roleDate.isDie)
            {
                return;
            }
            //if (!roleDate.isCanBeHit) return;
            //取到施展攻击角色的方向
            //float _roleScaleX = -atkObj.transform.localScale.x;


            if (IsCanBeDodge)
            {
                //print("roleDate  " + roleDate);
                //print(" isCanbeihit  " + roleDate.isCanBeHit);
                if (!roleDate.isCanBeHit)
                {
                    return;
                }
            }

            //这个已经不需要了
            //if (Coll.GetComponent<BeHit>()) Coll.GetComponent<BeHit>().GetBeHit(jn_date, _roleScaleX);


            //print("   这里是否进来  " + Coll.transform.position.x + "  -------    " + this.transform.parent.transform.transform);
            if (this.transform.parent)
            {
                atkScaleX = Coll.transform.position.x < this.transform.parent.transform.position.x ? -1 : 1;
            }
            GetBeHit(jn_date, atkScaleX);
            //力作用  这个可以防止 推力重叠 导致任务飞出去
            Vector3 tempV3 = _rigidbody2D.velocity;
            _rigidbody2D.velocity = new Vector3(0, tempV3.y, tempV3.z);

            if (jn_date != null && gameBody != null)
            {
                gameBody.HasBeHit();

                if (this.transform.parent == null)
                {
                    return;
                }
                if (Coll.transform.position.x > this.transform.parent.transform.position.x)
                {
                    //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(400 , 0));
                    Coll.GetComponent <GameBody>().GetZongTuili(new Vector2(400, 0));
                }
                else
                {
                    //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(-400 , 0));
                    Coll.GetComponent <GameBody>().GetZongTuili(new Vector2(-400, 0));
                }
            }


            //毒伤害
            if (jn_date.DuChixuShanghai != 0)
            {
                //print(beHitObj.name + "  --beihitteam  " + BeHitRoleDate.team + "  jnteam  " + jn_date.team + "   atkObjname " + atkObj.name);
                if (gameBody != null && roleDate.team != jn_date.team)
                {
                    gameBody.GetComponent <ChiXuShangHai>().InDu(jn_date.DuChixuShanghai, jn_date.DuChixuShanghaiTime);
                }
            }

            if (jn_date.HuoChixuShanghai != 0)
            {
                if (gameBody != null && roleDate.team != jn_date.team)
                {
                    gameBody.GetComponent <ChiXuShangHai>().InHuo(jn_date.HuoChixuShanghai, jn_date.HuoChixuShanghaiTime);
                }
            }
        }
    }
Example #18
0
 void Start()
 {
     _roleDate = GetComponent <RoleDate>();
     _gameBody = GetComponent <GameBody>();
 }
Example #19
0
 void Awake()
 {
     ceil = gameObject.GetComponent <Ceil> ();
     body = ceil.body;
     this.init();
 }
Example #20
0
 // Start is called before the first frame update
 void Start()
 {
     _gameBody = GetComponent <GameBody>();
     _roleDate = GetComponent <RoleDate>();
     _runNear  = GetComponent <AIAirRunNear>();
 }
Example #21
0
    //return 0.没撞到 1.撞到左边 2.撞到上面 3.撞到右边  4.撞到下面
    public int MoveGameBody(GameBody body, float x, float y)
    {
        ArrayList ceils = body.ceils;
        float     px    = (body.gameObject.transform.position.x + x) / 0.16f;
        float     py    = (body.gameObject.transform.position.y + y) / 0.16f;
        int       cx    = 0; // = Mathf.RoundToInt(px);
        int       cy    = 0; // = Mathf.RoundToInt(py);
        int       tx    = 0;

        if (x > 0)
        {
            cx = (int)Mathf.Ceil(px);
            tx = (int)Mathf.Floor(px);
        }
        else
        {
            cx = (int)Mathf.Floor(px);
            tx = (int)Mathf.Ceil(px);
        }
        if (y > 0)
        {
            cx = (int)Mathf.Ceil(py);
        }
        else
        {
            cy = (int)Mathf.Floor(py);
        }
        int result = 0;
        int ground = -1;

        foreach (Ceil ceil in ceils)
        {
            if (coords.ContainsKey((cx + ceil.ceilx) + "," + (cy + ceil.ceily)))
            {
                if (coords[(cx + ceil.ceilx) + "," + (cy + ceil.ceily)].body != body)
                {
                    if (cy - ceil.coordy == 0)
                    {
                        if (cx - ceil.coordx > 0)
                        {
                            result = 3;
                            body.gameObject.transform.position = new Vector3(body.coordx * 0.16f, body.gameObject.transform.position.y);
                        }
                        else
                        {
                            result = 1;
                            body.gameObject.transform.position = new Vector3(body.coordx * 0.16f, body.gameObject.transform.position.y);
                        }
                    }
                    else
                    {
                        if (cy - ceil.coordy > 0)
                        {
                            result = 2;
                            body.gameObject.transform.position = new Vector3(body.gameObject.transform.position.x, body.coordy * 0.16f);
                        }
                        else
                        {
                            result = 4;
                            body.gameObject.transform.position = new Vector3(body.gameObject.transform.position.x, body.coordy * 0.16f);
                        }
                    }
                    break;
                }
            }
            if (y == 0 && ground == -1)
            {
                if (coords.ContainsKey((tx + ceil.ceilx) + "," + (-1 + ceil.coordy)))
                {
                    if (coords [(tx + ceil.ceilx) + "," + (-1 + ceil.coordy)].body != body)
                    {
                        ground = 0;
                    }
                }
            }
        }
        if (result == 0)
        {
            x = body.gameObject.transform.position.x + x;
            y = body.gameObject.transform.position.y + y;
            if (cx != body.coordx || cy != body.coordy)
            {
                body.ChangeCoord(cx, cy);
            }
            body.gameObject.transform.position = new Vector3(x, y);
            return(ground);
        }
        return(result);
    }
Example #22
0
    void OnTriggerEnter2D(Collider2D Coll)
    {
        gameBody     = Coll.GetComponent <GameBody>();
        roleDate     = Coll.GetComponent <RoleDate>();
        _rigidbody2D = Coll.GetComponent <Rigidbody2D>();

        var txObj = this.transform.parent;

        atkObj = txObj.GetComponent <JN_base>().atkObj;

        JN_Date jn_date = txObj.GetComponent <JN_Date>();

        if (roleDate != null && roleDate.team != jn_date.team)
        {
            //print("击中的2Dbox  "+Coll.GetComponent<BoxCollider2D>().transform.position);

            if (roleDate.isDie)
            {
                return;
            }
            if (!roleDate.isCanBeHit)
            {
                return;
            }
            //取到施展攻击角色的方向
            float _roleScaleX = -atkObj.transform.localScale.x;


            //这个已经不需要了
            //if (Coll.GetComponent<BeHit>()) Coll.GetComponent<BeHit>().GetBeHit(jn_date, _roleScaleX);
            GetBeHit(jn_date, _roleScaleX);
            //力作用  这个可以防止 推力重叠 导致任务飞出去
            Vector3 tempV3 = _rigidbody2D.velocity;
            _rigidbody2D.velocity = new Vector3(0, tempV3.y, tempV3.z);

            if (jn_date != null && gameBody != null)
            {
                //判断是否破防   D 代办事项
                if (jn_date.atkPower - roleDate.yingzhi > roleDate.yingzhi * 0.5)
                {
                    gameBody.HasBeHit();
                    //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(400 * _roleScaleX, 0));
                    gameBody.GetZongTuili(new Vector2(400 * _roleScaleX, 0));
                }
                else if (jn_date.atkPower - roleDate.yingzhi > 0)
                {
                    gameBody.HasBeHit();
                    //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(300 * _roleScaleX, 0));
                    gameBody.GetZongTuili(new Vector2(300 * _roleScaleX, 0));
                    if (atkObj && jn_date._type == "1")
                    {
                        atkObjV3Zero();
                        //atkObj.GetComponent<Rigidbody2D>().AddForce(new Vector2(-300 * _roleScaleX, 0));
                        atkObj.GetComponent <GameBody>().GetZongTuili(new Vector2(-300 * _roleScaleX, 0));
                    }
                }
                else
                {
                    if (atkObj && jn_date._type == "1")
                    {
                        atkObjV3Zero();
                        //atkObj.GetComponent<Rigidbody2D>().AddForce(new Vector2(-500 * _roleScaleX, 0));
                        atkObj.GetComponent <GameBody>().GetZongTuili(new Vector2(-500 * _roleScaleX, 0));
                    }
                }
            }


            //判断作用力与反作用力  硬直判断

            //
            //Coll.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, 300));

            //如果是碰撞就消失 调用消失方法
            if (jn_date != null && jn_date._type == "3")
            {
                //if (gameObject) ObjectPools.GetInstance().DestoryObject2(gameObject);
                txObj.GetComponent <JN_base>().DisObj();
            }
        }
    }