Ejemplo n.º 1
0
    public override void update(ShipLogic ship)
    {
        if (!m_enabled)
        {
            return;
        }

        m_delayToNextProjectile -= Time.deltaTime;

        if (ship.fire && m_delayToNextProjectile <= 0)
        {
            if (m_bulletCount >= m_weaponCount)
            {
                m_delayToNextProjectile = m_longFireRate;
                m_bulletCount           = 0;
            }
            else
            {
                m_delayToNextProjectile = m_fireRate;
            }

            SoundSystem.instance.play(new BernoulliDistribution().Next(new StaticRandomGenerator <DefaultRandomGenerator>()) ? m_shootClip : m_shootClip2, 0.1f);

            float startOffset = -m_offset * (m_projectileCount - 1) / 2;
            for (int i = 0; i < m_projectileCount; i++)
            {
                fire(m_projectile, ship.gameObject, new Vector3(0, startOffset + m_offset * i, 1), 0, (int)m_power, m_baseSpeed + m_rateSpeed * ship.fireRate, m_life, m_color);
            }

            m_bulletCount++;
        }
    }
Ejemplo n.º 2
0
    // Populate scene with game-specific objects
    void Begin()
    {
        //Create UI controller object
        GameObject objUI = Instantiate(UIObject);
        UIDocument UIDoc = objUI.GetComponent <UIDocument>();

        //Create ScoreController, and bind to logic script
        GameObject scoreController = Instantiate(ScoreObject);
        ScoreLogic sLogic          = scoreController.GetComponent <ScoreLogic>();

        //Give ScoreLogic a reference to my own logic script
        sLogic.gLogic = GetComponent <GameLogic>();
        sLogic.UIRef  = UIDoc;

        //Ship creation
        GameObject PlayerShip = Instantiate(ShipObject, new Vector3(7, 3, 1), Quaternion.Euler(0, -90, -90));
        ShipLogic  Logic      = PlayerShip.GetComponent <ShipLogic>();

        Logic.Player = (1);
        AllShips.Insert(0, Logic);

        PlayerShip   = Instantiate(ShipObject, new Vector3(-7, -3, 1), Quaternion.Euler(0, 90, 90));
        Logic        = PlayerShip.GetComponent <ShipLogic>();
        Logic.Player = (2);
        AllShips.Insert(1, Logic);
    }
Ejemplo n.º 3
0
    private void Awake()
    {
        m_ship    = GetComponent <ShipLogic>();
        m_lifebar = GetComponentInChildren <LifebarLogic>();

        onAwake();

        EnemyList.add(this);
    }
Ejemplo n.º 4
0
    public override void updateStats(ShipLogic ship)
    {
        m_fireRate = 1 / (m_baseFireRate * ship.fireRate);
        m_power    = ship.power * m_powerMultiplier;

        int count = countItemOfType <WeaponSimple>(ship.modifiers);

        m_rotation = count * m_rotationPerLevel;

        m_delayToNextProjectile = 0;
    }
Ejemplo n.º 5
0
    private void Awake()
    {
        m_ship           = GetComponent <ShipLogic>();
        m_particleSystem = GetComponentInChildren <ParticleSystem>();
        m_particleSystem.Stop();
        m_renderer = GetComponent <SpriteRenderer>();
        m_cursor   = transform.Find("Cursor");
        m_timeFromLastCursorMove = m_cursorHideDelay;

        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
    }
Ejemplo n.º 6
0
    public override void updateStats(ShipLogic ship)
    {
        m_fireRate = 1 / (m_baseFireRate * ship.fireRate);
        m_power    = ship.power * m_powerMultiplier;


        int index = indexOfTypeOf(this, ship.modifiers);
        int count = countItemOfType <WeaponTriple>(ship.modifiers);

        m_offset = (-(count - 1) / 2.0f + index) * m_offsetPerLevel;

        m_delayToNextProjectile = 0;
    }
Ejemplo n.º 7
0
    public override void updateStats(ShipLogic ship)
    {
        int count = countItemOfType <WeaponStraight>(ship.modifiers);

        m_fireRate = 1 / (m_baseFireRate * ship.fireRate * count);
        m_power    = ship.power * m_powerMultiplier;

        int index = indexOfTypeOf(this, ship.modifiers);

        m_enabled = index == 0;

        m_delayToNextProjectile = 0;
    }
Ejemplo n.º 8
0
    public override void updateStats(ShipLogic ship)
    {
        m_fireRate     = 1 / (m_baseFireRate * ship.fireRate);
        m_fireRateSlow = 1 / (m_baseFireRateSlow * ship.fireRate);
        m_power        = ship.power * m_powerMultiplier;


        int index = indexOfTypeOf(this, ship.modifiers);
        int count = countItemOfType <WeaponEnemySimpleShape>(ship.modifiers);

        m_rotation = index * 360 / count + 90;

        m_delayToNextProjectile = 0;
    }
Ejemplo n.º 9
0
    public override void update(ShipLogic ship)
    {
        m_delayToNextProjectile -= Time.deltaTime;

        if (ship.fire && m_delayToNextProjectile <= 0)
        {
            m_delayToNextProjectile = m_fireRate;

            SoundSystem.instance.play(new BernoulliDistribution().Next(new StaticRandomGenerator <DefaultRandomGenerator>()) ? m_shootClip : m_shootClip2, 0.1f);
            fire(m_projectile, ship.gameObject, new Vector3(0, m_offset, 1), 0, (int)m_power, m_baseSpeed + m_rateSpeed * ship.fireRate, m_life, m_color);
            fire(m_projectile, ship.gameObject, new Vector3(0, m_offset, 1), -m_rotation, (int)m_power, m_baseSpeed + m_rateSpeed * ship.fireRate, m_life, m_color);
            fire(m_projectile, ship.gameObject, new Vector3(0, m_offset, 1), m_rotation, (int)m_power, m_baseSpeed + m_rateSpeed * ship.fireRate, m_life, m_color);
        }
    }
Ejemplo n.º 10
0
        private void BtnSetShip_Click(object sender, EventArgs e)
        {
            var length = (int)nudLength.Value;
            var width  = (int)nudWidth.Value;

            InfoShip.Visible         = true;
            ConfigShip.Visible       = false;
            lblContainersWeight.Text = "0";
            btnAddContainer.Enabled  = true;

            ShipLogic          = new ShipLogic(width, length);
            lblLength.Text     = length.ToString();
            lblWidth.Text      = width.ToString();
            lblShipWeight.Text = ShipLogic.Ship.MaxWeight.ToString();
            //FillTestData();
            //lblCountUnsorted.Text = lbUnsortedContainers.Items.Count.ToString();
        }
Ejemplo n.º 11
0
    public override void update(ShipLogic ship)
    {
        m_delayToNextProjectile -= Time.deltaTime;

        if (ship.fire && m_delayToNextProjectile <= 0)
        {
            m_projectileCount++;
            if (m_projectileCount >= m_weaponLevel)
            {
                m_delayToNextProjectile = m_fireRateSlow;
                m_projectileCount       = 0;
            }
            else
            {
                m_delayToNextProjectile = m_fireRate;
            }

            Vector3 offset = Quaternion.Euler(0, 0, m_rotation) * new Vector3(0.6f, 0, 1);

            fire(m_projectile, ship.gameObject, offset, m_rotation, (int)m_power, m_baseSpeed + m_rateSpeed * ship.fireRate, m_life, m_color);
        }
    }
Ejemplo n.º 12
0
    void onCrush(CrushEvent e)
    {
        foreach (var o in m_objects)
        {
            Destroy(o.transform.gameObject);
        }
        m_objects.Clear();

        m_modifier = e.modifier;
        m_ship     = e.ship;

        setInfos(m_crusher, e.modifier);

        foreach (var m in e.ship.modifiers)
        {
            var        obj   = Instantiate(m_modifierPrefab);
            ObjectInfo infos = new ObjectInfo();
            infos.transform = obj.transform;
            infos.sprite    = obj.GetComponent <SpriteRenderer>();
            infos.line1     = obj.transform.Find("Line1").GetComponent <SpriteTextLogic>();
            infos.line2     = obj.transform.Find("Line2").GetComponent <SpriteTextLogic>();
            infos.line3     = obj.transform.Find("Line3").GetComponent <SpriteTextLogic>();

            setInfos(infos, m);

            infos.transform.parent        = m_objectsBase;
            infos.transform.localPosition = new Vector3(m_objects.Count * m_itemSpacing - (e.ship.modifiers.Count - 1) * m_itemSpacing / 2, 0, 0);

            m_objects.Add(infos);
        }

        setCruherIndex(m_objects.Count / 2 - 1);

        m_background.size = new Vector2((m_objects.Count + 1) * m_itemSpacing, m_background.size.y);

        gameObject.SetActive(true);
        m_active = true;
    }
        public void OnPost()
        {
            IsStatus           = true;
            ActiveGame.Players = new List <Player>();

            // Reset last game state
            ActiveGame.Init();

            // Loop through each form param
            foreach (var key in Request.Form.Keys)
            {
                // Only check names
                if (!key.Contains("name-"))
                {
                    continue;
                }

                // Get name
                Request.Form.TryGetValue(key, out var names);
                var name = names.ToString();

                // Check input validity
                if (!InputValidator.CheckValidPlayerName(name))
                {
                    IsError   = true;
                    StatusMsg = "Invalid player name!";
                    return;
                }

                ActiveGame.Players.Add(new Player(name, ShipLogic.GenGameShipList()));
            }

            // Set pointers
            ActiveGame.InitPlayerPointers();

            StatusMsg = "Players created!";
        }
Ejemplo n.º 14
0
        private static void InitializePlayers()
        {
            var playerCount = ActiveGame.GetRuleVal(RuleType.PlayerCount);

            ActiveGame.Players = new List <Player>();

            for (var i = 0; i < playerCount; i++)
            {
                string name;

                while (true)
                {
                    name = NameMenu("Creating players", $"Input a name for player {i + 1}/{playerCount}");

                    // User chose to quit the menu
                    if (name == null)
                    {
                        return;
                    }

                    // Check input validity
                    if (!InputValidator.CheckValidPlayerName(name))
                    {
                        Console.WriteLine("Invalid name!");
                        Console.ReadKey(true);
                        continue;
                    }

                    break;
                }

                // Generate ships for the player based on current rules
                var ships = ShipLogic.GenGameShipList();
                ActiveGame.Players.Add(new Player(name, ships));
            }
        }
Ejemplo n.º 15
0
 // Start is called before the first frame update
 void Start()
 {
     hostLogic = hostShip.GetComponent <ShipLogic>();
 }
Ejemplo n.º 16
0
        public void IntegrationTest()
        {
            //Arrange
            Ship expected = new Ship(1, 3);

            Container container1 = new Container(4000, false, true);
            Container container2 = new Container(4000, false, false);
            Container container3 = new Container(4000, false, false);
            Container container4 = new Container(4000, true, false);

            List <Container> containers = new List <Container>();

            containers.Add(container1);
            containers.Add(container2);
            containers.Add(container3);
            containers.Add(container4);

            List <Container> stack1 = new List <Container>();

            stack1.Add(container1);

            List <Container> stack2 = new List <Container>();

            stack2.Add(container2);
            stack2.Add(container4);

            List <Container> stack3 = new List <Container>();

            stack3.Add(container3);

            expected.Stack[0, 0].Containers = stack1;
            expected.Stack[0, 1].Containers = stack2;
            expected.Stack[0, 2].Containers = stack3;
            expected.Weight = 16000;

            Ship      actual = new Ship(1, 3);
            ShipLogic logic  = new ShipLogic(1, 3);

            //Act
            actual = logic.SortContainers(containers);

            //Assert
            Assert.AreEqual(expected.Weight, actual.Weight);

            Assert.AreEqual(expected.Stack[0, 0].Containers.Count, actual.Stack[0, 0].Containers.Count);
            Assert.AreEqual(expected.Stack[0, 1].Containers.Count, actual.Stack[0, 1].Containers.Count);
            Assert.AreNotEqual(expected.Stack[0, 0].Containers.Count, actual.Stack[0, 1].Containers.Count);

            for (int i = 0; i < expected.Stack[0, 0].Containers.Count; i++)
            {
                Assert.AreEqual(expected.Stack[0, 1].Containers[i], actual.Stack[0, 1].Containers[i]);
            }

            for (int i = 0; i < expected.Stack[0, 1].Containers.Count; i++)
            {
                Assert.AreEqual(expected.Stack[0, 1].Containers[i], actual.Stack[0, 1].Containers[i]);
            }

            for (int i = 0; i < expected.Stack[0, 1].Containers.Count; i++)
            {
                Assert.AreEqual(expected.Stack[0, 1].Containers[i].TopWeight, actual.Stack[0, 1].Containers[i].TopWeight);
            }
        }
Ejemplo n.º 17
0
 public CrushEvent(ModifierBase _modifier, ShipLogic _ship)
 {
     modifier = _modifier;
     ship     = _ship;
 }
Ejemplo n.º 18
0
 private void Start()
 {
     m_ship         = m_player.GetComponent <ShipLogic>();
     m_exitPosition = GameObject.Find("Exit").transform;
 }
Ejemplo n.º 19
0
 public virtual void update(ShipLogic ship)
 {
 }
Ejemplo n.º 20
0
 public override void Start()
 {
     sl = logicobj.GetPart <ShipLogic>();
 }
Ejemplo n.º 21
0
 public UpdateUIEvent(ShipLogic _ship)
 {
     ship = _ship;
 }
Ejemplo n.º 22
0
 public virtual void updateStats(ShipLogic ship)
 {
 }