Exemplo n.º 1
0
    // Start is called before the first frame update
    private void Awake()
    {
        TankList = new Dictionary <int, TankPrepare>();
        TankPrepare t1 = new TankPrepare(1, tankType.small, KeyCode.W, KeyCode.S, KeyCode.A, KeyCode.D, KeyCode.Z, KeyCode.X);
        TankPrepare t2 = new TankPrepare(2, tankType.small, KeyCode.UpArrow, KeyCode.DownArrow, KeyCode.LeftArrow, KeyCode.RightArrow, KeyCode.KeypadEnter, KeyCode.RightShift);
        TankPrepare t3 = new TankPrepare(3, tankType.small, KeyCode.Y, KeyCode.H, KeyCode.G, KeyCode.J, KeyCode.N, KeyCode.M);
        TankPrepare t4 = new TankPrepare(4, tankType.small, KeyCode.Keypad8, KeyCode.Keypad5, KeyCode.Keypad4, KeyCode.Keypad6, KeyCode.Keypad2, KeyCode.Keypad3);

        TankList.Add(t1.tankId, t1);
        TankList.Add(t2.tankId, t2);
        TankList.Add(t3.tankId, t3);
        TankList.Add(t4.tankId, t4);
    }
Exemplo n.º 2
0
    public void PlayerStart()
    {
        Transform playerStartTrans = GameObject.FindWithTag("PlayerStart").transform;

        TankPrepare[] tankPrepares = new TankPrepare[5];
        tanks = new GameObject[5];
        for (int i = 1; i <= 4; i++)
        {
            tankPrepares[i] = TankModel.TankList[i];

            GameObject tank = null;
            switch (tankPrepares[i].tanktype)
            {
            case TankModel.tankType.small:
                tank = Resources.Load <GameObject>("Prefabs/Tank/SmallTank");
                break;

            case TankModel.tankType.middle:
                tank = Resources.Load <GameObject>("Prefabs/Tank/BigTank");
                break;

            case TankModel.tankType.big:
                tank = Resources.Load <GameObject>("Prefabs/Tank/SpecialTank");
                break;
            }

            tanks[i] = Instantiate <GameObject>(tank, playerStartTrans.Find("PlayerStart" + i).position, playerStartTrans.Find("PlayerStart" + i).rotation);
            TankUserController userController = tanks[i].AddComponent <TankUserController>();
            userController.key_forward = tankPrepares[i].key_Up;
            userController.key_back    = tankPrepares[i].key_Down;
            userController.key_left    = tankPrepares[i].key_Left;
            userController.key_right   = tankPrepares[i].key_Right;
            userController.key_attack  = tankPrepares[i].key_Attack;
            userController.key_use     = tankPrepares[i].key_Use;

            tanks[i].GetComponent <TankColorSet>().SetColor(i);
        }

        UIplayer.canGet = true;
    }