示例#1
0
    /// <summary>
    /// Commence la prévisualisation de préparation d'une salve
    /// </summary>
    /// <param name="salvo">Salve à prévisualiser</param>
    public void ShowPreparePreview(Salvo salvo)
    {
        if (!BeingUsed)
        {
            lockDirectionAfterStartShoot = false;
        }

        previewingSalvo = salvo;

        if (spawnedPreviews == null)
        {
            spawnedPreviews = new List <ShootPreview>();
        }

        Projectile previewingProjectile = GameManager.gameManager.PoolManager.GetProjectile(salvo.GetProjectileType, PoolInteractionType.PeekPrefab);
        bool       isBoulder            = previewingProjectile.IsBoulder;

        List <Vector3> allShootDirections = isBoulder ? GetAllShootPositions(salvo) : GetAllShootDirections(salvo);

        foreach (Vector3 vector in allShootDirections)
        {
            /*Instantiate(previewingProjectile.GetShootPreviewPrefab)*/
            ShootPreview preview = GameManager.gameManager.PoolManager.GetPreview(previewingProjectile.GetShootPreviewType, PoolInteractionType.GetFromPool) as ShootPreview;
            preview.ShowPreparePreview(salvo, currentShootParameters.GetProjectileTag);

            spawnedPreviews.Add(preview);
        }

        showPreview = true;
    }
示例#2
0
        private bool _isExiting; // Used to prevent double confirmation box


        #region  " Form "

        public FormMain()
        {
            _salvo = new Salvo();
            InitializeComponent();

            DrawMyShip();
        }
示例#3
0
 /// <summary>
 /// Commence la prévisualisation de la préparation d'une compétence
 /// </summary>
 /// <param name="salvo">Salve à prévisualiser</param>
 public void StartShowPreview(Salvo salvo)
 {
     foreach (ShootOrigin shootOrigin in shootOrigins)
     {
         shootOrigin.ShowPreparePreview(salvo);
     }
 }
示例#4
0
    /// <summary>
    /// Commence à prévisualiser la préparation
    /// </summary>
    /// <param name="salvo">Salve à prévisualiser</param>
    public override void ShowPreparePreview(Salvo salvo, AttackTag sourceTag)
    {
        base.ShowPreparePreview(salvo, sourceTag);

        float size = salvo.GetProjectileParameters.GetCurrentProjectileSize;

        maxSize = size * previewCircleSizeMultiplier;

        fixedCircles[0].gameObject.SetActive(true);
        trajectoryLineRenderer.gameObject.SetActive(true);

        previewingSalvo = salvo;

        Vector3 scale = Vector3.one * GetTotalCircleSize * previewCircleSizeMultiplier;

        //scale.y = fixedCircles[0].localScale.y;
        scale.z = fixedCircles[0].localScale.z;
        fixedCircles[0].localScale = scale;
        //fixedCirclesSprites[0].color = play

        growingCircles[0].localScale = new Vector3(0, /*growingCircles[0].localScale.y*/ 0, growingCircles[0].localScale.z);

        previewingProjectile = GameManager.gameManager.PoolManager.GetProjectile(salvo.GetProjectileType, PoolInteractionType.PeekPrefab) as ProjectileBoulder;

        SetPreviewColor(sourceTag);
    }
示例#5
0
    public List <float> GetAllDistances(Salvo salvo)
    {
        List <float> allDistances = new List <float>();

        foreach (Vector3 position in GetAllShootPositions(salvo))
        {
            allDistances.Add(Vector3.Distance(transform.position, position));
        }

        return(allDistances);
    }
    /// <summary>
    /// Commence à prévisualiser la préparation
    /// </summary>
    /// <param name="salvo">Salve à prévisualiser</param>
    public override void ShowPreparePreview(Salvo salvo, AttackTag sourceTag)
    {
        base.ShowPreparePreview(salvo, sourceTag);

        float size = salvo.GetProjectileParameters.GetCurrentProjectileSize;

        previewRenderer.gameObject.SetActive(true);
        previewRenderer.startWidth = size;
        previewRenderer.endWidth   = size;

        previewSalvo = salvo;

        currentTilingOffset = 0;
    }
示例#7
0
    /// <summary>
    /// Permet de récupérer toutes les directions de tirs dans le cas d'un tir direct
    /// </summary>
    /// <param name="salvo">Salve tirée</param>
    /// <returns>Toutes les directions dans lesquelles tirer</returns>
    public List <Vector3> GetAllShootDirections(Salvo salvo)
    {
        List <Vector3> allShootDirections = new List <Vector3>();

        float minAngleModificator = -salvo.GetAngleBetweenDirections / 2 * (salvo.GetNumberOfDirections - 1);

        for (int i = 0; i < salvo.GetNumberOfDirections; i++)
        {
            float modificationAngle = minAngleModificator + (salvo.GetAngleBetweenDirections) * i;
            allShootDirections.Add(Quaternion.Euler(0, modificationAngle, 0) * GetTrueShootDirection);
        }

        return(allShootDirections);
    }
示例#8
0
    public void ContinueLaunchedPreview(Salvo salvo)
    {
        if (spawnedPreviews == null)
        {
            return;
        }

        Projectile previewingProjectile = GameManager.gameManager.PoolManager.GetProjectile(salvo.GetProjectileType, PoolInteractionType.PeekPrefab);

        List <float> allDistances = GetAllDistances(previewingSalvo);

        bool           isBoulder          = previewingProjectile.IsBoulder;
        List <Vector3> allShootDirections = isBoulder ? GetAllShootPositions(salvo) : GetAllShootDirections(salvo);

        foreach (Vector3 vector in allShootDirections)
        {
            //ShootPreview preview = Instantiate(previewingProjectile.GetShootPreviewPrefab);
            ShootPreview preview = GameManager.gameManager.PoolManager.GetPreview(previewingProjectile.GetShootPreviewType, PoolInteractionType.GetFromPool) as ShootPreview;
            preview.ShowPreparePreview(salvo, currentShootParameters.GetProjectileTag);

            spawnedPreviews.Add(preview);
        }

        if (spawnedPreviews == null)
        {
            return;
        }

        for (int i = 0; i < spawnedPreviews.Count; i++)
        {
            Preview preview = spawnedPreviews[i];

            float parameter = 0;

            if (previewingProjectile as ProjectileBoulder != null)
            {
                parameter = (previewingProjectile as ProjectileBoulder).GetLifeTimeWithDistance(allDistances[i]);
            }

            preview.StartLaunchedPreview(transform.position, shootedPositions[i], parameter);
        }

        spawnedPreviews = new List <ShootPreview>();
    }
示例#9
0
    /// <summary>
    /// Permet de récupérer toutes les positions de tirs dans le cas d'un tir en cloche
    /// </summary>
    /// <param name="salvo">Salve tirée</param>
    /// <returns>Toutes les positions sur lesquelles tirer</returns>
    public List <Vector3> GetAllShootPositions(Salvo salvo)
    {
        List <Vector3> allShootPositions = new List <Vector3>();

        float minAngleModificator = -salvo.GetAngleBetweenDirections / 2 * (salvo.GetNumberOfDirections - 1);

        for (int i = 0; i < salvo.GetNumberOfDirections; i++)
        {
            float   modificationAngle = minAngleModificator + (salvo.GetAngleBetweenDirections) * i;
            Vector3 relativePos       = lockDirectionAfterStartShoot ? relativeShootAimPosition : shootAimPosition - transform.position;

            Vector3 goodPosition = transform.position + Quaternion.Euler(0, modificationAngle, 0) * relativePos;
            goodPosition.y = GameManager.gameManager.GetSeaLevel;

            allShootPositions.Add(goodPosition);
        }

        return(allShootPositions);
    }
示例#10
0
    /// <summary>
    /// Actualise la prévisualisation de préparation d'une salve
    /// </summary>
    /// <param name="salvo">Salve à prévisualiser</param>
    public void UpdatePreparePreview(Salvo salvo)
    {
        Projectile previewingProjectile = GameManager.gameManager.PoolManager.GetProjectile(salvo.GetProjectileType, PoolInteractionType.PeekPrefab);

        for (int i = 0; i < spawnedPreviews.Count; i++)
        {
            Vector3 position  = new Vector3();
            Vector3 direction = new Vector3();

            position = transform.position;

            if (previewingProjectile as ProjectileBoulder != null)
            {
                direction = GetAllShootPositions(salvo)[i];
            }
            else
            {
                direction = GetAllShootDirections(salvo)[i];
            }

            spawnedPreviews[i].UpdatePreparePreview(position, direction);
        }
    }
示例#11
0
        /// <summary>Runs a LAN game, here this computer is the host.</summary>
        public override void RunGame()
        {
            string buf = "";

            Console.Clear();
            IPAddress[] hostIPs = Dns.GetHostAddresses(Dns.GetHostName());
            IPAddress   hostIP  = null;

            foreach (IPAddress i in hostIPs)
            {
                if ((i.AddressFamily == AddressFamily.InterNetworkV6) == Program.IPv6Hosting && !i.ToString().Substring(0, 3).Equals("127"))
                {
                    hostIP = i;
                    break;
                }
            }
            if (hostIP == null)
            {
                Console.Write("Cannot get ip address, make sure your IPv" + (Program.IPv6Hosting ? "6" : "4") + " network is connected.\nPress ESC to return to main menu");
                while (Console.ReadKey().Key != ConsoleKey.Escape)
                {
                }
                return;
            }
            Console.Clear();
            Console.WriteLine("Waiting for a connection, your ip is: " + hostIP.ToString());
            TcpListener host = new TcpListener(hostIP, Program.Port);

            host.Start();
            TcpClient client = host.AcceptTcpClient();

            if (!SendData(Salvo.ToString() + FieldDelimiter + Bonus.ToString() + FieldDelimiter + Advanced.ToString(), client))
            {
                return;
            }
            SetUpMap temp = new SetUpMap(Player1, Advanced);

            if (!SendData(temp.ManualSetUp("Host", ShipList, PlaneList), client))
            {
                host.Stop(); return;
            }

            Console.Clear();
            Console.WriteLine("Waiting for Client to finish setting up map.");

            temp = new SetUpMap(Player2, Advanced);
            if ((buf = GetData(client)).Equals(""))
            {
                host.Stop(); return;
            }
            temp.TextSetUp(buf, ShipList, PlaneList);

            Turn t;

            do
            {
                if (Advanced)
                {
                    t = new AdvancedTurn(Bonus, Salvo, Player1, Player2);
                }
                else
                {
                    t = new Turn(Bonus, Salvo, Player1, Player2);
                }
                PauseGame("It's time for the host to play, press ESC to continue.");
                buf = t.DoManualTurnSequence();
                if (!SendData(buf, client))
                {
                    host.Stop(); return;
                }
                if (Player2.hasLost())
                {
                    PauseGame("The host has won the game, press ESC to return to main menu.");
                    client.Close();
                    host.Stop();
                    return;
                }
                Console.Clear();
                Console.WriteLine("It's time for the client to play, please wait.");
                if ((buf = GetData(client)).Equals(""))
                {
                    host.Stop(); return;
                }
                if (Advanced)
                {
                    t = new AdvancedTurn(Bonus, Salvo, Player2, Player1);
                }
                else
                {
                    t = new Turn(Bonus, Salvo, Player2, Player1);
                }

                t.DoTextTurnSequence(buf);
                if (Player1.hasLost())
                {
                    PauseGame("The host has lost the game, press ESC to return to main menu.");
                    client.Close();
                    host.Stop();
                    return;
                }
            } while (true);
        }
示例#12
0
    /// <summary>
    /// Lance une salve
    /// </summary>
    /// <param name="salvo">Salve à lancer</param>
    public void Shoot(Salvo salvo)
    {
        currentTimeBeforeNextSalvo = currentShootParameters.GetTimeBewteenSalvos;
        currentShootParameters.IncreaseSalvoIndex();

        shootedPositions = new List <List <Vector3> >();

        #region Calculate Directions
        PoolingManager poolManager           = GameManager.gameManager.PoolManager;
        Projectile     shootProjectilePrefab = poolManager.GetProjectile(salvo.GetProjectileType, PoolInteractionType.PeekFromPool);
        bool           isBoulder             = shootProjectilePrefab.IsBoulder;

        List <Vector3> allShootDirections = isBoulder ? GetAllShootPositions(salvo) : GetAllShootDirections(salvo);
        float          projectilesSpacing = salvo.GetProjectilesSpacing;
        foreach (Vector3 direction in allShootDirections)
        {
            List <Vector3>      thisShootedPos       = new List <Vector3>();
            /**/ List <Vector3> allPossiblePositions = CirclePositionsGenerator.GetAllPositionsInCircle(salvo.GetProjectileParameters.GetCurrentProjectileSize, projectilesSpacing, salvo.GetImprecisionParameter);
            for (int i = 0; i < salvo.GetNumberOfProjectiles; i++)
            {
                Projectile shootProjectile = poolManager.GetProjectile(salvo.GetProjectileType, PoolInteractionType.GetFromPool);
                shootProjectile.transform.position = transform.position;
                shootProjectile.transform.rotation = Quaternion.identity;

                if (relatedShip != null)
                {
                    shootProjectile.SetSource(relatedShip);
                }
                else if (relatedTurret != null)
                {
                    shootProjectile.SetSource(relatedTurret);
                }

                if (isBoulder)
                {
                    //List<Vector3> allPossiblePositions

                    //Vector3 modifiedPosition = direction + new Vector3(Random.Range(-salvo.GetImprecisionParameter, salvo.GetImprecisionParameter), 0, Random.Range(-salvo.GetImprecisionParameter, salvo.GetImprecisionParameter));
                    /**/
                    int     randomIndex      = Random.Range(0, allPossiblePositions.Count);
                    Vector3 modifiedPosition = direction + allPossiblePositions[randomIndex] + new Vector3(Random.Range(-projectilesSpacing / 2, projectilesSpacing / 2), 0, Random.Range(-projectilesSpacing / 2, projectilesSpacing / 2));
                    allPossiblePositions.RemoveAt(randomIndex);
                    /**/
                    shootProjectile.ShootProjectile(salvo.GetProjectileParameters, transform.position, modifiedPosition);

                    thisShootedPos.Add(modifiedPosition);
                }
                else
                {
                    Vector3 modifiedDirection = Quaternion.Euler(0, Random.Range(-salvo.GetImprecisionParameter, salvo.GetImprecisionParameter), 0) * direction;
                    shootProjectile.ShootProjectile(salvo.GetProjectileParameters, modifiedDirection, GameManager.gameManager.Player.GetShipVelocity);
                }

                shootProjectile.SetProjectileTag(currentShootParameters.GetProjectileTag);

                #region Special Parameters
                if (projectileSpecialParameters != null)
                {
                    shootProjectile.SetProjectileSpecialParameters(
                        new ProjectileSpecialParameters(
                            new ShipSpeedModifier(projectileSpecialParameters.GetSpeedModifier),
                            new ProjectilePiercingParameters(projectileSpecialParameters.GetPiercingParameters),
                            new ProjectileSkeweringParameters(projectileSpecialParameters.GetSkeweringParameters),
                            projectileSpecialParameters.GetExplosionParameters,
                            new SmokeZoneParameters(projectileSpecialParameters.GetSmokeZoneParameters),
                            new SlowingZoneParameters(projectileSpecialParameters.GetSlowingZoneParameters)
                            ));
                    shootProjectile.GetProjectileSpecialParameters.GetSkeweringParameters.SetSourceProjectile(shootProjectile);
                }
                #endregion

                if (allPossiblePositions.Count == 0 && isBoulder)
                {
                    Debug.LogWarning("couldn't shoot all boulders");
                    break;
                }
            }
            shootedPositions.Add(thisShootedPos);
        }
        #endregion

        #region Feedback
        if (shootParticleSystem != null)
        {
            //ParticleSystem.EmitParams parameters = shootParticleSystem.emission.;
            //if (shootParticleSystem.isPlaying)
            //{
            //Debug.Log("ui");
            //shootParticleSystem.Stop();
            //shootParticleSystem.Play();
            //shootParticleSystem.Emit(8);
            //waitingTimeToRelaunchShootEffect = 0.05f;

            /*}
             * else
             *  shootParticleSystem.Play();*/
            shootParticleSystem.Emit(2);
        }

        if (currentShootParameters.GetProjectileTag == AttackTag.Player)
        {
            Vibration.Vibrate(shootVibrationDuration);
            GameManager.gameManager.ScrshkManager.StartScreenshake(shootShakeParameters);
        }

        if (shootAudioSource != null)
        {
            shootAudioSource.PlaySound(currentShootParameters.GetShootSound);
        }
        #endregion

        if (currentShootParameters.GetCurrentSalvoIndex > 1)
        {
            ContinueLaunchedPreview(salvo);
        }
    }
示例#13
0
 /// <summary>
 /// Commence à prévisualiser la préparation
 /// </summary>
 /// <param name="salvo">Salve à prévisualiser</param>
 public virtual void ShowPreparePreview(Salvo salvo, AttackTag sourceTag)
 {
     gameObject.SetActive(true);
 }