Exemplo n.º 1
0
    // Do that on collision from bullet / laser
    void OnCollisionEnter2D(Collision2D coll)
    {
        ShootScript shot = coll.gameObject.GetComponent <ShootScript> ();

        if (shot != null)
        {
            if (isEnemy)
            {
                hp -= shot.dammage;
            }
            else
            {
                if (hp == 1)
                {
                    hp -= shot.dammage;
                    gui.SendMessage("MinHealth", 1);
                }
                else
                {
                    hp -= shot.dammage;
                    gui.SendMessage("MinHealth", shot.dammage);
                }
            }
        }
    }
Exemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        // Est-ce un tir ?
        ShootScript shot = collider.gameObject.GetComponent <ShootScript>();

        if (shot != null)
        {
            // Tir allié
            if (shot.isEnemyShot != isEnemy)
            {
                hp -= shot.damage;

                // Destruction du projectile
                // On détruit toujours le gameObject associé
                // sinon c'est le script qui serait détruit avec ""this""
                Destroy(shot.gameObject);

                if (hp <= 0)
                {
                    // 'Splosion!
                    SpecialEffectsHelper.Instance.Explosion(transform.position);

                    SoundEffectsHelper.Instance.MakeExplosionSound();

                    // Destruction !
                    Destroy(gameObject);
                }
            }
        }
    }
Exemplo n.º 3
0
    //--------------------------------
    // 3 - Shooting from another script
    //--------------------------------

    /// <summary>
    /// Create a new projectile if possible
    /// </summary>
    public void Attack(bool isEnemy)
    {
        if (CanAttack)
        {
            shootCooldown = shootingRate;

            // Create a new shot
            var shotTransform = Instantiate(shotPrefab) as Transform;

            // Assign position
            shotTransform.position = transform.position + spawnOffset;

            // The is enemy property
            ShootScript shot = shotTransform.gameObject.GetComponent <ShootScript>();
            if (shot != null)
            {
                shot.isEnemyShot = isEnemy;
            }

            // Make the weapon shot always towards it
            MoveScript move = shotTransform.gameObject.GetComponent <MoveScript>();
            if (move != null)
            {
                move.direction = this.transform.right; // towards in 2D space is the right of the sprite
            }
        }
    }
Exemplo n.º 4
0
    void Init()
    {
        _Sphere = GetComponent<SphereCollider>();
        _ShootingScript = GetComponent<ShootScript>();
        if (this.CompareTag("PlayerLogic"))
        {
            _PlayerCar = CarUserControl.Instance.m_Car;
        }
        else
        {
            _PlayerCar = GetComponent<CarController>();
        }

        if (_Weapons.Length != 0)
        {
            for (int i = 0; i < _Weapons.Length; i++)
            {
                _Weapons[i]._HitBox = _Weapons[i]._WeaponCollider.GetComponent<HitBox>();
                _Weapons[i]._Tower._HitBox = _Weapons[i]._Tower._TowerCollider.GetComponent<HitBox>();
                _Weapons[i]._WeaponTransform = transform.SearchChildWithName(_Weapons[i]._Name);
                _Weapons[i]._Tower._TowerTransform = transform.SearchChildWithName(_Weapons[i]._Tower._Name);
            }
        }

        _ShootingScript.Init();
    }
Exemplo n.º 5
0
    void Start()
    {
        transform.Find("Turret/Camera").gameObject.SetActive(isPlayer);
        transform.Find("Minimap camera").gameObject.SetActive(isPlayer);
        transform.Find("HUD").gameObject.SetActive(isPlayer);
        transform.Find("Minimap object/Number").GetComponent <TextMesh> ().text        = (index + 1).ToString();
        transform.Find("Minimap object").GetComponent <MeshRenderer> ().material.color = (isPlayer) ? Color.green : Color.red;
        Color c = (isPlayer) ? new Color32(44, 55, 200, 1) : new Color32(200, 55, 44, 1);

        foreach (Transform o in transform.Find("Base/Colored"))
        {
            o.GetComponent <MeshRenderer> ().material.color = c;
        }
        transform.Find("Turret").GetComponent <MeshRenderer> ().material.color = c;

        if (isPlayer)
        {
            controller = gameObject.AddComponent <PlayerControllerScript> ();
        }
        else
        {
            controller = gameObject.AddComponent <EnemyControllerScript> ();
            controller.GetComponent <EnemyControllerScript> ().easy = StaticData.easy;
        }


        gc = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript> ();

        tms = GetComponent <TankMovementScript> ();
        ss  = GetComponent <ShootScript> ();
    }
Exemplo n.º 6
0
    //--------------------------------
    // 3 - Tirer depuis un autre script
    //--------------------------------

    /// <summary>
    /// Création d'un projectile si possible
    /// </summary>
    public void Attack(bool isEnemy)
    {
        if (CanAttack)
        {
            shootCooldown = shootingRate;

            // Création d'un objet copie du prefab
            GameObject shotGameObject = Instantiate(shotPrefab);

            // Position
            shotGameObject.transform.position = transform.position;

            // Propriétés du script
            ShootScript shot = shotGameObject.GetComponent <ShootScript>();
            if (shot != null)
            {
                shot.isEnemyShot = isEnemy;
            }

            // On saisit la direction pour le mouvement
            MoveScript move = shotGameObject.GetComponent <MoveScript>();
            if (move != null)
            {
                move.direction = this.transform.right;                 // ici la droite sera le devant de notre objet
            }
        }
    }
Exemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     shoot      = transform.GetChild(0).GetComponent <ShootScript>();
     aim        = transform.GetChild(0).GetChild(0).GetComponent <Aiming>();
     controller = GetComponent <FirstPersonController>();
     mapCam     = GameObject.Find("MapCamera").GetComponent <Camera>();
 }
Exemplo n.º 8
0
 private void Start()
 {
     spriteRenderer = GetComponent <SpriteRenderer>();
     rigidbody      = GetComponent <Rigidbody2D>();
     anim           = GetComponent <Animator>();
     shootScript    = GetComponent <ShootScript>();
     //if (hand) { animHand.GetComponent<Animator>();  }
 }
Exemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     if (this.transform.position.y < -0.5)
     {
         Destroy(this.gameObject);
         shoot_script_obj = Camera.main.GetComponent<ShootScript>();
         shoot_script_obj.RespawnBall();
     }
 }
Exemplo n.º 10
0
 protected override void Awake()
 {
     base.Awake();
     //disable cursor in play mode
     Cursor.visible    = false;
     Screen.lockCursor = true;
     //set rigidbody abd transform
     UFORgbd     = GetComponent <Rigidbody>();
     _reloading  = ReloadTime;
     _bulletBase = GetComponent <ShootScript>();
 }
Exemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     eventLog          = GetComponent <PlayerLog>();
     Time.timeScale    = 1;
     penguinMovement   = GameObject.Find("PenguinMovement");
     shootScript       = gameObject.GetComponent <ShootScript> ();
     PenguinInfoHolder = GetComponent <PenguinData>();
     penguinData       = GameObject.Find("Penguin").GetComponent <PenguinData>();
     SpawnTimeMin      = 20 - (penguinData.difficultyIndex * 0.36f);
     SpawnTimeMax      = 20;
 }
Exemplo n.º 12
0
    /**
     *  Helper method that calculates the point where the enemy should shoot at
     *
     *  @param targetPosition The current position of the target
     *  @param barrel "right" or "left"
     *
     *  @return A random vector3 in between the target position and the predicted intercept position. Accuracy of shot can be modified in inaccurateInterceptPoint
     */
    private Vector3 CalculateInterceptPosition(Vector3 targetPosition, Transform barrel)
    {
        Vector3 interceptPoint = ShootScript.FirstOrderIntercept(
            barrel.position, _rb.velocity, _bulletSpeed, new Vector3(targetPosition.x, targetPosition.y - 0.7f, targetPosition.z), player.getVelocity());
        Vector3 inaccurateInterceptPoint = new Vector3(Random.Range(targetPosition.x, interceptPoint.x), interceptPoint.y, Random.Range(targetPosition.z, interceptPoint.z));

        if (player.timeSinceLastDodge > 8)
        {
            return(interceptPoint);
        }
        return(interceptPoint);
    }
    /**
     *  Helper method that calculates the point where the enemy should shoot at
     *
     *  @param targetPosition The current position of the target
     *
     *  @return A random vector3 in between the target position and the predicted intercept position. Accuracy of shot can be modified in inaccurateInterceptPoint
     */
    private Vector3 CalculateInterceptPosition(Vector3 targetPosition)
    {
        Vector3 interceptPoint = ShootScript.FirstOrderIntercept(
            this.transform.position, _rb.velocity, _bulletSpeed, new Vector3(targetPosition.x, targetPosition.y - 1.5f, targetPosition.z), hero1.getVelocity());
        Vector3 inaccurateInterceptPoint = new Vector3(Random.Range(targetPosition.x, interceptPoint.x), interceptPoint.y, Random.Range(targetPosition.z, interceptPoint.z));

        if (hero1.timeSinceLastDodge > 8)
        {
            return(interceptPoint);
        }
        return(inaccurateInterceptPoint);
    }
Exemplo n.º 14
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player" && (other.GetComponent <ShootScript>() != null))
     {
         ShootScript scr = other.GetComponent <ShootScript>();
         if (scr.shoot != scr.autoShoot)
         {
             scr.shootingRate = (rate + scr.shootingRate) / 2;
             scr.shoot        = scr.autoShoot;
         }
         Destroy(this.gameObject);
     }
 }
Exemplo n.º 15
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player" && (other.GetComponent <ShootScript>() != null))
     {
         ShootScript scr = other.GetComponent <ShootScript>();
         if (scr.shotPrefab != rocket.transform)
         {
             scr.shotPrefab   = rocket.transform;
             scr.shootingRate = (scr.shootingRate + rate) / 2;
         }
         Destroy(this.gameObject);
     }
 }
Exemplo n.º 16
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player" && (other.GetComponent <ShootScript>() != null))
     {
         ShootScript scr = other.GetComponent <ShootScript>();
         if (scr.bulletDeploy != scr.trippleDeploy)
         {
             scr.bulletDeploy = scr.trippleDeploy;
             scr.shootingRate = (scr.shootingRate + rate) / 2;
         }
         Destroy(this.gameObject);
     }
 }
Exemplo n.º 17
0
 void Start()
 {
     penguinMovementController = gameObject.GetComponent <PenguinMovementController> ();
     shootScript = gameObject.GetComponent <ShootScript> ();
     score       = 0;
     scoreTimer  = scoreTimerMax;
     pickupTimer = pickupTimerMax;
     isInferno   = false;
     isSlimey    = false;
     isFrozen    = false;
     isCrusty    = false;
     ammoTypeText.GetComponent <Text>().text = ("Regular Ammo");
     difficultyIndex = 1;
 }
 void Start()
 {
     player1                    = GameObject.Find("Player1");
     player2                    = GameObject.Find("Player2");
     shootScript                = player1.GetComponent <ShootScript>();
     shootScriptPlayer2         = player2.GetComponent <ShootScriptPlayer2>();
     moveScript1                = player1.GetComponent <MoveScript>();
     moveScript2                = player2.GetComponent <MoveScript>();
     moveScript2.enabled        = false;
     shootScriptPlayer2.enabled = false;
     shootScript.enabled        = false;
     moveScript1.enabled        = false;
     whosTurn                   = true;
 }
Exemplo n.º 19
0
 void Start()
 {
     gBall          = GameObject.FindGameObjectWithTag("Ball");
     my_ShootScript = gBall.GetComponent <ShootScript> ();
     gFlag          = my_ShootScript.gHole [0];
     freecam        = false;
     MoveSpeed      = 3;
     RotSpeed       = MoveSpeed + 10;
     cc             = GetComponent <CharacterController>();
     Cursor.visible = false;
     offset         = transform.position - gBall.transform.position;
     gGhost.transform.LookAt(gBall.transform);
     transform.position = gGhost.transform.position;
     transform.rotation = gGhost.transform.rotation;
 }
Exemplo n.º 20
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Paper" && enable) {
            Debug.Log("Collided with a recycle bin");
            Destroy(other.gameObject);
            shoot_script_obj = Camera.main.GetComponent<ShootScript>();
            shoot_script_obj.RespawnBall();
            this.gameObject.GetComponentInChildren<ParticleSystem>().Play();
            this.gameObject.GetComponentInChildren<AudioSource>().Play();
            ExecuteEvents.Execute<PointInterface>(
                target: GameObject.Find("GameManager"),
                eventData: null,
                functor: (x,y)=>x.OnSuccess());

            enable = false;
        }
    }
Exemplo n.º 21
0
    //Called when script is enabled
    void Start()
    {
        cur_spr = min_spr;

        lineRenderer = GetComponent <LineRenderer>();
        fpsCam       = GetComponentInParent <Camera>();
        player       = GameObject.Find("Player");
        sm           = player.GetComponent <SwapManager>();
        source       = GetComponents <AudioSource>();   //Added line here
        tracer       = GetComponent <ShootScript>();

        pMenu     = GameObject.Find("UICanvas").transform.Find("PauseMenu").gameObject;
        oMenu     = GameObject.Find("UICanvas").transform.Find("OptionsMenu").gameObject;
        goScreen  = GameObject.Find("UICanvas").transform.Find("GameOverScreen").gameObject;
        winScreen = GameObject.Find("UICanvas").transform.Find("WinScreen").gameObject;
        ammoCount = GameObject.Find("HUD").transform.Find("Ammo Counter").GetComponent <TextMeshProUGUI>();
    }
Exemplo n.º 22
0
    void OnTriggerEnter2D(Collider2D otherCollider)
    {
        // Is this a shot?
        ShootScript shot = otherCollider.gameObject.GetComponent <ShootScript>();

        if (shot != null)
        {
            // Avoid friendly fire
            if (shot.isEnemyShot != isEnemy)
            {
                Damage(shot.damage);

                // Destroy the shot
                Destroy(shot.gameObject); // Remember to always target the game object, otherwise you will just remove the script
            }
        }
    }
Exemplo n.º 23
0
    public void enemyEquip(GameObject weapon)
    {
        w = weapon.GetComponent <W_Makarov>();

        gunEnd   = w.gunEnd;
        range    = w.range;
        damage   = w.damage;
        spread   = w.spread + .6f;
        fireRate = w.fireRate + .1f;
        clip     = w.clip;
        cur_clip = w.cur_clip;
        reload   = w.t_reload + .4f;

        source = weapon.GetComponents <AudioSource>();

        w.enabled  = false;
        w.equipped = false;

        Rigidbody w_rb = weapon.GetComponent <Rigidbody>();

        if (w_rb.useGravity)
        {
            w_rb.isKinematic = true;
            w_rb.useGravity  = false;

            Collider[] c_off = weapon.GetComponents <Collider>();
            foreach (Collider c in c_off)
            {
                c.enabled = false;
            }
        }
        else
        {
            weapon.GetComponent <LineRenderer>().enabled = false;
        }

        sh = weapon.GetComponent <ShootScript>();

        weapon.transform.parent   = transform;
        weapon.transform.position = transform.position;
        Vector3 pos = w.cam_pos + Vector3.up * 2 - Vector3.forward * .4f;

        weapon.transform.Translate(pos, transform);
        weapon.transform.localEulerAngles = new Vector3(transform.rotation.y, transform.rotation.x - 180, 0);
    }
Exemplo n.º 24
0
 private void Start()
 {
     //Gets The Rigid Body Attatched to this Game Object
     myRigidBody = gameObject.GetComponent <Rigidbody2D>();
     //Gets the Sprite Renderer attatched to this game object
     sprite = gameObject.GetComponent <SpriteRenderer>();
     //Gets The Shot Manager Script attatched to this Game Object
     shooterScript = GameObject.Find("ShotManager").GetComponent <ShootScript>();
     //Assigns the Sprites to the player lives array
     playerLivesSprites = transform.GetChild(2).gameObject.GetComponent <SpriteRenderer>();
     //Creates the pool of ShotPrefabs
     shooterScript.CreateChildren(shotPrefab);
     //Resets the Time to Respawn in the editor
     timeToRespawnMax = timeToRespawn;
     //Finds the Spawn Script
     spScript = GameObject.Find("SpawnManager").gameObject.GetComponent <SpawnManager>();
     //Finds the UI Script
     uiScript = GameObject.Find("CanvasUI").gameObject.GetComponent <UIManager>();
     health   = 3;
     PlayerHealthSpriteChanger(health);
     GetComponent <AudioSource>().volume = GameManagment.instance.sfxLevel;
 }
Exemplo n.º 25
0
    // Update is called once per frame
    void Update()
    {
        float inputX = Input.GetAxis("Horizontal");
        float inputY = Input.GetAxis("Vertical");

        movement = new Vector2(speed.x * inputX, speed.y * inputY);
        if (Mathf.Approximately(inputX, 0) || ((inputX > 0) && (inputX < 0.1)))
        {
            transform.position = new Vector3(transform.position.x + 0.03f, transform.position.y, 0);
        }
        bool shoot = Input.GetButtonDown("Fire1");

        shoot |= Input.GetButtonDown("Fire2");
        if (shoot)
        {
            ShootScript shot = GetComponent <ShootScript>();
            if (shot != null)
            {
                shot.Attack(false);
            }
        }
    }
Exemplo n.º 26
0
 public void SetUpShootEnd(ShootScript s, Image i)
 {
     shootScript    = s;
     GameOverScreen = i;
 }
Exemplo n.º 27
0
 public void Start()
 {
     gui = Utilities.FindGameObject("GUI");
     kinect = GameObject.Find("Player").GetComponent<KinectPointController>();
     GameObject sara = GameObject.Find("Sara");
     sara.transform.Rotate(Vector3.left, 90);
     sara.transform.position += new Vector3(0,9,0);
     camera = GameObject.Find("CameraRight");
     animator = sara.GetComponent<Animator> ();
     rightHandTrigger = Animator.StringToHash("right");
     leftHandTrigger = Animator.StringToHash("left");
     bothHandTrigger = Animator.StringToHash("both");
     turnHorizontalTrigger = Animator.StringToHash("horizontal");
     turnVerticalTrigger = Animator.StringToHash("vertical");
     idleTrigger = Animator.StringToHash("idle");
     GameObject player = GameObject.Find("Player");
     crystals = GameObject.Find ("Crystals");
     listOfCrystals = GameObject.FindGameObjectsWithTag ("Crystal");
     crystals.SetActive (false);
     shootScript = player.GetComponent<ShootScript> ();
     flightScript = player.GetComponent<FlightScript> ();
     //shootScript.Shoot += new ShootEventHandler(HasShot);
     flightScript.Flown += new FlightEventHandler(HasFlown);
     //GameObject.Find("CameraRight").camera.backgroundColor = Color.white;
     text = welcomeText;
     playSound(welcomeAudio);
 }
Exemplo n.º 28
0
 // Use this for initialization
 void Start()
 {
     shoot = gameObject.GetComponent<ShootScript>();
 }
Exemplo n.º 29
0
 // Start is called before the first frame update
 void Awake()
 {
     shoot = GetComponent <ShootScript>();
 }
Exemplo n.º 30
0
 public SpreadShot(ShootScript owner)
 {
     this.owner = owner;
 }
Exemplo n.º 31
0
 void Start()
 {
     energyGun = (shootWithBullet2Script)GetComponent<shootWithBullet2Script>();
     fireGun = (shootWithBulletScript)GetComponent<shootWithBulletScript>();
     bulletGun = (ShootScript)GetComponent<ShootScript>();
 }
Exemplo n.º 32
0
 // Start is called before the first frame update
 void Start()
 {
     planeDetection = GameObject.Find("AR Session Origin").GetComponent <PlaneDetection>();
     shootScript    = GameObject.Find("ShootScript").GetComponent <ShootScript>();
 }
Exemplo n.º 33
0
 public RapidShot(ShootScript owner)
 {
     this.owner = owner;
 }
Exemplo n.º 34
0
 // Start is called before the first frame update
 void Start()
 {
     shootScript = GameObject.Find("ShootScript").GetComponent <ShootScript>();
 }
Exemplo n.º 35
0
 public DefaultShot(ShootScript owner)
 {
     this.owner = owner;
 }