Ejemplo n.º 1
0
    public void basicAttack(Transform targetTrans)
    {
        Vector3    startPosition = muzzle.position + (Random.insideUnitSphere * .1f);
        GameObject bullet        = GameObject.Instantiate(basicAttackPrefab, startPosition, muzzle.rotation) as GameObject;

        SimpleProjectile projectileScript = bullet.GetComponent <SimpleProjectile>();

        projectileScript.SetTarget(targetTrans);
    }
Ejemplo n.º 2
0
    public override void AttackAction(Unit target)
    {
        SimpleProjectile bullet = Instantiate(Links.links.smallBullet).GetComponent <SimpleProjectile>();

        bullet.Attacker = this;
        bullet.team     = team;
        bullet.damage   = attackDamage;
        bullet.lifeTime = bulletRange / bulletSpeed;
        bullet.speed    = bulletSpeed;

        bullet.LaunchAt(transform.position + centerHeight * Vector3.up, target.transform.position + target.centerHeight * Vector3.up);
    }
Ejemplo n.º 3
0
        public void Shoot(Unit target)
        {
            Projectile projectile;

            switch ((int)_projectileType)
            {
            case (int)ProjectileType.unvisible:
            {
                projectile = new UnvisibleProjectile(target, _dmg, X, Y);
                break;
            }

            case (int)ProjectileType.simple:
            {
                projectile = new SimpleProjectile(target, _dmg, X, Y);
                break;
            }

            case (int)ProjectileType.large:
            {
                projectile = new LargeProjectile(target, _dmg, X, Y);
                break;
            }

            case (int)ProjectileType.building:
            {
                projectile = new BuildingProjectile(target, _dmg, X, Y);
                break;
            }

            case (int)ProjectileType.none:
            {
                projectile = new NoProjectile(target, _dmg, X, Y);
                break;
            }

            case (int)ProjectileType.dragon:
            {
                projectile = new DragonProjectile(target, _dmg, X, Y);
                break;
            }

            case (int)ProjectileType.priest:
            {
                projectile = new PriestProjectile(target, _dmg, X, Y);
                break;
            }

            default:
                throw new Exception("Unknown weapon type");
            }
            _parent.Add(projectile);
        }
Ejemplo n.º 4
0
    public override void AttackAction(Unit target)
    {
        SimpleProjectile bullet = Instantiate(Links.links.crystalBullet).GetComponent <SimpleProjectile>();

        bullet.Attacker = this;
        bullet.team     = team;
        bullet.damage   = attackDamage;
        bullet.lifeTime = bulletRange / bulletSpeed;
        bullet.speed    = bulletSpeed;
        Vector3 direction = (target.transform.position - transform.position).normalized;

        bullet.Launch(transform.position + 0.5f * direction + centerHeight * Vector3.up, direction);
    }
Ejemplo n.º 5
0
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("hit");
        SimpleProjectile sp = other.gameObject.GetComponent <SimpleProjectile>();
        BulletProjectile bp = other.gameObject.GetComponent <BulletProjectile>();

        if (used == false)
        {
            if (sp || bp)
            {
                Debug.Log("BUTTON HIT!");

                newobj = Instantiate(spawnPrefab, spawnLocation.transform.position,
                                     spawnLocation.transform.rotation);
            }
            used = true;
        }
    }
    //  Event handling method for the "Fire" button
    public void FireButtonClicked(object source, EventArgs e)
    {
        //  Get the initial values from the textfield
        double vx0 = Convert.ToDouble(vxTextBox.Text);
        double vy0 = Convert.ToDouble(vyTextBox.Text);
        double vz0 = Convert.ToDouble(vzTextBox.Text);

        distanceToHole = Convert.ToDouble(distanceTextBox.Text);

        //  Create a SimpleProjectile object representing the golf ball.
        golfball = new SimpleProjectile(0.0, 0.0, 0.0, vx0, vy0, vz0, 0.0);

        //  Update the display
        UpdateDisplay();

        //  Fire the golf ball using a Timer object
        //  to slow down the action.
        gameTimer.Start();
    }
 private void RpcSpawnProjectile(Vector3 position, Vector3 targetPosition)
 {
     SimpleProjectile newProjectile = Instantiate(projectilePrefab);
     //newProjectile.InitProjectile(position, targetPosition, this);
 }
Ejemplo n.º 8
0
    public void Attack(GameObject actor)
    {
        SimpleProjectile proj = (Instantiate(projectile, actor.transform.position, Quaternion.identity) as GameObject).GetComponent <SimpleProjectile>();

        proj.target = CommandsData.instance.target;
    }
    public GolfGame()
    {
        //  Create a SimpleProjectile object with default values so
        //  the display can be updated the first time.
        golfball = new SimpleProjectile(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);

        //  Set up images
        golferIcon = Image.FromFile("Golfer.jpg");
        flagIcon   = Image.FromFile("Hole_Cartoon.jpg");

        //  Initialize the distanceToHole field.
        distanceToHole = 200.0;

        //  Create a Timer object that will be used
        //  to slow the action down.
        gameTimer          = new Timer();
        gameTimer.Interval = 50; //  delay in milliseconds.
        gameTimer.Tick    += new EventHandler(ActionPerformed);

        //  Create some Labels
        vxLabel       = new Label();
        vxLabel.Text  = "Initial x-velocity, m/s";
        vxLabel.Font  = new Font(vxLabel.Font, FontStyle.Bold);
        vxLabel.Top   = 50;
        vxLabel.Left  = 10;
        vxLabel.Width = 130;

        vyLabel       = new Label();
        vyLabel.Text  = "Initial y-velocity, m/s";
        vyLabel.Font  = new Font(vyLabel.Font, FontStyle.Bold);
        vyLabel.Top   = 80;
        vyLabel.Left  = 10;
        vyLabel.Width = 130;

        vzLabel       = new Label();
        vzLabel.Text  = "Initial z-velocity, m/s";
        vzLabel.Font  = new Font(vzLabel.Font, FontStyle.Bold);
        vzLabel.Top   = 110;
        vzLabel.Left  = 10;
        vzLabel.Width = 130;

        distanceLabel       = new Label();
        distanceLabel.Text  = "Distance to hole, m";
        distanceLabel.Font  = new Font(distanceLabel.Font, FontStyle.Bold);
        distanceLabel.Top   = 140;
        distanceLabel.Left  = 10;
        distanceLabel.Width = 120;

        axesLabel       = new Label();
        axesLabel.Text  = "View axes";
        axesLabel.Font  = new Font(axesLabel.Font, FontStyle.Bold);
        axesLabel.Top   = 170;
        axesLabel.Left  = 10;
        axesLabel.Width = 70;

        //  Create TextBox objects to display the inputs.
        vxTextBox          = new TextBox();
        vxTextBox.Width    = 50;
        vxTextBox.Text     = "31.0";
        vxTextBox.AutoSize = true;
        vxTextBox.Top      = vxLabel.Top;
        vxTextBox.Left     = 150;

        vyTextBox          = new TextBox();
        vyTextBox.Width    = 50;
        vyTextBox.Text     = "0.0";
        vyTextBox.AutoSize = true;
        vyTextBox.Top      = vyLabel.Top;
        vyTextBox.Left     = 150;

        vzTextBox          = new TextBox();
        vzTextBox.Width    = 50;
        vzTextBox.Text     = "35.0";
        vzTextBox.AutoSize = true;
        vzTextBox.Top      = vzLabel.Top;
        vzTextBox.Left     = 150;

        distanceTextBox          = new TextBox();
        distanceTextBox.Width    = 50;
        distanceTextBox.Text     = "200.0";
        distanceTextBox.AutoSize = true;
        distanceTextBox.Top      = distanceLabel.Top;
        distanceTextBox.Left     = 150;

        //  Create a ComboBox to select the view axes.
        axesComboBox = new ComboBox();
        axesComboBox.Items.Add("XZ");
        axesComboBox.Items.Add("XY");
        axesComboBox.SelectedIndex = 0;
        axesComboBox.Left          = 80;
        axesComboBox.Top           = axesLabel.Top;

        //  Create Button objects
        int buttonHeight = 30;
        int buttonWidth  = 50;
        int buttonLeft   = 20;

        fireButton        = new Button();
        fireButton.Text   = "Fire";
        fireButton.Height = buttonHeight;
        fireButton.Width  = buttonWidth;
        fireButton.Top    = 200;
        fireButton.Left   = buttonLeft;
        fireButton.Click += new EventHandler(FireButtonClicked);

        resetButton        = new Button();
        resetButton.Text   = "Reset";
        resetButton.Height = buttonHeight;
        resetButton.Width  = buttonWidth;
        resetButton.Top    = 250;
        resetButton.Left   = buttonLeft;
        resetButton.Click += new EventHandler(ResetButtonClicked);

        //  Create a drawing panel.
        drawingPanel             = new Panel();
        drawingPanel.Width       = 501;
        drawingPanel.Height      = 201;
        drawingPanel.Left        = 20;
        drawingPanel.Top         = 300;
        drawingPanel.BorderStyle = BorderStyle.FixedSingle;

        //  Add the GUI components to the Form
        this.Controls.Add(vxLabel);
        this.Controls.Add(vyLabel);
        this.Controls.Add(vzLabel);
        this.Controls.Add(distanceLabel);
        this.Controls.Add(axesLabel);
        this.Controls.Add(vxTextBox);
        this.Controls.Add(vyTextBox);
        this.Controls.Add(vzTextBox);
        this.Controls.Add(distanceTextBox);
        this.Controls.Add(axesComboBox);
        this.Controls.Add(fireButton);
        this.Controls.Add(resetButton);
        this.Controls.Add(drawingPanel);

        // Set the size and title of the form
        this.Width  = 600;
        this.Height = 550;
        this.Text   = "Golf Game";

        //  Center the form on the screen and make
        //  it visible.
        this.StartPosition = FormStartPosition.CenterScreen;
        this.Visible       = true;

        //  Update the GUI display
        UpdateDisplay();
    }
 public FEProjectileAdapter(SimpleProjectile proj)
 {
     this.proj = proj;
 }