Esempio n. 1
0
    void CreateTestTank()
    {
        Vector2 sz = Utils.HalfCameraSize;
        // 创建普通单位
        TankSyncInfo syncInfo = new TankSyncInfo();

        //syncInfo.baseInfo = ResourceManager.instance.LoadUnit("", m_testUnits[Utils.Random.Next(m_testUnits.Count)].text);
        syncInfo.baseInfo.model     = "Test";
        syncInfo.baseInfo.maxHp     = 500;
        syncInfo.baseInfo.isfixed   = false;
        syncInfo.baseInfo.name      = "TestTank";
        syncInfo.baseInfo.revivable = true;
        syncInfo.baseInfo.move      = 2;
        syncInfo.position           = new Vector2((float)(-sz.x + Utils.Random.NextDouble() * sz.x * 2), (float)(-sz.y + Utils.Random.NextDouble() * sz.y * 2));
        syncInfo.rotation           = (float)Utils.Random.NextDouble() * 360.0f;
        syncInfo.id    = Utils.IdGen.nextId;
        syncInfo.hp    = (float)syncInfo.baseInfo.maxHp;
        syncInfo.force = Utils.Random.Next(8);
        TankGunSyncInfo gunInfo = new TankGunSyncInfo();

        gunInfo.position = new Vector3(0.0f, 0.0f, 0.0f);
        gunInfo.rotation = 0.0f;
        syncInfo.guns.Add(gunInfo);
        World.Current.CreateTank(syncInfo);
    }
Esempio n. 2
0
    public void ServerCreateTanks()
    {
        Vector2 sz = Utils.HalfCameraSize;

        // 创建玩家单位
        foreach (GamePlayerController ctrl in GameManager.AllPlayers.Values)
        {
            Player playerInfo = ctrl.Player;
            //string path = string.Format("Units/[Player{0}]", ctrl.playerId);
            TankSyncInfo syncInfo = new TankSyncInfo();
            //syncInfo.baseInfo = ResourceManager.instance.LoadTank(path, playerInfo.heroData);
            syncInfo.baseInfo.model     = "Player";
            syncInfo.baseInfo.maxHp     = 2000;
            syncInfo.baseInfo.isfixed   = false;
            syncInfo.baseInfo.name      = "PlayerTank";
            syncInfo.baseInfo.revivable = true;
            syncInfo.baseInfo.move      = 2;
            AttackInfo attackSkill = new AttackInfo();
            attackSkill.cd                = 1.75f;
            attackSkill.type              = "Physical";
            attackSkill.value             = 60;
            attackSkill.vrange            = 0.2f;
            attackSkill.range             = 2.5f;
            attackSkill.horizontal        = false;
            attackSkill.animations        = new string[0];
            attackSkill.projectile        = "Projectiles/MageBolt";
            syncInfo.baseInfo.attackSkill = attackSkill;
            syncInfo.id    = Utils.IdGen.nextId;
            syncInfo.hp    = (float)syncInfo.baseInfo.maxHp;
            syncInfo.force = playerInfo.force;

            syncInfo.position = new Vector2((float)(-sz.x + Utils.Random.NextDouble() * sz.x * 2), (float)(-sz.y + Utils.Random.NextDouble() * sz.y * 2));
            syncInfo.rotation = (float)Utils.Random.NextDouble() * 360.0f;
            TankGunSyncInfo gunInfo = new TankGunSyncInfo();
            gunInfo.position    = new Vector3Serializable(0.0f, 0.0f, 0.0f);
            gunInfo.rotation    = 0.0f;
            gunInfo.rotateSpeed = 1.0f;
            syncInfo.guns.Add(gunInfo);
            Tank unit = World.Current.CreateTank(syncInfo, ctrl.playerId);
            if (ctrl.isLocalPlayer)
            {
                World.Current.SetCameraFollowed(unit.gameObject);
            }
        }

        // 随即创建单位
        StartCoroutine(RepeatCreateUnit("CreateTestTank"));

        //CreateOneTestUnit();

        // 世界开始运转
        World.Current.StartWorld();
    }