Example #1
0
    private void OnNotifyReborn(SocketModel model)
    {
        NotifyReborn notify = SerializeUtil.Deserialize <NotifyReborn>(model.message);

        BaseTank t = TankManager.instance.GetTank(notify.tank.id);

        if (t != null)
        {
            TankManager.instance.RemoveTank(t);
            t.Clear();
        }
        BaseTank tank = null;

        if (notify.tank.id == CacheManager.instance.account)
        {
            tank = new Tank(notify.tank);
        }
        else
        {
            tank = new OtherTank(notify.tank);
        }
        TankManager.instance.AddTank(tank);
    }
Example #2
0
    void ArenaTankDeath(AccountData acc, AccountData enemy, Battle battle)
    {
        Arena arena = battle as Arena;

        if (acc.team == ETeam.Blue)
        {
            arena.blueKillCount++;
        }
        else
        {
            arena.redKillCount++;
        }
        if (arena.blueKillCount >= 5 || arena.redKillCount >= 5)
        {
            //通知战斗结束
            NotifyArenaEnd notify = new NotifyArenaEnd();
            notify.blueKillCount = arena.blueKillCount;
            notify.redKillCount  = arena.redKillCount;

            if (notify.blueKillCount > notify.redKillCount)
            {
                notify.winteam = (int)ETeam.Blue;
            }
            else if (notify.blueKillCount < notify.redKillCount)
            {
                notify.winteam = (int)ETeam.Red;
            }
            else
            {
                notify.winteam = (int)ETeam.None;
            }

            for (int i = 0; i < arena.accounts.Count; i++)
            {
                AccountData  accData = arena.accounts[i];
                TankKillData d       = new TankKillData();
                d.account    = accData.account;
                d.deathCount = accData.deathCount;
                d.hurt       = accData.hurt;
                d.kill       = accData.killCount;
                d.team       = (int)acc.team;

                notify.datas.Add(d);

                accData.killCount  = 0;
                accData.team       = ETeam.None;
                accData.hurt       = 0;
                accData.deathCount = 0;
            }
            MsgSender.SendAll <NotifyArenaEnd>(arena.accounts, (int)MsgID.NotifyArenaEnd, notify);

            arena.timers.Clear();

            CacheManager.instance.arenas.Remove(arena);
        }
        else
        {
            Timer timer = new Timer(3f, () =>
            {
                Tank t = arena.GetTank(enemy.account);
                if (t == null)
                {
                    return;
                }
                t.hp = 100;
                //真随机
                Random r = new Random(System.Guid.NewGuid().GetHashCode());
                t.pos    = SpawnPoint.point[r.Next(0, 5)];

                NotifyReborn notify  = new NotifyReborn();
                notify.tank          = new TankDTO();
                notify.tank.id       = t.uid;
                notify.tank.hp       = t.hp;
                notify.tank.pos      = Tools.ToVec_3(t.pos);
                notify.tank.color    = Tools.UC2TC(t.color);
                notify.tank.team     = (int)t.team;
                notify.tank.nickName = t.nickName;

                MsgSender.SendAll <NotifyReborn>(arena.accounts, (int)MsgID.NotifyReborn, notify);
            });

            arena.timers.Add(timer);
        }
    }