Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        playerMvntSCR = GetComponent <PlayerMovement>();
        globalMap     = GameObject.FindGameObjectWithTag("Manager").GetComponent <ShipMap>();
        if (isAlly)
        {
            engineMng = GameObject.FindGameObjectWithTag("MainShip").GetComponent <EnginesManager>();
        }
        else
        {
            engineMng = GameObject.FindGameObjectWithTag("Enemy").GetComponent <EnginesManager>();
        }
        medicEngine = engineMng.GetEngine(Engine.engineType.medic);
        if (medicEngine == null)
        {
            StartCoroutine(initCrt());
            return;
        }
        Vector3 medicPos = globalMap.GetEnginePos(Engine.engineType.medic, isAlly);

        foreach (ShipCell cell in globalMap.GetRoomByPos(medicPos).cells)
        {
            medicsPos.Add(cell.position);
        }
        StartCoroutine(RepairCoroutine());
        StartCoroutine(OperateCrt());
    }
        public ActionResult Index([FromBody] RegisterModel model)
        {
            Player player = null;

            try
            {
                player = _playerService.Find(model.Key);
            }
            catch (PlayerNotFoundException)
            {
                try
                {
                    player    = _playerService.Register(model.Name);
                    model.Key = player.Key;
                }
                catch (EntityValidationException exception)
                {
                    _addValidationErrors(exception);
                }
            }

            if (player == null)
            {
                return(View(model));
            }

            if (ModelState.IsValid)
            {
                var cells = new List <Point>();
                ShipMap.Iterate((x, y) =>
                {
                    if (model.ShipMap[x][y])
                    {
                        cells.Add(new Point {
                            X = x, Y = y
                        });
                    }
                });

                try
                {
                    _playerService.UpdateMap(player.Key, cells);
                }
                catch (EntityValidationException exception)
                {
                    _addValidationErrors(exception);
                }
                catch (MapValidationException exception)
                {
                    ModelState.AddModelError(string.Empty, exception.Message);
                }
                catch (ShipsCollisionException exception)
                {
                    ModelState.AddModelError(string.Empty, exception.Message);
                }
            }

            return(View(model));
        }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        shipMap        = GameObject.FindGameObjectWithTag("Manager").GetComponent <ShipMap>();
        enginesManager = GetComponent <EnginesManager>();

        Initialize();
        lastPosition    = transform.position;
        shipMap.shipMap = map;
    }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        mapSCR  = GameObject.FindGameObjectWithTag("Manager").GetComponent <ShipMap>();
        aiLerp  = gameObject.GetComponent <AILerp>();
        charMng = gameObject.GetComponent <CharacterManager>();
        isAlly  = charMng.isAlly;

        StartCoroutine(Initialization());
    }
Beispiel #5
0
    public int fleeOperateModifier = 5;   // bonus en flat par level d'opérate



    // Use this for initialization
    void Start()
    {
        iAMng            = GetComponent <EnemyIA>();
        statsSCR         = GetComponent <EnemyStats>();
        shipMap          = GameObject.FindGameObjectWithTag("Manager").GetComponent <ShipMap>();
        eventsMng        = GameObject.FindGameObjectWithTag("Manager").GetComponentInChildren <EventsMainManager>();
        weaponsMng       = GameObject.FindGameObjectWithTag("Manager").GetComponent <WeaponManager>();
        weaponsMng.enemy = gameObject;
        StartCoroutine(RepairHullCrt());
        StartCoroutine(InitCrew());
    }
    // Use this for initialization
    void Start()
    {
        globalMap = GameObject.FindGameObjectWithTag("Manager").GetComponent<ShipMap>();
        weapons[0] = new Weapon(GameObject.FindGameObjectWithTag("Manager").GetComponent<ItemDatabase>().GetItem(2));
        weapons[1] = new Weapon();
        weapons[2] = new Weapon();
        weapons[3] = new Weapon();
        displayMng.weapon0 = weapons[0].weaponItem;

        StartCoroutine(UseWeaponCRT(0,0));
        displayMng.RefreshWeapons();
    }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        globalMap          = GameObject.FindGameObjectWithTag("Manager").GetComponent <ShipMap>();
        weapons[0]         = new Weapon(GameObject.FindGameObjectWithTag("Manager").GetComponent <ItemDatabase>().GetItem(2));
        weapons[1]         = new Weapon();
        weapons[2]         = new Weapon();
        weapons[3]         = new Weapon();
        displayMng.weapon0 = weapons[0].weaponItem;


        StartCoroutine(UseWeaponCRT(0, 0));
        displayMng.RefreshWeapons();
    }
Beispiel #8
0
    void Start()
    {
        body = GetComponent <Rigidbody2D> ();
        map  = GetComponent <ShipMap>();
        map.Rebuild(this);


        CreateArmor(1, 0);
        CreateArmor(0, 1);
        CreateArmor(1, 1);
        CreateArmor(-1, 1);
        CreateArmor(-1, 0);
        CreateArmor(-1, -1);
        CreateArmor(1, -1);
        CreateGun(0, 2);
    }
        /// <summary>
        /// Verifies and stores the map in the database
        /// </summary>
        /// <param name="key">Player secret key</param>
        /// <param name="cells">Selected ship cells on the map</param>
        public void UpdateMap(string key, List <Point> cells)
        {
            var player = _entities.Players.Include(t => t.Cells).FirstOrDefault(t => t.Key == key);

            if (player == null)
            {
                throw new KeyNotFoundException("Player with key " + key + " not found.");
            }

            if (player.MapValidated)
            {
                throw new EntityValidationException("Map changes are not allowed.");
            }

            var shipMap = new ShipMap();

            shipMap.ParseShips(cells);
            shipMap.Validate();

            player.MapValidated = true;

            var newCells = cells.Select(t => new ShipCell(t.X, t.Y)
            {
                PlayerId = player.Id
            });

            _entities.ShipCells.RemoveRange(player.Cells);
            _entities.ShipCells.AddRange(newCells);

            using (var transaction = _entities.Database.BeginTransaction())
            {
                try
                {
                    _entities.SaveChanges();
                    transaction.Commit();
                }
                catch (DbEntityValidationException exception)
                {
                    transaction.Rollback();
                    throw new EntityValidationException(exception);
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        shipMap = GameObject.FindGameObjectWithTag("Manager").GetComponent<ShipMap>();
        enginesManager = GetComponent<EnginesManager>();

        Initialize();
        lastPosition = transform.position;
        shipMap.shipMap = map;
    }
Beispiel #11
0
 public (bool isValid, string Message) PlaceShip(string str, Ship ship)
 {
     return(ShipMap.PlaceShip(str, ship));
 }
 // Use this for initialization
 void Start()
 {
     shipMap = GameObject.FindGameObjectWithTag("Manager").GetComponent<ShipMap>();
     Initialize();
     shipMap.enemyShipMap = map;
 }
Beispiel #13
0
 //int maxEnergy;
 // Use this for initialization
 void Start()
 {
     InitEngines();
     mapScr = GameObject.FindGameObjectWithTag("Manager").GetComponent<ShipMap>();
     StartCoroutine(CrewPositionManagement());
 }
    // Use this for initialization
    void Start()
    {
        playerMvntSCR = GetComponent<PlayerMovement>();
        globalMap = GameObject.FindGameObjectWithTag("Manager").GetComponent<ShipMap>();
        if (isAlly)
        {
            engineMng = GameObject.FindGameObjectWithTag("MainShip").GetComponent<EnginesManager>();
        }
        else
        {
            engineMng = GameObject.FindGameObjectWithTag("Enemy").GetComponent<EnginesManager>();
        }
        medicEngine = engineMng.GetEngine(Engine.engineType.medic);
        if (medicEngine == null)
        {
            StartCoroutine(initCrt());
            return;

        }
        Vector3 medicPos = globalMap.GetEnginePos(Engine.engineType.medic, isAlly);
        foreach (ShipCell cell in globalMap.GetRoomByPos(medicPos).cells)
        {
            medicsPos.Add(cell.position);
        }
        StartCoroutine(RepairCoroutine());
        StartCoroutine(OperateCrt());
    }
Beispiel #15
0
    //int maxEnergy;

    // Use this for initialization
    void Start()
    {
        InitEngines();
        mapScr = GameObject.FindGameObjectWithTag("Manager").GetComponent <ShipMap>();
        StartCoroutine(CrewPositionManagement());
    }
Beispiel #16
0
    void Start()
    {
        body = GetComponent<Rigidbody2D> ();
        map = GetComponent<ShipMap>();
        map.Rebuild(this);

        CreateArmor(1, 0);
        CreateArmor(0, 1);
        CreateArmor(1, 1);
        CreateArmor(-1, 1);
        CreateArmor(-1, 0);
        CreateArmor(-1, -1);
        CreateArmor(1, -1);
        CreateGun(0, 2);
    }
 // Use this for initialization
 void Start()
 {
     iAMng = GetComponent<EnemyIA>();
     statsSCR = GetComponent<EnemyStats>();
     shipMap = GameObject.FindGameObjectWithTag("Manager").GetComponent<ShipMap>();
     eventsMng = GameObject.FindGameObjectWithTag("Manager").GetComponentInChildren<EventsMainManager>();
     weaponsMng = GameObject.FindGameObjectWithTag("Manager").GetComponent<WeaponManager>();
     weaponsMng.enemy = gameObject;
     StartCoroutine(RepairHullCrt());
     StartCoroutine(InitCrew());
 }
Beispiel #18
0
 // Use this for initialization
 void Start()
 {
     shipMap = GameObject.FindGameObjectWithTag("Manager").GetComponent <ShipMap>();
     Initialize();
     shipMap.enemyShipMap = map;
 }
    // Use this for initialization
    void Start()
    {
        mapSCR = GameObject.FindGameObjectWithTag("Manager").GetComponent<ShipMap>();
        aiLerp = gameObject.GetComponent<AILerp>();
        charMng = gameObject.GetComponent<CharacterManager>();
        isAlly = charMng.isAlly;

        StartCoroutine(Initialization());
    }