public void ReplaceTarget(TargetBox target)
    {
        var i = Random.Range(0, maximumAmount - 1);

        target.transform.position = platforms[i].transform.position + Vector3.up;
        target.GetComponent <Rigidbody>().velocity = Vector3.zero;
    }
Exemple #2
0
        private void targetBoxItem_PreviewDragOver(object sender, DragEventArgs e)
        {
            try
            {
                var item = sender as ListBoxItem;
                if (item == null)
                {
                    return;
                }

                if (dStartBox(e) == SourceBox)
                {
                    TargetBox.UnselectAll();
                    item.IsSelected = true;
                }
                else if (dStartBox(e) == TargetBox)
                {
                    if (back_font == null)
                    {
                        back_font = item.FontWeight;
                    }
                    item.FontWeight = FontWeights.Bold;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
Exemple #3
0
 public Grid(TargetBox box, int dimX, int dimY)
 {
     owningTargetBox = box;
     this.dimX       = dimX;
     this.dimY       = dimY;
     grid            = new GridSquare[dimX, dimY];
 }
Exemple #4
0
    private void Shoot()
    {
        muzzleFlash.Play();

        RaycastHit hit;

        if (Physics.Raycast(lineLaser.transform.position, lineLaser.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);

            //레이가 맞은 지점의 게임 오브젝트의 스크립트를 읽어와서, 데미지 처리를 해준다.
            TargetBox tb = hit.transform.GetComponent <TargetBox>();
            if (tb != null)
            {
                tb.TakeDamage(power);
            }

            // 맞은 박스를 민다.

            if (hit.rigidbody != null)
            {
                hit.rigidbody.AddForce(-hit.normal * impactFos);
            }

            //총알이 맞은 지점에 파티클 후 사라지게.
            GameObject impactObj = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
            Destroy(impactObj, 2f);
        }
    }
    private void Boom()
    {
        TargetBox       expl = this.gameObject.GetComponent <TargetBox>();
        PointEffector2D pe2D = expl.GetComponent <PointEffector2D>();
        SpriteRenderer  s    = expl.GetComponent <SpriteRenderer>();

        pe2D.enabled = true;
        s.enabled    = false;
        Instantiate(ExplosionPrefab, transform.position, Quaternion.identity, transform.parent);
        Invoke("Destruct", 0.1f);
    }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stair"></param>
        /// <param name="dungeon"></param>
        public StairControl(Stair stair, Dungeon dungeon)
        {
            InitializeComponent();


            TargetBox.SetTarget(dungeon, stair.Target);
            DirectionBox.DataSource   = Enum.GetValues(typeof(StairType));
            DirectionBox.SelectedItem = stair.Type;


            Stair = stair;
        }
    private void Scored()
    {
        TargetBox      t    = this.gameObject.GetComponent <TargetBox>();
        float          mass = t.GetComponent <Rigidbody2D>().mass;
        SpriteRenderer s    = t.gameObject.GetComponent <SpriteRenderer>();

        if (s.color != Color.green)
        {
            ScoreKeeper.AddToScore(mass);
            s.color = Color.green;
        }
    }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pit">Pit handle</param>
        /// <param name="dungeon">Dungeon handle</param>
        public PitControl(Pit pit, Dungeon dungeon)
        {
            InitializeComponent();

            Dungeon = dungeon;

            IsHiddenBox.Checked   = pit.IsHidden;
            IsIllusionBox.Checked = pit.IsIllusion;
            TargetBox.SetTarget(dungeon, pit.Target);
            DamageBox.Dice      = pit.Damage;
            DifficultyBox.Value = pit.Difficulty;

            Pit = pit;
        }
Exemple #9
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="script">Script handle</param>
        /// <param name="dungeon">Dungeon handle</param>
        public SetToControl(SetTo script, Dungeon dungeon)
        {
            if (dungeon == null || script == null)
            {
                MessageBox.Show("Dungeon == NULL or script == NULL !", "SetToControl", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            InitializeComponent();

            Action  = script;
            Dungeon = dungeon;
            SquareControl.SetSquare(script.Square);
            TargetBox.SetTarget(Dungeon, Action.Target);
        }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="script"></param>
        public DeactivateTargetControl(DeactivateTarget script, Dungeon dungeon)
        {
            InitializeComponent();

            if (script != null)
            {
                Action = script;
            }
            else
            {
                Action = new DeactivateTarget();
            }

            TargetBox.SetTarget(dungeon, Action.Target);
        }
Exemple #11
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="script">Script handle</param>
        /// <param name="dungeon">Dungeon handle</param>
        public SpawnMonsterControl(SpawnMonster script, Dungeon dungeon)
        {
            InitializeComponent();


            Action = script ?? new SpawnMonster();

            TargetBox.Dungeon = dungeon;
            TargetBox.SetTarget(script.Target);

            MonsterNameBox.Items.AddRange(ResourceManager.GetAssets <Monster>().ToArray());
            if (!string.IsNullOrEmpty(SpawnScript.MonsterName))
            {
                MonsterNameBox.SelectedItem = SpawnScript.MonsterName;
            }
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="script"></param>
        /// <param name="dungeon"></param>
        public TeleportControl(Teleport script, Dungeon dungeon)
        {
            InitializeComponent();


            if (script != null)
            {
                Action = script;
            }
            else
            {
                Action = new Teleport();
            }

            TargetBox.Dungeon = dungeon;
            TargetBox.SetTarget(((Teleport)Action).Target);

            TargetBox.TargetChanged += new TargetControl.TargetChangedEventHandler(TargetBox_TargetChanged);
        }
Exemple #13
0
 public Grid(TargetBox box, int dimX, int dimY)
 {
     owningTargetBox = box;
     this.dimX = dimX;
     this.dimY = dimY;
     grid = new GridSquare[dimX, dimY];
 }
        private void processTargetBoxChanges(Object sender)
        {
            bool zoom = this.settings.zoom;
            ushort boxes = this.settings.amntTargetBoxes;
            TargetBox targetBox = new TargetBox();

            // Initialize the targetBoxes collection
            targetBoxes = new TargetBoxes(boxes);

            int boxStep = 640 / (boxes + 1);
            int boxWidth = (zoom ? 380 : 540) / boxes;
            int boxRadius = boxWidth / 2;

            // Prepare the boxes first to make things easier
            for (int i = 0; i < boxes; i++)
            {
                targetBox = new TargetBox();
                targetBox.middle.y = 480 / 2;
                targetBox.radius = boxRadius;
                targetBoxes.boxes.Add(targetBox);
            }

            // First the outer left/right boxes are placed at their respective edge
            targetBoxes.boxes[0].x = 0;
            targetBoxes.boxes[0].middle.x = boxRadius;
            targetBoxes.boxes[boxes - 1].x = 640 - boxWidth;
            targetBoxes.boxes[boxes - 1].middle.x = 640 - boxRadius;

            // The middle box
            int mid = boxes / 2; // will get rounded down, which is what we want due to 0 based
            targetBoxes.boxes[mid].middle.x = 320; // middle box is always @ 320px
            targetBoxes.boxes[mid].x = 320 - boxRadius;

            if (boxes == 3)
            {
                //nop
            }
            // I've given up on calculating this dynamically, so hardcoded will do
            else if (boxes == 5)
            {
                // Left of the middle box
                targetBoxes.boxes[1].middle.x = (320 - targetBoxes.boxes[0].middle.x) / 2 + boxRadius;
                targetBoxes.boxes[1].x = targetBoxes.boxes[1].middle.x - boxRadius;

                // Right of the middle box
                targetBoxes.boxes[3].middle.x = 320 + (targetBoxes.boxes[4].middle.x - 320) / 2;
                targetBoxes.boxes[3].x = targetBoxes.boxes[3].middle.x - boxRadius;
            }
            else if (boxes == 7)
            {
                int widthRemaining = targetBoxes.boxes[mid].x - boxWidth;	// Space remaining between the first and the middle box
                int padding = (widthRemaining - boxWidth * 2) / 3;			// Empty space between the boxes

                // Left of the middle box
                targetBoxes.boxes[1].x = boxWidth + padding;
                targetBoxes.boxes[1].middle.x = targetBoxes.boxes[1].x + boxRadius;
                targetBoxes.boxes[2].x = targetBoxes.boxes[1].middle.x + boxRadius + padding;
                targetBoxes.boxes[2].middle.x = targetBoxes.boxes[2].x + boxRadius;

                // Right of the middle box
                targetBoxes.boxes[4].x = targetBoxes.boxes[mid].middle.x + boxRadius + padding;
                targetBoxes.boxes[4].middle.x = targetBoxes.boxes[4].x + boxRadius;
                targetBoxes.boxes[5].x = targetBoxes.boxes[4].middle.x + boxRadius + padding;
                targetBoxes.boxes[5].middle.x = targetBoxes.boxes[5].x + boxRadius;
            }
            else
                throw new NotImplementedException("More target boxes than 7 is not implemented");

            for (int i = 0; i < boxes; i++ )
            {
                TargetBox tempBox = targetBoxes.boxes[i];
                tempBox.boxColours = new Colours(targetBox);
            }
        }
Exemple #15
0
 private void OnValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
 {
     TargetBox.ValueChanged -= OnValueChanged;
     TargetBox.Focus();
 }