Start() public méthode

public Start ( ) : void
Résultat void
Exemple #1
0
        private void TurnTableIntoRocket(FlippableCover table)
        {
            GameObject gameObject = (GameObject)ResourceCache.Acquire("Global VFX/VFX_Table_Exhaust");
            Vector2    vector     = DungeonData.GetIntVector2FromDirection(table.DirectionFlipped).ToVector2();
            float      num        = BraveMathCollege.Atan2Degrees(vector);
            Vector3    zero       = Vector3.zero;

            switch (table.DirectionFlipped)
            {
            case DungeonData.Direction.NORTH:
                zero = Vector3.zero;
                break;

            case DungeonData.Direction.EAST:
                zero = new Vector3(-0.5f, 0.25f, 0f);
                break;

            case DungeonData.Direction.SOUTH:
                zero = new Vector3(0f, 0.5f, 1f);
                break;

            case DungeonData.Direction.WEST:
                zero = new Vector3(0.5f, 0.25f, 0f);
                break;
            }
            GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject, table.specRigidbody.UnitCenter.ToVector3ZisY(0f) + zero, Quaternion.Euler(0f, 0f, num));

            gameObject2.transform.parent = table.specRigidbody.transform;
            Projectile projectile = table.specRigidbody.gameObject.AddComponent <Projectile>();

            projectile.Shooter         = Owner.specRigidbody;
            projectile.Owner           = Owner;
            projectile.baseData.damage = PickupObjectDatabase.GetById(398).GetComponent <TableFlipItem>().DirectHitBonusDamage;
            projectile.baseData.range  = 1000f;
            projectile.baseData.speed  = 20f;
            projectile.baseData.force  = 50f;
            projectile.baseData.UsesCustomAccelerationCurve     = true;
            projectile.baseData.AccelerationCurve               = PickupObjectDatabase.GetById(398).GetComponent <TableFlipItem>().CustomAccelerationCurve;
            projectile.baseData.CustomAccelerationCurveDuration = PickupObjectDatabase.GetById(398).GetComponent <TableFlipItem>().CustomAccelerationCurveDuration;
            projectile.shouldRotate = false;
            projectile.Start();
            projectile.SendInDirection(vector, true, true);
            projectile.collidesWithProjectiles = true;
            projectile.projectileHitHealth     = 20;
            Action <Projectile> value = delegate(Projectile p)
            {
                if (table && table.shadowSprite)
                {
                    table.shadowSprite.renderer.enabled = false;
                }
            };

            projectile.OnDestruction += value;
            ExplosiveModifier explosiveModifier = projectile.gameObject.AddComponent <ExplosiveModifier>();

            explosiveModifier.explosionData = PickupObjectDatabase.GetById(398).GetComponent <TableFlipItem>().ProjectileExplosionData;
            table.PreventPitFalls           = true;
        }
Exemple #2
0
            public override void Update()
            {
                var gamepadState = GamePad.GetState(_gamepadIndex);

                var shoot = gamepadState.ThumbSticks.Left;
                var move  = gamepadState.ThumbSticks.Right;

                //SetRotation(move.Normalized());

                #region Keyboard Override
                if (_gamepadIndex == 1)
                {
                    var kbState = OpenTK.Input.Keyboard.GetState();
                    if (kbState.IsKeyDown(Key.Up))
                    {
                        move.Y = -1;
                    }
                    else if (kbState.IsKeyDown(Key.Down))
                    {
                        move.Y = 1;
                    }
                    if (kbState.IsKeyDown(Key.Left))
                    {
                        move.X = -1;
                    }
                    else if (kbState.IsKeyDown(Key.Right))
                    {
                        move.X = 1;
                    }

                    if (kbState.IsKeyDown(Key.X))
                    {
                        _r -= 0.1f;
                    }
                    else if (kbState.IsKeyDown(Key.C))
                    {
                        _r += 0.1f;
                    }
                    if (kbState.IsKeyDown(Key.Space))
                    {
                        shoot.X = (float)Math.Cos(_r);
                        shoot.Y = (float)Math.Sin(_r);
                    }
                }
                #endregion

                MovePosition(move);
                if (shoot.LengthFast > 0.25)
                {
                    var projectile = new Projectile(this, 1, 240);
                    _sprites.Add(projectile);
                    projectile.Start(GetPosition(), shoot.Normalized());
                    projectile.SetRotation(_r);
                }
            }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        start     = gameObject.transform.position;
        end       = start + new Vector3(0, 2, 0);
        beta      = 0;
        increment = .02f;
        currTime  = spawnTime;
        int test = Random.Range(0, weapons.Length);

        this.gameObject.renderer.enabled = true;
        this.gameObject.collider.enabled = true;
        weapon = weapons[test];
        weapon.Start();
        this.gameObject.GetComponent <Light>().color             = new Color(weapon.runeColor.r, weapon.runeColor.g, weapon.runeColor.b, .5f);
        this.gameObject.GetComponent <MeshFilter>().mesh         = swapObject[test];
        this.gameObject.GetComponent <MeshCollider>().sharedMesh = swapObject [test];
        this.gameObject.renderer.material.color = new Color(7 * weapon.runeColor.r / 8, 7 * weapon.runeColor.g / 8, 7 * weapon.runeColor.b / 8, 1.0f);

        if (weapon.name == "FireballProjectile")
        {
            rotated = false;
            transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
        }
        else if (weapon.name == "FireblastProjectile")
        {
            rotated = false;
            transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
        }
        else if (weapon.name == "RicochetProjectile")
        {
            rotated = false;
            transform.localScale = new Vector3(1.2f, 1.2f, 1.2f);
        }
        else if (weapon.name == "ZapProjectile")
        {
            rotated = false;
            transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
        }
        else if (weapon.name == "Twofer")
        {
            rotated = true;
            transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
            transform.Rotate(new Vector3(0, 90, 0));
        }
        else if (weapon.name == "WallBulletProjectile")
        {
            rotated = true;
            transform.localScale = new Vector3(1.4f, 1.4f, 1.4f);
            transform.Rotate(new Vector3(0, 90, 0));
        }
        else if (weapon.name == "SinCosProjectile")
        {
            rotated = true;
            transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
            transform.Rotate(new Vector3(0, 90, 0));
        }
        else if (weapon.name == "ThreeRoundProjectile")
        {
            rotated = true;
            transform.localScale = new Vector3(4.0f, 4.0f, 4.0f);
            transform.Rotate(new Vector3(0, 90, 0));
        }

        tempY = Random.value * 50;
    }
Exemple #4
0
    void Reset()
    {
        Rune[] runes = GameObject.FindObjectsOfType <Rune>();
        Dictionary <Projectile, float> spawnChance = new Dictionary <Projectile, float>();
        Dictionary <Projectile, int>   runeCount   = new Dictionary <Projectile, int>();

        foreach (Projectile p in weapons)
        {
            runeCount.Add(p, 0);
        }
        foreach (Rune r in runes)
        {
            if (r.renderer.isVisible)
            {
                runeCount[r.weapon]++;
            }
        }
        float totalSpawnChance = 0;

        for (int i = 0; i < weapons.Length; i++)
        {
            if (!spawnChance.ContainsKey(weapons[i]))
            {
                spawnChance.Add(weapons[i], 0);
            }
            spawnChance[weapons[i]] = (float)(100 / weapons.Length) / (Mathf.Pow(2, runeCount[weapons[i]]));
            print(spawnChance[weapons[i]] + " weapon type: " + weapons[i].ToString());
            totalSpawnChance += spawnChance[weapons[i]];
        }
        //print (totalSpawnChance);
        currTime = spawnTime;
        float number = Random.Range(0.0f, totalSpawnChance);

        this.gameObject.renderer.enabled = true;
        this.gameObject.collider.enabled = true;
        int test = findRune(spawnChance, number);

        //print (number);
        weapon = weapons[test];
        weapon.Start();
        this.gameObject.GetComponent <Light>().color     = new Color(weapon.runeColor.r, weapon.runeColor.g, weapon.runeColor.b, .5f);
        this.gameObject.GetComponent <MeshFilter>().mesh = swapObject[test];

        if (weapon.name == "FireballProjectile")
        {
            if (rotated)
            {
                transform.Rotate(new Vector3(0, -90, 0));
                rotated = false;
            }
            transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
        }
        else if (weapon.name == "FireblastProjectile")
        {
            if (rotated)
            {
                transform.Rotate(new Vector3(0, -90, 0));
                rotated = false;
            }
            transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
        }
        else if (weapon.name == "RicochetProjectile")
        {
            if (rotated)
            {
                transform.Rotate(new Vector3(0, -90, 0));
                rotated = false;
            }
            transform.localScale = new Vector3(1.2f, 1.2f, 1.2f);
        }
        else if (weapon.name == "ZapProjectile")
        {
            if (rotated)
            {
                transform.Rotate(new Vector3(0, -90, 0));
                rotated = false;
            }
            transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
        }
        else if (weapon.name == "Twofer")
        {
            if (!rotated)
            {
                transform.Rotate(new Vector3(0, 90, 0));
                rotated = true;
            }
            transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
        }
        else if (weapon.name == "WallBulletProjectile")
        {
            if (!rotated)
            {
                rotated = true;
                transform.Rotate(new Vector3(0, 90, 0));
            }
            transform.localScale = new Vector3(1.4f, 1.4f, 1.4f);
        }
        else if (weapon.name == "SinCosProjectile")
        {
            if (!rotated)
            {
                transform.Rotate(new Vector3(0, 90, 0));
                rotated = true;
            }
            transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
        }
        else if (weapon.name == "ThreeRoundProjectile")
        {
            if (!rotated)
            {
                transform.Rotate(new Vector3(0, 90, 0));
                rotated = true;
            }
            transform.localScale = new Vector3(4.0f, 4.0f, 4.0f);
        }
        this.gameObject.renderer.material.color = new Color(7 * weapon.runeColor.r / 8, 7 * weapon.runeColor.g / 8, 7 * weapon.runeColor.b / 8, 1.0f);
        tempY = Random.value * 50;
    }
 // Use this for initialization
 void Start()
 {
     //p.Start();
     p = (Projectile)Instantiate(p);
     p.Start();
 }
Exemple #6
0
        private void HandleProjectileEffect(TableTechChaosEffectIdentifier identifier, FlippableCover table)
        {
            if (identifier == TableTechChaosEffectIdentifier.PROJECTILE)
            {
                GameObject original = (GameObject)ResourceCache.Acquire("Global VFX/VFX_Table_Exhaust");
                Vector2    vector   = DungeonData.GetIntVector2FromDirection(table.DirectionFlipped).ToVector2();
                float      z        = BraveMathCollege.Atan2Degrees(vector);
                Vector3    zero     = Vector3.zero;
                switch (table.DirectionFlipped)
                {
                case DungeonData.Direction.NORTH:
                    zero = Vector3.zero;
                    break;

                case DungeonData.Direction.EAST:
                    zero = new Vector3(-0.5f, 0.25f, 0f);
                    break;

                case DungeonData.Direction.SOUTH:
                    zero = new Vector3(0f, 0.5f, 1f);
                    break;

                case DungeonData.Direction.WEST:
                    zero = new Vector3(0.5f, 0.25f, 0f);
                    break;
                }
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(original, table.specRigidbody.UnitCenter.ToVector3ZisY(0f) + zero, Quaternion.Euler(0f, 0f, z));
                gameObject.transform.parent = table.specRigidbody.transform;
                Projectile projectile = table.specRigidbody.gameObject.AddComponent <Projectile>();
                projectile.Shooter         = base.Owner.specRigidbody;
                projectile.Owner           = base.Owner;
                projectile.baseData.damage = 30f;
                projectile.baseData.range  = 1000f;
                projectile.baseData.speed  = 20f;
                projectile.baseData.force  = 50f;
                projectile.baseData.UsesCustomAccelerationCurve     = true;
                projectile.baseData.AccelerationCurve               = this.CustomAccelerationCurve;
                projectile.baseData.CustomAccelerationCurveDuration = 0.8f;
                projectile.shouldRotate = false;
                projectile.Start();
                projectile.SendInDirection(vector, true, true);
                projectile.collidesWithProjectiles = true;
                projectile.projectileHitHealth     = 20;
                Action <Projectile> value = delegate(Projectile p)
                {
                    if (table && table.shadowSprite)
                    {
                        table.shadowSprite.renderer.enabled = false;
                    }
                };
                projectile.OnDestruction += value;
                ExplosiveModifier explosiveModifier = projectile.gameObject.AddComponent <ExplosiveModifier>();
                explosiveModifier.explosionData = this.ProjectileExplosionData;
                table.PreventPitFalls           = true;
                if (base.Owner && base.Owner.PlayerHasActiveSynergy("#HIDDEN_TECH_SUPER_CHAOS"))
                {
                    HomingModifier homingModifier = projectile.gameObject.AddComponent <HomingModifier>();
                    homingModifier.AssignProjectile(projectile);
                    homingModifier.HomingRadius    = 20f;
                    homingModifier.AngularVelocity = 720f;
                    BounceProjModifier bounceProjModifier = projectile.gameObject.AddComponent <BounceProjModifier>();
                    bounceProjModifier.numberOfBounces    = 4;
                    bounceProjModifier.onlyBounceOffTiles = true;
                }
            }
        }