コード例 #1
0
    private void Start()
    {
        Singleton = this;

        isShot = false;

        shoting = true;
    }
コード例 #2
0
ファイル: Bullet.cs プロジェクト: Dragolla/2D-Platformer
    void OnTriggerEnter2D(Collider2D hit)
    {
        FollowEnemy enemy = hit.GetComponent <FollowEnemy>(); //access the Following enemy's script

        if (enemy != null)                                    // if the bullet is not NULL/if the bullet hit something
        {
            enemy.TakeDamage(damage);                         // then take health from the enemy
        }
        Destroy(gameObject);                                  //then destroy the bullet
        ;
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        //Os gameobjects a seguir sao inicializados para conseguir componentes de outros scripts utilizando
        //as variaveis ja declaradas.
        GameObject f = GameObject.Find ("bigcrush 1(Clone)/idle");
        fe = f.GetComponent<FollowEnemy> ();

        GameObject h = GameObject.Find ("Sihir");
        HPSihir = h.GetComponent<Hpsih> ();
        trs = GameObject.Find ("Sihir");
        Attack = h.GetComponent <SihirSounds> ();
    }
コード例 #4
0
    void Shoot()
    {
        RaycastHit2D HitInfo = Physics2D.Raycast(FirePoint.position, FirePoint.right);

        //Instantiate(BulletPrefab, FirePoint.position, FirePoint.rotation);
        if (HitInfo)
        {
            FollowEnemy enemy = HitInfo.transform.GetComponent <FollowEnemy>(); //access the Following enemy's script
            if (enemy != null)                                                  // if the bullet is not NULL/if the bullet hit something
            {
                enemy.TakeDamage(damage);                                       // then take health from the enemy
            }
        }
    }
コード例 #5
0
    // Use this for initialization
    void Start()
    {
        //Os gameobjects a seguir sao inicializados para conseguir componentes de outros scripts utilizando
        //as variaveis ja declaradas.
        GameObject f = GameObject.Find("bigcrush 1(Clone)/idle");

        fe = f.GetComponent <FollowEnemy> ();

        GameObject h = GameObject.Find("Sihir");

        HPSihir = h.GetComponent <Hpsih> ();
        trs     = GameObject.Find("Sihir");
        Attack  = h.GetComponent <SihirSounds> ();
    }
コード例 #6
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (target == null)
        {
            target = gameObject.GetComponent <FollowEnemy>().target;
        }

        if (target != null && Time.time - lastLaunchTime > timeBetweenLaunches && (target.transform.position - transform.position).magnitude < minLaunchDistance)
        {
            lastLaunchTime = Time.time;
            GameObject  missile       = GameObject.Instantiate(missilePrefab, transform.position, Quaternion.identity);
            FollowEnemy missileEntity = missile.GetComponent <FollowEnemy>();
            missileEntity.moveVector = gameObject.GetComponent <Entity>().moveVector;
            missileEntity.speed      = missileEntity.maxSpeed;
            missileEntity.target     = target;

            missileEntity.AvoidCollisions(gameObject.GetComponent <Entity>(), 2);
        }
    }