コード例 #1
0
 //0: Normal - Undeflectable
 //1: Normal - Deflectable
 //2: Offlane- Deflectable - Left
 //3: Offlane- Deflectable - Right
 //4: Offlane- Undeflectable
 //5: Split (undeflectable only)
 //6: Missile (deflectable MUST)
 //7: Empty / Silent (ada bagian di pattern yang kosong)
 //8: Ghost - Undeflectable
 //lane 0 | 1 | 2 | 3 | 4
 void Start()
 {
     //BSPAWN = GameObject.Find ("BulletSpawn").GetComponent<BulletSpawn> ();
     BSPAWN = FindObjectOfType <BulletSpawn>();
     GR     = FindObjectOfType <GetReady> ();
     //BSPAWN.addBullet (1, 2);
 }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        if (Target == null)
        {
            Target = GameObject.FindGameObjectWithTag("Player").transform;
        }

        Y     = Body.GetComponent <RotateY>();
        X     = Gun.GetComponent <RotateX>();
        Shoot = BulletSpawn.GetComponent <Shoot>();

        X.rotationSpeed = RotateSpeed;
        Y.rotationSpeed = RotateSpeed;

        X.VisibleDistance = VisibleDistance;
        Y.VisibleDistance = VisibleDistance;

        X.UnvisibleDistance     = UnvisibleDistance;
        Y.UnvisibleDistance     = UnvisibleDistance;
        Shoot.UnvisibleDistance = UnvisibleDistance;

        Shoot.Bullet = Bullet;

        Shoot.ShootingSpeed = 1f / ShootsPerSecond;

        X.target     = Target;
        Y.target     = Target;
        Shoot.target = Target;

        Shoot.BulletDestroyTime = BulletDestroyTime;
        Shoot.BulletSpeed       = BulletSpeed;
    }
コード例 #3
0
 void Start()
 {
     pm = GetComponent <PlayerMovement>();
     fc = GetComponent <FlipCharacter>();
     pj = GetComponent <PlayerJump>();
     bs = GetComponent <BulletSpawn>();
 }
コード例 #4
0
 public void WeaponRotation(Vector3 aim)
 {
     if (IsReloading)
     {
         return;
     }
     BulletSpawn.LookAt(aim);
     _animator.SetFloat("Magnitude", PlayerController.MoveMagnitude);
 }
コード例 #5
0
    // Use this for initialization
    void Start()
    {
        chargeTime  = 0;
        player      = GameObject.FindObjectOfType <PlayerMove>();
        rigidbody   = gameObject.GetComponent <Rigidbody2D>();
        collider    = gameObject.GetComponent <CircleCollider2D>();
        bulletSpawn = GameObject.FindObjectOfType <BulletSpawn>();

        if (Input.GetKey(KeyCode.Z) || (Input.GetAxis("RT") > 0))
        {
            StartCoroutine(ChargeShot());
        }
    }
コード例 #6
0
    void Awake()
    {
        bulletSpwn = GetComponent <BulletSpawn>();
        rb         = this.GetComponent <Rigidbody2D>();
        var coll = GameObject.Find("Colliders").GetComponentsInChildren <Collider2D>();

        foreach (var item in coll)
        {
            levelColl.Add(item);
        }

        _totalLife = life;

        //Events
        EventManager.SubscribeToEvent("Life", LifeUpdated);
        EventManager.SubscribeToEvent("Hero defeated", HeroDefeated);
        EventManager.SubscribeToEvent("Lose", Lose);
    }
コード例 #7
0
    void Start()
    {
        audioPlayer = GetComponent <AudioPlayer>();
        stats       = GetComponent <EnemyStats>();
        bulletSpawn = GetComponentInChildren <BulletSpawn>();
        player      = GameObject.FindGameObjectWithTag("Player");
        enemySprite = GetComponentInChildren <SpriteRenderer>();
        var randomDirection = Random.Range(1, 3);

        if (randomDirection == 1)
        {
            strafeDirection = 1;
        }
        else
        {
            strafeDirection = -1;
        }
    }
コード例 #8
0
 void Start()
 {
     bulletSpwn = GetComponent <BulletSpawn>();
     chr        = FindObjectOfType <Character>();
 }
コード例 #9
0
 public void SetSpawn(BulletSpawn spwn)
 {
     bSpw = spwn;
 }
コード例 #10
0
        // TODO: calc/find how far we gotta fly away until, the 7* dist currently is just experimental

        public void CheckForTarget(int index)
        {
            Boid boid = boidsData[index];

            if (boid.autoTarget == 0)
            {
                if (boid.timeUntilAutoTarget < time || math.distance(boid.target, cellSeparation[index]) < boid.obstacleAversionDistance)
                {
                    boid.autoTarget = 1;
                }
                else
                {
                    // TODO: maybe if target in front and no cooldown: shoot
                    cellTargetPositions[index] = boid.target;
                    return;
                }
            }

            CollisionFilter targetFilter = new CollisionFilter()
            {
                BelongsTo    = ~0u,
                CollidesWith = groupIndex,
                GroupIndex   = 0
            };
            PointDistanceInput targetPointDistanceInput = new PointDistanceInput {
                Position    = cellSeparation[index],
                MaxDistance = settings.MaxTargetDistance,
                Filter      = targetFilter
            };
            DistanceHit targetHit;

            if (!physicsWorld.CalculateDistance(targetPointDistanceInput, out targetHit))
            {
                cellTargetPositions[index] = new float3(0, -1000, 0);  // for me to see if sth goes wrong. idle or destroy if no enemy left
                boidsData[index]           = boid;
                return;
            }
            cellTargetPositions[index] = targetHit.Position;
            if (targetHit.Distance < boid.obstacleAversionDistance)
            {
                boid.autoTarget = 0;
                // maybe go for 1 out of 4 positions so that the boids keep grouped
                //boid.target = (cellSeparation[index] - targetHit.Position) * 7 + cellSeparation[index];
                boid.target = math.select((cellSeparation[index] - targetHit.Position) * 7 + targetHit.Position, -(cellSeparation[index] - targetHit.Position) * 7 + targetHit.Position, ((int)cellSeparation[index][0] % 2 == 0));
                boid.timeUntilAutoTarget = time + 30;
            }
            if (boid.timeToReload > time)
            {
                boidsData[index] = boid;
                return;
            }
            CollisionFilter obstacleFilter = new CollisionFilter()
            {
                BelongsTo    = ~0u,
                CollidesWith = 16u,
                GroupIndex   = 0
            };

            if (physicsWorld.CastRay(new RaycastInput {
                Start = cellSeparation[index], End = targetHit.Position, Filter = obstacleFilter
            }))
            {
                boidsData[index] = boid;
                return;
            }
            var dirToTarget = math.dot(cellAlignment[index], math.normalizesafe(targetHit.Position - cellSeparation[index]));

            if (dirToTarget > 0.9f && targetHit.Distance < 75)
            {
                bulletSpawns[index] = new BulletSpawn {
                    exists   = 1,
                    position = cellSeparation[index],
                    rotation = quaternion.LookRotationSafe(cellAlignment[index], math.up()) // TODO: i might want dirToTarget but with a little bit of random
                };

                boid.timeToReload = time + boid.reloadTime;
            }

            boidsData[index] = boid;
        }
コード例 #11
0
 // Call this when firing a bullet in Update()
 void fireBullet(BulletSpawn bulletSpawn)
 {
     //TODO fire the bullet
 }
コード例 #12
0
 void Awake()
 {
     bulletSpawn = GameObject.Find("BulletSpawn");
     bulletScript = bulletSpawn.GetComponent<BulletSpawn>();
 }
コード例 #13
0
ファイル: BulletSpawn.cs プロジェクト: Belu123mm/ContraMAII
 void Awake()
 {
     _instance  = this;
     bulletPool = new Pool <Bullet>(8, BulletFactory, Bullet.InitializeBullet, Bullet.DisposeBullet, true);
 }