Ejemplo n.º 1
0
    /// <summary>
    /// Need cleaning => Create core with enemy and drop it afterward
    /// </summary>
    protected void DropCore()
    {
        GameObject i_newCore = Instantiate(Resources.Load <GameObject>("EnemyResource/EnemyCore"));

        i_newCore.name = "Core of " + gameObject.name;
        i_newCore.transform.position = transform.position;
        Vector3 i_wantedDirectionAngle = SwissArmyKnife.RotatePointAroundPivot(Vector3.forward, Vector3.up, new Vector3(0, UnityEngine.Random.Range(0, 360), 0));
        float   i_throwForce           = UnityEngine.Random.Range(deathValues.minMaxDropForce.x, deathValues.minMaxDropForce.y);

        i_wantedDirectionAngle.y = i_throwForce * 0.035f;
        i_newCore.GetComponent <CorePart>().Init(null, i_wantedDirectionAngle.normalized * i_throwForce, 1, (int)UnityEngine.Random.Range(deathValues.minMaxCoreHealthValue.x, deathValues.minMaxCoreHealthValue.y));
    }
Ejemplo n.º 2
0
    private void GenerateReviveParts()
    {
        float i_currentAngle           = 0;
        float i_defaultAngleDifference = 360f / revivePartsCount;

        for (int i = 0; i < revivePartsCount; i++)
        {
            GameObject i_revivePart = Instantiate(Resources.Load <GameObject>("PlayerResource/PlayerCore"), null);
            i_revivePart.name = "Part " + i + " of " + gameObject.name;
            i_revivePart.transform.position = transform.position;
            Vector3 i_wantedDirectionAngle = SwissArmyKnife.RotatePointAroundPivot(Vector3.forward, Vector3.up, new Vector3(0, i_currentAngle, 0));
            float   i_throwForce           = Random.Range(minMaxProjectionForce.x, minMaxProjectionForce.y);
            i_wantedDirectionAngle.y = i_throwForce * 0.035f;
            i_revivePart.GetComponent <CorePart>().Init(this, i_wantedDirectionAngle.normalized * i_throwForce, revivePartsCount, 0);
            i_currentAngle += i_defaultAngleDifference + Random.Range(-i_defaultAngleDifference * partExplosionAngleRandomness, i_defaultAngleDifference * partExplosionAngleRandomness);
        }
    }