Пример #1
0
        public TankType AddTankType(TankType TankType)
        {
            var addResult = _context.TankTypes.Add(TankType);

            _context.SaveChanges();
            return(addResult.Entity);
        }
Пример #2
0
            public bool AddTank(TechType tank, float baseCapacity, Sprite sprite = null, bool bUpdate = false, bool bUnlockAtStart = false)
            {
                if (TankTypes == null)
                {
                    TankTypes = new Dictionary <TechType, TankType>();
                }

                //if (TankTypes[i].tankTechType == tank)
                if (TankTypes.TryGetValue(tank, out TankType tt))
                {
                    if (bUpdate)
                    {
#if !RELEASE
                        Logger.Log(Logger.Level.Debug, $"Updating tank type for TechType '{tank.AsString()}' with value {baseCapacity}");
#endif
                        TankTypes[tank].UpdateCapacity(baseCapacity);
                    }
                    return(false);
                }
#if !RELEASE
                Logger.Log(Logger.Level.Debug, $"Adding Tank '{tank.AsString()}' with capacity of {baseCapacity}");
#endif
                TankTypes[tank] = new TankType(tank, baseCapacity, bUnlockAtStart: bUnlockAtStart);
                return(true);
            }
Пример #3
0
 protected Tank(Armor armor, Engine engine, Gun gun)
 {
     Armor  = armor;
     Engine = engine;
     Gun    = gun;
     Type   = GetTankType(armor);
 }
Пример #4
0
        /*
         * void Start ()
         * {
         *  asset.gameObject.AddComponent<BoxCollider2D>();
         *  asset.gameObject.AddComponent<Rigidbody2D>();
         * }
         */

        public void SetColor(TankType _tankType)
        {
            Color color;

            ColorUtility.TryParseHtmlString(_tankType.ToString(), out color);
            SetColor(color);
        }
Пример #5
0
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            TankType type = (TankType)comboBox2.SelectedItem;

            GameState.Instance.tankType = type;
            Networking.SetTankTypeAsync(type);
        }
Пример #6
0
 public TankModel(TankType type, float speed, float health, int spawnspot)
 {
     tankType  = type;
     Speed     = speed;
     Health    = health;
     Spawnspot = spawnspot;
 }
Пример #7
0
    public void SetTankType(TankType tankType)
    {
        ObjectType objectType = ObjectType.Tank_Green;

        mTankAttack.Damage = 25f;
        switch (tankType)
        {
        case TankType.Blue:
            mTankAttack.Damage = 20f;
            objectType         = ObjectType.Tank_Blue;
            break;

        case TankType.Red:
            mTankAttack.Damage = 10f;
            objectType         = ObjectType.Tank_Red;
            break;
        }

        if (mTankModel != null)
        {
            mTankModel.Recycle();
        }

        mTankModel = ObjectPool.Instance.GetRecyclableObject(objectType);
        mTankModel.Spawn(transform.position, transform.rotation, transform);

        mTankRigidbody.isKinematic = false;
    }
Пример #8
0
        public async Task <IActionResult> Edit(int id, [Bind("TankTypeId,TankTypeName")] TankType tankType)
        {
            if (id != tankType.TankTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tankType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TankTypeExists(tankType.TankTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tankType));
        }
Пример #9
0
    public void shoot(TankType type)
    {
        GameObject bullet = Singleton <MyFactory> .Instance.getBullets(type);

        bullet.transform.position = new Vector3(transform.position.x, 2.0f, transform.position.z) + transform.forward * 2.0f;
        bullet.transform.forward  = transform.forward; //方向
        bullet.GetComponent <Rigidbody>().AddForce(bullet.transform.forward * 20, ForceMode.Impulse);
    }
Пример #10
0
 private void ThirdPhaseUpdate()
 {
     if (enemiesSpawned - enemiesDestroyed < maxEnemies)
     {
         TankType type = enemiesTypes[Random.Range(0, enemiesTypes.Count)];
         SpawnEnemy(type);
     }
 }
 // Calls the constructor of Tank class
 public Enemy(int x, int y, TankType type, int rank)
     : base(x, y, Tanks.GetType(type), rank)
 {
     random = new Random();
     velocity = 1;
     lastShot = Environment.TickCount;
     ChangeDirection();
 }
Пример #12
0
 public override Element factory(TankType type, int x, int y)
 {
     switch (type)
     {
         case TankType.PlayerTank: return new PlayerTank(x, y);
     }
     return null;
 }
Пример #13
0
 public Tank(string _id, string _nation = "", string _name = "", TankType _type = TankType.Heavy, string _filename = "")
 {
     this.id = _id;
     this.nation = _nation;
     this.name = _name;
     this.type = _type;
     this.filename = _filename;
 }
Пример #14
0
        public Tank(TankType Tank)
        {
            Random rand = new Random();

            Ammunition       = rand.Next(0, 100);
            Armor            = rand.Next(0, 100);
            Maneuverablility = rand.Next(0, 100);
            TankType         = Tank;
        }
Пример #15
0
        public HealthModifier(IDamageReceiver _receiver, TankType _damageType)
        {
            if (_receiver == null)
            {
                return;
            }
            var damagePoint = TableService.Instance.GetDamagePoint(_damageType);

            _receiver.TakeDamage(damagePoint);
        }
Пример #16
0
        public TankController(TankScriptableObject tankProps)
        {
            model = new TankModel();
            view  = GameObject.Instantiate(tankProps.tankPrefab);
            view.SetController(this);
            shellPool = new ShellPool(tankProps.shellPrefab);
            tankType  = tankProps.tankType;

            shellPrefab = tankProps.shellPrefab;
        }
Пример #17
0
    private void AddTargetBreakable(TankType type, int index, Breakable target)
    {
        // Do not add another tank or player as target
        if (target.GetComponent <Tank>() != null || target.transform == playerTransform)
        {
            return;
        }
        units[type].instances[index].targetBreakable = target;

        Debug.Log($"{units[type].instances[index].tank.name}: Add target breakable");
    }
Пример #18
0
        public async Task <IActionResult> Create([Bind("TankTypeId,TankTypeName")] TankType tankType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tankType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tankType));
        }
Пример #19
0
    private void SpawnEnemy(TankType type)
    {
        Vector2 spawnPoint = GetEnemySpawnPoint();
        Tank    tank       = tanksFactory.GetTank(type);

        tank.SpawnTank(spawnPoint);
        enemiesSpawned++;
        lastSpawnPoint = spawnPoint;
        lastSpawnTime  = Time.time;
        tank.GetComponent <EnemyLogicBase>().Init(tankPlayer.transform);
    }
Пример #20
0
 public void SetValues(TankScriptable tankScriptable)
 {
     health = tankScriptable.health;
     healthSlider.maxValue = health;
     tankType      = tankScriptable.tankType;
     movementSpeed = tankScriptable.movementSpeed;
     turnSpeed     = tankScriptable.turnSpeed;
     for (int i = 0; i < tankParts.Length; i++)
     {
         tankParts[i].material = tankScriptable.material;
     }
 }
Пример #21
0
        public Tanks(TankType Tank)
        {
            Random rand = new Random();

            Ammunition       = rand.Next(0, 100);
            Armor            = rand.Next(0, 100);
            Maneuverablility = rand.Next(0, 100);
            TankType         = Tank;
            War war = new War();

            war.FillLists(this);
        }
Пример #22
0
    public void CmdFire(TankType type)
    {
        GameObject bullet = Singleton <MyFactory> .Instance.getBullets(type);

        bullet.transform.position = new Vector3(gameObject.transform.position.x, 1.5f, gameObject.transform.position.z) + gameObject.transform.forward * 1.5f;
        bullet.transform.forward  = gameObject.transform.forward; //方向
        bullet.GetComponent <Rigidbody>().AddForce(bullet.transform.forward * 20, ForceMode.Impulse);

        NetworkServer.Spawn(bullet);

        Destroy(bullet, 2.0f);
    }
Пример #23
0
    private int GetActiveIndex(TankType type, int unitIndex)
    {
        var unit = units[type];

        for (int i = 0; i < unit.activeCount; i++)
        {
            if (unit.activeIndicesMap[i] == unitIndex)
            {
                return(i);
            }
        }
        return(-1);
    }
Пример #24
0
    public override void OnStartClient()
    {
        if (NetworkServer.active)
        {
            return;
        }

        //TODO
        TankType found = TankTypeManager.Lookup(tankType);

        tt = found;

        GetComponent <SpriteRenderer>().sprite        = tt.skinBody;
        turret.GetComponent <SpriteRenderer>().sprite = tt.skinTurret;
    }
Пример #25
0
        public TankType UpdateTankType(TankType TankTypeToUpdate)
        {
            var currentValue = _context.TankTypes.First(n => n.TankTypeId == TankTypeToUpdate.TankTypeId);

            TankTypeToUpdate.CreatedBy             = currentValue.CreatedBy;
            TankTypeToUpdate.DatetimeCreated       = currentValue.DatetimeCreated;
            TankTypeToUpdate.DatetimeUpdated       = DateTime.Now;
            TankTypeToUpdate.UpdatedBy             = "SYSTEM";
            _context.Entry(currentValue).State     = Microsoft.EntityFrameworkCore.EntityState.Detached;
            _context.Entry(TankTypeToUpdate).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            var updateResult = _context.TankTypes.Update(TankTypeToUpdate);

            _context.SaveChanges();
            return(updateResult.Entity);
        }
Пример #26
0
    public void Spawn(TankType type, Vector3 position)
    {
        TankUnit unit  = units[type];
        int      index = unit.nextIndex;

        unit.nextIndex++;

        var tank = unit.instances[index].tank;

        tank.GetComponent <Breakable>().OnBreak += () => UnSpawn(type, index);
        tank.OnCollideBreakable += breakable => AddTargetBreakable(type, index, breakable);
        tank.collisionMask       = tankCollisionMask;

        StartCoroutine(UnearthTank(tank, position, type, index));
    }
Пример #27
0
        public static async void SetTankTypeAsync(TankType type)
        {
            if (!IsConnected())
            {
                return;
            }

            try
            {
                await connection.InvokeAsync("SetTankType", type);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error setting tank type: " + e.Message);
            }
        }
Пример #28
0
 public void SetTankType(TankType tankType)
 {
     this.machine      = Machine.Active();
     this._tankType    = tankType;
     this._tankTypeInt = (int)tankType;
     this.regulations.TryGetValue((int)_tankType, out this.regulation);
     BoundResetter.Instance.refresh = true;
     if (this._tankTypeInt == 5)
     {
         this.isJunkTank = true;
     }
     else
     {
         this.isJunkTank = false;
     }
 }
Пример #29
0
        public void run()
        {
            try
            {
                remoteProcessClient.WriteToken(token);
                int teamSize = remoteProcessClient.ReadTeamSize();

                IStrategy[] strategies = new IStrategy[teamSize];
                TankType[] tankTypes = new TankType[teamSize];

                for (int strategyIndex = 0; strategyIndex < teamSize; ++strategyIndex)
                {
                    IStrategy strategy = new MyStrategy();
                    strategies[strategyIndex] = strategy;
                    tankTypes[strategyIndex] = strategy.SelectTank(strategyIndex, teamSize);
                }

                remoteProcessClient.WriteSelectedTanks(tankTypes);

                PlayerContext playerContext;

                while ((playerContext = remoteProcessClient.ReadPlayerContext()) != null)
                {
                    Tank[] playerTanks = playerContext.Tanks;
                    if (playerTanks.Length != teamSize)
                    {
                        break;
                    }

                    Move[] moves = new Move[teamSize];

                    for (int strategyIndex = 0; strategyIndex < teamSize; ++strategyIndex)
                    {
                        Move move = new Move();
                        moves[strategyIndex] = move;
                        strategies[strategyIndex].Move(playerTanks[strategyIndex], playerContext.World, move);
                    }

                    remoteProcessClient.WriteMoves(moves);
                }
            }
            finally
            {
                remoteProcessClient.Close();
            }
        }
Пример #30
0
    public void InitializeFromTankType(TankType newTT)
    {
        tt               = newTT;
        tankType         = tt.tankTypeName;
        health           = tt.maxHealth;
        heat             = 0;
        ammunitionTurret = tt.maxAmmunitionTurret;
        ammunitionMG     = tt.maxAmmunitionMG;
        armorFront       = tt.armor * 2;
        armorBack        = tt.armor * 0.8f;
        armorLeft        = tt.armor;
        armorRight       = tt.armor;
        team             = (int)(Time.time) % 2;

        GetComponent <SpriteRenderer>().sprite        = tt.skinBody;
        turret.GetComponent <SpriteRenderer>().sprite = tt.skinTurret;
    }
Пример #31
0
 public Tank(long id, string playerName, int teammateIndex,
     double x, double y, double speedX, double speedY, double angle, double angularSpeed,
     double turretRelativeAngle, int crewHealth, int hullDurability,
     int reloadingTime, int remainingReloadingTime, int premiumShellCount, bool isTeammate, TankType type)
     : base(id, GetWidth(type), GetHeight(type), x, y, speedX, speedY, angle, angularSpeed)
 {
     this.playerName = playerName;
     this.teammateIndex = teammateIndex;
     this.turretRelativeAngle = turretRelativeAngle;
     this.crewHealth = crewHealth;
     this.hullDurability = hullDurability;
     this.reloadingTime = reloadingTime;
     this.remainingReloadingTime = remainingReloadingTime;
     this.premiumShellCount = premiumShellCount;
     this.isTeammate = isTeammate;
     this.type = type;
 }
        public override void TestStartUp()
        {
            base.TestStartUp();

            part.partInfo = new AvailablePart(); // So that it thinks it's loading from a save

            module.baseVolume = 1;

            resourceDef1 = new PartResourceDefinition("resource1");
            resourceDef2 = new PartResourceDefinition("resource2");
            resourceDef3 = new PartResourceDefinition("resource3");

            TankResource tankResource1 = new TankResource();

            tankResource1.resourceDefinition = resourceDef1;
            TankResource tankResource2 = new TankResource();

            tankResource2.resourceDefinition = resourceDef1;
            TankResource tankResource3 = new TankResource();

            tankResource3.resourceDefinition = resourceDef2;

            TankType tankType1 = new TankType();

            tankType1.resources.Add(tankResource1);
            TankType tankType2 = new TankType();

            tankType2.resources.Add(tankResource2);
            tankType2.resources.Add(tankResource3);

            subtype1             = new PartSubtype();
            subtype1.subtypeName = "subtype1";
            subtype1.tankType    = tankType1;
            module.subtypes.Add(subtype1);

            subtype2             = new PartSubtype();
            subtype2.subtypeName = "subtype2";
            subtype2.tankType    = tankType2;
            module.subtypes.Add(subtype2);

            subtype3             = new PartSubtype();
            subtype3.subtypeName = "subtype3";
            subtype3.tankType    = B9TankSettings.StructuralTankType;
            module.subtypes.Add(subtype3);
        }
Пример #33
0
    private IEnumerator UnearthTank(Tank tank, Vector3 position, TankType type, int index)
    {
        // Telegraph enemy spawning to player
        Instantiate(spawnEffect, position, spawnEffect.transform.rotation);
        float waitTime = spawnEffect.main.duration - riseFromUnderworldTime;

        yield return(new WaitForSeconds(waitTime));

        var toBase = playerBasePosition - position;

        toBase.y = 0;
        var startRotation = Quaternion.LookRotation(-toBase);
        var endRotation   = Quaternion.LookRotation(toBase);

        position.y = -tank.height;
        tank.transform.position = position;
        tank.transform.rotation = startRotation;
        tank.gameObject.SetActive(true);
        tank.collider.enabled = false;

        // Rise
        float percent = 0f;

        while (percent < 1f)
        {
            percent += Time.deltaTime / riseFromUnderworldTime;

            position.y = (percent - 1f) * tank.height;             // minimized lerp
            tank.transform.position = position;

            tank.transform.rotation = Quaternion.Slerp(startRotation, endRotation, percent);

            yield return(null);
        }

        // Active after pondering a moment
        yield return(new WaitForSeconds(decisionMakeDelay));

        tank.collider.enabled = true;

        var unit = units[type];

        unit.activeIndicesMap[unit.activeCount++] = index;
        Sort(unit.activeIndicesMap, unit.activeCount);
    }
Пример #34
0
    IEnumerator CheckForCollision(Collider other)
    {
        yield return(new WaitUntil(() => GameManager.Instance.player1.hasBulletReached || GameManager.Instance.player2.hasBulletReached));

        if (isFilled)
        {
            GameObject explosion = Instantiate(tankExplosion, this.transform) as GameObject;
            explosion.SetActive(true);
            if (tankType.Equals(TankType.TankQ))
            {
                tankType = TankType.TankP;
                MeshRenderer[] renderers = tankPlaced.GetComponentsInChildren <MeshRenderer>();

                // Go through all the renderers...
                for (int i = 0; i < renderers.Length; i++)
                {
                    renderers[i].material.color = Color.green;
                }
            }
            else
            {
                tankPlaced.SetActive(false);
                if (GameManager.Instance.player1.hasBulletReached)
                {
                    GameManager.player1Score++;
                }
                else
                {
                    GameManager.player2Score++;
                }
                GameManager.Instance.SetScore();
                GameManager.Instance.CheckWinner();
            }
        }
        else
        {
            GameObject explosion = Instantiate(shellExplosion, this.transform) as GameObject;
            explosion.SetActive(true);
        }
        other.gameObject.SetActive(false);
        GameManager.Instance.player1.hasBulletReached   = false;
        GameManager.Instance.player2.hasBulletReached   = false;
        GameManager.Instance.player1.tileNumberToAttack = -1;
        GameManager.Instance.player2.tileNumberToAttack = -1;
    }
Пример #35
0
        public static int[] GetType(TankType enumType)
        {
            switch (enumType)
            {
                case TankType.Yellow:
                    return type["Yellow"];
                case TankType.White:
                    return type["White"];
                case TankType.Green:
                    return type["Green"];
                case TankType.Purple:
                    return type["Purple"];
                default:
                    break;
            }

            return null;
        }
Пример #36
0
    private void UnSpawn(TankType type, int index)
    {
        var tank = units[type].instances[index];

        tank.tank.gameObject.SetActive(false);
        tank.path            = null;
        tank.targetBreakable = null;

        OnTankDestroyed?.Invoke();

        // Swap with last active, and sort those left
        int activeIndex = GetActiveIndex(type, index);
        var unit        = units[type];

        unit.activeCount--;
        unit.activeIndicesMap[activeIndex] = unit.activeIndicesMap[unit.activeCount];
        Sort(unit.activeIndicesMap, unit.activeCount);
    }
Пример #37
0
        public static void ReloadTankDefs()
        {
            tankTypes.Clear();

            // Structural tank type is hard coded
            tankTypes.Add(structuralTankName, StructuralTankType);
            
            foreach (var node in GameDatabase.Instance.GetConfigNodes("B9_TANK_TYPE"))
            {
                TankType t = new TankType();
                t.Load(node);
                if (tankTypes.ContainsKey(t.tankName))
                {
                    Debug.LogError($"B9TankSettings: The tank type {t.tankName} already exists");
                    continue;
                }
                tankTypes.Add(t.tankName, t);
                Debug.Log($"B9TankSettings: registered tank type {t.tankName}");
            }

            LoadedTankDefs = true;
        }
Пример #38
0
        // Output level - Low, High
        // Convertible - true, false
        // Biopower - true, false
        // Diagnostics - EOBD, OBD2, LOBD
        // SAI - true, false
        // Clutch start - true, false
        // Tank type - AWD, US, EU
        public bool GetPI01(out bool convertible, out bool sai, out bool highoutput, out bool biopower, out DiagnosticType diagnosticType, out bool clutchStart, out TankType tankType, out string raw)
        {
            convertible = false;
            sai = false;
            highoutput = false;
            biopower = false;
            raw = string.Empty;
            diagnosticType = DiagnosticType.EOBD;
            tankType = TankType.EU;
            clutchStart = false;
            byte[] data = RequestECUInfo(0x01);
            Console.WriteLine("01data: " + data[0].ToString("X2") + " " + data[1].ToString("X2"));

            if (data[0] == 0x00 && data[1] == 0x00) return false;
            if (data.Length >= 2)
            {
                // -------C
                biopower = BitTools.GetBit(data[0], 0);

                // -----C--
                convertible = BitTools.GetBit(data[0], 2);

                // ---01--- US
                // ---10--- EU
                // ---11--- AWD
                switch (data[0] & 0x18)
                {
                    case 0x08:
                        tankType = TankType.US;
                        break;
                    case 0x10:
                        tankType = TankType.EU;
                        break;
                    case 0x18:
                        tankType = TankType.AWD;
                        break;
                }

                // -01----- OBD2
                // -10----- EOBD
                // -11----- LOBD
                switch (data[0] & 0x60)
                {
                    case 0x20:
                        diagnosticType = DiagnosticType.OBD2;
                        break;
                    case 0x40:
                        diagnosticType = DiagnosticType.EOBD;
                        break;
                    case 0x60:
                        diagnosticType = DiagnosticType.LOBD;
                        break;
                    default:
                        diagnosticType = DiagnosticType.None;
                        break;
                }

                // on = -----10-
                // off= -----01-
                clutchStart = !BitTools.GetBit(data[1], 1) && BitTools.GetBit(data[1], 2) ? true : false;

                // on = ---10---
                // off= ---01---
                sai = !BitTools.GetBit(data[1], 3) && BitTools.GetBit(data[1], 4) ? true : false;

                // high= -01-----
                // low = -10-----
                highoutput = BitTools.GetBit(data[1], 5) && !BitTools.GetBit(data[1], 6) ? true : false;

                for (int i = 0; i < data.Length; i++)
                {
                    raw += "0x" + data[i].ToString("X2") + " ";
                }
            }

            return true;
        }
Пример #39
0
 public TankIcon getTankIcon(TankType type, bool isAlly)
 {
     if (isAlly) {
         return allyTankIcons[type];
     } else {
         return enemyTankIcons[type];
     }
 }
Пример #40
0
 private static double GetWidth(TankType type)
 {
     switch (type)
     {
         case TankType.Medium:
             return 90.0D;
         case TankType.Heavy:
             return 105.0D;
         case TankType.TankDestroyer:
             return 112.5D;
         default:
             throw new ArgumentException();
     }
 }
Пример #41
0
 private static double GetHeight(TankType type)
 {
     switch (type)
     {
         case TankType.Medium:
             return 60.0D;
         case TankType.Heavy:
             return 75.0D;
         case TankType.TankDestroyer:
             return 67.5D;
         default:
             throw new ArgumentException();
     }
 }
Пример #42
0
 public TankIcon(string _id, bool _isAlly = true, TankType _type = TankType.Heavy, string _aliveFilename = "", string _deadFilename = "")
 {
     id = _id;
     isAlly = _isAlly;
     type = _type;
     aliveFilename = _aliveFilename;
     deadFilename = _deadFilename;
 }
Пример #43
0
 public virtual Element factory(TankType type, int x, int y)
 {
     return null;
 }
Пример #44
0
        public void WriteSelectedTanks(TankType[] tankTypes)
        {
            WriteEnum((sbyte?)MessageType.TankTypes);

            if (tankTypes == null)
            {
                WriteInt(-1);
            }
            else
            {
                int typeCount = tankTypes.Length;
                WriteInt(typeCount);

                for (int typeIndex = 0; typeIndex < typeCount; ++typeIndex)
                {
                    WriteEnum((sbyte?)tankTypes[typeIndex]);
                }
            }

            writer.Flush();
        }
Пример #45
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            if (tankType == null)
                tankType = B9TankSettings.StructuralTankType;

            if (string.IsNullOrEmpty(title))
                title = subtypeName;
        }
Пример #46
0
        protected void AddTank(TankType type, Position pos, bool ai = true)
        {
            // žlutý / zelený tank
            Texture2D texture;

            if (type == TankType.Yellow) { texture = this.tankTextures[0]; }
            else { texture = this.tankTextures[1]; }

            //
            Tank tank	=	new Tank(ai);

            // inicializace
            tank.Initialize(this.area, texture, this.prjTextures[0], pos);

            // ochrana aby se tank nevložil na pozici jiného
            if (!this.CheckTankPosition(pos, 2, 2)) { this.Tanks.Add(tank); }
        }
Пример #47
0
 public void AssignStructuralTankType()
 {
     if (!tankType.IsStructuralTankType)
         tankType = B9TankSettings.StructuralTankType;
 }
Пример #48
0
        public bool SetPI01(bool convertible, bool sai, bool highoutput, bool biopower, DiagnosticType diagnosticType, bool clutchStart, TankType tankType)
        {
            bool retval = false;
            byte[] data = RequestECUInfo(0x01);
            CANMessage msg = new CANMessage(0x7E0, 0, 7);
            ulong cmd = 0x0000000000013B06;
            // -------C
            data[0] = BitTools.SetBit(data[0], 0, biopower);

            // -----C--
            data[0] = BitTools.SetBit(data[0], 2, convertible);

            // ---01--- US
            // ---10--- EU
            // ---11--- AWD
            switch (tankType)
            {
                case TankType.US:
                    data[0] = BitTools.SetBit(data[0], 3, true);
                    data[0] = BitTools.SetBit(data[0], 4, false);
                    break;
                case TankType.EU:
                    data[0] = BitTools.SetBit(data[0], 3, false);
                    data[0] = BitTools.SetBit(data[0], 4, true);
                    break;
                case TankType.AWD:
                    data[0] = BitTools.SetBit(data[0], 3, true);
                    data[0] = BitTools.SetBit(data[0], 4, true);
                    break;
            }

            // -01----- OBD2
            // -10----- EOBD
            // -11----- LOBD
            switch (diagnosticType)
            {
                case DiagnosticType.OBD2:
                    data[0] = BitTools.SetBit(data[0], 5, true);
                    data[0] = BitTools.SetBit(data[0], 6, false);
                    break;
                case DiagnosticType.EOBD:
                    data[0] = BitTools.SetBit(data[0], 5, false);
                    data[0] = BitTools.SetBit(data[0], 6, true);
                    break;
                case DiagnosticType.LOBD:
                    data[0] = BitTools.SetBit(data[0], 5, true);
                    data[0] = BitTools.SetBit(data[0], 6, true);
                    break;
                case DiagnosticType.None:
                default:
                    data[0] = BitTools.SetBit(data[0], 5, false);
                    data[0] = BitTools.SetBit(data[0], 6, false);
                    break;
            }

            // on = -----10-
            // off= -----01-
            data[1] = BitTools.SetBit(data[1], 1, !clutchStart);
            data[1] = BitTools.SetBit(data[1], 2, clutchStart);

            // on = ---10---
            // off= ---01---
            data[1] = BitTools.SetBit(data[1], 3, !sai);
            data[1] = BitTools.SetBit(data[1], 4, sai);

            // high= -01-----
            // low = -10-----
            data[1] = BitTools.SetBit(data[1], 5, highoutput);
            data[1] = BitTools.SetBit(data[1], 6, !highoutput);

            cmd = AddByteToCommand(cmd, data[0], 3);
            cmd = AddByteToCommand(cmd, data[1], 4);
            msg.setData(cmd);
            m_canListener.setupWaitMessage(0x7E8);
            if (!canUsbDevice.sendMessage(msg))
            {
                CastInfoEvent("Couldn't send message", ActivityType.ConvertingFile);
                return false;
            }
            CANMessage ECMresponse = new CANMessage();
            ECMresponse = m_canListener.waitMessage(timeoutP2ct);
            ulong rxdata = ECMresponse.getData();
            // response should be 0000000000017B02
            if (getCanData(rxdata, 1) == 0x7B && getCanData(rxdata, 2) == 0x01)
            {
                //7e0  02 27 FD 00 00 00 00 00 request sequrity access FD
                //7e8  04 67 FD 00 00 00 00 00
                RequestSecurityAccess(0);

                //7e0  07 AE 16 00 00 00 00 00
                //7e8  02 EE 16 00 00 00 00 00
                SendDeviceControlMessage(0x16);

                retval = true;
            }
            else if (getCanData(rxdata, 1) == 0x7F && getCanData(rxdata, 2) == 0x3B)
            {
                CastInfoEvent("Error: " + TranslateErrorCode(getCanData(rxdata, 3)), ActivityType.ConvertingFile);
            }
            return retval;
        }